Teams that want to count pallets through a dock door in a Bhiwandi warehouse, or customers entering a store each hour, usually begin by asking which detection model is best. That question matters less than it seems. The ceiling on accuracy is set earlier, by where the camera is mounted and what it can see, and those decisions are cheap to change before a model is trained and expensive afterwards. This post explains how counting in video works, part by part, so the camera decisions make sense.
The three steps behind a count
Counting objects in video is a computer vision task, one of several listed on our AI solutions page. It sounds like one task, but it is three separate steps, each with its own job.
- Detection finds objects in a single frame. A detector, which is a computer vision model, draws a box around each object it recognises and gives each box a score.
- Tracking links detections across frames, so that the same pallet in frame 10, frame 11 and frame 12 is understood as one object with one identity. The output is a track.
- Counting applies a rule to the tracks. A count fires when a track does what your definition says, such as crossing a line in the inward direction.
- 01Frameone still image
- 02Detectionsboxes with scores
- 03Tracksone ID per object
- 04Count ruleline, zone, direction
- 05Count
Each step only sees what the step before it produced.
In simple terms, the detector answers "what is in this picture", the tracker answers "is this the same thing I saw a moment ago", and the count rule answers "does this thing count". An error in any step flows into the number at the end, and most of the errors start before the detector, with the camera.
How the camera sets the ceiling
A detector can only find what is visible at a usable size. Four camera decisions control that, and each one can be checked on site before anything is bought.
| Camera decision | What it controls | What to check on site |
|---|---|---|
| Angle | Whether objects stay separate | Do objects overlap at the busy hour? |
| Distance and resolution | How many pixels each object gets | Is the smallest object clearly visible? |
| Lighting | What the scene looks like across a day | Morning glare, evening dark, night |
| Frame rate | How often each object is seen | Does a fast object appear in several frames? |
Angle comes first. A top-down view keeps objects apart when they are close together, which is exactly what counting needs. An oblique view, from the side and above, shows faces and carton labels, which helps for other purposes, but it lets objects hide behind one another.
Distance and resolution come next. Each object needs enough pixels to be recognised. A wide view that covers the whole floor may leave a person only twenty pixels tall, and a detector trained on larger objects will miss them.
Lighting changes through the day in ways the training clips may never have shown. A dock door is backlit at eight in the morning and dark by seven in the evening. Sun through a skylight moves across the floor. Fluorescent flicker, infrared at night and a polished showroom floor all change what the model sees.
Frame rate matters for tracking, because the tracker needs an object to appear in several consecutive frames to link them. A two-wheeler at a toll gate, filmed at a low frame rate, jumps across the frame and the link breaks. A very high frame rate costs compute without adding useful information.
- Camera position, lens, lightwhat is visible at all
- Resolution and frame ratehow large and how often
- Detectorfinds objects per frame
- Trackerlinks them across frames
- Count rulewhen a track counts
Each layer can only work with what the one above it provides.
Why occlusion causes so many errors
Occlusion means one object blocking the view of another. Two people walking side by side through a mall entrance become one detection. A forklift hides a pallet for a second, the tracker loses the track, and when the pallet reappears it gets a new identity and is counted twice.
The important part is that many occlusion errors are fixed without touching the model. You can move the camera higher, add a second camera from another angle, or count at a choke point where objects pass one at a time, such as a turnstile instead of the open floor. These are physical changes, which is another reason to decide them before training.
Writing down what a count means
A model does not know what you mean by a count, so write it down in one or two sentences before anyone buys a camera. Here are the questions the definition has to answer.
- Is a count a line crossing, presence inside a zone, or a unique object over a period?
- Does direction matter, and does someone who steps out to take a phone call and comes back count twice?
- Are staff, trolleys, children or empty pallets excluded?
- What happens to an object that is only half in the frame?
For a store, the staff question alone can change the number a lot. Sales staff walk in and out of frame all day, and if they are not excluded, they can add more to the footfall than the customers do.
The definition decides the tracking logic and the count rule. If it changes later, every manual count you compared against stops being valid, because those counts used the old definition.
Checking against clips counted by hand
Record short clips that cover the conditions the camera will actually meet: early morning, evening, the busiest hour, an empty hour, rain on the lens, the forklift in the way. For a store that means a Tuesday afternoon and the Saturday before Diwali, rather than only one of them. A person counts each clip using the written definition. For a sample, a second person counts independently. If the two disagree, the definition is not clear enough yet.
Run the system on the same clips and compare per clip, not in total. A system total of one hundred against a manual total of one hundred can hide ten misses and ten double counts that cancel out. Keep the clips and the manual counts, and rerun them after every change to the camera, the model or the count rule. The same discipline of building the labelled set before choosing a model is explained for still images in checking products in photos.
Common mistakes in video counting
The pattern I see described most often is the camera being mounted before the count is defined, and the angle then turning out not to separate objects at the busy hour. Validation also tends to happen on one afternoon's footage, while the system goes live for a year of lighting changes.
Another mistake is quieter. Someone adjusts the detector's score threshold until the system total matches the manual total. That balances misses against double counts and hides both. And sometimes the camera is moved after training, which means every clip and every label was made for a view that no longer exists. A count that is right in the first month can also drift as the scene changes, and the minimum monitoring for a model in production applies here as much as anywhere.
One more mistake is about people rather than models. Counting people and keeping the footage are two different decisions. Store the counts, decide how long any video is kept and who may see it, and write that down alongside the count definition.
First steps
- Write the count definition.
- Stand where the camera will go and look at the scene at the times that matter.
- Record clips across conditions and count them by hand.
- Only then choose and tune a detector and a tracker.
- Compare per clip, and keep the set for regression testing.
Write the definition before the camera is bought. It is one paragraph, and every clip, label and manual count afterwards depends on it.

