如下所示:

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 的各参数介绍就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com