核心函数
arrowedLine(img, pt1, pt2, color, thickness=None, line_type=None, shift=None, tipLength=None)
img: 需要绘制箭头的图像
pt1, pt2:绘制箭头线段的起点和终点坐标
color: 绘制箭头线段的颜色
thickness: 箭头线段的线宽(线的粗细)
line_type: 绘制线的类型参考定义LineTypes
shitf: 坐标系中的小数位数
tipLength: 箭头笔尖的长度(相对于线段长度的比例),默认0.1,比例越大箭头越长
代码展示
# -*- coding:utf-8 -*-
import cv2
import numpy as np
image = np.zeros((480, 640, 3), dtype=np.uint8)
cv2.arrowedLine(image,
pt1=(110, 10),
pt2=(110, 100),
color=(255, 255, 0),
thickness=2,
line_type=cv2.LINE_8,
shift=0,
tipLength=0.1)
cv2.imshow('image', image)
cv2.waitKey()