且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用OpenCV从轮廓获取蒙版

更新时间:2023-01-28 18:41:08

您正在为蒙版设置颜色(0,255,0),但是该蒙版是单通道的,因此您可以使用颜色0绘制轮廓.

you are setting color (0,255,0) to the mask, but the mask is single channel so you draw the contour in color 0.

尝试

 cv.drawContours(mask, contours, -1, (255),1)

 cv.drawContours(mask, contours, -1, (255,255,255),1)