AI Defect Detection for Bottle Cap Inspection at an Indian Lubricant Manufacturer
A computer vision proof of concept on a lubricant bottling line: 51 of 51 correct accept/reject decisions and 24 of 24 loose caps caught, with no good bottle wrongly rejected.
- Industry:
- Lubricants manufacturing
- Tech stack:
- Python, PyTorch, OpenCV +3 more
- Updated:

- Correct accept/reject decisions
- 51 of 51
- Faulty bottles caught
- 24 of 24
- Proven accuracy (95% confidence)
- ≥ 94.3%
- Proven faulty caught (95% confidence)
- ≥ 88.3%
Case study summary
Perimattic built an AI defect detection system that inspects bottle caps on a lubricant bottling line from camera frames. In an offline proof of concept on 51 evaluation bottles, it made the correct accept or reject decision on all 51 and caught all 24 faulty bottles, with no good bottle wrongly rejected. At 95% confidence the sample proves at least 94.3% overall accuracy and at least 88.3% of faulty bottles caught.
Why automate bottle cap inspection on a lubricant line?
The client is an Indian lubricant manufacturer that fills and caps oil bottles on a production line. A cap that is not fully seated on the neck ring can leak oil in transit and reach a customer as a faulty product. The manufacturer wanted to know whether a camera and AI visual inspection could make the accept or reject call on every bottle reliably, as a first step towards custom computer vision development on the line.
The challenge: catching a thin gap on every bottle
Loose caps leak in transit
A cap that is not fully seated on the neck ring can leak oil in transit and reach a customer as a faulty product.
A thin gap, at line speed
The gap that gives a loose cap away is a thin dark line, and it has to be spotted on every bottle at line speed, which is hard to do consistently by eye.
Two targets set before any testing
An overall accuracy of at least 90%, and at least 90% of faulty bottles caught.
How does the AI defect detection system judge each bottle?
Each camera frame goes through two checks, and a bottle is rejected if either one flags it. A cap is judged only when it is fully inside the frame and in the right-hand part of the image, where it is in focus. It is the same approach behind our computer vision for manufacturing work and the Intellyx Vision QC module.
Cap locator
- A trained model finds every cap in the frame
- It outlines each cap from the top of the cap down to the shoulder of the bottle
- It gives a first opinion: seated, loose, tilted or missing
Seam check
- A second model looks only at the strip where the cap meets the neck ring
- It works at full camera resolution
- It scores how likely a gap is
Inspection zone
- Only caps in the right-hand 58% of the frame are judged, where they are in focus
- A bottle left of the line is judged in a later frame
- Results count each bottle once, by the majority of its frames
Training data and labelling
- The production recording is 6,509 frames at 2000 µs exposure
- After dropping 27 empty frames and keeping every 12th, 541 frames remained and 300 of them were labelled, the kind of work our AI data annotation team does
- The models were trained on other time segments of that recording and on the second half of the staged faulty run
- All evaluation ran offline on recorded frames, not live on the line
What the AI sees on the bottling line
Recorded camera frames from the proof of concept, as the system judges them.



