c++ - filling contours with opencv python -
i have binary image polylines created with:
cv2.polylines(binaryimage,contours,1, (255,255,255))
what need effective method fill polylines. haven't found such method in opencv, maybe exists. alternatively, maybe implement algorithm job (but fast one- have hd ready pictures). please share thoughts..
i think looking cv2.fillpoly
, fills area bounded 1 or more polygons. simple snippet, generate contour of 4 points representing vertices of square, fill polygon white color.
import numpy np import cv2 contours = np.array( [ [50,50], [50,150], [150, 150], [150,50] ] ) img = np.zeros( (200,200) ) # create single channel 200x200 pixel black image cv2.fillpoly(img, pts =[contours], color=(255,255,255)) cv2.imshow(" ", img) cv2.waitkey()
Comments
Post a Comment