From my experiments, the angle returned by the RotatedRect angle variable varies from -90 to 0 degrees, which is not enough to determine if the object is tilted left or right.
For example, if the angle is -45 degrees, we cannot say whether we need to rotate +45 or -45 degrees to align it.
Excerpt from the code I use:
RotatedRect rotated_rect = minAreaRect(contour); float blob_angle_deg = rotated_rect.angle; Mat mapMatrix = getRotationMatrix2D(center, blob_angle_deg, 1.0);
Leaning on an object in one direction, I get angles from 0 to -90 degrees, and when you tilt the object to another direction, I get angles from -90 to 0 degrees.
How can I find the angle at which I should rotate the image on the table?
opencv rotation
JoΓ£o MS Silva
source share