gpt4 book ai didi

python - minAreaRect(contours) 的输出是什么

转载 作者:行者123 更新时间:2023-12-02 16:07:18 35 4
gpt4 key购买 nike

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

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

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

我认为可能是((x-coordinate, y-coordinate),(width, height), rotation)

最佳答案

你是对的。查看关于 cv::minAreaRect 的 OpenCV (C++) 文档,我们看到一个 cv::RotatedRect被退回。 full construcor cv::RotatedRect 是:

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 中被视为元组,所有三个参数也作为元组返回。所以,总而言之,这非常符合您的假设。

希望对您有所帮助!

关于python - minAreaRect(contours) 的输出是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57967420/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com