Shape Detection

Learn to detect shapes.

In this lesson, we’ll learn to detect shapes. It’ll help us find different types of shapes in our image. It can be used for data collection in scientific and various other fields.

First, we need to convert our image to grayscale. Converting the image to grayscale is really important, because it helps us find the edges properly. We use the edge detection algorithm to detect edges, along with the retrieval algorithm to detect shapes:

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Convert to a canny image

To convert an image to a Canny image, we use the cv2.Canny() function of the OpenCv ...