Polylines (img, point set, whether closed loop, color,...)
Img: specify which picture to draw on
Point set: it is the point we need to draw, and must be 32-bit
Closed loop or not: decide whether to connect together finally
import cv2 import numpy as np # 绘制一个黑色背景图 img=np.zeros((480,640,3),np.uint8) # 画多边形 pts=np.array([(320,240),(100,50),(450,100)],np.int32) cv2.polylines(img,[pts],True,(0,0,255)) # 填充多边形 cv2.fillPoly(img,[pts],(0,255,0)) # 显示 cv2.imshow('img',img) cv2.waitKey(0)