I have been trying to implement an algorithm for successfully counting cars in an image. I have tried implementing A Method for Vehicle Count in the Presence of Multiple-Vehicle Occlusions in Traffic Images

It estimates the background from a set of various images. I have looked into various other techniques for this purpose and all of these in one way or the other use either background estimation from a set of images or require a video. I have as an input, traffic images where the background (probably road in most of the papers) is hardly visible. Moreover, the images are from different areas so they don't have common backgrounds as well. How should I proceed in that case ?

I am thinking that if somehow I can match the structure of vehicles (car) then probably they can be matched. But I don't know if this is feasible and if it is how to proceed since the image contains multiple occluded vehicles as well.

Any hints or even research papers are also welcome.

A sample image is as follows: Traffic Sample Image

Traffic Sample Image 2

  • 2
    $\begingroup$ Can you post one or two representative example images? $\endgroup$
    – bjoernz
    Commented Apr 18, 2013 at 12:15
  • $\begingroup$ I would look into template matching if I were you $\endgroup$ Commented Apr 18, 2013 at 13:04
  • $\begingroup$ @bjoernz I have added the sample image. $\endgroup$
    – krammer
    Commented Apr 19, 2013 at 4:46
  • 1
    $\begingroup$ This is tough. Do you always see the cars from the front? Maybe something can be done with the windshield/roof combination... How accurate does the counting need to be? How many images need to be processed? Maybe manual labeling is an option mturk.com/mturk :) $\endgroup$
    – bjoernz
    Commented Apr 19, 2013 at 5:12
  • $\begingroup$ @bjoernz I can't depend upon an mturk ;-). I think I don't want it to be very accurate. Initially only a few counts would do. I think SIFT/SURF could help. I can train the classifier from multiple car data sets(most of them have 1 car/image). But I do not know if it would be able to detect multiple cars in an image (may be way less complex than this but still having more than one partially occluded vehicles ) $\endgroup$
    – krammer
    Commented Apr 19, 2013 at 5:24

2 Answers 2


As mentioned the object counting problem is very challenging. A good account of some common approaches is given in Learning To Count Objects in Images.

Creating a SIFT feature database on training images would appear to be the natural path to go down. That in combination with some image segmentation may be the way to go.

Another path might be to look at HOG Chris McCormick - HOG Person Detector Tutorial, which is similarly a feature detection algorithm, could be adapted for cars.


This is a relatively easy method using modern Computer Vision, namely, Deep Learning.
The easiest way would be using transfer learning one a model which was trained on face detection. The reason to use face detection is because it is usually trained to work in similar scenarios: many objects, multiple scales and crowded.

The approach I suggest is:

  1. Choose a well trained face detection model. For instance CenterFace.
  2. Use transfer learning to train it on cars using your own dataset / other available datsets.
  3. Add a wrapper to count the number of detected cars.

With today frameworks both will be straight forward to do.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.