mercredi 25 mars 2015

Calculating angle between two points in C++, getting weird results


I am trying to calculate the angle between two points using OpenCV C++ in visual studio 2013. One point is a tracked object and the other is the position where i clicked my mouse. However with my code i am getting a very long and fluctuating answer that does not seem correct...


Code extract:



float angle = (atan2(mousex - posX, mousey - posY) * 180) / 3.14159265;
sprintf_s(textA, "%d", angle);
putText(imgOriginal, textA, Point(posX, posY + 20),
FONT_HERSHEY_COMPLEX_SMALL, 0.8, Scalar(200, 200, 250), 1, CV_AA);


I have included and but still no result.


I get results that fluctuate (while in the same spot) between 50368 and 10732.


So if anyone could help my out it would be much appreciated!


Thank you.




Aucun commentaire:

Enregistrer un commentaire