NU · neighbordoorsrecords over spin
Open in NU's Reading Room →

How a Computer Counts Cars in a Video Clip, in Plain Language

A camera, a clip, and a number on the screen — here is what the machine is actually doing between the pixels and the count, with no magic.


You point a phone at a busy street, the clip runs, and a few seconds later a number appears: 14 cars. It feels like the screen just knew. It didn't. Underneath that tidy number is a chain of small, dumb, checkable steps — and once you see them, the whole thing stops feeling like magic and starts feeling like arithmetic. Here is what the machine is really doing.

A video is just a stack of pictures

Start with the thing people forget. A video clip is not a flowing river of motion. To a computer it is a flip-book — a stack of still images called frames, usually 24 to 30 of them per second. Nothing in the machine "watches" the clip. It picks up one frame, looks at it, sets it down, picks up the next.

So "count the cars in this video" really means: look at a pile of photographs, find the cars in each one, and figure out which cars are the same car showing up again across photos. Two separate jobs. The first is finding. The second is not double-counting. Most of the cleverness — and most of the mistakes — live in those two jobs.

Finding things: boxes and labels

The finding step is called object detection. The classic public example is a family of models called YOLO — short for "You Only Look Once," first published by Joseph Redmon and collaborators in 2016. The name is the whole idea: instead of sliding a magnifying glass over the image a thousand times, it takes one pass over the frame and reports everything it spots at once. That is what made it fast enough to run on live video.

What does it report? Two things per object: a box and a label. The box — the "bounding box" — is just four numbers that describe a rectangle: where its corners sit on the image. If you have seen a self-driving-car demo with colored rectangles snapping around every vehicle and pedestrian, you have seen bounding boxes. The label, called a class, is the model's guess at what is in the box: car, truck, person, dog, bicycle.

The model can only name things it was taught. The standard public teaching set here is COCO (Common Objects in Context), a Microsoft-released dataset with 80 everyday categories — including car, truck, bus, motorcycle, and bicycle, but not, say, fire hydrant color or brand of sedan. A detector trained on COCO will happily draw a box and say "car." Ask it for "delivery van versus moving truck" and it has no such word, because nobody showed it that distinction. The vocabulary is fixed by the training, not by the moment.

Confidence: the number behind the box

Here is the part that matters most and gets skipped most. The model never actually knows there is a car. For every box it draws, it attaches a confidence score — a number between 0 and 1 — that means roughly "how sure I am this is what I labeled it." A clean, close-up sedan in daylight might come back at 0.95. A half-hidden shape behind a bus in the rain might come back at 0.38.

Somebody has to pick a cutoff. That cutoff is called the confidence threshold, and it is a dial, not a fact. Set it high — only count boxes above 0.7 — and you get clean, trustworthy counts but you miss the hard cases: the partly-blocked car, the one at the dark edge of the frame. Set it low — count anything above 0.2 — and you catch those, but you also start counting shadows, reflections, and a parked motorcycle the model briefly mistook for a car.

This is why two honest tools can watch the same clip and report different numbers. They are not lying. They are sitting at different thresholds. Any car count without a stated threshold is half a fact.

One more cleanup: too many boxes

There is a quiet step between "find" and "count." A detector often draws several overlapping boxes around the same car — three rectangles, slightly different, all saying "car 0.9." A technique called non-maximum suppression does the obvious housekeeping: when boxes pile on top of each other, keep the most confident one and throw the rest away. Without it, one car becomes three. It is a plumbing detail, but it is exactly the kind of step that quietly inflates a count if it goes wrong.

Not double-counting across frames

Now the second job. The detector found cars in frame 1, and again in frame 2, and again in frame 3. The same red truck appears in all three. If you just add up boxes, a ten-second clip turns one truck into two hundred.

So the count needs tracking — stitching detections across frames into the conclusion "that red box in frame 2 is the same truck as the red box in frame 1." The simplest honest version just asks: is there a box in this frame sitting almost where a box was a moment ago, about the same size? Then it is probably the same object, traveling. Give each tracked object an ID, and your count becomes "how many distinct IDs appeared," not "how many boxes total."

This is where real counts get decided, and where they break. A car that drives behind a bus and reappears can pick up a fresh ID — counted twice. Two cars that overlap badly can briefly merge into one ID — counted once. Often the count is taken at a single line drawn across the road ("tally each ID the first time it crosses here"), which sidesteps a lot of the mess but also means cars that never cross the line never count.

Why the number is a measurement, not a verdict

Put it together and the magic dissolves into a stack of plain choices: which frames, which detector, what confidence threshold, how overlaps get cleaned up, how objects get matched across frames, where the counting line sits. Change any one of those dials and the final number moves — honestly, with no bug anywhere.

That is the useful takeaway. When a computer tells you "14 cars," treat it like any other measurement: good enough to act on, but produced by settings a human chose, and reproducible only if those settings are written down. The screen didn't know. It found rectangles it was fairly sure about, refused to count the same one twice, and added up what was left. Kooky till proven — and here, happily, it proves out, one frame at a time.

NU original — sourced analysis of the public record. Read it in the interactive Reading Room, or browse more at neighbordoors.com.

Transparency: NU articles are AI-assisted and editor-reviewed, built from the cited primary sources. We label what's proven, alleged, and opinion.