opencv在灰度图上,绘制polylines,填充

opencv在灰度图上,绘制polylines

opencv在灰度图上,绘制多边形

 

1、这是在彩色图上进行绘制:

somaBackground = np.zeros((self.imgsize[1], self.imgsize[0], 3), dtype=int)
somaBackground = cv.polylines(somaBackground, line, 2, (0, 255, 250), 2)

2、这是在灰度图上进行绘制(没有搞定)

技巧 | OpenCV中如何绘制与填充多边形_小白学视觉的博客-CSDN博客

somaBackground = np.zeros((width, heigh), dtype=np.uint16)
somaBackground = cv.polylines(somaBackground, line, 2, 255, 2)

这个效果不好

下边的方法仅供参考:

 

3、使用fillPoly

somaBackground = np.ones((width, heigh, 3)) * (255, 255, 255)
somaBackground = cv.fillPoly(somaBackground, line, (0, 255, 250))

posted @ 2022-05-20 17:51  bH1pJ  阅读(102)  评论(0编辑  收藏  举报