Results against the targets
Both targets are met on the bottles tested, but only the accuracy target is proven statistically; the faulty-caught target is not yet proven because only 24 faulty bottles were available.
| Target | Result on evaluation bottles | What the sample proves (95% confidence) | Status |
|---|---|---|---|
| Overall accuracy of at least 90% | 51 of 51 correct (100%) | At least 94.3% | Met |
| At least 90% of faulty bottles caught | 24 of 24 caught (100%) | At least 88.3% | Met |
Decisions by true condition
No seated bottle was rejected: 27 of 27 passed. One of them was flagged in 7 of its camera frames and passed on the majority of frames, which matters for how rejects are triggered on the line.
| True condition | Source | Bottles | Passed | Rejected | Fault reported as |
|---|---|---|---|---|---|
| Seated | Production recording | 22 | 22 | 0 | |
| Seated | Staged good run | 5 | 5 | 0 | |
| Loose | Production recording | 15 | 0 | 15 | Loose |
| Tilted | Production recording | 2 | 0 | 2 | Loose (not distinguished) |
| Faulty, as staged | Staged faulty run | 7 | 0 | 7 | Loose |
| Total | 51 | 27 | 24 |
Faulty bottles missed: 0 of 24. Seated bottles wrongly rejected: 0 of 27.
What data was the defect detection model tested on?
The 51 evaluation bottles come from three sources, and none of them was used to train the models.
| Source | How the true condition is known | Bottles | Faulty | Decided correctly | Frames judged | Frames flagged faulty |
|---|---|---|---|---|---|---|
| Production recording, October 2026 | Each cap labelled by eye from the image; not yet verified by the client's QA team | 39 | 17 | 39 | 39 | 17 |
| Staged faulty run, first half | Every bottle was deliberately made faulty | 7 | 7 | 7 | 290 | 290 |
| Staged good run | Every bottle was properly seated | 5 | 0 | 5 | 54 | 7, all on one bottle |
Caps outlined in the 300 labelled frames
Each cap's condition as judged by eye.
| Condition | Caps | Share |
|---|---|---|
| Seated | 269 | 56% |
| Unclear | 136 | 29% |
| Loose | 59 | 12% |
| Tilted | 7 | 1.5% |
| Missing cap | 6 | 1.3% |
| Total | 477 |
What are the limits of these results?
These results are preliminary and likely optimistic, for the reasons below.
| Practice | What it involves |
|---|---|
| Small sample | 51 bottles, 24 of them faulty. One missed faulty bottle would have brought the caught rate to 96%, and the proven floor well below 90%. |
| Tuning | The reject rule was chosen using the 39 production bottles, and the inspection zone was set using the staged faulty run. The staged good run was also looked at when comparing options, so no evaluation bottle was fully blind. |
| Labels | The true condition of the 39 production bottles was judged by eye from the images and has not yet been verified by the client's QA team. |
| Unclear caps | 136 of the 477 caps outlined in the labelled frames (29%) could not be judged by eye. 104 of them are inside the inspection zone. They are set aside for the client to rule on and appear in no result. |
| Inspection zone | Only caps in the right-hand 58% of the frame are judged. Left of that line the caps are out of focus: on the first half of the staged faulty run, 221 of 282 left-side views (78%) were flagged, against 290 of 290 right-side views. |
| Fault types | Only loose caps are proven. The 2 tilted caps in the evaluation were rejected but reported as loose. Missing caps and broken bands had no evaluation examples. |
| One decision per bottle | Results count each bottle once, by the majority of its frames. Linking frames to a physical bottle on the live line is not built yet. |
| Offline | No part of this ran on the line or in real time. |
What has to happen before this runs on the live line?
The steps that follow from the limits above.
| Practice | What it involves |
|---|---|
| Bottle tracking | Link camera frames to each physical bottle on the line, so one decision per bottle can trigger a reject. This is line integration work of the kind covered by our manufacturing software development services. |
| More faulty bottles | Test on more faulty bottles, so the 90% faulty-caught target can be proven statistically and not only met. |
| Verified labels | Have the client's QA team verify the labels on the production bottles and rule on the 136 unclear caps. |
| More fault types | Add evaluation examples of tilted caps, missing caps and broken bands, so those fault types can be reported separately. |
Results: did the AI meet its accuracy targets?
51 of 51 correct decisions
The system made the correct accept or reject decision on every evaluation bottle.
24 of 24 faulty bottles caught
No faulty bottle was missed: 15 loose and 2 tilted from production, and 7 from the staged faulty run.
No good bottle rejected
All 27 seated bottles passed.
Accuracy target proven
At 95% confidence the sample proves at least 94.3% overall accuracy, above the 90% target.
Faulty-caught target met, not yet proven
The sample proves at least 88.3% of faulty bottles caught; more faulty bottles are needed to prove the 90% target.
Loose caps proven
Only loose caps are proven so far. Tilted caps were rejected but reported as loose.
Services behind this project
- Computer Vision for ManufacturingAI visual inspection and defect detection on the production line.
- Computer Vision DevelopmentCustom computer vision for medical imaging, visual apps and inspection.
- AI Data AnnotationExpert-validated training data and labeling for AI models.
- Manufacturing Software DevelopmentCustom software for manufacturers, from shop floor to sales.
- AI for ManufacturingHow we apply AI across this industry.
Questions about this project
What is AI defect detection for bottle caps?
AI defect detection for bottle caps uses a camera and trained computer vision models to decide, bottle by bottle, whether a cap is properly seated or faulty (loose, tilted or missing). In this case study, one model locates every cap in the frame and a second model checks the seam where the cap meets the neck ring for a gap, and a bottle is rejected if either check flags it.
How accurate was the AI bottle cap inspection?
On 51 evaluation bottles the system made the correct accept or reject decision on all 51 and caught all 24 faulty bottles. No seated bottle was wrongly rejected (27 of 27 passed). Because the sample is small, the statistically proven figures at 95% confidence are at least 94.3% overall accuracy and at least 88.3% of faulty bottles caught.
Why is 51 of 51 correct reported as "at least 94.3%" and not 100%?
A perfect score on a small sample does not prove perfect accuracy. If the true accuracy were below 94.3%, the chance of getting all 51 bottles right would be under 5%, so 94.3% is the lowest accuracy the result supports at 95% confidence. The same calculation on 24 of 24 faulty bottles gives a floor of 88.3%, which is why the 90% caught target is met but not yet proven.
How does computer vision detect a loose cap?
A seated cap sits flush on the neck ring, while a loose cap shows a dark gap above it. The seam check model looks only at that strip, at full camera resolution, and scores how likely a gap is. Caps are judged only inside the in-focus inspection zone, the right-hand 58% of the frame, because out-of-focus caps produced false flags.
Can the system detect tilted and missing caps?
The cap locator gives a first opinion of seated, loose, tilted or missing, but in this proof of concept only loose caps are proven. The 2 tilted caps in the evaluation were rejected but reported as loose, and there were no missing cap or broken band examples to evaluate.
Did the AI defect detection run live on the bottling line?
No. All evaluation ran offline on recorded frames, not live on the line or in real time. Moving to production needs frames linked to each physical bottle on the line and a reject trigger based on the per-bottle decision.
How much data was used to train the defect detection models?
The production recording was 6,509 frames at 2000 µs exposure. After dropping 27 empty frames and keeping every 12th frame, 541 frames remained and 300 of them were labelled, outlining 477 caps. The models were trained on other time segments of that recording and on the second half of the staged faulty run, so none of the 51 evaluation bottles was used for training.


