Draw Polyline on Image using OpenCV

Draw Polyline on Image using OpenCV

OpenCV provides functionality to draw geometric shapes such as line, rectangle, circle, etc.

The polylines function can be used for drawing polyline. It is a continuous line composed of one or more line segments.

Python
C++
Java
import cv2 import numpy as np img = np.zeros((100, 300, 3), dtype=np.uint8) points = np.array([[100, 60], [140, 20], [180, 20], [220, 60]]) isClosed = True color = (0, 255, 0) thickness = 2 cv2.polylines(img, [points], isClosed, color, thickness) cv2.imshow('Image', img) cv2.waitKey(0) cv2.destroyAllWindows()

Result:

Draw Polyline on Image using OpenCV

Leave a Comment

Cancel reply

Your email address will not be published.