I am very new to computer vision, (a high school student) and I am working on a project to count the number of people present in a room. I have tried to use the HOGDecriptor for person detection provided by OpenCV (HOGDescriptor_getDefaultPeopleDetector()) but it is very inaccurate, understandably. I was thinking that it may be advantageous to train my own system, since each camera setup would be specific to a certain room. This would greatly restrict the bounds of what the computer has to recognize. (What I mean by this is that if I am analyzing a conference room, little about the environment changes, other than the addition of people. This would limit the scope of the detection problem.)

My question is whether to use a HOGDescriptor or a Neural Network. I was planning on using a HOGDescriptor but was advised that a Neural Network may be more accurate. At the same time however, the way I understand a Neural Network works is that I provide the number of input neurons as well as the number of output neurons, and the training algorithm creates the hidden neurons in between. The problem with this approach is that I would like to be able to count an arbitrary number of people in the camera frame, and thus I could not provide the training algorithm with a definite number of end neurons. I addition, I am able to mark frames positive or negative (whether or not they include people in them) quite easily, but providing the description of the number of people in them would be significantly harder. For both these reasons, it would seem to me that HOGDescriptors would work better, because they do not need to be told how many people are in the frame, and they can create an arbitrary number of "end neurons."

Any help clarifying the benefits of both technologies, as well as advice on which to use, would be greatly appreciated. I realize that this question might be very elementary, but I am willing to learn and will take all responses very seriously. Thank you.


1 Answer 1


Unfortunately, this remains a very challenging problem, that even state-of-the-art techniques find difficult to do accurately. It's probably too hard for a high school project.

The closest work is probably on "pedestrian detection". Do a search on Google Scholar, and you should find a bunch of research papers on this from the computer vision community. However, the state-of-the-art techniques are complex, and even the best techniques aren't super accurate.

You should also read about "object detection", "object recognition", and related topics. That will give you the basics of how to use machine learning (like neural networks) to recognize the location of objects in an image. One standard technique is to crop out a small rectangle from the image, use your classifier to check it contains the object you're looking for (e.g., a person), and then repeat this for many crops of many different regions of the image -- this tells you the location of all people. There are other approaches as well, based on regression to infer the location of the object.

You might find Stanford's CS231N useful for learning more about these techniques.

For your specific problem, doing this in the general case is probably too hard. I'd advise you to look for a way to make the problem easier. One way is to make the problem more constrained and place your cameras carefully to make the machine learning problem easier.

For instance, if the room is a lecture hall where everyone will be seated and facing the same direction, you could experiment with placing a camera that will see everyone from the front, and using facial detection to identify and count the number of faces in the image. Or, you could place a video camera at each entrance and exit and use facial detection or other methods to try to recognize people when they are entering/leaving the room, and count the number who have entered and the number who have left. This will probably be easier if you have two video cameras over each door: one on the outside pointing in, and one on the inside pointing out. Or, you could experiment with entirely different sensors, such as a FLIR camera which can see in the infrared. People are warm and glow in the FLIR wavelengths, which might make it easier to distinguish people from other elements of the scene.


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.