cv::findContours doesn't append to the OutputArrayOfArrays [closed]

asked 2019-12-12 13:53:53 -0500

exbigboss gravatar image

OpenCV somehow seems intelligent enough to resize my std::vector<std::vector<cv::Point>> from a size of 0 to however many contours it finds in an image _but_ it seems like it does not append to the container.

For example, I'm trying to build a set of known good contours from multiple images. Using this, I can read in contours from other images and compare the match of the contours. We have a specifically controlled environment where all of our images are of the same kinds of objects against the same background so this Just Works in practice.

But it seems like cv::findContours will _overwrite_ the output sequence instead of appending to it!

Is this a known issue? Is there a work around for this?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2019-12-12 14:50:22.655309


Doc is here and "contours Detected contours" in source image and that's all. There is no issue. If you want to create such array you have to write your own code

LBerger gravatar imageLBerger ( 2019-12-12 14:23:44 -0500 )edit

Ooh, I get it now lol.

It doesn't do any push back, it just does a rote assignment. So that's why it's overwriting and not appending. Ha, that makes good sense.

Man, I wish there was a function that did that natively but alas, writing my own will simply have to do.

Thank you for the quick reply!

exbigboss gravatar imageexbigboss ( 2019-12-12 14:29:09 -0500 )edit