People counting implementation using OpenCV
This is an ongoing research problem, which is much more difficult to solve than face detection due to a gigantic variety of poses, angles, and other factors that play a role. This is usually done with image feature extraction on a large set of images followed by a supervised learning algorithm. In short, there's no unique answer, and there's definitely not a simple "code snippet" one could use for this task.

If you're implementing a specific algorithm, you could probably get better help here, but not at this point.