Error findContours with mode RETR_TREE on CV_32SC1 images

asked 2019-01-08 07:20:28 -0500

Vojta David gravatar image

updated 2019-01-08 07:36:09 -0500

Hi guys,

I was wondering why I can't use findContours with mode RETR_TREE on CV_32SC1 images. I would like to do following:

auto A = cv::imread("C:\\devel\\test_image.png", -1);
cv::Mat labels;
int no_labels = cv::connectedComponents(A, labels, 4, CV_32S);

std::vector<std::vector<cv::Point> > contours0;
std::vector<cv::Vec4i> hierarchy;

cv::findContours(labels, contours0, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_NONE);

Or is there a solution how to convert hierarchy from RETR_CCOMP to RETR_TREE?

Thanks for your time.

edit retag flag offensive close merge delete