如下所示:
cv2.putText(img, str(i), (123,456)), font, 2, (0,255,0), 3)
各参数依次是:图片,添加的文字,左上角坐标,字体,字体大小,颜色,字体粗细
其中字体可以选择
FONT_HERSHEY_SIMPLEX
Python: cv.FONT_HERSHEY_SIMPLEX
normal size sans-serif font
FONT_HERSHEY_PLAIN
Python: cv.FONT_HERSHEY_PLAIN
small size sans-serif font
FONT_HERSHEY_DUPLEX
Python: cv.FONT_HERSHEY_DUPLEX
normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX)
FONT_HERSHEY_COMPLEX
Python: cv.FONT_HERSHEY_COMPLEX
normal size serif font
FONT_HERSHEY_TRIPLEX
Python: cv.FONT_HERSHEY_TRIPLEX
normal size serif font (more complex than FONT_HERSHEY_COMPLEX)
FONT_HERSHEY_COMPLEX_SMALL
Python: cv.FONT_HERSHEY_COMPLEX_SMALL
smaller version of FONT_HERSHEY_COMPLEX
FONT_HERSHEY_SCRIPT_SIMPLEX
Python: cv.FONT_HERSHEY_SCRIPT_SIMPLEX
hand-writing style font
FONT_HERSHEY_SCRIPT_COMPLEX
Python: cv.FONT_HERSHEY_SCRIPT_COMPLEX
more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX
FONT_ITALIC
Python: cv.FONT_ITALIC
flag for italic font
字体大小,数值越大,字体越大
字体粗细,越大越粗,数值表示线占有直径像素个数
void cv::putText( InputOutputArray img, const String & text, Point org, int fontFace, double fontScale, Scalar color, int thickness = 1, int lineType = LINE_8, bool bottomLeftOrigin = false ) Python: img =cv.putText(img, text, org, fontFace,fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]])
以上这篇对python opencv 添加文字 cv2.putText 的各参数介绍就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。