OpenCV 3 drawing arrow - 绘制箭头

OpenCV 3 drawing arrow - 绘制箭头

OpenCV documentation index - OpenCV 文档索引
https://www.docs.opencv.org/

master (4.x)
https://www.docs.opencv.org/master/

3.4 (3.4.x)
https://www.docs.opencv.org/3.4/

2.4 (2.4.x)
https://www.docs.opencv.org/2.4/

1. 3.4 (3.4.x) -> Modules -> Image Processing -> Drawing Functions -> arrowedLine()

1.1 Function Documentation - arrowedLine()

void cv::arrowedLine (InputOutputArray img,
Point pt1,
Point pt2,
const Scalar & color,
int thickness = 1,
int line_type = 8,
int shift = 0,
double tipLength = 0.1 
)

Python

img	= cv.arrowedLine(img, pt1, pt2, color[, thickness[, line_type[, shift[, tipLength]]]])
#include <opencv2/imgproc.hpp>

Draws a arrow segment pointing from the first point to the second one.
绘制从第一个点指向第二个点的箭头。

The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image.
函数 cv::arrowedLine 在图像中的 pt1 和 pt2 点之间绘制一个箭头。

Parameters
img - Image.
pt1 - The point the arrow starts from.
pt2 - The point the arrow points to.
color - Line color (B, G, R).
thickness - Line thickness.
line_type - Type of the line.
shift - Number of fractional bits in the point coordinates.
tipLength - The length of the arrow tip in relation to the arrow length.

2. 3.2.0 -> Sphinx Documentation -> imgproc. Image Processing -> Drawing Functions -> arrowedLine

2.1 Function Documentation - arrowedLine()

Draws a arrow segment pointing from the first point to the second one.
绘制从第一个点指向第二个点的箭头。

C++

void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0, double tipLength=0.1)

Parameters
img - Image.
pt1 - The point the arrow starts from. (起始点。)
pt2 - The point the arrow points to. (终止点。)
color - Line color (B, G, R).
thickness - Line thickness. (线条的粗细。)
lineType - (线条的类型。)
cv.LINE_8 - 8 (or omitted) - 8-connected line.
cv.LINE_4 - 4 - 4-connected line.
cv.LINE_AA - CV_AA - antialiased line.

shift - Number of fractional bits in the point coordinates. (点坐标中的小数位数。)
tipLength - The length of the arrow tip in relation to the arrow length.

The function arrowedLine draws an arrow between pt1 and pt2 points in the image.
arrowedLine 函数在图像中的 pt1 和 pt2 点之间绘制一个箭头。

aliase:n. 别名

3. arrow

#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
arrowedLine()
Draws a arrow segment pointing from the first point to the second one.
"""

import numpy as np
import cv2

img = np.zeros((512, 512, 3), np.uint8)
cv2.namedWindow("image")

while (True):
    cv2.arrowedLine(img, (50, 50), (200, 50), (0, 0, 255), thickness=3, line_type=cv2.LINE_4, shift=0, tipLength=0.1)
    cv2.arrowedLine(img, (50, 120), (200, 120), (0, 255, 0), thickness=3, line_type=cv2.LINE_8, shift=0, tipLength=0.3)
    cv2.arrowedLine(img, (50, 200), (200, 200), (255, 0, 0), thickness=3, line_type=cv2.LINE_AA, shift=0, tipLength=0.3)

    """
    arrowedLine(img, pt1, pt2, color[, thickness[, line_type[, shift[, tipLength]]]]) -> img
    .   @brief Draws a arrow segment pointing from the first point to the second one.
    .
    .   The function arrowedLine draws an arrow between pt1 and pt2 points in the image.
    .
    .   @param img - Image.
    .   @param pt1 - The point the arrow starts from.
    .   @param pt2 - The point the arrow points to.
    .   @param color Line color.
    .   @param thickn- ess Line thickness.
    .   @param line_type - Type of the line.
    .   @param shift - Number of fractional bits in the point coordinates.
    .   @param tipLength - The length of the arrow tip in relation to the arrow length.
    """

    cv2.imshow('image', img)

    k = cv2.waitKey(20) & 0xFF
    if 27 == k:
        break

cv2.destroyAllWindows()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

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

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

打赏作者

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

抵扣说明:

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

余额充值