13 线段绘制
import cv2
import numpy as np
newImageInfo = (500,500,3)
dst = np.zeros(newImageInfo,np.uint8)
cv2.line(dst,(100,100),(400,400),(0,0,255))
cv2.line(dst,(100,200),(400,200),(0,255,255),20)
cv2.line(dst,(100,300),(400,300),(0,255,0),20,cv2.LINE_AA)
cv2.line(dst,(100,150),(50,250),(25,100,255))
cv2.line(dst,(50,250),(400,380),(25,100,255))
cv2.line(dst,(400,380),(100,150),(25,100,255))
cv2.imshow('dst',dst)
cv2.waitKey(0)
14 矩形、圆形绘制
import cv2
import numpy as np
newImageInfo = (500,500,3)
dst = np.zeros(newImageInfo,np.uint8)
cv2.rectangle(dst,(50,100),(200,300),(255,0,0),0)
cv2.circle(dst,(250,250),(50),(0,255,0),2)
cv2.ellipse(dst,(256,256),(150,100),0,0,180,(255,255,0),-1)
points = np.array([[150,50],[140,140],[200,170],[250,250],[150,50]],np.int32)
print(points.shape)
points = points.reshape((-1,1,2))
print(points.shape)
cv2.polylines(dst,[points],True,(0,255,255))
cv2.imshow('dst',dst)
cv2.waitKey(0)
15文字、图片绘制
'''
# 文字的绘制
import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.rectangle(img,(200,100),(500,400),(0,255,0),3)
# 1:dst 2:文字内容 3:坐标 4:字体 5:字体大小 6:color 7:粗细 8:line type
cv2.putText(img,'this is flow',(100,300),font,1,(200,100,255),2,cv2.LINE_AA)
cv2.imshow('dst',img)
cv2.waitKey(0)
'''
import cv2
img = cv2.imread('image0.jpg',1)
print(img.shape)
height = int(img.shape[0]*0.2)
width = int(img.shape[1]*0.2)
imgResize = cv2.resize(img,(width,height))
print(imgResize.shape)
for i in range(0,height):
for j in range(0,width):
img[i+200,j+350] = imgResize[i,j]
cv2.imshow('dst',img)
cv2.waitKey(0)
总结
哼哼 今天 就不写总结