1、python opencv的putText只能畫英文上去
2、借鑒這個https://blog.csdn.net/dcrmg/article/details/79108491 使用pil
首先,你需要下載一個tff包,http://www.downcc.com/font/248408.html這個是在網上搜索的微軟雅黑的文字包,隨便你放在哪里,只有能讀到就好了。接下來就按照下面的代碼:
img_PIL = Image.fromarray(cv2.cvtColor(image_show, cv2.COLOR_BGR2RGB))
font = ImageFont.truetype('/unsullied/sharefs/zhouxingyu/isilon-home/CarPlate/test_scripts/chepai/msyh.ttf', 30)
fillColor = (255,0,0)
position = (30,300)
draw = ImageDraw.Draw(img_PIL)
draw.text(position, plate_num, font=font, fill=fillColor)
img_OpenCV = cv2.cvtColor(np.asarray(img_PIL),cv2.COLOR_RGB2BGR)
cv2.imshow('plate img',img_OpenCV)
注意pil和opencv的互相轉換