OpenCV算法的轮廓搜索和边界矩形的创建

OpenCV algorithm of contours searching and creation of bounding rectagle

大家好!

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

提前致谢。

根据 OpenCV 文档 findContours uses "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 只是找到输入点集的最小和最大坐标

PS对不起我的英语不好