Location:
Detection Accuracy Failing? 9 Troubleshooting Directions from Camera to Algorithm Part 2

Detection Accuracy Failing? 9 Troubleshooting Directions from Camera to Algorithm Part 2

Part 2: Software & Algorithm Layer

2026-08-09 14:08
MACHINE VISION · DETECTION ACCURACY GUIDE

Detection Accuracy Failing? 9 Troubleshooting Directions from Camera to Algorithm (Part 2: Software & Algorithm Layer)

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.

第1页-2 拷贝.png

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.

Direction 7: Image Preprocessing — The "Defense Line" Before the Algorithm

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.

Troubleshooting Tip: Isolate each step of the preprocessing pipeline and check the output images — from raw image → grayscale → filtered → enhanced → binarized. Wherever it starts to "go bad," that's where the problem lies.

Direction 8: Algorithm Parameters & Thresholds — The "Seesaw" of Overkill and Miss

This direction requires distinguishing between two different technical scenarios, because the threshold adjustment logic is completely different.

Scenario 1: Traditional Image Processing (Fixed Threshold / Otsu Adaptive Threshold / Edge Detection Threshold)

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.

Scenario 2: AI Deep Learning Inspection (Classification/Object Detection Confidence Threshold)

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.

Troubleshooting Tip: During acceptance testing, specifically test edge cases — samples whose quality falls right at the pass/fail boundary — these best test whether the threshold setting is reasonable. For AI models, it's recommended to collect at least 500 edge samples as an independent validation set for threshold tuning.

Direction 9: Representativeness of Training Samples — Defects the Model "Has Never Seen"

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.

Troubleshooting Tip: Collect all defect images missed in the last three months and check how many are types "never seen" in the training set. If the proportion is high, you need to supplement training samples and retrain the model.

Appendix: Complete Quick Troubleshooting Checklist (On-site Reference Table)

StepCheckpointQuick Verification MethodCommon Resolution Path
1Pixel AccuracyCalculate: FOV ÷ Resolution, is it ≤ 1/8 of tolerance?Upgrade to higher-res camera / Reduce FOV
2Shutter TypeAre edges of moving objects distorted/slanted?Switch to global shutter camera (e.g., Sony Pregius series)
3Calibration AccuracyIs reprojection error < 0.1 pixel?Re-calibrate / Switch to telecentric lens
4Lighting Selection & BrightnessUse standard gray card, is brightness consistent with debug?Adjust light type / Software brightness compensation
5Lens/Protective Glass ContaminationDoes accuracy recover after wiping?Add protective housing / Air purging / Adjust mounting orientation
6On-site Ambient Light & VibrationTest under extreme conditions (full power, day/night shifts) — stable?Add polarizers/narrow-band filters / Damping mounts / HDR mode
7Preprocessing PipelineCheck each step&#x27;s output — where does it start to degrade?Adjust filter kernel / Replace histogram equalization with CLAHE
8Threshold SettingTest edge cases — is overkill/miss distribution reasonable?Distinguish traditional vs AI thresholds / Independent validation set tuning
9Training Sample CoverageDo missed defects have similar samples in training set?Supplement diverse samples / Data augmentation / Periodic retraining

Final Words

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
Industrial Cameras & Machine Vision

Work With Us

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. &copy; MindVision

We’ll be glad to help you

  • Full Name

  • Company Name

  • E-mail*

  • Country / Region

  • Your Needs / Application*

  • Verification code

Tel:+86 18476546577
WhatsApp:1121038577
LinkedIn:Shenzhen MindVision Technology Co., LTD
Email