“Just count the boxes.” That is how most object-counting projects start, and it is exactly why so many of them miss the number in production. Run a detector, count the bounding boxes it returns, report the total. The pipeline works in a demo on clean footage, ships to the line, and then the reported count starts drifting from the physical count — sometimes by a few percent, sometimes by double digits on a dense scene. The problem is not that the detector is bad. The problem is that counting is not the same task as detection, and treating them as identical is where the number breaks. Counting deserves its own error budget because counting errors behave differently from detection errors. A single missed detection is one false negative. In a counting pipeline, that same miss becomes part of a running total across a frame, a conveyor pass, or a shift — and the errors accumulate rather than cancel. A detector that scores well on mean average precision can still miscount, because mAP rewards correct localisation on the objects it does find and says nothing about the systematic under- or over-counting that occlusion and dense packing introduce. How does Object Counting actually work? At its simplest, object counting produces a single scalar per region of interest: how many instances of a target class are present. There are three practical families of methods to get that scalar, and they diverge sharply once the scene stops being tidy. Detection-based counting runs an object detector — a YOLO variant, RT-DETR, or an R-CNN family model — and counts the surviving detections after non-maximum suppression. It is the most intuitive approach and the easiest to debug, because every counted object has a box you can inspect. It is also the most fragile under occlusion: when two objects overlap heavily, NMS may suppress one of them, and the count drops by one for every merged pair. Our starting point for most inspection-grade counting is a detector, precisely because the per-object evidence makes the precision, recall, and mAP behaviour of the detector auditable — but we do not assume the box count is the final answer. Density-estimation counting skips discrete boxes entirely. Instead of localising each object, the model regresses a density map whose integral over a region gives the count. This is the standard approach for crowd counting and for very dense scenes — think hundreds of near-identical parts in a bin, or grain, pills, or fasteners packed edge to edge. Density methods do not care that individual objects are indistinguishable; they learn the relationship between visual texture and count. The trade-off is that you lose per-object explainability: the model says “roughly 340 here” without pointing to 340 things. Tracking-based counting applies to counting across time rather than within a single frame — objects crossing a line, entering a zone, or passing an inspection station on a moving belt. Here the count is a function of unique object identities, not per-frame detections, so the pipeline needs a tracker that maintains stable IDs. The failure mode shifts from missed detections to ID switches and double-counting: if the tracker loses and re-acquires an object, it may count the same physical item twice. Counting-by-tracking is fundamentally a data-association problem layered on top of detection. When Should I Use Detection-Based Counting Versus Density Estimation Versus Tracking-Based Counting? The choice is driven by three variables: scene density, whether you count within a frame or across time, and how much per-object explainability you need for downstream reporting. The table below is the rubric we start from. Condition Detection-based Density-estimation Tracking-based Sparse, well-separated objects Best fit — auditable per-object Overkill Only if counting across time Dense / overlapping in one frame Degrades via NMS merges Best fit N/A for static frames Counting items crossing a line Needs a tracker on top Not applicable Best fit Per-object explainability required Yes — every count has a box No — count is a scalar Yes — every count has a track Very high throughput, low density Fast, simple Unnecessary compute Adds association overhead Occlusion is the dominant failure Weak Strong Depends on re-ID quality No single method wins across the matrix, which is why “just count the boxes” fails as a general strategy. A retail intake scenario with cartons on a pallet is a detection problem; a bin of loose fasteners is a density problem; parts crossing an inspection gate on a conveyor is a tracking problem. Getting the method wrong is often a larger error source than getting the model weights wrong. Why Does a Detector That Benchmarks Well Still Produce Inaccurate Counts in Production? Because benchmark accuracy and count accuracy measure different things. A detector tuned to a high mAP on a public benchmark has been optimised to localise objects correctly, averaged across confidence thresholds and IoU thresholds. Counting cares about exactly one derived quantity — the number of surviving detections — and that quantity is sensitive to failure modes mAP smooths over. Three mechanisms drive the gap, and all of them are versions of the same underlying issue this problem shares with every production computer vision deployment: the distance between demo-validated accuracy and measured performance under real conditions. First, distribution shift. The detector saw a training class distribution, lighting, and camera geometry that differ from your line. A model benchmarked on COCO-style imagery meets a top-down camera over a conveyor with specular glare, and its recall on the specific SKU you care about is nothing like its headline number. This is the same demo-to-production gap we treat as the central risk across our computer vision engineering practice. Second, threshold coupling. The count is the number of detections above a confidence threshold. mAP integrates over all thresholds, so it never commits to the single operating point your count depends on. Move the confidence threshold by 0.05 and the count can shift several percent — a sensitivity that never appears in the benchmark figure. Third, NMS behaviour under density. Non-maximum suppression is a count-altering operation. On dense scenes it merges overlapping true positives, and the merge rate scales with packing density — which is why a detector that is fine on sparse validation imagery under-counts systematically on a full bin. How Do Occlusion and Dense Packing Degrade Counting Accuracy, and How Is That Measured? Occlusion removes visual evidence: when object B sits in front of object A, the detector may see one object where there are two, or a partial object it rejects below threshold. Dense packing compounds this because inter-object spacing shrinks below the scale NMS was tuned for, and the suppression step starts eating true positives. Both push the count in the same direction — under-counting — and both get worse monotonically as density rises. The measurement that captures this is count error rate, not detection accuracy. Two metrics matter in practice: Mean absolute error (MAE) — the average absolute difference between predicted and true count across a validation set, in object units. This is the number a production owner actually cares about: “we are off by 4 items on average.” Percentage miscount — MAE expressed relative to the true count, which lets you compare error across scenes of different density. Characterising these against representative footage is the point. On dense or occluded scenes, a detector with a strong benchmark mAP can post a double-digit percentage miscount — an observed pattern across the dense-scene inspection work we do, not a single named benchmark figure — because the density-driven NMS merges and occlusion misses accumulate. Slicing techniques like SAHI running inference on image tiles before recombining can recover some of the density-lost detections, and dense-scene benchmarks such as the SKU110K dense-detection dataset exist precisely because standard benchmarks do not stress the packing regime that breaks counting. What Does Count Error Rate Look Like as a Production Metric Versus Benchmark Accuracy? Benchmark accuracy answers “how good is this detector at localising objects in general?” Count error rate answers “how wrong will the reported number be on this line?” They are not interchangeable, and conflating them is the single most common source of downstream cost. Consider a worked example, with explicit assumptions. Suppose a fastener-inspection station counts parts per tray, trays hold roughly 200 parts, and the detector posts a strong mAP on the vendor’s validation set. In deployment on representative footage, packing density triggers NMS merges and the station reports an MAE of 6 parts per tray — a percentage miscount of about 3%. That 3% is invisible in the mAP figure but directly corrupts the inventory tally, the throughput report, or the defect count that consumes it. If the count feeds automated replenishment or a quality gate, a 3% systematic bias is a shipped defect, not a rounding error. (Illustrative; the actual figure must be measured per environment.) The practical consequence: set an expected-performance contract on count error rate before deployment, not after. Knowing that a line will run at, say, MAE ≤ 3 parts per tray lets a team decide whether that is acceptable, whether it needs a density model instead of a detector, or whether the camera geometry has to change. Discovering the miscount from a physical audit three months later is far more expensive. How Do I Validate an Object-Counting Model Against Representative Production Footage Before Deployment? Validation for counting is not the same as validation for detection, and it has to happen on footage that actually represents the production scene — same camera, same lighting envelope, same density range, same class mix. The checklist below is the minimum we run before signing off a count. Collect representative footage across the full density range — not just the easy cases. The high-density tail is where the miscount lives. Establish ground-truth counts by manual annotation on a held-out set. This is tedious and non-negotiable; there is no count error rate without a true count. Report MAE and percentage miscount per density band, not a single pooled number. A pooled average hides that the model is fine at low density and badly biased at high density. Sweep the confidence threshold and record how the count moves. If the count is threshold-sensitive, pin the operating point explicitly and validate at that point. Check for systematic bias direction. Consistent under-counting from occlusion is a different problem — and a different fix — than random noise around the true value. Measure at production throughput. A model that counts accurately at 5 FPS offline may drop frames at line speed, and dropped frames on a tracking-based counter are dropped counts. That last point connects counting to throughput directly, which is the trade-off the next section addresses. What Throughput Trade-Offs Come With Each Counting Approach on an Industrial Line? Every counting method buys accuracy with compute, and the line speed sets the budget. Detection-based counting costs one detector forward pass per frame; it is the cheapest and scales best at low density, but at high density you may need slicing-aided inference that multiplies the per-frame cost to recover the merged detections. Density-estimation models are typically a single regression pass and can be cheaper than tiled detection on very dense scenes, at the cost of losing per-object boxes. Tracking-based counting adds the association step and requires processing enough frames per second that objects are not skipped between detections — which couples the count directly to sustained throughput rather than peak. The real throughput question is sustained, not peak: what real-time object detection actually costs under continuous load determines whether a tracking-based counter can keep IDs stable at line speed. A counter that meets its MAE target offline but cannot hold frame rate in production will miscount by dropping frames, and that failure looks identical in the tally to a model accuracy problem — which is why throughput belongs in the count validation, not a separate performance review. FAQ How should you think about object counting in practice? Object counting produces a single count per region using one of three method families: detection-based (count surviving detector boxes), density-estimation (integrate a learned density map), or tracking-based (count unique object IDs across time). Which one fits depends on scene density and whether you count within a frame or across frames. In practice the count is a derived quantity, not the detector’s raw output, and it needs its own error budget. When should I use detection-based counting versus density estimation versus tracking-based counting? Use detection-based counting for sparse, well-separated objects where per-object explainability matters. Use density estimation for dense or overlapping scenes where individual objects are indistinguishable. Use tracking-based counting when objects cross a line or zone over time, so the count depends on unique identities rather than per-frame detections. Getting the method wrong is often a larger error source than getting the model weights wrong. Why does a detector that benchmarks well still produce inaccurate counts in production? Because benchmark mAP measures localisation quality averaged over thresholds, while the count depends on the number of detections at one operating point. Distribution shift, confidence-threshold coupling, and NMS merging under density all push the count off without moving the headline mAP figure. A model can benchmark well and still under-count systematically on dense or occluded scenes. How do occlusion and dense packing degrade counting accuracy, and how is that measured? Occlusion removes visual evidence and dense packing shrinks inter-object spacing below what NMS was tuned for, so both cause systematic under-counting that worsens as density rises. It is measured by count error rate — mean absolute error in object units and percentage miscount relative to the true count — characterised per density band on representative footage, not by detection accuracy. What does count error rate look like as a production metric versus benchmark accuracy? Benchmark accuracy answers how well a detector localises objects in general; count error rate answers how wrong the reported number will be on a specific line. A detector with strong mAP can still post a double-digit percentage miscount on dense scenes. Count error rate lets teams set an expected-performance contract before deployment instead of discovering the miscount from a physical audit later. How do I validate an object-counting model against representative production footage before deployment? Collect footage across the full density range from the actual camera and lighting, establish manual ground-truth counts on a held-out set, and report MAE and percentage miscount per density band rather than a single pooled number. Sweep the confidence threshold to check count sensitivity, look for systematic bias direction, and measure at production throughput. Dropped frames at line speed are dropped counts. What throughput trade-offs come with each counting approach on an industrial line? Detection-based counting costs one forward pass per frame and scales best at low density, but tiled inference to recover dense-scene detections multiplies that cost. Density models are typically a single regression pass and can be cheaper on very dense scenes. Tracking-based counting adds association overhead and depends on sustained frame rate, because skipped frames between detections become miscounts. The number a counting system reports is only as trustworthy as the count error rate you measured on footage that looks like your line. Before you trust a count downstream, decide which density band it has to hold, what MAE is acceptable there, and whether the method you chose can hold frame rate at line speed — that characterisation is exactly what a production CV readiness assessment exists to produce, so the miscount cost is known before deployment rather than found in the physical tally.