Thursday, April 7, 2016

Traffic Count using OpenCV Python 'Moments' method | Code | Video

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.

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.

8 comments:

Hi Robert, This method is very primitive and basic and has its fair share of limitation and uses if more cars are there then the centroid will be in between those cars and the answer won't be accurate.I've applied better methods than this, but haven't uploaded on blog.