Ask Your Question

Revision history [back]

matchShapes return 0

I have found a similar post here: http://answers.opencv.org/question/14804/matchshapes-always-returns-0/

but I'm using version 3.0, anyone has the same problem?


Here is my code...

edge_map1 = cv2.Canny(img1, 100, 200)

edge_map2 = cv2.Canny(img2, 100,200)

contours1, hierarchy1 = cv2.findContours(edge_map1, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)

contours2, hierarchy2 = cv2.findContours(edge_map2, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)

for c1 in contours1: for c2 in contours2:

    ret = cv2.matchShapes(c1, c2, 1, 0.0)

However, the returned value is always zero. Thanks in advance!

click to hide/show revision 2
No.2 Revision

updated 2016-04-07 05:49:19 -0600

berak gravatar image

matchShapes return 0

I have found a similar post here: http://answers.opencv.org/question/14804/matchshapes-always-returns-0/

but I'm using version 3.0, anyone has the same problem?


Here is my code...

edge_map1 = cv2.Canny(img1, 100, 200)  

edge_map2 = cv2.Canny(img2, 100,200)

100,200)

contours1, hierarchy1 = cv2.findContours(edge_map1, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)

contours2, hierarchy2 = cv2.findContours(edge_map2, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)

cv2.CHAIN_APPROX_SIMPLE)

for c1 in contours1: for c2 in contours2:

contours2:
     ret = cv2.matchShapes(c1, c2, 1, 0.0)

However, the returned value is always zero. Thanks in advance!

matchShapes return 0Canny dynamic threshold

[update]

Thanks for one of the comments that remind me of the possibility that it doesn't find anything useful at all... I modified the threshold I used in creating edge map, and it started to work correctly! However, I am wondering if there is a more robust way to generate dynamic threshold for canny edge detection?


I have found a similar post here: http://answers.opencv.org/question/14804/matchshapes-always-returns-0/

but I'm using version 3.0, anyone has the same problem?


Here is my code...

edge_map1 = cv2.Canny(img1, 100, 200)  

edge_map2 = cv2.Canny(img2, 100,200)


contours1, hierarchy1 = cv2.findContours(edge_map1, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE) 

contours2, hierarchy2 = cv2.findContours(edge_map2, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)


for c1 in contours1:
    for c2 in contours2:

         ret = cv2.matchShapes(c1, c2, 1, 0.0)

However, the returned value is always zero. Thanks in advance!

Canny dynamic threshold

[update]

Thanks for one of the comments that remind me of the possibility that it doesn't find anything useful at all... I modified the threshold I used in creating edge map, and it started to work correctly! However, I am wondering if there is a more robust way to generate dynamic threshold for canny edge detection?

below is the img I used

image description image description


I have found a similar post here: http://answers.opencv.org/question/14804/matchshapes-always-returns-0/

but I'm using version 3.0, anyone has the same problem?

Here is my code...

edge_map1 = cv2.Canny(img1, 100, 200)  

edge_map2 = cv2.Canny(img2, 100,200)


contours1, hierarchy1 = cv2.findContours(edge_map1, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE) 

contours2, hierarchy2 = cv2.findContours(edge_map2, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)


for c1 in contours1:
    for c2 in contours2:

         ret = cv2.matchShapes(c1, c2, 1, 0.0)

However, the returned value is always zero. Thanks in advance!