Python Opencv实践 - 在图像上绘制图形

import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

img = cv.imread("../SampleImages/pomeranian.png")
print(img.shape)

plt.imshow(img[:,:,::-1])

#画直线
#cv.line(img,start,end,color,thickness)
#参考资料:https://blog.csdn.net/weixin_42618420/article/details/106097270
cv.line(img, (0,0), (512,512), (0, 0, 255), 1)
plt.imshow(img[:,:,::-1])

#画圆
#cv.circle(img,centerpoint,r,color,thickness)
#参考资料:https://blog.csdn.net/viven_hui/article/details/102807995
cv.circle(img,(335,360),16,(0,255,0),2)
plt.imshow(img[:,:,::-1])

#画矩形
#cv.rectangle(img,uppperLeftPoint,downRightPoint,color,thickness)
#参考资料:https://blog.csdn.net/Kefenggewu_/article/details/109909087
cv.rectangle(img, (50,50), (100,100), (255,0,0), 2)
plt.imshow(img[:,:,::-1])

#绘制文字
#cv.putText(img, text, org, fontFace, fontScale, color, thickness=None, lineType=None, bottomLeftOrigin=None)
# org: 文字在图像中的左下角位置
#参考资料:https://blog.csdn.net/weixin_41010198/article/details/89155899
cv.putText(img, 'Cute Pomeranian~', (50, 300), cv.FONT_HERSHEY_SIMPLEX, 1, (100,200,50), 2, cv.LINE_AA)
plt.imshow(img[:,:,::-1])

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

亦枫Leonlew

希望这篇文章能帮到你

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值