tuoheng_algN/test/demo/demo8.py

10 lines
358 B
Python

import cv2
from PIL import ImageFont
label = ' 0.95'
# fontScale=fontScale, thickness=tf
text_width, text_height = cv2.getTextSize(label, 0, fontScale=1, thickness=1)[0]
print(text_height)
font = ImageFont.truetype("/home/th/tuo_heng/dev/AIlib2/conf/platech.ttf", 22, encoding='utf-8')
x, y, width, height = font.getbbox("植被")
print(x, y, width, height)