MinAreaRect angles - Unsure about the angle returned
I'm going to assume you're using C++, but the answer should be the same if you're using C or Python.
The function
minAreaRect
seems to give angles ranging from -90 to 0 degrees, not including zero, so an interval of [-90, 0).
The function gives -90 degrees if the rectangle it outputs isn't rotated, i.e. the rectangle has two sides exactly horizontal and two sides exactly vertical. As the rectangle rotates clockwise, the angle increases (goes towards zero). When zero is reached, the angle given by the function ticks back over to -90 degrees again.
So if you have a long rectangle from
minAreaRect
, and it's lying down flat, minAreaRect
will call the angle -90 degrees. If you rotate the image until the rectangle given by minAreaRect
is perfectly upright, then the angle will say -90 degrees again.
I didn't actually know any of this (I procrastinated from my OpenCV project to find out how it works :/). Anyway, here's an OpenCV program that demonstrates
minAreaRect
if I haven't explained it clear enough already: