Region of Interest opencv python

前端 未结 3 2025
余生分开走
余生分开走 2020-12-06 00:55

I am trying to get a region of an image (ROI) using opencv python. The version of opencv used is 2.4.3. However when I try to call the API

cv2.SetImageROI
         


        
3条回答
  •  心在旅途
    2020-12-06 02:01

    Okay, On further analysis realized that the cv2 since it has been supporting numpy array structure, there is no longer any need for a API, the entire image can be manipulated in the array itself. eg:

    img = cv2.imread('image.png')
    img = img[c1:c1+25,r1:r1+25]
    

    Here c1 is the left side column pixel location, and r1 is the corresponding row location. And img now has the image specified within the pixels as the ROI.

    EDIT: Very nicely explained here, How to copy a image region using opencv in python?

提交回复
热议问题