python + opencv 第四节 绘图函数 绘制直线 绘制矩形


import numpy as np
import cv2
# 1.画直线 
img = np.zeros((512, 512, 3), np.uint8)
# print(type(img))
# print(img)
cv2.line(img, (100,100), (511, 511), (255, 0, 0), 5, lineType=8, shift=1)
# def line(img, pt1, pt2, color, thickness=None, lineType=None, shift=None)
# img : 要画的线所在的图像
# pt1 : 直线起点
# pt2 : 直线终点
# color : 线条颜色 BGR
# thickness : 线条宽度
# lineType : 8 -- 8-connected line 8邻连接线
#            4 -- 4-connected line 4邻连接线
#            CV_AA   反锯齿连接线 (采用了高斯滤波)
# shift : 坐标点小数点位数(即坐标点的缩小倍数,0表示不缩小,1表示缩小10背
#          比如现在坐标是 起点(100, 100),终点(511,511) shift = 1 坐标就变成 起点(10.0, 10.0),终点(51.1, 51.1)
cv2.namedWindow('line')
cv2.imshow('line', img)
cv2.waitKey(10000) #显示 10000ms 即10s后消失
cv2.destroyAllWindows()
#关于linetype这个参数,可以用下面这段代码去体验不同值的不同效果
#
# lineType = cv2.LINE_8
# # lineType = cv2.LINE_4
# # lineType = cv2.LINE_AA
#
# img = np.zeros((420, 1000, 4), np.uint8)
# cv2.putText(
#     img=img,
#     text='XerCis',
#     org=(0, 300),
#     fontFace=cv2.FONT
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值