Python
[Python] openCV : Text
SangRok Jung
2022. 11. 10. 14:43
반응형

문자열 출력 함수¶
getTextSize¶
문자열 출력 크기를 반환하는 함수
putText¶
문자열을 출력하는 함수
In [7]:
import cv2
import numpy as np
img = np.zeros(shape=(512, 512, 3), dtype=np.uint8) + 255
text = 'OpenCV Programming.'
org = (50,100)
fontScale = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, text, org, fontScale, 1,(0,0,255))
size, baseLine = cv2.getTextSize(text, fontScale, 1, 1)
print('size = ', size)
print("baseLine= ", baseLine)
cv2.rectangle(img, org, (org[0]+size[0], org[1]-size[1]), (255,0,0))
cv2.circle(img, org, 3, (0,255,0), 2)
cv2.imshow('img', img)
cv2.waitKey(300)
cv2.destroyAllWindows()
size = (354, 22)
baseLine= 10
반응형