Perimattic
Manufacturing case study

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
Updated:
Work with us
Capped plastic bottles moving along an automated bottling line conveyor
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%
Back to all case studies
At a glance

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.

About the client

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

The challenge: catching a thin gap on every bottle

1

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.

2

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.

3

Two targets set before any testing

An overall accuracy of at least 90%, and at least 90% of faulty bottles caught.

Our approach

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
From the project

What the AI sees on the bottling line

Recorded camera frames from the proof of concept, as the system judges them.

Two recorded camera frames: a loose cap marked REJECT in the staged faulty run and a seated cap marked PASS in the staged good run, each inside the inspection zone
Two recorded frames as the system judges them. The cap inside the inspection zone gets a decision; the bottle left of the line is judged in a later frame.
Six close-up crops of the cap seam: three seated caps the system passed, flush on the neck ring, and three loose caps it rejected, each showing a dark gap
What the seam check looks at. Seated caps sit flush on the neck ring; loose caps show a dark gap above it.
The same faulty bottle cap twice: blurred and passed left of the inspection zone, then sharp and rejected inside it
Why the left of the frame is excluded: the same faulty bottle, out of focus and passed on the left, then sharp and rejected once inside the zone.
Results

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.

Results against the targets
TargetResult on evaluation bottlesWhat 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 caught24 of 24 caught (100%)At least 88.3%Met
Results

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.

Decisions by true condition
True conditionSourceBottlesPassedRejectedFault reported as
SeatedProduction recording22220
SeatedStaged good run550
LooseProduction recording15015Loose
TiltedProduction recording202Loose (not distinguished)
Faulty, as stagedStaged faulty run707Loose
Total512724

Faulty bottles missed: 0 of 24. Seated bottles wrongly rejected: 0 of 27.

Test data

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.

What data was the defect detection model tested on?
SourceHow the true condition is knownBottlesFaultyDecided correctlyFrames judgedFrames flagged faulty
Production recording, October 2026Each cap labelled by eye from the image; not yet verified by the client's QA team3917393917
Staged faulty run, first halfEvery bottle was deliberately made faulty777290290
Staged good runEvery bottle was properly seated505547, all on one bottle
Test data

Caps outlined in the 300 labelled frames

Each cap's condition as judged by eye.

Caps outlined in the 300 labelled frames
ConditionCapsShare
Seated26956%
Unclear13629%
Loose5912%
Tilted71.5%
Missing cap61.3%
Total477
Scope and limits

What are the limits of these results?

These results are preliminary and likely optimistic, for the reasons below.

What are the limits of these results?
PracticeWhat it involves
Small sample51 bottles, 24 of them faulty. One missed faulty bottle would have brought the caught rate to 96%, and the proven floor well below 90%.
TuningThe 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.
LabelsThe 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 caps136 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 zoneOnly 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 typesOnly 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 bottleResults count each bottle once, by the majority of its frames. Linking frames to a physical bottle on the live line is not built yet.
OfflineNo part of this ran on the line or in real time.
Next steps

What has to happen before this runs on the live line?

The steps that follow from the limits above.

What has to happen before this runs on the live line?
PracticeWhat it involves
Bottle trackingLink 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 bottlesTest on more faulty bottles, so the 90% faulty-caught target can be proven statistically and not only met.
Verified labelsHave the client's QA team verify the labels on the production bottles and rule on the 136 unclear caps.
More fault typesAdd evaluation examples of tilted caps, missing caps and broken bands, so those fault types can be reported separately.
Outcomes

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.

Tech stack

What the bottle cap inspection system is made of

The languages, frameworks, platforms and integrations used to deliver this project.

Inspection pipeline

Cap locator & seam check models
Frame handling & cropping
Training & evaluation
FAQ

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.

Further reading

Related articles from our blog