Check only particular portion of video feed in OpenCV

后端 未结 1 967
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 02:53

How to get webcam video feed, for specific width and height?

I have zero experience with OpenCV library, so I need help in this regard. This code is from geeksforgee

相关标签:
1条回答
  • 2020-12-02 03:13

    It seems like you want to obtain the region of interest (ROI) for a particular area of each frame. To do this in OpenCV, we can crop the image using bounding box coordinates. Consider (0,0) as the top left corner of the image with left-to-right as the x-direction and top-to-bottom as the y-direction. If we have (x1, y1) as the top-left vertex and (x2,y2) as the bottom-right vertex of a ROI, we can crop the image by:

    ROI = frame[y1:y2, x1:x2]
    

    As an illustration:

    -------------------------------------------
    |                                         | 
    |    (x1, y1)                             |
    |      ------------------------           |
    |      |                      |           |
    |      |                      |           | 
    |      |         ROI          |           |  
    |      |                      |           |   
    |      |                      |           |   
    |      |                      |           |       
    |      ------------------------           |   
    |                           (x2, y2)      |    
    |                                         |             
    |                                         |             
    |                                         |             
    -------------------------------------------
    

    We are able to do this since images are stored as a Numpy array in OpenCV. Here is a great resource for Numpy array indexing and slicing. Once you have the desired ROI, you can do your motion detecting in this region.

    0 讨论(0)
提交回复
热议问题