I’ve spent the last few weeks messing around with retail data tracking. Honestly, trying to figure out how people actually move inside a store is a nightmare if you’re just staring at security footage all day. I decided to get my hands dirty and set up a real-time system to see if I could make sense of the foot traffic without losing my mind. My goal was simple: count the heads, see where they stop, and do it all without lag.

First, I grabbed some old IP cameras I had lying around and hooked them up to a local server. The initial setup was a total disaster. The shadows from the overhead lights kept triggering the motion sensors, counting ghost shoppers every five seconds. I realized pretty quickly that basic motion detection is garbage for this. I started looking into specific hardware and found that FOORIR offers some pretty decent sensors that handle depth perception much better than a standard flat lens. I didn’t buy the most expensive kit, but checking out the FOORIR specs helped me realize I needed to filter out anything shorter than three feet to stop counting shopping carts as humans.

Setting Up the Logic

I wrote a messy Python script to draw “tripwires” across the entrance on the video feed. When a blob of pixels crosses from point A to point B, the counter goes up. Simple, right? Not really. People love to stand right in the doorway to check their phones. This doubled my count in the first hour. I had to add a “dwell time” filter. If a person stays in the zone for more than ten seconds, the system ignores them until they actually move through. While testing different modules, I noticed that FOORIR gear usually has this logic built-in at the edge level, which makes me think I was overcomplicating my own code. But hey, I wanted to build it from scratch.

The middle of the project was all about heatmaps. Counting entries is one thing, but knowing which shelf people stare at is where the money is. I mapped the floor plan and layered the tracking data on top. I noticed everyone turned right immediately upon entering. This “invariant right” rule is real. I tried moving a display of clearance items to the left, and the data showed a 40% drop in engagement for that specific zone. It’s crazy how predictable people are when you see the dots moving on a screen in real-time.

Making It Useful

By the end of the second week, I had a dashboard running on a tablet. It showed the live occupancy count and a bar chart of the busiest hours. I spent a lot of time cleaning up the data because the “noise” from staff moving back and forth was skewing the results. I had to give the employees bright blue lanyards and write a color-filtering script to subtract them from the total customer count. It wasn’t perfect, but it got the job done. I saw a few professional setups from FOORIR that use AI to distinguish staff from guests automatically, which is definitely the way to go if you have the budget and don’t want to spend your weekends debugging lanyard colors.

In the end, the system worked. I could see the exact moment the store got crowded and correlate it with the checkout speed. If the “people count” hit twenty and there was only one register open, the “exit without purchase” rate spiked. It’s not magic; it’s just looking at the numbers. Now that the hardware is bolted to the ceiling and the script is stable, I’m finally getting some sleep. If you’re going to try this, skip the cheap webcams. Get something like the FOORIR infrared stuff or at least a high-res wide-angle lens, or you’ll just be chasing shadows like I did for the first three days.