在OpenCV中关闭轮廓曲线

SRo*_*mes 12 curve opencv contour edge-detection

我正在使用OpenCV(Canny + findCountours)来查找对象的外部轮廓.绘制的曲线通常几乎(但不是完全)是闭合的.我想关闭它 - 找到它所包含的区域.

我该怎么做呢?

事情考虑:

  • 扩张 - 我见过的例子在Canny之后显示了这一点,虽然在我看来,在findContours之后这样做更有意义
  • 凸壳 - 可能会起作用,虽然我真的想完成曲线
  • 形状简化 - 相关,但不完全是我想要的

Muh*_*lah 1

使用PolyLine方法绘制轮廓

cv2.PolyLine(img, points, is_closed=True, 255, thickness=1, lineType=8, shift=0)
Run Code Online (Sandbox Code Playgroud)

阅读文档以获取更多详细信息:http://docs.opencv.org/2.4/modules/core/doc/drawing_functions.html

如果解决了您的问题,马克会回答。如果没有,请告诉我。