How does product counting with a camera work, and which counting job is it for?
Product counting with a camera covers three different jobs, each with its own set-up: counting items passing a point on a conveyor, checking that a carton or tray holds the expected items before it is closed, and counting cartons on a pallet. Before buying a "product counting system", establish which job you mean:
- Counting in the flow: items passing a point on a conveyor, to reconcile production with shipments.
- Missing-item check in a case: the expected count and arrangement in a carton, tray or blister, to stop short cartons.
- Pallet carton count: cartons on a pallet or in a stack, as a last check before dispatch.
If customers receive short cartons, the problem is usually the second job; if production numbers never match shipments, it is the first or the third.
What can a camera count reliably, and what can it not?
A camera counts only what it can see: it is reliable for items that stand apart from each other and the background, and not enough on its own for hidden, covered or background-coloured items. A camera looking down into a carton sees only the top layer; in a two-layer carton, a missing item underneath leaves no trace as long as the top layer is complete. That is geometry, not a model problem.
In return, a camera can separate touching items, count product types separately, say which slot is empty and keep a proof image of every decision; a photoelectric sensor or a scale cannot.
How does conveyor counting with vision work?
Conveyor counting vision draws a virtual line in the image, tracks each item from frame to frame and counts it once, when it crosses the line. The documentation for the LineZone counter in the open-source Supervision library shows the logic: it ignores detections without a confirmed tracker ID, counts each direction separately, and can require an object to be seen on the far side for several consecutive observations before a crossing counts. A box jittering on the line is not counted twice, and an item carried back by a reversing belt is counted in the other direction and subtracted.
The hard part is items that touch or overlap. With gaps between items and good contrast, classic blob analysis (thresholding, finding connected regions, filtering by area) is fast and easy to explain. The OpenCV watershed tutorial shows touching coins that still touch after thresholding, and separates them by combining a distance transform with marker-based watershed. When types are mixed or items partly overlap, you need an object detection model trained on labelled images. Overlap also disturbs tracking: the ByteTrack paper notes that most trackers discard low-score detections such as occluded objects, causing missed objects and fragmented trajectories. A broken track that resumes under a new ID can count one item twice.
When items travel as a bulk pile, density estimation can replace detecting each one. Lempitsky and Zisserman's Learning To Count Objects in Images estimates an image density whose integral over a region gives the number of objects in it. That is an estimate; if the count is the unit you sell, singulate the flow. Matching identities across several cameras is a separate topic, not covered here.
How do you set up a missing-item check before a carton is closed?
A missing-item check uses a camera looking straight down into the carton, before it is closed, to confirm that every slot of the expected pattern holds the right item. With a fixed pattern such as 3 by 4, each slot is checked: is there an item, is it the right one, is it sitting correctly? That beats a total count: one empty slot and one extra item give the right total and a wrong carton. The image is triggered by a carton-present sensor or encoder pulse, not a software timer.
In multi-layer cartons each layer is checked after it is placed, usually with a second camera at the layer-forming station. Where that is impractical, the camera checks the top layer and a checkweigher the total weight. The OIML R 51-1 recommendation defines a checkweigher as an automatic catchweigher that sub-divides prepackages into two or more sub-groups according to the difference between their mass and the nominal set point. A scale does not know where the gap is, and if one item weighs little next to normal item and packaging variation, it may miss the shortage altogether. Camera and scale are not substitutes; each covers the other's blind spot.
Can cartons on a pallet be counted with a camera?
Yes, but since a camera sees only the outside faces, a pallet carton count is a calculation from the known stacking pattern on single-product pallets, and a label-reading job on mixed pallets. On a single-product pallet, layers and arrangement are read from two or four faces and compared with the pattern. A missing carton in the middle shows on no face, so counting layer by layer during palletising beats counting a wrapped pallet. On mixed pallets, label product codes are read and matched to the dispatch order.
Photoelectric sensor, checkweigher or camera: which fits which counting job?
A photoelectric sensor is enough for single-file, spaced, same-type items; a checkweigher is enough when total weight reliably reveals a shortage; a camera wins when items touch, types are mixed, or you need the position of the gap or a proof image. Yabanova and Yumurtacı's paper on counting moving products draws the same line: standard-shaped products passing one at a time are easily counted with reflective photoelectric sensors, while irregular products that move in groups and change position call for infrared-based systems or machine vision.
| Counting job | Photoelectric sensor | Checkweigher | Camera | Where to start |
|---|---|---|---|---|
| Single-file, spaced, same-type flow | Enough | Not needed | Not needed | Sensor; a sensor pair if items can move backwards |
| Touching items, random orientation | Counts touching items as one | Not suitable | Blob analysis or detection model plus tracking | Open up the flow first, otherwise camera |
| Bulk flow | Not suitable | Total mass | Estimated count by density methods | Singulate if the count is the selling unit |
| Single-layer carton, tray or blister | Not suitable | Catches a shortage if the weight gap is large enough | Shows the empty slot and wrong item | Camera with proof image |
| Multi-layer carton | Not suitable | Catches a total shortage | Sees only the visible layer | Camera per layer, or top-layer camera plus checkweigher |
| Single-product pallet | Not suitable | Rough check | Outside faces plus stacking pattern | Count layer by layer while palletising |
| Mixed pallet | Not suitable | Rough check | Through label and barcode reading | Match carton by carton to the dispatch order |
How do lighting, camera position and packaging affect the count?
Lighting and camera position often decide accuracy before the model does: no method reliably counts an item that does not stand out from its background.
- Glossy stretch or shrink film: direct light causes glare; diffuse dome lighting or a polarising filter reduces it.
- Transparent packaging or products: a backlight for a silhouette, or angled light that picks out edges.
- Dark items on a dark belt: a different belt colour, a backlight, or a depth camera that measures height.
- Camera position: straight down for cartons and trays; for flow counting, just after an accelerating belt that opens up the gaps.
Resolution, exposure and triggering are covered in our article on the engineering reality of computer vision for quality control.
How is the count connected to the line and to ERP?
A count is useful only when it is recorded against its production order and SKU; a bare counter value reconciles nothing.
- Recipe selection: expected count and pattern load from the SKU of the active order in MES, ERP or the PLC, not by operator choice.
- Short carton: reject or stop, with a separate sensor confirming the reject gate fired.
- Uncertain result: an image that cannot be evaluated (glare, skewed carton) is not a pass; the carton goes to a manual check, and that rate is tracked.
- Pushing counts: at order close, counted, rejected and manually checked quantities go to MES or ERP.
- Proof image: stored with order, SKU, time and carton label number, so a customer claim can be answered with that carton's picture.
What data does a pilot need, and how is success measured?
A pilot needs complete and deliberately short cartons for every SKU, images at line speed, access to sensor and PLC signals and a line owner who signs off results, but no large labelled archive. Success is three separate numbers, with targets set from your own error costs and measured baseline, not a vendor brochure:
- Counting error per 1,000 items: the same flow is counted independently, by hand or from video, and misses and double counts are added up separately. Net difference misleads: 10 misses and 10 double counts give zero.
- Short-carton escape rate: in a challenge test, how many of 100 deliberately short cartons got through. Spread the empty slots across corners, middle and bottom layer.
- False stop rate: how many of 1,000 complete cartons were stopped or rejected for no reason.
Report each number per SKU and at full line speed. The line team, not the system's builders, should feed in challenge cartons at random times. Writing acceptance criteria and sizing the sample are covered in our article on acceptance tests for a vision inspection pilot.
Hypothetical example: how do you measure missing packs in a biscuit carton?
The following example is hypothetical; the numbers only illustrate the method. A biscuit maker packs 24 packs per carton in two layers of 3 by 4 and runs two SKUs on one line at 20 cartons per minute. It installs a camera that looks at each layer after placement and keeps its end-of-line checkweigher.
For flow counting, 10,000 packs on the conveyor before packing are counted independently from video. The system counts 9,994, a net difference of only 6, but the video shows 11 packs missed and 5 counted twice. The counting error is (11 + 5) / 10,000, or 1.6 per 1,000 packs.
In the challenge test, the line team feeds in 200 short cartons at random times during a shift, with the empty slot in different positions. The system stops 196: an escape rate of 4 / 200 = 2%. All four gaps sat in the corner with the strongest film glare, so the lighting angle is changed and the test repeated. The 9,600 complete cartons in the same 8-hour shift produce 12 false stops, or 1.25 per 1,000. Split by SKU, 10 of the 12 come from the glossy second product; the average had hidden it. Acceptance is decided per SKU.
What makes a quote bigger or smaller?
The number of SKUs and patterns, line speed, inspection points and integration depth set the size of the job, so a price is written item by item after the keşif (the discovery look at your line). Checking every layer, multi-face pallet counting, glossy or transparent packaging, bulk flow and a new reject mechanism make it bigger. A good quote itemises hardware (cameras, lenses, lighting, enclosure, trigger sensor), sample collection and labelling, software, PLC and ERP integration, commissioning with the challenge test, and monitoring after go-live.
Why do counting projects fail?
They usually fail on measurement and set-up, not on the model:
- Assuming a top-down camera also checks the bottom layer of a multi-layer carton.
- Reporting counting error as a net difference.
- Triggering on a timer instead of the carton's position.
- Not measuring false stops, so operators bypass a system that stops too often.
- Storing proof images without order and carton number.
Hatson Tech builds counting and missing-item checks like these as part of its image recognition and computer vision service. If you would like to look at the counting job on your line and which method fits it, the first meeting and the keşif are free.