python-OpenCV之在图片上添加文字(cv.putText())
opencv
OpenCV: 开源计算机视觉库
项目地址:https://gitcode.com/gh_mirrors/opencv31/opencv
·
函数原型:
cv2.putText(src, text, place, Font, Font_Size, Font_Color, Font_Overstriking)
参数解释
| src | 输入图像 |
| text | 需要添加的文字 |
| place | 左上角坐标 |
| Font | 字体类型 |
| Font_Size | 字体大小 |
| Font_Color | 文字颜色 |
| Font_Overstriking | 字体粗细 |
代码示例
import cv2 as cv
import numpy as np
# 读入图片
src = cv.imread('test.jpg')
# 调用cv.putText()添加文字
text = "Nice to see you!"
AddText = src.copy()
cv.putText(AddText, text, (200, 100), cv.FONT_HERSHEY_COMPLEX, 2.0, (100, 200, 200), 5)
# 将原图片和添加文字后的图片拼接起来
res = np.hstack([src, AddText])
# 显示拼接后的图片
cv.imshow('text', res)
cv.waitKey()
cv.destroyAllWindows()
效果

OpenCV: 开源计算机视觉库
最近提交(Master分支:3 个月前 )
40ab4110
Fixed stack-use-after-scope errors in charuco detector 1 天前
b2042a61
docs(core): update Universal Intrinsics for VLA (RVV/SVE) and v4.11+ API changes 1 天前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)