Skip to content

Conversation

sumanmichael
Copy link

in the 135 line
changed this

_, contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

to this

contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

it's because in a previous version of opencv that function used to return 3 values, now it returns just 2 values

in the 135 line
changed this

_, contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

to this

contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

it's because in a previous version of opencv that function used to return 3 values, now it returns just 2 values
@yuxi-liu-wired
Copy link

This version is back-compatible :

def get_contours(img):
    work = threshold(img)
    debug_show('threshold', work)
    contours_result = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
    if len(contours_result) == 3:
        _, contours, hierarchy = contours_result
    else:
        contours, hierarchy = contours_result
        
    return contours, hierarchy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants