Explore the Detector module in food inspection

Food inspection dataset
– Download the dataset and trained project from our Partner Portal –

In one of our recent studies, we explored food inspection using NIR (near-infrared) illumination and a standard Datalogic monochrome camera. One key characteristic of NIR light is its ability to enhance contrast between different materials—a property we leveraged to differentiate between stones and tea leaves. In this post, we’ll take a closer look at how the PEKAT VISION Detector module was used.

The Detector module in food inspection—using NIR illumination
Image 1: Stones within tea leaves under visible light (left) and NIR

Detector Module: With or Without Classification?

When using the Detector module, you have two options—deploying it with or without classification. If you’re looking for a single type of object (such as stones in our case), the Detector module alone is sufficient. However, if you’re identifying multiple object types and need to distinguish between them, you can enable the „Classify“ feature. This allows you not only to detect objects but also to determine which ones they are—useful if you need to set evaluation criteria based on their numbers.

For example, in our Quality Inspection of Chocolate Boxes study, each box was required to contain 16 different pieces of chocolate, one of each kind. Any deviation from this standard—whether a missing or duplicate piece—was flagged as faulty. 16 unique classes were required for this project.

Setting Up the Detector Module for Stones in Tea Leaves

For our next example, we’ll use the Detector module with just one class—“Stone“—for clarity. Otherwise, detected objects would default to „Defect,“ and we wouldn’t be able to choose the color of the detection rectangle. Setting up and training the module is straightforward—you can follow along using our downloadable dataset.

Preparation

  1. Download the image dataset from our Partner Portal and unzip it (file name: partner-portal-IMAGES-Stones.in.Loose.Tea.Leaves).
  2. Launch the PEKAT VISION application.

Create a New Project

  1. Click Create New Project.
  2. Enter a project name, e.g., Stones in Loose Tea Leaves, then click CREATE and START.

Create Tags (Optional but Recommended)

Adding tags makes it easier to sort, verify accuracy, and visually identify OK/NG images.

  1. Click the OPEN TAGS icon in the upper menu.
  2. Click + ADD TAG, choose green, and rename it OK.
  3. Click + ADD TAG again, keep red, and rename it NG.
  4. Click SAVE.

Upload and Tag Images

  1. Click ADD IMAGES, locate the unzipped folder, filter for NG, select all images, and click Open.
  2. Click NG + to tag all the uploaded images, then click SUBMIT.
  3. Repeat for OK images.

Open the Detector Module

  1. In the left menu, click Modules, then EDIT.
  2. Click +, select Detector, then click ADD.
  3. Click SAVE CHANGES.
  4. Click Detector from the menu tree to open its settings.

Annotate the Images

Image 2: Creating a Stone class
  1. Filter NG images or scroll to find the first one.
  2. Check Classify in the upper right menu. Click CLASS MANAGER, rename Class 1 to Stones, select red, and delete Class 2. Click SAVE.
  3. Draw a rectangle around each stone and assign it to the Stone class.
  4. Annotate several images—starting with 8–10 is a good approach.
Annotation of the image before training
Image 3: Annotating images

Train the Model

  1. Click START TRAINING.
  2. Set the percentage of annotated defects used for training/testing (default: 80% training, 20% testing).
  3. Click START TRAINING again.
Food Inspection - Stones in Tea Leaves
Image 4: Result of the trained model

Check the Results

Click CONFUSION MATRIX. If accuracy isn’t 100%, return to the Labeling tab to add more annotations and retrain the model.

Confusion Matrix—evaluation the accuracy of inspection
Image 5: Confusion Matrix showing 100% accuracy

Set Evaluation Criteria

  1. Click EVALUATION.
  2. Click +RULE.
  3. Set the rule: Stone → Count → = → 0 (if no stones are detected, the image is OK; otherwise, NG).
  4. A green or red stripe will appear over each image for easy validation.
Setting evaluation criteria
Image 6: Setting evaluation criteria

Get a Cup of Tea

Congratulations! You’re done. Take a well-deserved tea break (maybe with a doughnut?). Or, if you’re up for more, read on for additional model setup nuances.

For a simpler setup, you could skip tagging and classification entirely—the model would still detect stones. On the other hand, if you wanted to overcomplicate things (just for fun), you could annotate individual tea leaves, though that’s unnecessary for this case.

Food inspection - stones among tea leaves
Image 7: Model with two classes—stones and tea leaves

Other Examples of Food Inspection

We’ve explored multiple food inspection use cases with PEKAT VISION:

  • Rice Cakes Inspection: The Detector module was trained with only two classes—OK and NG. NG covered all possible defects, from breakage to burn marks.
  • Salmon Inspection: The Surface Detection module was used to identify defects with precise shape and location data.
  • Meat Packaging Inspection: The Anomaly Detector module was ideal for identifying unknown contaminants or irregularities.

For a comparison between the Detector and Anomaly Detector modules, check out our Chocolate Packaging Inspection post.

Not Sure Which Module to Use?

If you’re unsure which module—or combination—is best for your application, send us sample images! We’ll conduct a free feasibility study to determine the optimal solution.

Want to test PEKAT VISION yourself? Explore our demo options and download our datasets & trained models.

Not a customer yet? Register here for full access to our Partner Portal.

Nehmen Sie Kontakt auf

Benötigen Sie weitere Informationen? Lassen Sie es uns wissen, wir werden jede Ihrer Fragen beantworten.
PEKAT VISION is now part of Datalogic Group