Reputation: 958
I have recently started working with openCV and and python. I have a project where I am finding contours using findContours
. I get roughly around 6-8 contours on which I am looping to get the bounding box that fits the contour.
For that I have used minAreaRect(contours)
which gives me rotated rectangle that should fit the contour. Now the output of this command is a list of tuples.
Each tuple looks like this ((81.0, 288.0), (22.0, 10.0), -0.0)
I couldnt get any description on what each of that number mean?
I think it might be ((x-coordinate, y-coordinate),(width, height), rotation).
Upvotes: 5
Views: 18296
Reputation: 41
Based on my observations that function gives u back following: (center(x, y), (width, height), angle of rotation) = cv2.minAreaRect(points)
Upvotes: 0
Reputation: 18895
You are correct. Having a look at OpenCV's (C++) documentation on cv::minAreaRect
, we see that a cv::RotatedRect
is returned. The full construcor of cv::RotatedRect
is:
cv::RotatedRect::RotatedRect(const cv::Point2f& center, const cv::Size2f& size, float angle)
The description of the corresponding parameters is:
center The rectangle mass center.
size Width and height of the rectangle.
angle The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
Obviously, center
and size
are treated as tuples in the Python API, and all three parameters are returned as a tuple also. So, all in all this fits quite well your assumption.
Hope that helps!
Upvotes: 9