Back to projectsMuhamad Syafiq
Proof of concept

Vision System

An industrial machine-vision system that tunes itself. A toolbox of vision Tools running under one loop that improves each one from a verification signal, instead of hours of manual tuning.

This is a proof of concept and still under active development. The architecture and results described here may change as it evolves.

The Vision System app measuring a part live: Path Find Align locating the datum and a Diameter step reporting Ø3.125 mm, with the accuracy panel below.
The live app: a Path Find Align step locates the part and provides a datum; a linked Diameter step measures Ø3.125 mm; the accuracy panel below tracks results as the system tunes its own parameters.

The problem

Commissioning a machine-vision inspection station is slow, and the slowest part is tuning. Every new part means an engineer hand-adjusting thresholds, regions and lighting parameters by trial and error until the inspection is reliable. On the factory floor I've watched that eat hours per station — and it has to be redone whenever the part, lighting or batch changes.

I wanted a vision system where the tuning tunes itself: you tell it what "good" looks like, and it converges on the parameters instead of you doing it by hand.

How it works — the tuning loop

The system is a toolbox of Tools, each a single vision capability you select and configure. Sitting above them is a adaptivemeta-layer that improves a Tool's parameters or model from a verification signal: an automated right/wrong measure, such as accuracy on a labelled set, or an operator confirming a reading. It's the same idea behind autonomous-research loops, applied to vision instead of robot policies.

The loop improves a Tool in one of three ways:

Retrain

Fits an ML Tool's model on accumulated, operator-confirmed labels.

Search

Optimizes a Tool's parameters — edge/score thresholds, OCR pre-processing — against the verification signal.

Exemplar

Learns a reference pattern and accept threshold from known-good samples, averaging the part's real matched region across frames into a denoised reference.

The three Tools

OCR reader tool reading 'SANTAL PRIVÉ' from a product label, with self-tuning pre-processing parameters on the right.
Reading a product label — the pre-processing parameters on the right are what the tool self-tunes.
OCR reader tool reading a shipping label 'iDazci520 iDazci, 300mm x 200mm x 140mm' with the status bar showing done · 100%.
Done · 100% — the tool converged on its own pre-processing for this label.

OCR Reader

Machine learning

Reads serial numbers, date codes and part markings using a pretrained recognition model (RapidOCR). It self-learns by searching over image pre-processing (upscale, threshold, CLAHE, sharpen, invert) against the operator's confirmed reading, so it adapts to a new part's lighting and contrast without anyone editing parameters.

Measurement tool: a Path Find Align datum and a linked Diameter step measuring Ø3.125 mm on a metal part.
A Path Find Align step fixtures the part; a linked Diameter step measures Ø3.125 mm.

Measurement

Classical CV

A dimensional-metrology Tool built as an ordered pipeline of measurement steps: Circle Align and Path Find Align establish a datum, then Diameter and other steps report dimensions linked to that datum so each region follows the part as it moves. It replaced a rigid single-caliper approach with a composable pipeline.

Template match tool in Locate mode finding all six screws across two check areas, reporting PASS — 6 found.
Locate mode finds all 6 screws across two check areas from a single captured template — PASS.
Template match tool in Count mode, reporting PASS — 14 found, across a tray of scattered screws with a captured template thumbnail.
Count mode on a scattered tray — PASS, 14 found, from the same captured template.

Template Match

Classical CV

Captures a reference pattern (the exemplar) by dragging a box on the live image, then finds it across the frame. It runs three ways: Locate (is the pattern present, and where — including per-area present/absent checks), Count (how many), and Inspect (flag the part good or flawed against the reference).

Talking to the line — environment settings

A vision algorithm is only useful on the floor if it can plug into the machine: trigger on the part, hand a pass/fail back to the PLC, and keep a record. That's what the Environment Settings do: a tabbed editor where every tab is wired to real behavior, not a mockup. It's the part that turns the tool into an actual inspection station.

Vision System context · talking to the line
trigger → inspect → result out
SENSING · TRIGGER
Camera
live frames
PLC trigger
part in position
INSPECTION
Vision System
PRIMARY
inspect → verdict, value, counter
Adaptive tuning
retrain · search · exemplar
LINE I/O · PER RESULT
PLC
modbus regs
TCP
OK / NG line
Record
CSV + images
Light / IO
serial on/off
Camera

Sets the device, resolution and exposure/gain — and the grab mode: Continuous, Software Trigger (one part per button press), or PLC / External Trigger, where the line's part-in-position signal fires each inspection. The live view never stops.

Communication (TCP)

The app runs a TCP server and emits one line per inspection — e.g. OK <value> — to any host, PLC or test tool that connects. Configurable line terminator, separator and send mode (every result, on change, or NG only).

PLC (Modbus / TCP)

Writes a 3-register block per result in a single transaction — verdict (good/NG), a scaled measurement value, and an incrementing counter — so the PLC always reads a consistent snapshot. Runs as Modbus master, or as a slave the PLC reads directly, smart-camera style. An optional PLC-triggered mode lets the PLC request an inspection and read the result back.

Data Record

Appends every result to a dated CSV (timestamp, verdict, value) and optionally saves both the raw frame and the overlaid result image — all results, NG only, or off.

IO & Light

Sends serial on/off commands to drive an inspection light or simple IO, so lighting is part of the recipe rather than a manual step.

Logging

Log level and location for diagnostics — so issues on the floor can be traced after the fact.

The optional integrations are safe to skip. If the Modbus or serial libraries aren't installed, those tabs still save their config and no-op with a clear message, so the app runs anywhere.

Built with

PythonOpenCVRapidOCRNumPyClassical CVQt / HMIPyInstaller

Right now it's a working proof of concept: the three Tools above, with the tuning loop running. The code is private, but I'm happy to walk through the architecture and a live demo.

Ask me about this projectSee other projects