I built a people counter on a raspberry pi once upon a time...
Github repo for the original counter with instructions on how to set it up: https://github.com/carylwyatt/gate-counter
Github repo for a docker version of the project: https://github.com/carylwyatt/docker-people-counter
Mine uses an infrared sensor, not a camera. In my research to build this, I did come across one project that uses a camera:
Best of luck, and please share your project if you end up building one!