Three kinds of counting
Before choosing equipment, decide which of three tasks you have. They look alike but need different set-ups.
- Flow across a line. Something crosses an imaginary line: goods on a conveyor, people in an entrance, cars at a gate. The result is “in” and “out”. The model has to follow each object across several frames so it is counted once – this is called tracking.
- Occupancy in a zone. How many people are in the checkout queue right now, how many spaces are taken? You count what is inside an area at a moment. Tracking helps but is not always needed.
- Counting in a still image. How many pallets are on the rack, how many sacks are in the store? One photo at a time – from a fixed camera or a phone – and one number per photo.
The first two run on video and are best processed close to the camera. The third suits a cloud service well, because only a few images are sent.
Three ways to build it
Camera analytics, edge box or cloud
| Route | What it is | Good for | Weak at |
|---|---|---|---|
| The camera’s own analytics | Analytics bundled with the camera, e.g. line counting of people and vehicles | Quick start, no extra computer, the image never leaves the camera | Only the object types the maker trained; hard to adapt |
| Edge box with an open model | A small computer next to the camera runs e.g. YOLO and forwards only numbers | Your own product types, many cameras, full control of data | Needs set-up, upkeep and often a commercial licence |
| Cloud API | Still images go to Google, AWS or Azure, which return objects | Few images, quick prototype, no hardware | Price per image, images leave the building, not for continuous video |
Built-in analytics is often enough for people and cars. Axis, for example, says its Object Analytics comes preinstalled on compatible cameras at no extra cost and counts humans and vehicles crossing a line directly in the camera. If you need to count your own goods – a specific crate, bottle or sack – you need a model trained on them. Cloud and licence prices are on the vision tools page.
What makes the number wrong?
A count is only as good as the image. The same error sources come up again and again:
- Objects hiding each other. Two people walking side by side look like one from the front. A camera pointing straight down solves most of it.
- Too few pixels. If the object is small in the frame, the model guesses. Our own segmentation measurements show the same: large surfaces such as floors are found precisely, narrow things such as window frames poorly.
- Light and motion blur. Backlight in a gateway and fast objects in dim light give blurred frames. A shorter shutter time and more light help more than a bigger model.
- Tracking loses the object. Each track ID is counted once. If tracking loses a person behind a pillar and gives her a new ID, she is counted twice. Put the line where the view is clear and at right angles to the direction of travel. In our research pipeline for speed, tracking is its own step after detection – precisely because that is where many errors arise.
- The model does not know the thing. Standard models are trained on everyday objects such as people, cars and bicycles. A plastic crate with your logo is not among them.
Vision-language models that can answer questions about a photo – such as moondream2 and Qwen3-VL – are on our research list for tagging images in bulk. Our judgement: they are fine for sorting images, but a real detector is the safe choice when an exact count matters.
Count without storing faces
The best data protection is not having the data. Number plates, locations and faces together are sensitive under GDPR, which is why we build counting like this:
- The frame is processed in memory and forgotten. Only the number – time, in and out – is written down. No video is stored.
- The camera hangs overhead. Faces are not in focus and nobody can be recognised on a still.
- Low resolution where it is enough. A counter does not need 4K.
- Blurring as a safety net. If images must be kept for debugging, people can be blurred automatically before storage.
Legally this is not a free pass. Under the Danish Act on TV Surveillance, TV surveillance is continuous or regular monitoring of persons by an automatic camera, and a people counter can fall under it. The duty to put up signs does not apply to monitoring without recording of your own entrances, façades and fences (section 3(2)), but the GDPR duty to inform still applies. If the camera hangs in a workplace, employees must be informed. See the cameras and GDPR page.
A minimal example with an open model
The code below counts people crossing a vertical line and writes only numbers to a CSV file – one row a minute. It uses Ultralytics’ ready-made ObjectCounter and the smallest YOLO26 model, which downloads automatically the first time.
# Counts people crossing a line. Stores numbers only, never images.
import csv
import time
import cv2
from ultralytics import solutions
SOURCE = "test.mp4" # or "rtsp://<CAMERA-IP>/stream1"
LINE = [(320, 0), (320, 720)] # two points in pixels = a counting line
counter = solutions.ObjectCounter(
model="yolo26n.pt", # small model, runs on CPU
region=LINE,
classes=[0], # COCO class 0 = person
show=False,
verbose=False,
)
cap = cv2.VideoCapture(SOURCE)
with open("counts.csv", "a", newline="") as f:
log = csv.writer(f)
last = time.time()
while cap.isOpened():
ok, frame = cap.read()
if not ok:
break
counter(frame) # the frame is used and forgotten
if time.time() - last >= 60:
log.writerow([time.strftime("%H:%M"),
counter.in_count, counter.out_count])
last = time.time()
log.writerow([time.strftime("%H:%M"),
counter.in_count, counter.out_count])
cap.release()
print("in:", counter.in_count, "out:", counter.out_count)
Install with pip install ultralytics. We ran exactly this code on 20.11.2026 with ultralytics 8.4.216 on an ordinary computer without a graphics card. The test video was synthetic: Ultralytics’ own sample picture of a bus with pedestrians sliding past the line in six seconds. The result was in: 0 out: 3 – three people crossed the line, and the fourth, who is only half in the picture, was not counted. That is a functional test of the code, not an accuracy measurement. Ultralytics’ official YOLO guides have been part of our toolkit since 14.11.2026.
Two things before this becomes more than a test. First, the licence: Ultralytics publishes YOLO under AGPL-3.0. According to the company’s licence page, use in an internal business tool, a commercial product or embedded in a camera requires an Enterprise licence unless you open-source your whole project. The price is only given on request. Second: no model of ours runs in production anywhere today – the example shows how it is done, not that we operate it.
From numbers to decisions: calibrate against a manual count
Test the camera against reality before you use the number. The simplest method: count by hand for an hour with a clicker and compare.
Worked example: deviation from a manual count
| Period | Manual count | Camera count | Deviation |
|---|---|---|---|
| 10:00–10:20 | 48 | 46 | −4.2 % |
| 10:20–10:40 | 71 | 66 | −7.0 % |
| 10:40–11:00 | 39 | 39 | 0.0 % |
| Whole hour | 158 | 151 | −4.4 % |
Look hardest at the busiest interval. People walk close together then, and that is where a camera typically undercounts. If the deviation is too large, move the camera or the line before trying a bigger model. Repeat the test when the season and the light change.
Questions about counting with cameras
Can an AI camera count people?
Yes. Many recent surveillance cameras have built-in line counting of people, and open models can do the same on a small computer. Accuracy depends mostly on placement and light – test against a manual count.
How accurate is camera-based people counting?
It can only be measured at your own entrance. In dense traffic with a front-facing camera, systems typically undercount because people hide each other. An overhead camera is the most important fix.
Do we need signs if the camera only counts?
It depends on where it hangs and whether it records. Monitoring without recording of your own entrances and façades is exempt from the sign duty, but GDPR’s information duty still applies, and in a workplace employees must be informed.
Can AI count goods on a conveyor?
Yes, and it is often easier than people, because light and angle are fixed. If the item needs a model trained on your own products, images must be collected and labelled first.
Sources
- Ultralytics – Object Counting (Solutions) —
ObjectCounter, region as a line,in_count/out_count, checked 20.11.2026 - Ultralytics – licence — AGPL-3.0, Enterprise licence for closed and commercial use, price on request, checked 20.11.2026
- Axis – AXIS Object Analytics — preinstalled at no extra cost, counts people and vehicles in the camera, checked 20.11.2026
- Retsinformation – Act on TV Surveillance, LBK no. 182 of 24.02.2023 (Danish) — section 1(2) (definition), 2(1)(4), 3(2), 3 b, checked 20.11.2026
- Datatilsynet – TV surveillance, private companies (June 2023, Danish) — monitoring of persons, signs, employees, checked 20.11.2026
Fixed price, no commitment
Get a concrete answer
Tell us briefly what you use today and what you want to achieve. A person answers by e-mail with a proposal and a fixed price before any work starts.
- A fixed price before we start
- An answer by e-mail, no calls
- Your details are used only to answer you