我尝试通过 OpenCV 的 MSER 检测来查找图像上的对象。但是函数 cvExtractMSER
返回的不是轮廓,而是创建图形的点集 (CvSeq
):
(1, 4), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4), ...
但我只需要轮廓点:
(1, 4), (8, 4), (8, 1), (4, 1)
如何找到这个轮廓?
我认为,最简单(但不是最快)的方法是:
- 绘制所有点的黑白图像(如何?逐点?)
- 使用
findContours
在新图像上查找轮廓
最佳答案
findContours() 中的一个选项是传递一个参数,该参数将删除除水平、垂直或对角线上的端点之外的所有点。如果您创建图像并绘制列出的点,则 findContours() 可以为您完成其余工作。
CV_CHAIN_APPROX_SIMPLE compresses horizontal, vertical, and diagonal segments and leaves only their end points. For example, an up-right rectangular contour is encoded with 4 points.
关于opencv - 在 OpenCV 中查找点集的轮廓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10297713/