Change language

Python OpenCV | cv2.arrowedLine () method

OpenCV-Python — is a Python bindings library for solving computer vision problems. 
cv2.arrowedLine () is used to draw an arrow segment pointing from start point to end point.

Syntax: cv2 .arrowedLine (image, start_point, end_point, color [, thickness [, line_type [, shift [, tipLength]]]])

Parameters:
image: It is the image on which line is to be drawn.
start_point: It is the starting coordinates of line. The coordinates are represented as tuples of two values ​​ie ( X coordinate value, Y coordinate value).
end_point: It is the ending coordinates of line. The coordinates are represented as tuples of two values ​​ie ( X coordinate value, Y coordinate value).
color: It is the color of line to be drawn. For BGR , we pass a tuple. eg: (255, 0, 0) for blue color.
thickness: It is the thickness of the line in px .
line_type: It denotes the type of the line for drawing.
shift: It denotes number of fractional bits in the point coordinates.
tipLength: It denotes the length of the arrow tip in relation to the arrow length.
Return Value: It returns an image.

The image is used for all the examples below:

Example No. 1:

# Python program to explain the cv2.arrowedLine () method

 
# cv2 import

import cv2 

 
# path

path = r ’ C: UsersAtomixDesktoppythonengineeringgeeks.png’

 
# Read the image in default mode

image = cv2. imread (path) 

 
# Name of the window in which the image is displayed

window_name = ’Image’

 
# Starting coordinate, here (0, 0)
# represents the top left corner of the image

start_ point = ( 0 , 0

  
# End coordinate

end_point = ( 200 , 200

  
# Green in BGR

color = ( 0 , 255 , 0

  
# Line width 9 px

< code class = "plain"> thickness = 9

  
# Using the cv2.arrowedLine () method
# Draw a green arrow diagonal line
# 9px thick

image = cv2.arrowedLine (image, start_point, end_point,

  color, thickness) 

 
# Display image
cv2.imshow (window_name, image) 

Output:

Example # 2:

# Python program to explain the cv2.arrowedLine () method

 
# cv2 import

import cv2 

 
# path

path = r ’ C: UsersAtomixDesktoppythonengineeringgeeks.png’

 
# Read image in default mode

image = cv2.imread (path) 

 
# Name of the window in which the image is displayed

window_name = ’Image’

  
# Starting coordinate, here (225, 0)
# represents the top right corner of the image

start_point = ( 225 , 0

 
# End coordinate

end_point = ( 0 , 90

 
# Red color in BGR

color = ( 0 , 0 , 255

 
# 9 px line thickness

thickness = 9

 
# Using the cv2.arrowedLine () method
# Draw a red arrow line
# 9px thick and tipLength = 0.5

image = cv2.arrowedLine (image, start_point, end_point, 

color, thickness, tipLength = 0.5

 
# Display image
cv2.imshow (window_name, image) 

Output:

Shop

Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best laptop for development

$499+
Gifts for programmers

Best laptop for Cricut Maker

$299+
Gifts for programmers

Best laptop for hacking

$890
Gifts for programmers

Best laptop for Machine Learning

$699+
Gifts for programmers

Raspberry Pi robot kit

$150

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically