Once the hardware is ruled out, the problem is usually in software: image preprocessing, threshold tuning, and training-data coverage. Here are directions 7–9 plus a full on-site checklist.

In Part 1, we started with hardware selection and the physical environment, covering 6 troubleshooting directions — from camera resolution, shutter type, and lens calibration, to lighting selection, lens contamination, and on-site environmental interference. Part 2 moves to the software and algorithm layer, focusing on image preprocessing, threshold tuning, and training sample coverage, along with a complete 9-item quick troubleshooting checklist.
Many peoples first reaction when accuracy fails is "tune the algorithm parameters," but in reality, the problem often lies in the preprocessing stage.
Heres a real case: lab accuracy reached 99.8%, but dropped sharply to 65% on the production line. After 72 hours of troubleshooting, the root cause was found to be in the most basic image preprocessing step — an improperly set kernel size in a dilation operation — which overly amplified fine defect features and mixed them with background noise, making it impossible for the subsequent algorithm to distinguish real defects from artifacts.
Common troubleshooting points and corresponding operators in the preprocessing stage include:
Filtering & Denoising: Choose the appropriate filter based on noise type. Use median filtering for salt-and-pepper noise; use Gaussian filtering for Gaussian noise. Using the wrong one wont remove noise and will blur edges.
Contrast Enhancement: Simple histogram equalization (equalizeHist) tends to cause local over-exposure. CLAHE (Contrast Limited Adaptive Histogram Equalization) is recommended — it limits contrast amplification, enhancing local contrast while preventing excessive noise amplification, resulting in more stable performance.
Illumination Non-uniformity Correction: Non-uniform brightness often causes global thresholding to fail — bright areas get over-exposed with increased artifacts, while dark areas get under-exposed with lost targets. Try homomorphic filtering to separate illumination and reflectance components, or use Top-hat transform to correct uneven backgrounds.
This direction requires distinguishing between two different technical scenarios, because the threshold adjustment logic is completely different.
In traditional vision, the threshold determines which pixels are classified as "target" (defects) and which are classified as "background."
Taking the simplest binary threshold as an example:
Threshold set too high: Only pixels with very strong contrast are classified as defects → Miss rate increases (weak defects are ignored), Overkill decreases (noise is filtered out).
Threshold set too low: More pixels are classified as defects → Overkill increases (normal areas are misjudged), Miss rate decreases (weak defects can also be detected).
The traditional "overkill-miss" seesaw relationship basically follows this pattern, but the exact direction may vary slightly depending on the algorithm type.
In AI models, the network outputs a confidence score (0~1) indicating "this region is a defect," and the system decides whether to trigger an alarm by setting a confidence threshold.
Threshold set too high: The model must be "very certain" to report a defect → Miss rate increases (blurred or occluded defects may be let go due to insufficient confidence), Overkill decreases (false alarms decrease).
Threshold set too low: The model reports a defect with just "a little suspicion" → Overkill increases (numerous false alarms), Miss rate decreases (more real defects are detected).
Key Difference: In traditional thresholding, the direction of threshold change on "overkill" and "miss" depends on the algorithm logic; but in AI models, increasing the threshold always helps reduce overkill but increases miss rate (and vice versa), and the direction is deterministic.
Another easily overlooked point: combined judgment of multiple defect types. A single defect may fall below the threshold, but if there are multiple minor defects approaching the threshold on the same workpiece, should it be judged as non-conforming? If this composite judgment logic isn't clearly defined during system design, suppliers typically adopt the simplest single-threshold judgment, often leading to misjudgment of edge cases.
The generalization capability of AI vision inspection models depends on whether the training data can represent the defect distribution encountered in actual production.
If only the most typical defect types are collected during training, the model will miss defects when encountering variants not present in the training set. In actual production environments, the morphological variation of the same defect type is often more diverse than under lab conditions — changes in workpiece material batches, seasonal temperature and humidity effects, and workpiece surface consistency changes due to equipment wear — all generate new defect samples not seen during training.
As a general rule, the training set needs to cover at least 90% of known defect variants for the model to achieve usable performance on the actual production line.
The sampling strategy should cover defect diversity, not just total quantity. Different severity levels, different locations, and different workpiece batches of the same defect type — all must be covered. When actual samples of certain defect types are insufficient, data augmentation techniques (rotation, scaling, random brightness/contrast variation, adding simulated noise, etc.) can be used to expand sample diversity — but augmented samples must maintain physical authenticity and not deviate from the actual visual characteristics of defects.
Moreover, sample collection should be an ongoing effort — as more edge cases accumulate during production, the model needs to be periodically retrained with new samples.
| Step | Checkpoint | Quick Verification Method | Common Resolution Path |
|---|---|---|---|
| 1 | Pixel Accuracy | Calculate: FOV ÷ Resolution, is it ≤ 1/8 of tolerance? | Upgrade to higher-res camera / Reduce FOV |
| 2 | Shutter Type | Are edges of moving objects distorted/slanted? | Switch to global shutter camera (e.g., Sony Pregius series) |
| 3 | Calibration Accuracy | Is reprojection error < 0.1 pixel? | Re-calibrate / Switch to telecentric lens |
| 4 | Lighting Selection & Brightness | Use standard gray card, is brightness consistent with debug? | Adjust light type / Software brightness compensation |
| 5 | Lens/Protective Glass Contamination | Does accuracy recover after wiping? | Add protective housing / Air purging / Adjust mounting orientation |
| 6 | On-site Ambient Light & Vibration | Test under extreme conditions (full power, day/night shifts) — stable? | Add polarizers/narrow-band filters / Damping mounts / HDR mode |
| 7 | Preprocessing Pipeline | Check each step's output — where does it start to degrade? | Adjust filter kernel / Replace histogram equalization with CLAHE |
| 8 | Threshold Setting | Test edge cases — is overkill/miss distribution reasonable? | Distinguish traditional vs AI thresholds / Independent validation set tuning |
| 9 | Training Sample Coverage | Do missed defects have similar samples in training set? | Supplement diverse samples / Data augmentation / Periodic retraining |
When detection accuracy fails, the order of troubleshooting matters. My advice is:
Hardware before software, physics before algorithm, traditional before AI.
From "Is camera resolution sufficient?" → "Did you choose the right shutter type?" → "Is lens distortion calibrated?" → "Is lighting brightness and type appropriate?" → "Is the lens contaminated?" → "Is there interference from on-site light and vibration?" → "Does the preprocessing pipeline have issues?" → "Is the threshold setting reasonable?" → "Do training samples cover the actual defect distribution?"
Take it step by step — don't start by tuning the algorithm. In many cases, the root cause of accuracy issues isn't in the code, but in the camera, lens, lighting, or workshop environment. Use the quick checklist above and go through it item by item — more than 90% of accuracy issues can be localized to the root cause within 30 minutes.
In the end, 70% of machine vision accuracy is determined at the selection stage. The remaining 30% depends on every link from the lab to the production line performing flawlessly.
MindVision supplies industrial machine vision cameras for quality inspection and factory automation — global-shutter CMOS sensors, flexible interfaces (GigE Vision / USB3 Vision / CoaXPress-12), and the resolution and speed most inspection lines need. Tell us your part tolerance, line speed, and defect types — we help you select the right camera and avoid the accuracy traps covered in this guide.
This is an educational guide to machine-vision detection accuracy for reference. Actual specs are subject to the product datasheet. © MindVision
Please Login