简体   繁体   English

minAreaRect(contours) 的 output 是什么

[英]What is the output of minAreaRect(contours)

I have recently started working with openCV and and python.我最近开始使用 openCV 和 python。 I have a project where I am finding contours using findContours .我有一个项目,我正在使用findContours查找轮廓。 I get roughly around 6-8 contours on which I am looping to get the bounding box that fits the contour.我得到大约 6-8 个轮廓,我在这些轮廓上循环以获得适合轮廓的边界框。

For that I have used minAreaRect(contours) which gives me rotated rectangle that should fit the contour.为此,我使用minAreaRect(contours) ,它为我提供了应该适合轮廓的旋转矩形。 Now the output of this command is a list of tuples.现在这个命令的 output 是一个元组列表。

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?每个元组看起来像这样((81.0, 288.0), (22.0, 10.0), -0.0)我无法对每个数字的含义进行任何描述?

I think it might be ((x-coordinate, y-coordinate),(width, height), rotation) .我认为它可能是((x-coordinate, y-coordinate),(width, height), rotation)

You are correct. 你是对的。 Having a look at OpenCV's (C++) documentation on cv::minAreaRect , we see that a cv::RotatedRect is returned. 看一下cv::minAreaRect上的OpenCV(C ++)文档,我们看到返回了cv::RotatedRect The full construcor of cv::RotatedRect is: cv::RotatedRect完整结构为:

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. 显然, centersize在Python API中被视为元组,并且所有三个参数也都作为元组返回。 So, all in all this fits quite well your assumption. 因此,所有这些都非常符合您的假设。

Hope that helps! 希望有帮助!

Based on my observations that function gives u back following: (center(x, y), (width, height), angle of rotation) = cv2.minAreaRect(points)根据我的观察,function 给了你以下信息:(center(x, y), (width, height), angle of rotation) = cv2.minAreaRect(points)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM