Add Shapes

Learn to add shapes to images.

Imagine we want to put a certain shape, such as a rectangle, around a specific portion of an image to draw the viewer’s attention. It takes a very long time to add borders to all the images. Instead, we can use OpenCV to draw the required shapes on those images much more easily.

In this lesson, we’ll draw different shapes on the image below. We’ll draw a circle around one of the balls, a rectangle around a button, and a line on the diagonal.

Draw the circle

To draw a circle, we use the cv2.circle() function of the OpenCV library. This function requires five parameters, which are listed below: ...