python - What is the output of minAreaRect(contours)
问题描述
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).
解决方案
你是对的。查看 OpenCV 的 (C++) 文档cv::minAreaRect
,我们看到cv::RotatedRect
返回了 a 。的完整构造是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.
显然,center
和size
在 Python API 中被视为元组,并且所有三个参数也作为元组返回。所以,总而言之,这很符合你的假设。
希望有帮助!
推荐阅读
- javascript - React Bootstrap - 当值增加但重置为 0% 时如何为 ProgressBar 设置动画?
- android - 文本视图形状显示为椭圆形,即使形状是圆形
- database - 您如何处理现有系统中新数据的收集和存储?
- android - 是否有 API 可以访问移动设备上的位置历史记录?
- javascript - 如果通过循环动态创建html,如何将图像对象设置为图像src
- python - 高性能适用于熊猫分组
- c++ - “隐藏在外部范围中定义的同名实体”不成立
- elasticsearch - Elasticsearch:我可以安全地删除收缩索引吗?
- java - xpath如何选择所有匹配的元素
- excel - 使用 xlwings 打开工作簿