CountIn
A browser-based computer vision system that counts people in real time. TensorFlow.js does detection; a from-scratch tracker and geometric line-crossing logic handle the counting, all on the client.
CountIn counts people in real time from a webcam with TensorFlow.js. Everything runs in the browser: no server, no install, and the camera feed never leaves the machine. The project is paused for now, kept online as a reference.
How it works
- Detection. A COCO-SSD model loaded through TensorFlow.js finds people in each frame. Detection runs on every other frame to keep the UI responsive.
- Tracking. A hand-written centroid tracker matches new detections to existing tracks by distance, with a confidence gate against flickering false positives and a short position history to survive occlusion.
- Line crossing. You draw counting lines; for each track the system tests whether the segment between its previous and current position intersects a line, using a cross product with a direction sign for in versus out.
- Dashboard. Counts update live per line, with running occupancy and a flow chart.
What is interesting
- The tracker is from scratch, so every stage is debuggable: when counts drift, you can see which stage is at fault.
- Counting is geometry, not ML: a cross product with a sign.
- Zero-server privacy is structural. The camera permission is the only permission, the model is fetched once and cached, and it works offline after the page loads.
TensorFlow.js performance varies a lot across hardware, so processing every other frame and rendering to canvas instead of the DOM is what keeps it feeling real-time.
Status
Paused. The live demo is offline right now; run it locally from the repo. It is static HTML, JS and CSS with no build step, and was tested across modern browsers and a limited range of devices.
Written with AI assistance. I plan to rewrite it by hand.