def cv2AddChineseText img text position textColor02550textSize30if isinstance img np.ndarray判断是否OpenCV图片类型img Image.fromarray cv2.cvtColor img cv2.COLOR BGR2RGB创建一个可以在给定图像上绘图的对象draw ImageDraw.Draw img字体的格式fontStyle ImageFont.truetype r D其它tensorRT Pro main example python simsun.ttc textSize encoding utf8绘制文本draw.text position text textColor font fontStyle转换回OpenCV格式return cv2.cv