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

asked 2014-10-11 06:45:38 -0600

gfx gravatar image

updated 2020-10-21 10:49:52 -0600

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?

edit retag flag offensive reopen merge delete

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 ( 2014-10-11 07:02:42 -0600 )edit