So, I got this idea a while back. You see these restaurants, especially the smaller ones, right? They never really know exactly how many people are walking in or just passing by. Gut feeling is fine, but sometimes you need actual numbers. My buddy runs a little diner, always wondering about peak times beyond just guessing. We were chatting, and I thought, “Hey, maybe I can rig something up.”
Getting Started – The ‘Why’ and ‘How’
First off, I looked around online. There are commercial systems, sure, but man, they cost a fortune. Way too much for a small place. I figured, there had to be a cheaper way. I’m not trying to build Skynet here, just count folks walking through a doorway. How hard could it be?
I had an old Raspberry Pi collecting dust in a drawer. You know how it is, you buy these things for a project, finish it (or don’t), and then it sits there. So, Pi it was. And I needed a camera. Didn’t need anything fancy, just a basic USB webcam. Found one for cheap, like, really cheap. The goal was always to keep costs super low.
Putting Pieces Together
Okay, hardware sorted. Next step was figuring out the actual counting. I remembered playing around with OpenCV a bit before – that’s some open-source computer vision stuff. Seemed like the right tool. The plan was simple: point the camera at the entrance, draw a virtual line across the doorway in the software, and count whenever something that looks like a person crosses that line.
Setting up was… fun. And by fun, I mean slightly annoying. Finding the right spot for the camera took some trial and error. Needed a good view of the doorway, high enough to avoid people blocking it accidentally, but not so high it couldn’t see properly. Ran a long USB cable, tried to hide it so it didn’t look messy. Used some sticky pads first, camera fell off. Ended up using a tiny screw-in mount. Took basically a whole afternoon.
The Code Bit – Keeping it Simple
Then came the software part. Installed the necessary stuff on the Pi. Getting OpenCV running wasn’t too bad. The core logic was about detecting movement. When something moved across my virtual line, increment a counter. Sounds easy, but took some fiddling.
- First attempts counted everything. Shadows shifting, leaves blowing past the door, even a big dog once.
- Had to add some basic filtering. Ignore things that are too small or move too fast. Tried to make it look for roughly person-shaped blobs.
- Lighting was a pain. Bright sunlight in the morning versus dim light in the evening messed with detection. Had to adjust the camera settings and the detection sensitivity quite a bit.
It wasn’t super sophisticated, honestly. No facial recognition or anything creepy like that. Just basic shape detection and line crossing. Good enough, I figured.
Making it ‘Real-Time’ (Sort Of)
Counting is one thing, but my buddy needed to see the numbers easily. Just logging it to a file on the Pi wasn’t very helpful for him day-to-day. So, I set up a super simple web server on the Pi itself. Nothing fancy, just a plain page showing the current count for the day, maybe the last hour’s count. He could just pull it up on his phone or the tablet they use for orders.
I made it reset the count every night automatically. Kept the data stored in a simple text file or a basic database, just so we could look back at trends later if needed.
Did it Work? Well… Yeah, Mostly.
We ran it for a few weeks. Compared the automated counts to the staff’s rough manual counts and the number of orders. It wasn’t 100% accurate, obviously. Sometimes it missed someone if two people walked in too close together. Sometimes it double-counted if someone lingered right in the doorway. But overall? It gave a pretty decent picture. Way better than just guessing.
My friend found it useful to see the actual busy times, not just when tables were full but when people were actually entering. Helped him schedule staff a bit better. It wasn’t a magic bullet that solved all his problems, but it was a helpful little tool built with cheap parts and a bit of tinkering.
Was it worth the effort? For me, yeah. It was a fun little project, dusting off the Pi and making something tangible. For my friend’s restaurant, it provided some useful data without breaking the bank. Sometimes these simple, low-tech (ish) solutions are all you really need. Didn’t need cloud AI blockchain magic, just a cheap camera, a Pi, and some basic code. Job done.