Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Centroid coordinate at [-1.#IND, -1.#IND]

$
0
0
Hi, I had been looking for centroid in an image using this code vector< vector> contours; findContours(frame_gray, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE); vector mu(contours.size() ); for( int i = 0; i < contours.size(); i++ ) { mu[i] = moments( contours[i], false ); } vector mc( contours.size() ); for( int i = 0; i < contours.size(); i++ ) { mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 ); circle( draw, mc[i], 4, Scalar(0,0,255), -1, 8, 0 );//waitKey(0); } if((mc.size() == 2)&&flagsave==0) { cerr << "2 contours detected" << endl; centroid =2; Point2f a = mc[0]; Point2f b = mc[1]; cerr << mc[0] << endl; cerr << mc[1] << endl; } My question is, there is a few image return the coordinate mc[1] as [-1.#IND, -1.#IND] i.e. the location is at (0,0) at the image cartesan and i do not understand what is it. I had tried to look in the image and could not find the contour there. Is there a bug that i could not found? Thanks

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>