Python+opencv2画图

记录一下,老是会忘掉

opencv画圆

cv2.circle(img,r,(x,y),(0,0,255),t)#r为半径,(x,y)为圆心坐标,t为线宽

opencv画矩形

cv2.rectangle(img,(x0,y0),(x1,y1),(0,0,255),t)#(x0,y0)表示矩形左上点,(x1,y1)表示矩形右下点,t表示线宽

opencv画线

cv2.line(img,(x0,y0),(x1,y1),(0,0,255),t)#(x0,y0)表示起点坐标,(x1,y1)表示终点坐标

opencv画多边形

points=[[130,250],[170,290],[335,145],[295,105]]
points=np.array(points,np.int32)
cv2.polylines(img,points,(0,0,255),t)

opencv画热力图

img_gray=np.array(hm.reshape((128,128,1))*255,np.uint8)
im_color = cv2.applyColorMap(img_gray, cv2.COLORMAP_HOT)

 

你可能感兴趣的:(Python+opencv2画图)