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()