Result from Euc Distance Calculation
Hello, I'm calculating the euc line and the degree for 2 points. Most of the results are OK but sometimes there are results showed like this.
-1.#IND,-1.#IND
May I know what does this means?
The formula for the ecludian distance and the degree (atan) as below.
Point2f a = mc[0]; Point2f b = mc[1]; double res = cv::norm(a-b);
double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;
thanks
Does the a and b points have the same x? If so, there is a division by 0, so just do an if there
based on the output from the program.
Results - it does not say it is 0. consistent with -1.#IND. What is that?
-1.#IND is a kind of infinite, like in division by 0 or something like that
Have you tried to do a
res = cv::norm(a, b)
? Anyway, the problem is ina
, it has already infinite values. How did you compute themc
?mc is the centroid point by using this vector<point2f> 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); }
I get the blob area binary image and calculate the centroid of the white blob area.
So, you are doing a division by
mu[i].m00
There may be the cause of the-1.#IND
. Check for the cause there ;)@thdrksdfthmn u are correct. I details out the value and found out this.
m10/mu[i].m0 = 00
Is it anyway that I can solve on this matter?
Your moments are computed on a binary image, so you need to look in that image, what are the problems, why is it 0? Does the image have any white regions? If you find why is that 0, then you shall treat that case special. Bu what version of OpenCV are you using? Could this be a bug, from theory: m00, could be 0 only if all the points have at least one coordinate 0?
I found out that, the output seeing a very small white region at (0,0) which is proven inside the image where I draw a line from another centroid which is quite weird. I'm using 2.4.11 opencv version. Is it a bug or something else?
I do not think it is a bug (but it may be treated by someone as a special case). I would say that you r problem is in the image, why do you have that white top-left corner region (one pixel, or something like that)? I would suggest you to find why do you get in this case and fix the problem there
Hope it helped ;)