Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

please take another look at the docs

Centroids are accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.

so, it's not a Mat of Point2d, but a 2xN Mat, and you'll have to access it like:

double x = centroids.at<double>(i, 0);
double y = centroids.at<double>(i, 1);