How to address a specific centroid obtained from the function connectedComponentsWithStats?
Hello everyone, I hope you can help me with a specific issue. I have been using the function connectedComponentsWithStats to extract the centroid of an object in an image. Here is part of my code,
int num_objects = connectedComponentsWithStats(img, labels, stats, centroids);
cout << "Object " << i << "with position: " << centroids.at<Point2d>(i) << endl;
when I try to debug this instruction I get the following error:
OpenCV Error: Assertion failed (elemSize() == (((((DataType<_Tp>::type) & ((512 - 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)16384|0x3a50) >> ((DataType<_Tp>::type) & ((1 << 3) - 1))2) & 3))) in cv::Mat::at, file c:\opencv310\build\include\opencv2\core\mat.inl.hpp, line 962
I am trying to obtain a point (x, y) which the definition type of each element is a double or CV_64F. When I run the following instruction, I can see all the values of all the found centroids. Nevertheless when I try to retrieve just one specific centroid, the centroid reference "centroids.at<point2d>(i)" just lanches the failure message
cout <<"positions: " << centroids << endl;
I really appreciate any suggestion that can help me retrieve a particular centroid point information in the correct format (double)
Thank you in advance