OpenCV Contours - need more than 2 values to unpack

前端 未结 9 1689
旧时难觅i
旧时难觅i 2020-12-17 10:39

I am trying to implement contours using the following code..

im = cv2.imread(\'C:\\Users\\Prashant\\Desktop\\T.jpg\')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2         


        
相关标签:
9条回答
  • 2020-12-17 11:00

    This should help:

    image, contours, hierarchy = cv2.findContours(thresh.copy(),
                                                  cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    
    0 讨论(0)
  • 2020-12-17 11:02

    Depending on the OpenCV version, cv2.findContours() has varying return signatures. In OpenCV 3.4.X, cv2.findContours() returns 3 items. In OpenCV 2.X and 4.1.X, cv2.findContours() returns 2 items

    You can easily obtain the contours regardless of the version like this:

    cnts = cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    cnts = cnts[0] if len(cnts) == 2 else cnts[1]
    
    0 讨论(0)
  • 2020-12-17 11:04

    As per the Current Opencv Versions cv2.findContours returns 2 Values and that is Contours and heirachy. Contours can be explained simply as a curve joining all the continuous points (along the boundary), having same color or intensity. The contours are a useful tool for shape analysis and object detection and recognition.

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