This article was written by Andrey Nikishaev.
Today I will show you very simple but powerful example of how to count traffic capacity with the algorithm that you can run on devices.
So this algorithm works in 4 steps:
1. Get frame edges.
2. Blur them to get the more filled area.
3. Binary threshold blurred the image.
4. Overlap threshold image with ROI(you mask where you count) and count black pixels/white pixels which gives you traffic capacity.
Edges
Here we use CLAHE equalization to remove noise from the image that can occur on cheap/old cameras at night. It not the best thing, but gives a better result.
Then we use Canny Edge Detector to get edges from the image. We invert it to get white background (just for visual convenient).
Blur
We use basic blur with bilateral filtering which removes some color noise and gives better segmentation.
Threshold
The last filter is a binary threshold which we use to get only white and black pixels which give as our segmentation on car/not car.
Counting
And the last simple step just divides the number of black pixels with the number of white pixels to get traffic capacity.
To read the rest of the article, with illustrations, click here.