Ask Your Question

ian's profile - activity

2016-06-09 07:52:30 -0600 asked a question cvMatchContourTrees seems to be removed. What do I use instead?

I'm trying to determine a distance between two hierarchies of contours in Python. I recall a function called cvMatchContourTrees that worked very badly in 2010, so I'm not completely surprised in 2016 that it seems to have been removed. (There was another question on this that seems to have been closed, although it's not very clear as to why.)

My starting place is this this:

import cv2
myImage = cv2.imread(inFilename, cv2.IMREAD_GRAYSCALE)
ret, thresh = cv2.threshold(myImage, 127, 255, 0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)

I want to compare this tree of contours to another such tree. It seems like it would be straightforward -- that I could compare the trees structurally and add up the results of matchShapes. However, my concerns about the ordering of contours within a hierarchy led me to this question.

How can I properly match two contour trees?