python opencv画图可视化

画直线

import numpy as np
import cv2

# Create a black image
img = np.zeros((512,512,3), np.uint8)

# Draw a diagonal blue line with thickness of 5 px
cv2.line(img,(0,0),(511,511),(255,0,0),5)
cv2.imshow('line',img)
cv2.waitKey()


画polygon

import numpy as np
import cv2

# Create a black image
img = np.zeros((512,512,3), np.uint8)

pts = np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)
pts = pts.reshape((-1,1,2))
cv2.polylines(img,[pts],True,(0,255,255))


cv2.imshow('line',img)
cv2.waitKey()

 

https://segmentfault.com/a/1190000015585635

 

posted @ 2019-01-09 15:10  有梦就要去实现他  阅读(1731)  评论(0编辑  收藏  举报