Object Counting
Last updated
Was this helpful?
Last updated
Was this helpful?
Counting objects is a widely encountered problem in the computer vision field. This tutorial will teach you how to count circular objects in a given area using conventional computer vision algorithms.
The example image is already provided in AugeLab Studio in the example images folder as coins2.jpg file.
Create block in an empty scenario with the example image shown below:
However, you may see that white areas are not separated from each other perfectly. Using the Find Contour block would yield the wrong result:
Now, using the find contour block should yield how many coins we have the in reference image:
That's it! You now know how to count each object in a given area with AugeLab Studio!
As a first step, we'll need to separate the coins from the background using the block. This can also be done with or but separating the color areas and acquiring a binary image will suffice. Create the logic below:
Since we'll be using the block to count how many distinct white area exist, we'll be selecting THRESH_BINARY_INV option to filter the image and adjust the slider to filter the background.
As you see, there aren't 14 block coins in the provided image. We'll need an algorithm to separate or shrink the white areas. For this, we'll be using the block:
Distance transformation calculates how far away each pixel from white color density. Using again will yield distinct white areas for each one: