OpenCV reached version 1.0 this month, and with it automated visual inspection on a production line stops depending on a proprietary library at every step. The typical quality-control pipeline — acquisition, feature extraction, classification, reject decision — now composes from software whose code can be read, modified, and reproduced on commodity hardware.
Context
Inspection of surfaces and machined parts on a line has long been the territory of closed systems: camera, illuminator, and software sold as a sealed block, calibrated by the supplier, hard to adapt when the part or the defect of interest changes. The cost is not only the licence. It is that the algorithm cannot be inspected: when the system rejects a good part or passes a defect, the operator has no way to learn which feature the decision rested on.
Pattern recognition applied to quality is, at bottom, a supervised classification problem. An image of the part is acquired, a numerical representation is drawn from it, and a decision is made whether that representation falls in the “conforming” or “defective” region of a feature space. The three steps — representation, training, decision — separate cleanly, and each now has an established open implementation.
Architecture
The first step is representation. For surface defects (scratches, porosity, inclusions) the historical choice is Haar features computed on the integral image, the approach Viola and Jones describe in 2001 for face detection and later extend to arbitrary objects. The integral image makes the cost of a rectangular feature independent of its size: three sums for any window. To recognise parts in variable position and orientation, Lowe’s SIFT (Scale Invariant Feature Transform) descriptors, published in 2004, give keypoints stable under scale and rotation — useful when the part does not always arrive the same way under the camera.
The second step is classification. Here LIBSVM comes in, the support vector machine library by Chang and Lin available since 2001, which covers the common case: given a feature vector, decide between two or more classes with a maximised margin. In defect detection the problem is nearly always imbalanced — good parts are the overwhelming majority — and the one-class SVM formulation, also in LIBSVM, trains the system on conforming examples alone and treats a defect as a deviation from the learned distribution. This avoids collecting a representative sample of every possible defect, something rarely achievable in production.
The third step, the reject decision, is where the system touches the production process: a threshold on the classifier score, a cycle time to respect, an actuator that diverts the part. OpenCV 1.0 provides acquisition, the pre-processing primitives (filters, thresholds, morphology), and the Viola-Jones cascade classifier, trainable with the included tools. The cascade matters precisely because it orders classifiers by increasing complexity: most conforming windows fall away at the early, cheap stages, and only suspect candidates reach the expensive ones. On a line with a tight cycle time it is this asymmetry that makes detection sustainable in real time.
Critical point
The system’s precision is not lost in the classifier, but upstream, in acquisition. An SVM trained on well-lit images degrades silently when illumination drifts: the feature vector shifts, the point crosses the decision boundary, and the system rejects good parts while reporting no error. The classifier cannot tell “defective part” from “image acquired under conditions different from training”. In both cases what it produces is a vector far from the conforming region.
This moves the reliability problem from the algorithm to the acquisition rig and to the discipline with which one trains. A stable illuminator, a fixed imaging geometry, and a protocol that retrains when the batch changes weigh more than the choice between one SVM kernel and another. The advantage of open tools here is diagnostic: when the false-reject rate rises, one looks at the feature vector of the rejected parts and checks whether the drift is in the image or in the part. With a sealed system that check cannot be done.
Implications
Composability changes who can build and maintain an inspection system. With OpenCV, LIBSVM, and descriptors documented in the literature, a defect-detection pipeline becomes a project that whoever knows the production process can put together themselves, rather than a purchase from a single supplier. Domain knowledge — which defects matter, what false-reject rate is tolerable, when the part has changed enough to force a retraining — stays in the company instead of ending up inside an opaque binary.
Reproducibility has a second consequence, on validation. A system built from open components can be verified independently: the pipeline is rerun on a known sample, the decisions are compared with human judgement, the false-positive and false-negative rates are measured on traceable data. For a quality control that must answer for its own decisions — to a customer, an audit, a contested non-conformity — that traceability is a requirement, not an implementation detail.
Limits
Open tools cover the pipeline, not the calibration. SIFT is patent-encumbered and its commercial use requires care, regardless of code availability. The Viola-Jones cascade wants thousands of labelled examples per stage and a training run that, on 2006 hardware, is measured in hours or days. The one-class SVM reduces the need for defective examples but stays sensitive to parameter choice, and a wrong calibration produces a system that rejects too much or too little, with the error invisible before production. None of these tools replaces the manual, part-specific stage in which one decides what counts as a defect. It is that decision, not the library, that settles whether automated inspection holds up.
How these components are assembled into a real industrial quality control is recounted in a noze insight on in-line defect detection: https://www.noze.it/en/insights/pattern-recognition/.
- https://opencv.org/
- https://www.cs.cmu.edu/~efros/courses/LBMV07/Papers/viola-cvpr-01.pdf
- https://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf
- https://www.csie.ntu.edu.tw/~cjlin/libsvm/
Cover image: Black-and-white group photo with rectangular bounding boxes drawn around each face by the OpenCV face detector — photo by Sylenius, public domain — https://commons.wikimedia.org/wiki/File:Face_detection_example_openCV.jpg