I have a problem understanding how OpenCV works when it comes to RotatedRect.
I have extracted a contour and I then try to fit a rotated rectangle over it. The angles that I keep getting range only in 0 to -90. Even if I have the contour directing the other way by flipping it, I still get 0 to -90 angles.
My problem is to make sure the contour lies at 0′ degrees. And for that I have to calculated the orientation and then rotate accordingly.
How are these angles represented in OpenCV (2.4.3)?
Regards
Wajih
In some cases
RotatedRectangle can be the same for contour rotated 180 deg. The best way to figure out if it happens in your case is to draw fitted RotatedRect.I think that more suited for your case are contour moments.
See my answers there:
Rotation and scale invariant template matching in OpenCV
and there:
Find the orientation of an image
You can compute moments with
cv::Moments: http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=moments#cv.Moments