hierachy[u][2] find moments.x moments.y [closed]

asked Oct 11 '14

gfx gravatar image

updated Oct 21 '0

findContours(imgRes1, contours3, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0,0));}
....
for(int u = 0; u < contours3.size(); u++)
Moments moment = moments(contours3[hierarchy[u][2]]);
.....}

I try to find center of contours with [u][2] hierarchy ... obviously this function not work because contours3 is a vector not a mat image ...there is some way to do that?

Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-21 10:50:05.420827

Comments

2

moments can handle both contours and images.

but better check if hierarchy[u][2] is valid..

berak gravatar imageberak (Oct 11 '14)edit