I am trying to find out how can I count the number of people in a room using the feed coming in from a CCTV camera fixed in one of the top corners of the room. The number of cameras can be 2 at max but 1 for now. The objective is to only be able to tell how many persons are present in the room, in real time. The precision of it is not too important, for e.g. the system could suggest a range like "there are more than 5 people right now".

Upon browsing and researching, I came across a lot of very complex algorithms and terms related to Computer Vision and Image Processing that I have not understood at all like OpenCV, HOG, Blob Detection/Tracking, Foreground/Background Subtractions etc.

I am a design student. I do not have a background in programming. But, about a week back I got introduced to Processing. So, if some could help me out here with some tutorials/references/code to have it work in a language like Processing for prototyping purposes.

Thanks in advance.

  • 4
    $\begingroup$ Not to be overly pessimistic, but unless there's some piece of code or application that does this out of the box, I think you'll have a hard time solving this problem without understanding the complex algorithms. $\endgroup$
    – Ivo Flipse
    Sep 15, 2013 at 18:34
  • $\begingroup$ Start with the most, most simple case, for example counting the cars in this Matlab demonstration It will give you a basic idea of the steps involved. $\endgroup$
    – Maurits
    Sep 16, 2013 at 11:24
  • $\begingroup$ Unless you are willing to do a lot of programming and to understand those algorithms you used (like those in opencv), I donot see a good chance for you to finish this task. $\endgroup$
    – pitfall
    Sep 23, 2013 at 17:54
  • $\begingroup$ please help how can i count the number of people entering in a minibus taxi using this.in my country the drivers and the assistant of him are cheating the transport authority by loading a number of people beyond the limit. i am working on it and how can i count the number of people so that if the limit excceds the engine will shutoff? it is better to be on the seat. $\endgroup$ Oct 14, 2017 at 8:40

2 Answers 2


This is clearly not an easy task.

The problem is, if you want a more-or-less accurate count, then you need to turn to advanced algorithms (and maybe use 2 cameras, or a kinect).

If you can't afford to take this path, then you need to try simpler options. Personally, I would try the following:

  • detecting skin pixels, segmenting the image with respect to that, then count the blobs (complexity medium);
  • detect faces, then count them. Obviously, people have to be facing the camera, but you can find any implementations of face detection with different libraries (complexity low);
  • use background subtraction (after some careful tuning to take into account natural illumination changes) and guess a count based on the number of pixels that belong to the foreground (complexity low, but expect poor results);
  • apply some existing pedestrian detection algorithm (complexity medium to high).

You don't have to implement all that by yourself. In your case, checking what OpenCV can do (or if your algorithm of choice is implemented in OpenCV) seems a good choice because:

  1. Processing and openFrameworks have wrappers to OpenCV;
  2. OpenCV usually has a good runtime performance;
  3. many computer vision algorithms that will interest you are developed with OpenCV (face detection, background subtraction, probably pedestrian detection).

OpenCV is a open source computer vision library that is based and can be used in most languages. It provides a quick way to compute Computer vision.

That being said, this problem is very complex, if you do not have any real experience in image processing and of course, programming! You want to identify how many people are in the room, so yes, foreground / background subtraction is going to come in useful in this problem domain. The main concern would be to identify a person from an object in the room. Ask yourself: How would/could I do this?

If I was you, I would take this work and base it on a "still image" and gain knowledge and experience in identifying people that are in a room. Stay away from programming languages (such as C/C++ -- for now!) concentrate on something like Python + OpenCV alternatively use Matlab.

Hope this helps a bit.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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