
While finding contours, first always apply binary thresholding or Canny edge detection to the grayscale image. Converting the image to a single channel grayscale image is important for thresholding, which in turn is necessary for the contour detection algorithm to work properly. Converting the image to grayscale is very important as it prepares the image for the next step. Read the image and convert the image to grayscale format. Read the Image and convert it to Grayscale Format.Steps for Detecting and Drawing Contours in OpenCV
Now that you have been introduced to contours, let’s discuss the steps involved in their detection.
Do refer to this paper to study this approach in detail.Ĭomparative image, input image and output with contours overlaid. Notice how the group of people standing still in the left side of the image are not detected. In the figure below, see how detecting the movement of people in a video stream could be useful in a surveillance application.
Motion Detection : In surveillance video, motion detection technology has numerous applications, ranging from indoor and outdoor security environments, traffic control, behaviour detection during sports activities, detection of unattended objects, and even compression of video. Some really cool applications have been built, using contours for motion detection or segmentation. Drawing contours using CHAIN_APPROX_SIMPLE.Īpplication of Contours in Computer Vision. Drawing contours using CHAIN_APPROX_NONE. Finding and drawing contours using OpenCV. Steps for finding and drawing contours using OpenCV. Application of Contours in Computer Vision. So let’s learn about contours and contour detection, using OpenCV, and see for ourselves how they can be used to build various applications. It is often the first step for many interesting applications, such as image-foreground extraction, simple-image segmentation, detection and recognition. Using contour detection, we can detect the borders of objects, and localize them easily in an image.