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.
CODE:
VIDEO:
Here's a small video on how it works.
Hi, what will happen of more than 1 car is detected?
ReplyDeleteHi 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.
ReplyDeleteI've applied better methods than this, but haven't uploaded on blog.
can u send me the code for that. I am currently working on this project. please help me
Deletemas saya mau tanya, nentuin x dan y dari jalan nya gimana ya.
ReplyDeletecan you upload those better methods sir,,need help
ReplyDeletesir error occure in erode function .... can you tell me how to solve this error ?
ReplyDeletesir error occurred
ReplyDeleteIs there any changes in backgroundSubstractorMOG() method it throws up an error, and also using backgroundSubstractorMOG2() it throws a type error
ReplyDelete