import cv2
img = cv2.imread("test.jpg")
imgt = img[949:1113,420:580]
cv2.putText(imgt,"6",(5,30),cv2.FONT_HERSHEY_COMPLEX,1,(0,0,0),2)
""" 写字换行 """
y0,dy = 50,10
ans = 'white\nred\nwhite\nwhite\nred\nwhite'
for i,txt in enumerate(ans.split('\n')):
y = y0+i*dy
if i==1 or i==2:
color = (0,255,0)
else:
color = (0,255,0)
cv2.putText(imgt,txt,(110,y),cv2.FONT_HERSHEY_COMPLEX_SMALL,0.6,color,1)
cv2.imwrite('w.jpg',imgt)
python+opencv写字换行
于 2021-09-07 20:22:07 首次发布