minAreaRect(contours) 的输出是什么

What is the output of minAreaRect(contours)

我最近开始使用 openCV 和 python。我有一个项目,我正在使用 findContours 查找等高线。我得到大约 6-8 个轮廓,我在这些轮廓上循环以获得适合轮廓的边界框。

为此,我使用了 minAreaRect(contours),它为我提供了适合轮廓的旋转矩形。现在这个命令的输出是一个元组列表。

每个元组看起来像这样((81.0, 288.0), (22.0, 10.0), -0.0)我无法得到关于每个数字的含义的任何描述?

我觉得可能是((x坐标,y坐标),(宽度,高度),旋转).

你是对的。查看 cv::RotatedRectcv::minAreaRect, we see that a cv::RotatedRect is returned. The full construcor 上的 OpenCV (C++) 文档是:

cv::RotatedRect::RotatedRect(const cv::Point2f& center, const cv::Size2f& size, float angle)    

对应参数的说明为:

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.

显然,centersize 在 Python API 中被视为元组,所有三个参数也作为元组返回。所以,总而言之,这非常符合你的假设。

希望对您有所帮助!