python opencv 线 矩形 圆 字

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/TingHW/article/details/84486683
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
img = cv2.line(img,(100,0),(511,511),(255,0,0),10)#画板, 起点,终点,颜色,宽度

img = cv2.rectangle(img,(384,0),(510,128),(0,255,0),5)#画板, 左上,右下,颜色,宽度(-1为填充)

img = cv2.circle(img,(447,63),63,(0,0,255),-1)#画板, 圆心,半径,颜色,宽度(-1为填充)

img = cv2.ellipse(img,(256,256),(100,50),90,0,270,(0,255,0),-1)#中心点坐标,长轴短轴,偏转角度,起始角度,终止角度,颜色,宽度

pts = np.array([[10,5],[20,30],[70,20],[50,10]],np.int32)
pts = pts.reshape((-1,1,2))

img = cv2.polylines(img,[pts],True,(0,255,255))#true-封闭图形   false-不封闭

font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, 'OpenCV', (10,500), font, 4,(255,255,255), 2, cv2.CV_16UC1)#画板,文字,位置,字体,大小,颜色,宽度,线的类型

cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

猜你喜欢

转载自blog.csdn.net/TingHW/article/details/84486683