Zum Hauptinhalt springen

Packaging Control

Detecting Cuts in Quark Lids

Quark packages on a conveyor belt inspected by an industrial camera

Introduction​

This demo shows an end-of-line quality control scenario in food packaging. Quark cups move along a conveyor belt and pass under an industrial camera with ring light. For every package, the AI inspects the sealed lid and segments cuts in the foil.

A cut in the lid breaks the seal of the package. Even a small cut can lead to contamination, leaking product and a shorter shelf life, so damaged packages must be sorted out reliably before they leave the production line.

Detecting cuts on printed packaging is challenging because the defects are:

  • thin and narrow compared to the full label
  • placed anywhere on the lid, with random length and orientation
  • easily confused with printed lines, text, barcodes and graphics on the label
  • affected by reflections on the glossy foil

Workflow​

Instead of sending the full camera frame into one large model, the inspection is split into two small, task-specific ONE AI models. The first one finds the label, the second one looks for defects on it:

1. Capture & Crop

Crop the captured camera frame to the part of the conveyor belt where the package stops.

➜
2. Find the label

A small ONE AI segmentation model, trained on just a few images, finds the label. See Location Detection.

➜
3. Resize

Cut out the label and resize it to the input size of the defect model, in our case 600 × 400 pixels.

➜
4. Detect defects

A second ONE AI segmentation model, trained on labeled cuts, marks every defect on the label. See Defect Detection.

Splitting the task keeps both models small and fast: the location model only has to find a large, clearly visible label, and the defect model always sees the label at the same position and size, so it can fully focus on the fine cuts.

Dataset​

The demo uses two datasets: camera frames of the conveyor belt for the location detection, and images of the lids for the defect detection.

Camera frame of the conveyor belt with a quark package
Camera frame of the conveyor belt.

All packages share the same label design. The defect model learns what an intact lid looks like and highlights everything that does not belong there.

Intact quark package lid
Intact lid without defects.

The defective samples show cuts of different length, position and orientation on the lid:

Quark lid with cut, example 1Quark lid with cut, example 2Quark lid with cut, example 3Quark lid with cut, example 4

Examples of defective lids with cuts.

The cuts were labeled as segmentation masks in ONE WARE Studio. Segmentation is a good fit for this task because the exact shape and length of a cut matters, and a pixel mask can easily be turned into a pass/fail decision by checking the defect area.

Labeling cuts with segmentation masks in ONE WARE Studio

Location Detection​

The first model finds the label on the conveyor belt. Most of the camera frame shows the empty belt and the machine around it, so there is no need to send the full frame into the model. Only the area where the package stops under the camera is relevant.

Since the label always looks the same and only its position changes slightly, a few training images are enough. The natural variations (packages that stop a bit earlier or later, are slightly rotated or vary slightly in distance to the camera) are covered by augmentations instead of collecting more data.

Labeling​

The location model is a Segmentation project in ONE WARE Studio. In each image, the whole label area of the lid is marked with a segmentation mask. For more details, see Create your ONE AI project.

Labeling the lid area with a segmentation mask in ONE WARE Studio
The complete label is marked as one segmentation mask.

Crop Filter​

A Crop Filter limits the input to the part of the belt where the package stops. This removes the irrelevant background, reduces the input size and makes the model faster.

Crop filter settings for location detection
The crop filter keeps only the stop position of the package (520 × 660 pixels).

Augmentations​

Move, Rotate and a small Resize augmentation are enabled. They simulate the different stop positions and orientations of the packages, so the model generalizes from only a few images.

Move, rotate and resize augmentations for location detection
Move augmentation of ±5 % in X and Y. The preview shows how the label shifts within the cropped frame.

Defect Detection​

The second model receives the cropped label at 600 × 400 pixels and segments the cuts. Because the location model already aligns the label, the input is very consistent:

  • The camera position, lighting and label design are always the same
  • The cuts are local defects and don't need much context from the rest of the image
  • The model only has to separate cuts from the known label print

Data Processing​

A CLAHE filter (Contrast Limited Adaptive Histogram Equalization) is applied before augmentation. It equalizes the contrast locally in small tiles, which compensates for uneven lighting across the label and makes the thin cuts stand out more clearly against the print. A clip limit of 2 and a tile grid of 8x8 enhance the cuts without amplifying noise too much.

CLAHE filter settings for defect detection
CLAHE filter with clip limit 2 and tile grid 8x8. Original on the left, filtered image on the right.

The following augmentations add slight placement variation without breaking the segmentation masks:

AugmentationSettingWhy
Move±5 %Covers small offsets of the label after cropping
Rotate±1°Covers slightly rotated packages
Resize95 % to 105 %Covers small differences in label size

The remaining processing settings are chosen with the small defects in mind:

  • Color augmentation with mild ranges: covers small changes in lighting and print color without hiding the cuts.
  • Resolution 100 %: the smallest cuts are only a few pixels wide, so lowering the resolution would make them disappear.
  • No blur augmentation: a light blur usually helps generalization, but here the fine cuts are exactly what the model has to find, so blurring them would hurt.

Model Settings​

SettingValue
Optimize Small ObjectsOn
Position Prediction Resolution50 %
Type of EnvironmentControlled
Type of Objects or FeaturesLimited

Optimize Small Objects helps with the thin cuts, and a Position Prediction Resolution of 50 % is still fine enough to outline them. The environment is controlled because camera, lighting and label never change, and the features are limited because cuts always look similar. See Output Settings and Input Settings for details.

Results​

The video shows the complete pipeline running live on the conveyor belt. As soon as a package stops under the camera, the location model finds the label, the label is cut out and passed to the defect model, and the cuts are highlighted.

The defect model reliably segments the cuts on the lid while ignoring the printed text, barcode and graphics of the label. Because both models are small and task-specific, the inspection keeps up with the conveyor belt, and the predicted mask can directly be used to reject damaged packages.

More Possibilities with ONE AI​

Cuts are only one of many defects that can be caught on the same line. With the same camera setup, ONE AI can generate additional task-specific models that check the print on every package:

Lid with wrongly printed or blurred text

Text Inspection

Detect labels with missing, shifted or wrong text, for example when the wrong label roll was loaded. Smeared, faded or blurred print caused by worn print heads, ink problems or moisture is caught as well, so only packages with correct and clean print leave the line.

Best before date printed on the lid

Best Before Date

Check that the best before date is printed on every package and that it is valid, meaning it matches the expected best before date of the current batch. Packages with a missing or wrong date are rejected before they reach the customer.

Because ONE AI models are small and task-specific, these checks can run alongside the cut detection on the same edge hardware, so a single camera station can cover the complete visual inspection of the package. Learn more about comparing images to a reference in the Reference-Based Object Detection demo.

Christopher - Development Support

Need Help? We're Here for You!

Christopher from our development team is ready to help with any questions about ONE AI usage, troubleshooting, or optimization. Don't hesitate to reach out!

Our Support Email:support@one-ware.com