I'm currently working on various simple image processing modules at my internship and got permission to showcase my simple traffic count using a slightly different method than conventional blob analysis or contours method, which is moments method. The moments method works on the geometries of the image like centroid, area etc.
The following is the algorithm that i've applied:
- Get the Video frame by frame, thereby applying processing techniques for every frame/image.
- Apply Background subtraction. Generally when static background is present as in the case of a static CCTV camera, to get a binary image for the moving vehicles. We simply subtracted a static background from the current image thus leaving us with just the moving vehicles.
- Next, apply moments function to each frame, therefore getting the centroid of the moving vehicles( binary image).
- Finally assign a certain range of pixel values in (x,y) form on the frame so that when the centroid of the moment area crosses this range the counter increments by one which is reflected in the counter text.
Here's a small video on how it works.