본문 바로가기

Opencv

how to put text message on images using opencv library on python

반응형

** 파이썬에서 opencv를 이용하여 이미지에 text를 삽입하는 방법!! **

 

See the following cold.

 

cv2.putText(image, "Hello. world!!", bottomLeftOrigin, fontFace, fontScale, textcolor)

 

. image : numpy array of size [img_height, img_width, img_depth]

. "Hello. world!!" : This will be displayed.

. bottomLeftOrigin : for example, if you set (10, 10), bottom left corner of "H" character will be placed at (10, 10).

. fontFace : Possible choices

cv2.FONT_HERSHEY_COMPLEX
cv2.FONT_HERSHEY_COMPLEX_SMALL
cv2.FONT_HERSHEY_DUPLEX
cv2.FONT_HERSHEY_PLAIN
cv2.FONT_HERSHEY_SCRIPT_COMPLEX
cv2.FONT_HERSHEY_SCRIPT_SIMPLEX
cv2.FONT_HERSHEY_SIMPLEX
cv2.FONT_HERSHEY_TRIPLEX
cv2.FONT_ITALIC

. fontScale: 1 is the basic size. If you set 2, the characters of size (the basic size x 2) will be displayed.

. textcolor: put some integer value.