Counting objects with OpenCV using Edge detection, Thresholding, and Contours detection (2/17)
January 22, 2019
This is Project #2 in series of 17. Started with a quick refresher in OpenCV basics, I have covered:
- Loading and displaying an image.
- Accessing individual pixels.
- Array slicing and cropping for extracting ROIs(Region of Interest).
- Resizing images.
- Rotating an image.
- Smoothing an image.
- Drawing on an image.
You can find the source code to all the above-mentioned processes here. And see the image below to check how the output of each one of them looks like.
Now, the next part of the project is "Counting the no. of objects in an image". For now, it is limited to images with white background.
So, to prepare an image for the above use-case, we are required to undergo the following steps:
- Learning how to convert images to grayscale
- Performing edge detection
- Thresholding a grayscale image
- Finding, counting, and drawing contours
- Conducting erosion and dilation
- Masking an image
And after each of the above step, respectively, the image would look something like (considering an "example-input image", for instance):
And the final output, be like:
Have a glance at the source-code for the above use-case here.
That's all for this project.
Till next time! o/