轮廓搜索的OpenCV算法及边界矩形的生成

2024-05-19 00:41:58 发布

您现在位置:Python中文网/ 问答频道 /正文

向整个程序员协会致敬!在

对我来说,在项目中使用的每一种算法都得到认可已经成为我的习惯。不久前,我实现了OpenCV库方法来检测输入帧内的轮廓,以及在检测到的对象周围绘制边界矩形。所以我提出了一个问题:当调用适当的方法时,OpenCV实际上使用了什么算法?(我指的是精确的cv2.findContours和cv2.boundingRect方法)

提前谢谢你。在


Tags: 项目对象方法算法绘制cv2opencv程序员
1条回答
网友
1楼 · 发布于 2024-05-19 00:41:58

根据OpenCV文档,findContours使用“Suzuki, S. and Abe, K., Topological Structural Analysis of Digitized Binary Images by Border Following

The function retrieves contours from the binary image using the algorithm [Suzuki85].

我没有找到boundingRect算法的描述,但找到了this file in opencv repo

7.a. Straight Bounding Rectangle It is a straight rectangle, it doesn't consider the rotation of the object. So area of the bounding rectangle won't be minimum. It is found by the function cv2.boundingRect(). Let (x,y) be the top-left coordinate of the rectangle and (w,h) be its width and height. @code{.py} x,y,w,h = cv2.boundingRect(cnt) cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) @endcode

所以boundingRect似乎只找到输入点集的最小和最大坐标

抱歉,我的英语很差

相关问题 更多 >

    热门问题