An occupancy screen showing a “negative” number of people in an empty building at midnight is the most familiar fault of a people counting project on site. Counting data becomes input to decisions on energy management, staff planning, evacuation and space use; that’s why the question of how accurate the count is should be answered before installation, not afterwards. Whether it’s a store, office, factory entrance, meeting area or campus passage, below we explain camera placement, counting line design, the occlusion problem in crowds and how to measure accuracy against manual counts.
The difference between counting and occupancy analysis
The two applications are often confused. Yet they need different camera designs and make errors in different ways.
| Feature | Entry–exit counting | Area occupancy analysis |
|---|---|---|
| What it measures | Number of people crossing a line (directional) | Number of people in an area at a given moment |
| Camera location | Above the passage point, narrow frame | Wide frame seeing the whole area |
| Error accumulation | The entry–exit difference can drift during the day | Each measurement independent; no accumulation |
| Typical use | Visitor traffic, capacity control | Meeting room, canteen, waiting room |
It’s possible to calculate the instantaneous number of people in a building from the difference between entries and exits; but small counting errors accumulate during the day. A “negative” count in the evening, or people appearing in an empty building, is the result of this accumulation. The system isn’t broken; that’s how the calculation works. Reset the occupancy calculation based on the entry–exit difference at set times (for example at midnight), or support it in critical areas with direct occupancy analysis.
Overhead and angled camera placement
For entrance counting, the most reliable results come from placing the camera directly above the passage point, looking down (overhead). In this position, people don’t hide each other; each person appears as a separate head-and-shoulders silhouette.
Overhead placement
- Advantage: Occlusion is minimized, and people walking side by side are separated. Because faces aren’t visible, less data is produced in privacy terms too. Even so, the result being an aggregate count doesn’t mean the source image is anonymous; state separately whether raw video and metadata are recorded.
- Limit: The width covered is determined by mounting height and lens angle. With a low ceiling, seeing a wide door with a single camera gets harder; multiple cameras and merging counts are needed.
- Note: Many manufacturers offer dedicated overhead cameras for counting (including stereo or depth-sensing models) and give the mounting height range on the datasheet. Going outside this range lowers accuracy. A common deviation is the suspended ceiling height being measured incorrectly during the survey.
Angled placement
- Advantage: Can be done with existing security camera systems; wide entrances can be seen with a single camera.
- Limit: People walking toward the camera end up behind each other, and misses increase in crowds. Strollers, hand trucks and large bags distort the bounding box.
Ceiling-mounted fisheye cameras see a wide area from above and can be used for both counting and occupancy; however, people get distorted and smaller toward the edge of the image. We covered their limits in the fisheye and panoramic cameras article. For the relationship between mounting height and field of view, see the camera mounting height and angle guide.
Counting line and direction definition
Counting happens when a person’s tracked trajectory crosses a virtual line in a given direction. Line design affects accuracy as much as the camera does:
- Put the line near the center of the frame. The person must be trackable for a few frames before and after the line; a line close to the edge misses the crossing before tracking starts.
- Choose the point where the flow settles, not the doorway threshold. People who hesitate, turn back or chat in the doorway produce double counts. Put the line one or two meters inside the door, in the area where people walk straight.
- Define the direction explicitly. Entries and exits should be written to separate counters; for a two-way line, which side is “inside” should be documented. A reversed direction turns the whole report upside down.
- Filter out turning back and hesitation. Some systems remove from the net count a person who crosses the line and turns back; check whether this behavior is enabled.
- Clarify expectations about separating staff and visitors. This separation usually can’t be made reliably from video; if needed, combining with the access control system is required.
Crowding and occlusion problems
Most counting errors happen at busy moments: shift changes, the end of meetings, store opening. The main situations you’ll encounter at these moments are:
- Occlusion: On an angled camera, two people walking one behind the other are tracked as one person. An overhead camera largely solves this problem.
- Identity switches: The tracks of people walking side by side get mixed up; one person may be counted twice or not at all.
- Carried objects and children: A child on a shoulder, a stroller or a hand truck may be counted differently depending on the model’s training. Write down how these situations are handled as a business rule.
- Light changes: Sunlight coming through a glass door, shadows and reflections on the floor produce errors, especially in simple motion-based counters. Deep learning–based models are more robust; even so, they aren’t accepted without testing.
At busy passage points, comparing the counts of two cameras seeing the same line makes problem periods visible. We examined the basic reliability limits of person detection in the person detection with AI cameras article.
Accuracy measurement method
Accuracy is measured by comparing the system count with a reference count made for the same period. The reference is made manually from the same camera’s recording or a separate camera, preferably independently by two people. A reference counted by one person makes mistakes too.
- Choosing the period: Choose a sample totaling a few hours that covers quiet, medium and busy periods. If day and night light differ, include both.
- Splitting into intervals: Split the sample into 5- or 15-minute intervals; count entries and exits separately in each interval.
- Absolute, not net, difference: If the system misses one person and counts another twice, the total looks right. That’s why, as well as the total difference, you should also report the sum of the absolute differences in each interval.
- Separating error types: If possible, match at event level: missed crossings, extra counts, wrong direction.
The worked example below shows why interval-level comparison is necessary. The data is entirely illustrative:
# Example: 4 intervals, entry direction (manual reference vs system)
manual = [42, 118, 37, 15]
system = [44, 109, 38, 15]
total_diff = abs(sum(system) - sum(manual)) # |206 - 212| = 6
abs_diff = sum(abs(s - m) for s, m in zip(system, manual)) # 2+9+1+0 = 12
total_accuracy = 1 - total_diff / sum(manual) # 0.972
interval_accuracy = 1 - abs_diff / sum(manual) # 0.943
print(round(total_accuracy, 3), round(interval_accuracy, 3))
In this example, the total count shows an accuracy of about 0.97, while the interval-based value drops to 0.94; most of the absolute error (9 of the 12 people) occurred in the busy interval. The error clusters at the busy moment. This points to the camera placement or line position needing review. When writing the acceptance criterion, put both values and the separate result for busy periods in the contract. For the general test protocol and precision/recall calculation, see the video analytics performance testing article.
Measurement isn’t a one-off. A short validation should be repeated after furniture changes, door layout changes, lighting upgrades or camera maintenance. In the long run, monitoring the number of “ghost” people left in the building overnight is a simple but useful health indicator.
Reporting and integration
The value of counting data shows in the system it flows into. Common integration options:
- VMS or analytics platform reports: Hourly, daily and weekly entry–exit charts, occupancy curves by area. Often enough for small projects.
- API and webhook: Counting data is pulled via REST API or delivered per event via webhook; it’s transferred to a data warehouse, BI tool or building automation system.
- MQTT: Some cameras and edge devices publish counting events via MQTT; in facilities with IoT infrastructure, this makes connecting to the building management system easier. For protocol details, see the official mqtt.org page.
- ERP/MES and HR systems: Area density per shift can be compared with production planning. In these integrations, data should be numerical only (number of people, time, area); no video or identity information should be transferred.
Keep timestamps with the time zone; have the camera, server and reporting system connected to the same NTP source. Otherwise hourly charts shift and comparison between systems loses its meaning. The first place to look in the console is the camera’s clock setting.
For camera selection and deployment scope in counting and density analysis, see our people counting and density analysis page, and for transferring the data to enterprise systems, our camera API, ERP and MES integrations page.
Frequently asked questions
Which camera position is most accurate for people counting?
For entrance counting, the most reliable results come when the camera is mounted directly above the passage point looking down (overhead). In this position, people don’t hide each other; angled cameras miss more in busy moments because of occlusion.
Can people counting be done with existing security cameras?
It can, but angled security cameras suffer from occlusion in crowds and accuracy drops. They can give acceptable results at low- and medium-density entrances; decide with a pilot comparing against manual counts.
How is counting accuracy measured?
The system count is compared, in 5- or 15-minute intervals, with a manual reference count made for the same period. As well as the total difference, calculate the sum of the absolute differences in the intervals; misses and extra counts can cancel each other out in the total.
Why does the number of people in the building drift with the entry–exit difference?
Small counting errors accumulate during the day, and the entry–exit difference drifts away from the real occupancy. Reset counters at set times, or support them in critical areas with cameras doing direct occupancy analysis.