Ask Your Question

Moving object classification

asked 2016-03-17 04:33:29 -0500

devansh20la gravatar image

My project requires me to track road traffic parameters from a stationary camera.

I have tracked moving features using optical flow farneback algorithm, created a binary image with white blob on the moving object. Now, my want to classify them as cars or motorbikes.

I tried using the blob area but the problem is the contour/blob area increases or decreases as the object comes closer or away from the camera.

Any suggestion on how can I tackle this issue?

Binary image:

Output Image:

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-03-18 03:38:36 -0500

Have a look at the cascade classifier to effectively "recognize" cars and motorbikes. This classifier is able to perform multi-scale recognition, so the difference in appearance shouldn't be a problem. OpenCV comes with an already trained car detector, but I don't know if it is suitable for your needs.

In a general approach, you don't necessarily perform object tracking before the recognition, but as you already have it and it could speed up a lot! your recognition stage (only try to recognize the detected object), you should try to keep it.

If you don't know how to start with the cascade classifier, have a look at these tutorials or the chapter 5 of the book named "OpenCV 3 Blueprints". They will give you a lot of indication on how to start, and (in the book) how important it is to collect a good dataset to fulfill your needs.

edit flag offensive delete link more


Thank you for the advice. I wasn't planning to recognize objects before but then I thought of extending the project to recognition of objects. My opencv folder has xml files only for full body eyes face smile license plate I couldn't find one for cars.I tried it with few other cascades available online for cars but no luck.

devansh20la gravatar imagedevansh20la ( 2016-03-18 11:42:48 -0500 )edit

Maybe I was too enthusiastic... It's a plate recognition file... You could probably find database online or create your own dataset from the videos you have.

Mathieu Barnachon gravatar imageMathieu Barnachon ( 2016-03-18 11:55:42 -0500 )edit

answered 2016-03-17 06:38:08 -0500

zshn25 gravatar image

The aspect ratio of cars and moterbikes may be relatively less. But, cars will have more width (and length) You can check the length and width of each blob and set a threshold to classify the vehicles.

Also, you can check the blob properties in an ROI (the junction) to make it more effective. The blob area and aspect ratio wouldn't vary that much within the ROI

edit flag offensive delete link more


The aspect ratio of the object changes as the take turns around the junction the ROI works well but I am detecting car with a red bounding box and bikes with blue. Is there a way to detect contour in a region and then set the color for the entire time the object is in the frame?

devansh20la gravatar imagedevansh20la ( 2016-03-18 11:35:50 -0500 )edit

Question Tools

1 follower


Asked: 2016-03-17 04:33:29 -0500

Seen: 617 times

Last updated: Mar 18 '16