Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Outlines are not needed. Simply convert the image to black and white so that the object is white and the background is black. Next, call the cv2.fitLine function, take the arc tangent from its results, and that's it, the angle is obtained.
What is an angle of inclination?
To answer this question, you need to understand where is the top / bottom and where is the side, and this, as you understand, depends on what exactly is depicted.
If the images are exactly the same as in the question, then the zero position can be determined by the length (length) of the object. We are looking for the findContours contour and find two points of the contour, the distance between which is maximum, this segment can be considered a line, the angle of which is considered.
You can also calculate the linear regression of all points of the object (no need to calculate its contour) to the line, and already calculate its angle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question