The task: remove manual inspection without overbuilding the machine
Czech company 3iD develops vending machines that accept reusable cups. After each return, the machine must decide whether the cup can enter another cycle or should be rejected. A person previously performed this check, so expanding the machine fleet would have required a proportional increase in manual sorting.
The inspection covered three different areas:
- the bottom, for cracks, deformation and contamination;
- the wall, for scratches, fractures and other surface damage;
- the handle or holder, for bending, detachment and shape deviation.
3iD engaged EDIH-DIGIMAT and the INTEMAC testbed through a Test Before Invest service. The goal was deliberately narrow: before designing a production machine, determine whether an affordable embedded computer could perform the inspection in real time.
This is a useful framing for a small manufacturer. The team did not start by buying a GPU, collecting a large dataset and training a neural network. It first asked whether defects could be described with observable geometric and colour features.
The prototype architecture
The test rig used a Raspberry Pi 5 with 8 GB of RAM, a 12-megapixel Raspberry Pi Camera Module 3 and a SmartView spotlight. According to the published case, the components cost CZK 2,748, or roughly €110 at the time of the project. That figure describes the compute and optical parts of the test setup, not a finished industrial station.
Three independent rules were implemented in Python with OpenCV.
For the cup wall, Canny edge detection ran twice: on a thresholded image and on its inverse. This allowed the system to find both light and dark defects. The number of edge pixels was compared with a configurable threshold; exceeding it classified the cup as NOK.
For the bottom, a circular region-of-interest mask removed the background around the cup. Canny then searched only inside the base for cracks and deformation. For the handle, the image was converted to HSV, the blue object was isolated by a colour range, and its tilt angle was calculated from the largest contour. A deviation outside the tolerance meant rejection.
A CustomTkinter interface displayed the live camera image, processed result and OK/NOK counters. Its purpose was not decorative reporting, but on-site adjustment of lighting, thresholds and mechanics using real samples.
Everything ran on the Raspberry Pi without a GPU or cloud connection. In a vending machine, this creates a short local path: camera, processing, decision and actuator command can all remain inside one device.
Why rules beat a model in this case
Classical computer vision is effective when the object appears predictably, lighting can be controlled and a feature can be measured. A crack produces an edge, a circle limits the bottom, colour isolates the handle, and an angle describes its deformation. The decision is transparent: an engineer can inspect the mask, contour and threshold that caused a rejection.
A neural network becomes justified when defect appearance varies widely, geometry cannot be stabilised or hand-designed features no longer separate good and bad parts. It also adds costs: annotation, control of imbalanced rare defects, retraining after a material change and drift monitoring.
The case had little training data and a well-defined task, so simple algorithms produced a testable prototype faster. This is not an argument against machine learning. It is a rule for choosing the least expensive method that reliably controls a specific risk.
Lighting and mechanics matter more than code complexity
The main lesson from the test was to begin with controlled illumination. Source geometry, direction, spectrum, reflections and ambient light determine whether the camera can see a defect. A larger model cannot recover a crack that disappears in glare.
One camera in the published prototype could not see the entire cup wall. The authors recommend mechanically rotating the cup for full-perimeter inspection. That changes the architecture: it requires a drive, capture of several frames, synchronisation with lighting and a rule for combining results.
A practical sequence is:
1. Fix the object's position and allowed movement.
2. Select light, background, exposure and focus for each defect type.
3. Limit the region of interest so the background cannot create false edges.
4. Implement the simplest measurable rule.
5. Only then compare it with an ML model on the same test set.
The sequence applies to packaging, caps, labels, components and surface inspection. Many apparent “AI problems” first turn out to be fixture and optics problems.
What the prototype actually proved
EDIH reports that all three algorithms ran in real time on the Raspberry Pi 5 and that the prototype established the technical feasibility of affordable embedded inspection. The source describes reliable identification of wall damage, bottom deformation and handle deviation. Very fine cracks with insufficient contrast could be missed; the case authors regarded those cracks as non-critical to the reuse decision.
However, the published record does not disclose test-set size, the number of samples in each class, a confusion matrix, actual line speed or continuous operating duration. Its “high accuracy” statement should therefore not become a ready-made percentage in another company's business plan. Production operation is not confirmed either: the outcome was a validated blueprint and prototype code from which 3iD could proceed to a functional machine.
The €110 figure is not an implementation price. It excludes the enclosure, industrial camera protection, rotation mechanism, reject actuator, electrical work, integration, certification, installation, logging, spare parts and maintenance.
How to validate quality without fooling yourself
One overall accuracy figure is insufficient for a production decision. Build a confusion matrix for each defect type and for the two business risks:
- false accept: a defective cup is declared fit;
- false reject: a good cup is discarded.
These errors have different costs. The first can affect safety and customer trust, while the second reduces packaging circulation and raises unit cost. A Canny threshold or permitted handle angle should be chosen from an agreed cost of error, not from an attractive demo image.
The test set must represent the real flow: new and worn batches, wet and dry cups, contamination, material shades, reflections, slight misalignment, every allowed defect and borderline cases. Samples used to tune thresholds cannot be the only final test.
A minimum pilot report should contain:
- sample count and class distribution;
- defect recall and the share of missed defects;
- rejection precision and the false-reject share;
- results by defect type and severity;
- p95 decision latency and throughput;
- stability after hours of continuous operation;
- behaviour with a dirty lens, shifted camera and failed light.
If the camera is uncertain or a control frame does not match the expected illumination, a safer policy is to request another image or send the item to manual review rather than automatically accept it.
Economics for a small manufacturer
The project does not publish actual labour savings or a payback period, so any calculation must be a model. First measure inspections per hour, operator time per item, error cost, repeat-inspection rate and equipment downtime.
Annual benefit can be expressed as:
`benefit = released manual-inspection hours + avoided error losses − maintenance − electricity − depreciation − repeat inspection`.
The full pilot cost includes not only a Raspberry Pi and camera but also mechanics, lighting, development, a reference sample set, acceptance testing and process-engineer time. For a small production run, engineering can easily cost more than the electronics, and that is normal.
The economic threshold is better expressed as cost per thousand correctly inspected units than as board price. If a simple rule reaches the required quality, adding ML increases lifecycle cost without guaranteeing additional business value.
A four-step pilot
First, define defects and the cost of both error types with the process owner. Replace “find everything bad” with measurable features and accepted borderline cases.
Second, build a rig with a fixed camera and controlled lighting, then collect representative OK and NOK samples. A human remains the source of the reference decision at this stage.
Third, compare simple rules and a small model on the same held-out set. Score the confusion matrix, latency, stability and maintenance cost.
Fourth, run in shadow mode on the real flow: the system classifies, but an operator confirms physical rejection. Connect the actuator only after an agreed period without unacceptable misses. Rollback must return the machine to manual mode without stopping the primary process.
The management takeaway
The 3iD story is not “cheap AI for €110.” It is a disciplined sequence: test optics and simple features in a lab before investing in a production machine. For a constrained visual task, local OpenCV on a compact computer may be sufficient.
The next step is to select one repetitive inspection, collect real good and bad samples, and commission a short test of optics, mechanics and thresholds. Move to a trained model only if simple rules fail the predefined confusion-matrix requirements.
