Industries · 7 min read
Bottle cap inspection with a camera at the capper outfeed
Sealed, loose and missing as three classes, a reject on the second two before the case packer, and the loose rate per batch as the number the technician wants.
Summary
This post puts a camera at the outfeed of a capper on a bottling line and works through sealed, loose and missing as three classes, with loose as the one that decides whether the system is worth having. It covers the reject signal on the second two classes, the defect rate logged per shift and batch, and re-tuning the thresholds when a new batch of caps moves the base rate. It is written for line engineers on a first computer vision project.
Esdras Ntuyenabo · Engineer · Sep 24, 2026

Bottling line, one bottle missing its cap, generated scene with detections from our model
The capper on line 2 puts a screw cap on a bottle every half second, and the capper technician can hear a loose one over the noise of the line. It is a skill that took him four years to acquire, and it does not work from the canteen. A loose cap that reaches the case packer leaks in the case; a missing cap reaches the case packer and floods it. Both stop the line for twenty minutes, and the second one means a wet pallet nobody wants.
The camera at the outfeed sees each bottle for a moment as it leaves the capper, and the question is small enough to state in three words.
Of sealed, loose and missing, loose is the hard class
Missing is easy. A bottle with no cap on line 2 has a bare neck, and a model that has seen a few dozen finds every one. Sealed is the ordinary case and the model sees a thousand an hour. Loose is the class that decides whether the project is worth doing, and it is hard because a loose cap looks almost exactly like a sealed one. The cap is on and it is the right colour. The only difference is a thread's width of gap between the cap skirt and the neck ring, or a cap that sits a degree off level.
I think the definition of loose should be written by the capper technician rather than by whoever trains the model. He knows how much gap leaks. If the class is defined by the gap he would reject on the line, in the frames the camera actually sees, the labels agree with the person whose judgment the model is replacing on the night shift.
Object detection boxes the cap and the gap beneath it
The task is object detection, one box per bottle neck with its class, because the reject has to know which bottle in a frame of several. On line 2 the camera sees three or four bottles at once, and a frame-level verdict of "loose somewhere" is no use to a reject gate that has to fire on one of them.
The classes are typed once. Lexi proposes the boxes on frames the line has already recorded, and the capper technician checks each one before anything trains on it. His checking goes almost entirely on the loose class, because a loose cap in a frame is a small detail at the edge of a moving bottle and a box that includes the whole cap has not told the model where to look. The box goes on the neck ring and the skirt together, where the gap is. The assembly verification use case reads the same kind of question, is the part present and seated, from a box and its aspect, and the cap is a part.
Training frames come from the outfeed, across caps and shifts
Line 2 runs three cap colours and two bottle sizes, and a white cap on a clear bottle under the outfeed light looks nothing like a black cap on an amber one. The training frames are pulled from the line's own recordings for every combination, from the morning shift under the skylights and the night shift under the LEDs, with the conveyor running at line speed so the motion blur in training matches the blur at inference. A bottle photographed standing still on the bench teaches the model a bottle that never occurs on the line.
The frames also include the bottles the capper technician pulled by ear over a month, because the loose class does not occur on demand, and every one the line has produced is kept.
Loose and missing fire the reject and log the frame
The rule is written as a sentence, with a severity and a cooldown, approved before it goes live: a loose or missing cap on any bottle, critical, the reject gate fired and the frame logged against the batch. Nobody is paged for a single loose cap; the gate handles it. The monitoring and alerts guide describes the same shape of rule against a different camera, with the evidence frame attached so a person can judge in one look.
What the technician gets on his phone is a second rule: more than a handful of rejects in a short window, routine, sent with the frames. That pattern means the capper's torque has drifted or a cap batch is off, and the frames show which.
On line 2 the reject gate sits a short distance after the camera, and the decision has to reach the line controller and fire the air jet before the bottle is past. Sampling about every two seconds is not enough for a gate; this is one of the places where the model runs on a runner beside the line and the reject is wired to the controller directly.
The loose rate per batch is what the technician wanted
The rejects are also a record. Each one carries its shift, its cap colour, its bottle size and the cap batch number from the hopper, and LexInsight answers "which cap batches ran loose on line 2 this month" with the frames behind the answer. That question used to be answered by the technician's memory and a notebook. The answer, on the line this post is drawn from, was one supplier's caps, in one colour, on the night shift, and the torque setting had been chased for months when the caps were the problem.
Doubted bottles go to a person rather than the case
A cap that sits a hair off level, a reflection off the skirt that could be a gap, a bottle half hidden behind the one in front: these are the frames the model should not decide alone. They come back to the technician with the frame, his verdict is a label, and the next version has seen that reflection.
LexData takes the line 2 model through its whole life. You type what to look for, Lexi puts a box on every frame, and a person checks each label before anything trains on it. The model then watches the outfeed camera, in the cloud, on your servers or on a runner beside the recorder. Frames it is unsure of come back to a person, the corrections retrain it, and the new version replaces the old one with no downtime. The reflections from the first month are what the second version learned to ignore.
A cap batch that moves the base rate means re-tuning
In March a new cap batch arrives with a slightly softer liner, and the loose rate doubles for a fortnight. The model finds every one. The reject bin fills, the second rule fires every hour, and the technician's phone becomes a nuisance. Then the supplier fixes the liner and the rate falls below anything the line saw before, and the thresholds tuned around the old rate start sending sealed caps to review at a pace that floods the queue with bottles that were fine.
The drift catalog calls this the defect rate changed, and it is the condition most often mistaken for a model problem when it is a threshold problem. Per-bottle the model is as good as it was. The base rate moved, and the thresholds and the cooldown on the second rule are re-tuned against the current batch before anyone considers retraining. The reject volume against its own history is the cheapest signal on the line, and the technician already had it in his notebook.
See it on your own footage.
Start with your footageMore in Industries

Industries · 6 min read
AI visual inspection as the nondestructive testing step a camera can take over
Visual testing is the first NDT gate, its acceptance criteria are already written, and a camera can apply them to every weld instead of one in twenty.
Rob Hickey · Sep 24, 2026

Industries · 6 min read
Appearance inspection systems that judge scratches, chips and burrs the same way on every shift
The station, the light and the written standard matter more than the model. The outlines carry the limit, and a tightened tolerance makes every label wrong.
Rajiya Sultana · Sep 24, 2026

Industries · 7 min read
Automated pallet accounting from the camera over the staging zone
A polygon on the frame, every pallet tracked so it is counted once, entries and exits as the ledger, and a wash-down that nudges the camera as the failure.
Andreas Ohrvall · Sep 24, 2026