When a camera only has to say 'about six people, never more than eight', the build is far simpler than person tracking. This guide is for anyone who needs a live occupancy number for a room, a lab or a shop floor from one fixed overhead camera, with two cameras at most. You will size the floor coverage from mounting height and focal length, run a five-step background-subtraction pipeline, calibrate one pixels-per-person constant for your geometry, and learn what accuracy to promise: about ±1 person up to eight in view, and the point past which the method stops holding.
What a ceiling camera can and cannot count
The method that survives real rooms is foreground-pixel counting. Learn an image of the empty floor, mark the pixels that changed, and divide the foreground area by the floor area one person covers. Crowd-counting research has derived people counts from foreground pixel totals for years, and commercial occupancy estimators report exactly this kind of range. Nobody has to face the camera, and two people standing close enough to merge into one blob are handled automatically, because the estimator divides a total area rather than counting blobs.
Face detection and body detectors answer a different question, who is where, and pay for it: turned backs, seated people and anyone behind a shoulder drop out. Area integration has no such failure mode, and it runs in a few milliseconds per frame.
Commit to these expectations with a straight-down camera sampling the floor at 10 mm/px or finer: ±1 person up to about 8 people in view, ±2 up to about 15. Past roughly 15 people in one frame, occlusion and merged shoulders bias the count low. That is the method's wall, not a tuning problem. A corner-mounted camera can still work; the next section shows what it costs.
How much floor one camera covers
A downward-looking camera projects its sensor onto the floor as a rectangle. At mounting height H, focal length f, sensor width w, sensor height h and image width W in pixels:
Take the common 1080p security class: a 1920 × 1080 sensor in the 1/2.8-inch format has an active area of about 4.98 mm × 2.80 mm. At H = 5.0 m with a 2.8 mm lens, FOV_width = 5.0 m × 4.98 mm ÷ 2.8 mm = 8.89 m and FOV_depth = 5.00 m. The GSD is 8.89 m ÷ 1920 px = 4.6 mm/px.
Two corrections before trusting the rectangle. Rectilinear wide lenses stretch the outer tenth of the frame, so edge sampling runs 20-30 percent coarser than the centre; exclude the outer 10 percent from the count. And a camera that is not exactly vertical turns the rectangle into a trapezoid whose far edge sits at H ÷ cos(tilt), with sampling coarsened by the same factor.
Coverage per camera with that sensor and lens:
| Room | Mounting height | Floor coverage | Cameras |
|---|---|---|---|
| 4 m × 4 m meeting room | 3.0 m | 5.3 m × 3.0 m | 1 |
| 8 m × 5 m open area | 5.0 m | 8.9 m × 5.0 m | 1 |
| 10 m × 10 m classroom | 5.0 m | 8.9 m × 5.0 m | 2 in corners, zoned |
| 15 m × 8 m hall | 8.0 m | 14.2 m × 8.0 m | 2 |
A ceiling-corner mount views the far floor at 50-60 degrees off vertical, so slant range approaches twice the height and one person's pixel area falls toward a quarter of the near value. That is why corner installs need one calibrated constant per zone.
The five-step counting pipeline
Everything here is arithmetic that a smart camera or an ordinary PC clears in milliseconds per frame. Five frames per second is enough; 10 fps adds margin for fast walking.
- Learn the background. With the room empty, average about 30 frames at the working exposure into one reference image.
- Difference and threshold. Take the absolute pixel difference against the reference and mark pixels above 25 of 255 grey levels. LED-lit ceilings hold a fixed threshold; rooms with windows need a threshold per cell of an 8 × 8 grid.
- Clean the mask. Erode twice, dilate twice with a 3 × 3 kernel, fill holes, and drop any blob under a tenth of one person's area — under 300 px at the worked-example geometry. The pixel-area step is the same binary-image pixel counting used for part inspection, just with people as the blob.
- Mask the dead zones. Exclude the outer 10 percent border, flickering fixtures, door swings and furniture nobody stands on.
- Divide. people = round(foreground pixels inside the mask ÷ k). That one division is the whole estimator.
Because step 5 divides a total, two people touching still count as two, which is where area integration quietly beats blob counting. If the mount itself moves, the registered-subtraction variant for a moving background is the fix (object detection on a moving background).
Fix exposure at 5-10 ms and lock gain. Under 300-500 lux office lighting at f/2.8 that exposes cleanly on modern sensors, and a person walking at 1.4 m/s blurs only about 3 px in 10 ms. Auto exposure re-brightens the scene whenever the crowd changes and shifts the threshold under you (which pixels drive auto exposure on color cameras).
Calibrate pixels per person, then divide
Predict the constant from geometry, then measure it once. Seen from straight above, head plus shoulders form an ellipse of roughly 0.45 m × 0.35 m, an area of π ÷ 4 × 0.45 × 0.35 ≈ 0.12 m². At the 4.6 mm/px sampling above, the gross silhouette is 0.12 m² ÷ (0.0046 m)² ≈ 5,800 px. Thresholding and erosion keep roughly half of that in a furnished room with mixed clothing, so k lands near 3,000 px for that geometry.
Measure rather than assume: one person stands at five positions across the floor and you take the median foreground count. Expect the readings to spread ±30 percent with clothing and posture; the median absorbs that.
The constant scales with (H ÷ f)², so it moves fast with height. Mount at 4.0 m instead of 5.0 m and k falls to 3,000 × (4.0 ÷ 5.0)² = 1,920 px. Sampling coarser than about 10 mm/px leaves fewer than 45 px across a 0.45 m shoulder, and the mask starts fragmenting into pieces no morphology glues back. Turn your own coverage rectangle into a minimum pixel count with the calculator:
For a corner mount, calibrate near, mid and far zones separately; the far-zone constant is typically a quarter of the near one.
Worked example: 8 m by 5 m room, camera at 5.2 m
Room: an 8 m × 5 m open office area. Camera on the ceiling truss, straight down. Sensor 1920 × 1080 in 1/2.8-inch format, 2.8 mm lens.
- Coverage. At 5.0 m the rectangle is 8.89 m × 5.00 m, an exact fit on the 5 m side, so mount at 5.2 m: FOV = 5.2 m × 4.98 mm ÷ 2.8 mm = 9.2 m wide × 5.2 m deep, with margin on all four walls once the border mask is applied.
- Sampling. GSD = 9.2 m ÷ 1920 px = 4.8 mm/px. One 0.45 m shoulder spans 0.45 ÷ 0.0048 ≈ 94 px.
- Calibration. Five one-person readings across the floor come back at 2,450, 2,650, 2,800, 3,000 and 3,250 px. The median is 2,800, so k = 2,800 px — about half the gross 5,400 px silhouette that 0.12 m² ÷ (0.0048 m)² predicts, right where the geometry says it should land.
- Live count. At 17:40 the mask holds 19,600 px. 19,600 ÷ 2,800 = 7.0, so the display reads 7 people: more than 5, never more than 8.
- Confidence. A manual headcount at 17:40 also says 7. Across the afternoon, three manual headcounts all land within ±1 of the logged count.
That is the deliverable: a number, a band around it, and one day of evidence that the band holds.
Where the count drifts, and the fix
Four drifts remain, in order of how often they bite:
- Sunlight through windows lifts whole regions above threshold. Move to a per-cell threshold (step 2) and re-check at each season change; the same playbook used to control ambient light variation in vision cells applies.
- Shadows and reflections add foreground nobody stands in. Raise the threshold in 5-grey-level steps first; on a matte floor shadows rarely pass 35 of 255.
- Doors swap the background when they swing. Mask the swing area permanently.
- A loose mount changes the geometry and the calibrated k together. If counts drift with nothing visible in the frame, check the bracket before the algorithm.
Hardware that runs the count
The pipeline needs no machine-vision light — the room's own ceiling lighting is the illuminant — and no PC above the ceiling if you pick a camera that processes on device. A smart camera runs subtraction, morphology and the division internally and publishes the number over Ethernet.
The MV-SC6050C-08M-XBN is a 5 MP color smart camera with a global shutter, an 8 mm M12-mount lens and a GigE interface. For a small meeting room from one head at that class: at 5.2 m mounting height, an 8 mm lens over a 1/1.45-inch-format sensor covers about 5.7 m × 4.3 m of floor.
- Interface
- GigE
- Resolution
- 5 MP
- Sensor format
- 1/1.45"
- Shutter
- Global
Where you want the cleaner threshold a mono sensor gives (why mono contrast beats color), the MV-SC5060XM-08M-WBN is a 6 MP mono smart camera on GigE. Rooms wider than one head's rectangle take the C-mount route, where lens choice is yours: the MV-CU020-90GC is a 2.5 MP GigE camera with a global shutter and a C-mount that accepts any wide-angle C-mount lens you specify.
Large halls need pixel count at height, so mount the high-resolution head. The MV-CS200-10UM is a 20 MP mono camera on USB3.0 with a 1" sensor and C-mount. In a hall mounted at 8 m, twenty megapixels in the same coverage rectangle samples about three times finer than the 1080p example, which multiplies the pixels-per-person constant roughly ninefold and the count resolution with it.
- Interface
- GigE
- Resolution
- 6-10 MP
- Sensor format
- 1/1.7"
- Lens mount
- C-mount
- Sensor format
- 1"
- Lens mount
- C-mount
Browse the smart cameras and area scan cameras categories, filter the camera finder by interface and resolution, or start the camera configurator to size the whole chain.
Checks before you order
Ten minutes with a tape measure and a scale drawing prevents a re-mount:
- Lay the coverage rectangle (H × sensor width ÷ f) over the drawing at the planned mount point. Every spot a person may stand must fall inside, minus the outer 10 percent border.
- Compute the GSD at the farthest monitored point and keep it at or below 10 mm/px.
- Confirm the counting device holds 10 fps at full resolution with the pipeline running; at 1080p any current smart camera or desktop PC clears this.
- Fix exposure at 5-10 ms and gain at commissioning; no automatic modes anywhere in the chain.
- Plan the calibration walk: one person at five positions, then a two-person reading with people touching as the merge test.
- Specify a rated mount and a safety tether over any walkway.
- Agree the deliverable as a range: '7, no more than 8', not '7'.
When to use a different method
Pixel counting answers how many, now. It does not answer who, which direction, or how long, and stretching it to try is where installs disappoint:
- Exact entry and exit totals belong to a doorway line count at the threshold, not a room-area estimate. For the sensor technology behind a door or zone counter, compare active infrared depth with stereo (active infrared depth versus stereo for people counting).
- Dense rooms past about 15 people, racking, or bodies under tables need depth rather than area; a depth camera chosen for person detection resolves overlaps a 2-D mask cannot (person detection with a depth camera).
- Occupancy dashboards, room booking and ventilation control are the sweet spot: a range is genuinely enough, and the method's output is a number, which keeps the deployment on the private side of any discussion about storing imagery.
If that is your case, one straight-down camera and one calibrated division will hold ±1 person up to eight and keep holding while you work on something else. Send the room dimensions and mounting height through the contact page and we will check the coverage rectangle and constant with you, or continue with the applications topic guides.
Questions
How accurate is a foreground-pixel occupancy count?
Treat it as a range, not a census. With a straight-down camera and a calibrated constant, expect ±1 person up to about 8 in view and ±2 up to about 15. The worst case is dark clothing on a dark floor, which shrinks the mask, so calibrate with the darkest clothing the room sees. For an exact number, count where people pass a door instead.
How many pixels per person does this method need?
Keep the ground sample distance at or below 10 mm per pixel, which leaves roughly 45 pixels across a 0.45 m shoulder span. At the 4.6 mm/px coverage example one person spans about 97 pixels, comfortable even in dark clothing. Coarser than that, masks fragment and the count drifts low no matter how well the threshold is tuned.
Can one camera cover a 10 m by 10 m room?
Not from one head at 5 m: a 2.8 mm lens on a 1920 × 1080 sensor covers about 8.9 m × 5.0 m there. Two cameras in opposite corners do cover it, but slant range to the far wall doubles, so each zone needs its own calibrated constant. Four cameras facing straight down cost more hardware and give one constant for the whole floor.
Does the count survive when people stand still for minutes?
Walking people never merge into the background; still ones slowly do if the model keeps adapting. Watch the log for the symptom: a count that slides downward over ten minutes with a constant crowd means background leakage. Freeze the model during occupied hours and re-learn only at a known-empty time such as the night shift.
Why not detect faces and count the detections?
Face detection needs people facing the lens, so backs, seated people and anyone screened by another shoulder drop out, and it costs far more compute per frame than a subtraction and a division. The pixel method also stores only a number, which keeps an occupancy deployment on the private side: no face imagery is kept or processed.



