import cv2 as cv
def draw_in_pic(img, words, im_path, visual_dir):
'''
todo: draw text info on picture
img: numpy
'''
str_context = str(words)
font = cv.FONT_HERSHEY_COMPLEX # 字体类型
color = (255,0,0) # 颜色选择,单通道只有黑白
start_point = (50,50) # 文字起始点
print_size = 1 # 字体大小
thickness = 1 # 文字粗细
cv.putText(img, str_context, start_point,font,print_size,color,thickness)
image_name = os.path.basename(os.path.dirname(im_path))
cv.imwrite(os.path.join(visual_dir, image_name + '_' + str(pre_degree) + '_.png'), img)
以上!
Reference1
Reference2