minAreaRect(contours)的输出是什么

时间:2019-09-17 04:36:18

标签: python opencv contour

我最近开始使用openCV和Python。我有一个项目,正在使用[a-zA-Z]([0-9]{4})L\+([0-9\.]+)K([+\-][0-9]+)\-([a-zA-Z]+) 查找轮廓。我大约可以绕6-8个轮廓,然后在其上循环以获取适合轮廓的边界框。

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

每个元组看起来像这样minAreaRect(contours),我无法获得每个数字的含义的任何描述?

我认为可能是((x坐标,y坐标,(宽度,高度),旋转)

1 个答案:

答案 0 :(得分:1)

您是正确的。看一下cv::minAreaRect上的OpenCV(C ++)文档,我们看到返回了cv::RotatedRectcv::RotatedRect中的full construcor是:

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中被视为元组,并且所有三个参数也作为元组返回。因此,所有这些都非常符合您的假设。

希望有帮助!