OpenCV 图片中写入中文字符

import cv2
from PIL import Image,ImageDraw,ImageFont
import numpy as np
frame=cv2.imread("filename")
pil_img=Image.fromarray(cv2.cvtColor(frame,cv2.COLOR_BGR2RGB))#转化为pil 图片
draw=ImageDraw.Draw(pil_img)
font=ImageFont.truetype('simhei.ttf',20,encoding="utf-8")
draw.text((50,200),"中文字符",(0,0,255),font)
frame=cv2.cvtColor(np.array(pil_img),cv2.COLOR_RGB2BGR)#转化为cv2 image


你可能感兴趣的:(OpenCV,Python)