Visual inspection of components with OpenCV
In-line silkscreen verification with rotational template matching: no proprietary vision PLC required.
Runs on: Raspberry Pi + USB camera, Python 3 scripts (Linux PLC).
The application
A manufacturer of electrical components wanted to verify that every part leaves the line with the correct silkscreen, without investing in a proprietary vision system. A Raspberry Pi with a USB camera runs an OpenCV pipeline (background segmentation, CLAHE, adaptive thresholding) and compares against references using template matching across ±15° rotations; a score ≥ 0.85 means the part is correct. The operator manages references and parameters from a touch GUI with 4 tabs.
Architecture
- 1080p USB camera with manual focus locked by software
- Pipeline: background → morphology → cropping → CLAHE → adaptive thresholding
- Template matching with -15°/+15° rotational search
- PySide6 GUI with camera thread (live only on the active tab)
- Persisted references and parameters (processed PNGs + config.json)
Bill of materials
- Raspberry Pi + USB camera: Industrial Shields controller
- 1080p USB camera with manual focus: image capture
- Touch screen: in-line operation
- Diffuse LED lighting: image repeatability
What is in the pack
gui-pyside6-camera-thread.pyjson-config-references.pyopencv-silkscreen-pipeline.pyrotational-template-matching.py- Bill of materials + README
Get the pack by email: free
Fill in the form and we will send the complete pack to your inbox within minutes.