cv3.draw.arrow
- cv3.draw.arrow(img, x0, y0, x1, y1, rel=None, color=None, t=None, line_type=None, tip_length=None, copy=False)[source]
Draw an arrowed line on an image.
This is an experimental function. To use it, set experimental mode with cv3.opt.set_exp().
- Parameters:
img (numpy.ndarray) – Input image to draw on.
x0 (int or float) – X-coordinate of the starting point.
y0 (int or float) – Y-coordinate of the starting point.
x1 (int or float) – X-coordinate of the ending point.
y1 (int or float) – Y-coordinate of the ending point.
rel (bool, optional) – Whether to use relative coordinates. Defaults to None.
color – Color of the arrow (default: opt.COLOR).
t – Thickness of the arrow (default: opt.THICKNESS).
line_type – Type of line for drawing (default: opt.LINE_TYPE).
tip_length (float, optional) – The length of the arrow tip in relation to the arrow length. Defaults to 0.1.
copy (bool) – Whether to copy the image before drawing (default: False).
- Returns:
Image with the arrow drawn on it.
- Return type:
numpy.ndarray
Note
Relative coordinates are in the range [0, 1] where 0 is the top/left and 1 is the bottom/right of the image.
Example
>>> import cv3 >>> img = cv3.zeros(100, 100, 3) >>> # Draw an arrow >>> img = cv3.arrow(img, 10, 10, 90, 90, color='red', t=2) >>> # Draw an arrow with custom tip length >>> img = cv3.arrow(img, 20, 20, 80, 80, color='blue', tip_length=0.2)