OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 27 Oct 2015 01:16:09 -0500Result from Euc Distance Calculationhttp://answers.opencv.org/question/73716/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;
thanksTue, 20 Oct 2015 08:13:48 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73969#post-id-73969Hope it helped ;)Thu, 22 Oct 2015 07:24:28 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73969#post-id-73969Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=74323#post-id-74323I would not recommend it (it's deprecated C-api)... better find why it happens and eliminate that case.... Better use the [std::isnan](http://en.cppreference.com/w/cpp/numeric/math/isnan)Mon, 26 Oct 2015 07:07:12 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=74323#post-id-74323Comment by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=74307#post-id-74307I finally found the code.. (checking a wrong way where opencv did have one!!) here is the code that can be look on?
IsNaN
Determines if the argument is Not A Number.
C: int cvIsNaN(double value) Python: cv.IsNaN(value) → int
Parameters:
value – The input floating-point value
The function returns 1 if the argument is Not A Number (as defined by IEEE754 standard), 0 otherwise.
Thanks everyoneMon, 26 Oct 2015 06:05:03 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=74307#post-id-74307Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73960#post-id-73960I 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 thereThu, 22 Oct 2015 06:33:37 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73960#post-id-73960Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73908#post-id-73908Your 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?Thu, 22 Oct 2015 02:27:53 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73908#post-id-73908Comment by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73906#post-id-73906@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?Thu, 22 Oct 2015 01:58:54 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73906#post-id-73906Comment by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73946#post-id-73946I 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?Thu, 22 Oct 2015 04:39:32 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73946#post-id-73946Comment by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73786#post-id-73786based on the output from the program.
if((mc.size() == 2)&&flagsave==0)
{
centroid =2;
Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);
std::cout << "Res" <<res << std::endl;
std::cout << "a" <<a << std::endl;
std::cout << "b" <<b << std::endl;
double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;
std::cout << "(b.x-a.x)" <<(b.x-a.x) << std::endl;
std::cout << "(b.y-a.y)" <<(b.y-a.y) << std::endl;
std::cout << "deg" <<deg<< std::endl;
}
Results - it does not say it is 0. consistent with -1.#IND. What is that?
Res-1.#IND
a[-1.#IND, -1.#IND]
b[65.0653, 30.9768]
(b.x-a.x)-1.#IND
(b.y-a.y)-1.#IND
deg-1.#INDTue, 20 Oct 2015 23:29:32 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73786#post-id-73786Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73804#post-id-73804So, you are doing a division by `mu[i].m00` There may be the cause of the `-1.#IND`. Check for the cause there ;)Wed, 21 Oct 2015 03:32:13 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73804#post-id-73804Comment by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73795#post-id-73795mc 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.Wed, 21 Oct 2015 02:48:28 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73795#post-id-73795Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73792#post-id-73792-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 in `a`, it has already infinite values. How did you compute the `mc`?Wed, 21 Oct 2015 02:07:25 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73792#post-id-73792Comment by thdrksdfthmn for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73735#post-id-73735Does the a and b points have the same x? If so, there is a division by 0, so just do an if thereTue, 20 Oct 2015 09:51:52 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=73735#post-id-73735Comment by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=74395#post-id-74395ok, I take a note on that.. will look on the matter on this issue. I'll keep this thread posted for sharing.
tqTue, 27 Oct 2015 01:16:09 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?comment=74395#post-id-74395Answer by zms for <p>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.</p>
<p>-1.#IND,-1.#IND</p>
<p>May I know what does this means? </p>
<p>The formula for the ecludian distance and the degree (atan) as below.</p>
<p>Point2f a = mc[0];
Point2f b = mc[1];
double res = cv::norm(a-b);</p>
<p>double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;</p>
<p>thanks</p>
http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?answer=73966#post-id-73966ok noted.. thanks for all the explaination. :)Thu, 22 Oct 2015 07:11:24 -0500http://answers.opencv.org/question/73716/result-from-euc-distance-calculation/?answer=73966#post-id-73966