OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 12 Sep 2017 03:57:28 -0500orientation angle of ellipsehttp://answers.opencv.org/question/174078/orientation-angle-of-ellipse/ Hello everyone,
I am having some trouble in understanding how the angle parameter of the ellipse function actually works.
In the documentation it is meant to be anti-clockwise and referring to the main axis.
Therefore, for instance, if I try to draw an ellipse of size (100,50) and angle 45 deg I expect it to be in the first quadrant while instead it is in the second.
For instance this:
> ellipse(im, Point(im.cols/2, im.rows/2), Size(100, 50), 45, 0, 360, Scalar(200,0,0));
leads to the image below.
Of course if I switch the axis the orientation gets correct but this seems to be in contrast with the image shown in the documentation. ([opencv drawing doc](http://docs.opencv.org/2.4/modules/core/doc/drawing_functions.html))
What am I misunderstanding?
![image description](/upfiles/1505206320718566.png)
jappoz92Tue, 12 Sep 2017 03:57:28 -0500http://answers.opencv.org/question/174078/ellipse approximation of blob using contours moments : confusing orientation anglehttp://answers.opencv.org/question/75181/ellipse-approximation-of-blob-using-contours-moments-confusing-orientation-angle/ Dear all,
I want to draw the ellipse approximating an isolated blob (the largest contour found with findContours). Using the formulas of paper :http://goo.gl/yvcUO5 for the major and minor axes I obtain consistent axes lengths. However using the formula to compute the orientation angle from the same paper( and which I find almost everywhere) I obtain odd results. This is the formula : theta = 0.5*atan (2*mu11 / (mu20-mu02)) ;
As long as the blob (which represents a human silhouette) is not close to horizontal, the formula returns a consistent value of the orientation angle but as soon as the blob becomes almost horizontal the sign of the orientation angle is flipped suddenly. I know the reason of such a behavior. If we refer to the formula above : when the blob is not horizontal mu20 is smaller than mu02. This is true while the blob starts climbing (falling) counter clockwise until it reaches an orientation of about 45 degrees. When it reaches that value the pxels distribution of the blob becomes horizontal rather than vertical and mu20 becomes larger than mu02 which implies inversion of the angle's sign. I don't know if this formula is correct.
Thanks a lot for your help.louniceMon, 02 Nov 2015 11:07:20 -0600http://answers.opencv.org/question/75181/Angles in ellipse() functionhttp://answers.opencv.org/question/14541/angles-in-ellipse-function/Hi,
I am trying to draw an ellipse using OpenCV. But I have difficulty in understanding its angle arguments. Even it is not clear from the picture in OpenCV docs.
I tried following line:
cv2.ellipse(img,(256,256),(200,100),0,90,180,(0,0,255),4,cv2.CV_AA)
I got the result as below:
![image description](/upfiles/13702492172353122.png)
That means `startangle` is taken from positive x axis in clockwise direction and that is same for `endangle`.
**Now I tried this :**
cv2.ellipse(img,(256,256),(200,100),0,45,225,(0,0,255),4,cv2.CV_AA)
I got the output as below :
![image description](/upfiles/13702495225245992.png)
See, the `startangle` and `endangle` is not 45 and 225 here.
**What is the problem here? Did I miss something ? Or is it a bug?**
Abid Rahman KMon, 03 Jun 2013 03:54:17 -0500http://answers.opencv.org/question/14541/