IKH

Image Segmentation using Contours

From the previous segment, we have a thresholded image which denoted the presence/absence of a vehicle. In this segment, we will learn to extract vehicles using contours by cv2. findContours() function in OpenCV. Since contour is an enclosed shape, it will also give the centre coordinates of the vehicle which will be used for tracking. Further, these will be cropped for vehicle classification. You will learn about tracking in the next session.

The edges only show the boundary where the difference between the pixels is maximum. There is no relation between two or more pixels. Whereas, contours are curves joining all the continuous points (along with the boundary), having the same colour or intensity. It stores the (x,y) coordinates of the boundary of a shape. So, they represent an object/shape and are useful in object detection. Refer to the previous segment here for more clarity. Now, let’s see to draw the contour.

In the above lecture, you saw to plot the contours. As pointed out by Anand, three main parts of object detection are:

  1. Contour mapping
  2. Convex hull detection
  3. Blob detection and validation

In this segment, you learnt about contour mapping. In the next segment, you will learn to find convex hulls, and find and validate the blobs.

Report an error