How Sensitive Should a Machine Vision Inspection Camera Be? Defect Escapes vs. False Rejects

On a simulated line of 20,000 parts a day with 0.5% defective, a computer vision model with an AUC of 0.98 has to flag 2,163 parts a day to catch 95% of defects, and 4.4% of those flags are real. The cost-minimizing setting catches 85.4% at $12,411 a day, against $19,500 for inspecting every part by hand. The setting depends on one ratio of costs and defect rate, and a person reviewing flags can raise escapes.

Machine vision inspection cost chart: daily cost by camera sensitivity for 20,000 parts a day at 0.5% defective and AUC 0.98. Scrapping every flag is cheapest at 85.4% of defects caught for $12,411 a day; with a person reviewing flags the minimum is 94.2% caught for $12,832; manual inspection of every part costs $19,500 a day

A machine vision inspection camera does not decide pass or fail. It gives each part a score, and someone chooses the score above which a part gets pulled. That choice sets two error rates at once: defects that escape to the customer and good parts that get rejected. On a simulated line running 20,000 parts a day with 0.5% defective, a camera with an AUC of 0.98 has to flag 2,163 parts a day to catch 95% of the 100 defects. Only 4.4% of those flags are real.

Scrapping every flag at that setting costs $19,042 a day in escapes and lost good parts. The cheapest setting for the same camera flags fewer parts, catches 85.4% of defects and costs $12,411 a day, against $19,500 for a person inspecting every part and $50,000 for no inspection at all. The code below finds that setting in closed form, checks it on sampled scores, and shows what moves it. The machine vision inspection calculator runs the same model in your browser.

How a machine vision inspection camera turns scores into decisions

Any classifier that outputs a score can be described by two distributions: the scores of good parts and the scores of defective ones. The simplest standard model, the equal-variance binormal model from signal detection theory, treats both as normal curves with the same spread, with defective parts shifted up by d standard deviations. Under that model the area under the ROC curve, the chance that a random defective part scores above a random good one, is

AUC = Phi(d / √2)

so an AUC of 0.98 means d = √2 × Φ⁻¹(0.98) ≈ 2.904. Pick a threshold t and flag every part that scores above it. The share of defects flagged (the catch rate) is 1 − Φ(t − d), and the share of good parts flagged (the false reject rate) is 1 − Φ(t).

AUC is a ranking measure. It says nothing about the defect rate, and the defect rate decides what a flag means. At 0.5% defective, a 20,000-part day has 100 defects and 19,900 good parts. Catching 95 of the defects takes a threshold that also flags 10.39% of good parts, which is 2,068 good parts against 95 defects. A camera that ranks parts almost perfectly still produces a reject bin that is 96% good parts.

The cost-minimizing threshold

Each threshold gives a daily cost. With every flag scrapped, it is the escaped defects times the cost of an escape (warranty, rework at the customer, a containment action) plus the flagged good parts times the value lost when a good part is scrapped. The demo's defaults are $500 per escape and $8 per scrapped good part, illustrative round numbers rather than figures from any plant.

Setting the derivative to zero gives the threshold directly. Flag a part when the likelihood ratio of its score, exp(d·t − d²/2) in the binormal model, exceeds the cost of flagging a good part times the number of good parts, divided by the saving from flagging a defect times the number of defects. Solved for t, with G good parts, D defective parts, scrap cost c_s and escape cost c_e:

t^* = d / 2 + 1 / d ln(G c_s) / (D c_e)

This is the binormal version of a general result. Charles Elkan showed in 2001 that any two-class cost matrix reduces to a single probability threshold, and that a change in the base rate moves the threshold without any change to the model. The inspection version makes the base rate concrete: D and G are counts of parts on your line, not in your training set.

When a person reviews every flag instead of scrapping it, flagging a good part costs the review ($1.50 in the demo), and flagging a defect saves the escape cost only when the reviewer confirms it. With a reviewer miss rate m and review cost c_r, the threshold becomes

t^*_review = d / 2 + 1 / d ln(G c_r) / (D (c_e(1 − m) − c_r))

The code

It needs NumPy and SciPy (run here with Python 3.13, NumPy 2.5.3 and SciPy 1.18.1) and finishes in under a second. It computes the daily cost of each strategy, solves both thresholds in closed form, checks them against a brute-force grid, and checks the binormal rates against 220,000 sampled scores.

import numpy as np
from scipy.stats import norm

# A day on the line: the demo's defaults (illustrative round numbers, not a specific plant)
BASE = dict(parts=20_000, prev=0.005, auc=0.98,
            escape=500.0, scrap=8.0, review=1.50, manual=0.60, miss=0.15)

def line(t, p):
    """Daily outcomes when the camera flags every part scoring above threshold t.
    Equal-variance binormal scores: good ~ N(0,1), defective ~ N(d,1), AUC = Phi(d/sqrt 2)."""
    d = np.sqrt(2) * norm.ppf(p["auc"])
    D = p["parts"] * p["prev"]; G = p["parts"] - D
    catch, fr = norm.sf(t - d), norm.sf(t)              # share of defects / good parts flagged
    flags = D * catch + G * fr
    out = dict(d=d, catch=catch, false_reject=fr, flags=flags, precision=D * catch / flags)
    esc_cam = D * (1 - catch)                            # camera only: every flag is scrapped
    out["camera_only"] = esc_cam * p["escape"] + G * fr * p["scrap"]
    out["dppm_camera_only"] = esc_cam / (p["parts"] - G * fr - D * catch) * 1e6
    esc_rev = D * (1 - catch) + D * catch * p["miss"]    # a person reviews every flag
    out["camera_review"] = esc_rev * p["escape"] + flags * p["review"]
    out["manual"] = D * p["miss"] * p["escape"] + p["parts"] * p["manual"]
    return out

def best_threshold(kind, p):
    """Closed form: flag a part when its likelihood ratio exp(d*t - d^2/2) exceeds
    (G x cost of flagging a good part) / (D x net saving from flagging a defect)."""
    d = np.sqrt(2) * norm.ppf(p["auc"])
    D = p["parts"] * p["prev"]; G = p["parts"] - D
    if kind == "camera_only":
        ratio = G * p["scrap"] / (D * p["escape"])
    else:
        ratio = G * p["review"] / (D * (p["escape"] * (1 - p["miss"]) - p["review"]))
    return d / 2 + np.log(ratio) / d

p = BASE
d = np.sqrt(2) * norm.ppf(p["auc"])
at95 = line(d + norm.ppf(0.05), p)                       # threshold that flags 95% of defects
print(f"Separation d = {d:.3f}. No inspection: ${p['parts']*p['prev']*p['escape']:,.0f} a day; "
      f"manual: ${at95['manual']:,.0f}")
print(f"At 95% catch: {at95['false_reject']:.2%} of good parts flagged, {at95['flags']:,.0f} flags, "
      f"{at95['precision']:.1%} of them real; camera only ${at95['camera_only']:,.0f}, "
      f"camera + review ${at95['camera_review']:,.0f}")
for kind in ["camera_only", "camera_review"]:
    t = best_threshold(kind, p); o = line(t, p)
    grid = np.linspace(-1, 6, 70_001)
    t_grid = grid[np.argmin(line(grid, p)[kind])]          # brute-force check of the closed form
    print(f"Best {kind}: catch {o['catch']:.1%}, good parts flagged {o['false_reject']:.2%}, "
          f"{o['flags']:,.0f} flags, ${o[kind]:,.0f} a day (t = {t:.4f}, grid t = {t_grid:.4f})")
o = line(best_threshold("camera_only", p), p)
print(f"Camera-only optimum ships {o['dppm_camera_only']:,.0f} DPPM")

print("\nWhat moves the best setting (catch at the cost minimum, camera only | camera + review)")
for key, vals in [("escape", [100, 500, 2000, 10000]), ("auc", [0.95, 0.98, 0.99, 0.995, 0.999]),
                  ("prev", [0.001, 0.005, 0.02])]:
    for v in vals:
        q = dict(BASE, **{key: v})
        a = line(best_threshold("camera_only", q), q); b = line(best_threshold("camera_review", q), q)
        print(f"  {key}={v:<7}: {a['catch']:6.1%} (${a['camera_only']:>8,.0f}, {a['dppm_camera_only']:>5,.0f} DPPM) | "
              f"{b['catch']:6.1%} (${b['camera_review']:>8,.0f})  manual ${a['manual']:>8,.0f}")

print("\nThreshold set for 0.5% defective, then the defect rate changes (camera only, $ a day)")
t_fixed = best_threshold("camera_only", BASE)
for v in [0.001, 0.0025, 0.01, 0.02]:
    q = dict(BASE, prev=v)
    stale, fresh = line(t_fixed, q)["camera_only"], line(best_threshold("camera_only", q), q)["camera_only"]
    print(f"  {v:.2%} defective: old setting ${stale:,.0f}, re-set ${fresh:,.0f}, "
          f"excess {stale/fresh-1:.1%}")

rng = np.random.default_rng(7)                           # check the model on sampled scores
good, bad = rng.standard_normal(200_000), rng.standard_normal(20_000) + d
t = best_threshold("camera_only", p)
print(f"\nSampled scores: AUC {(bad[:2000, None] > good[None, :20000]).mean():.4f}, "
      f"catch {np.mean(bad > t):.3f} vs {line(t, p)['catch']:.3f}, "
      f"good flagged {np.mean(good > t):.4f} vs {line(t, p)['false_reject']:.4f}")

The output:

Separation d = 2.904. No inspection: $50,000 a day; manual: $19,500
At 95% catch: 10.39% of good parts flagged, 2,163 flags, 4.4% of them real; camera only $19,042, camera + review $12,869
Best camera_only: catch 85.4%, good parts flagged 3.21%, 724 flags, $12,411 a day (t = 1.8510, grid t = 1.8510)
Best camera_review: catch 94.2%, good parts flagged 9.15%, 1,914 flags, $12,832 a day (t = 1.3318, grid t = 1.3318)
Camera-only optimum ships 758 DPPM

What moves the best setting (catch at the cost minimum, camera only | camera + review)
  escape=100    :  69.1% ($   4,375, 1,562 DPPM) |  84.5% ($   3,823)  manual $  13,500
  escape=500    :  85.4% ($  12,411,   758 DPPM) |  94.2% ($  12,832)  manual $  19,500
  escape=2000   :  93.7% ($  26,078,   345 DPPM) |  98.0% ($  39,441)  manual $  42,000
  escape=10000  :  98.1% ($  51,372,   117 DPPM) |  99.5% ($ 165,466)  manual $ 162,000
  auc=0.95   :  74.7% ($  20,347, 1,334 DPPM) |  90.5% ($  16,297)  manual $  19,500
  auc=0.98   :  85.4% ($  12,411,   758 DPPM) |  94.2% ($  12,832)  manual $  19,500
  auc=0.99   :  90.2% ($   8,548,   504 DPPM) |  96.0% ($  11,191)  manual $  19,500
  auc=0.995  :  93.4% ($   5,898,   339 DPPM) |  97.2% ($  10,079)  manual $  19,500
  auc=0.999  :  97.3% ($   2,508,   139 DPPM) |  98.8% ($   8,674)  manual $  19,500
  prev=0.001  :  69.1% ($   4,380,   312 DPPM) |  84.5% ($   3,725)  manual $  13,500
  prev=0.005  :  85.4% ($  12,411,   758 DPPM) |  94.2% ($  12,832)  manual $  19,500
  prev=0.02   :  93.8% ($  25,874, 1,388 DPPM) |  98.0% ($  39,794)  manual $  42,000

Threshold set for 0.5% defective, then the defect rate changes (camera only, $ a day)
  0.10% defective: old setting $6,589, re-set $4,380, excess 50.4%
  0.25% defective: old setting $8,773, re-set $8,115, excess 8.1%
  1.00% defective: old setting $19,689, re-set $18,282, excess 7.7%
  2.00% defective: old setting $34,244, re-set $25,874, excess 32.3%

Sampled scores: AUC 0.9814, catch 0.854 vs 0.854, good flagged 0.0321 vs 0.0321

The cheapest setting misses about one defect in seven

At the demo's defaults, scrapping every flag is cheapest at a threshold that catches 85.4% of defects and flags 3.21% of good parts: 724 flags a day, $12,411. The closed form and the grid agree to four decimals (t = 1.8510), and the sampled scores land on the model (an AUC of 0.9814 from a 2,000 by 20,000 sample, and the same catch and false reject rates to three decimals).

That setting ships 758 defective parts per million (DPPM). Whether that is acceptable is not a modeling question. It is what $500 per escape implies. If an escape really costs a customer line stoppage or a recall exposure, the $500 is wrong, and the code shows how far the answer moves: at $2,000 per escape the best setting catches 93.7% and ships 345 DPPM; at $10,000 it catches 98.1% and ships 117 DPPM. A plant that holds a contractual DPPM target is, in effect, stating an escape cost, and the two should be checked against each other.

Camera quality moves the answer as much as cost does. At an AUC of 0.95 the cheapest camera-only setting catches 74.7% of defects for $20,347 a day, more than manual inspection. At 0.99 it catches 90.2% for $8,548, and at 0.999 it catches 97.3% for $2,508. A move from 0.98 to 0.99 sounds small on a model card. On this line it cuts the daily cost of the best setting by 31%.

Only one ratio sets the threshold

The formula has the defect rate and the two costs in a single term, G·c_s / (D·c_e). Any change that keeps that ratio fixed leaves the best catch rate where it is. The output shows it: $100 per escape at 0.5% defective and $500 per escape at 0.1% defective both give a best catch of 69.1%. A plant whose process improves from 0.5% to 0.1% defective should flag less, by exactly as much as if its escape cost had fallen fivefold.

That is also why a threshold set once and left alone drifts out of date. Set for 0.5% defective, the camera-only threshold costs 50.4% more than a re-set one when the defect rate falls to 0.1%, and 32.3% more when it rises to 2%. Small moves cost little: at 0.25% and 1% the excess is 8.1% and 7.7%. The defect rate is the input most likely to change after commissioning, because a working camera feeds the fixes that lower it.

When a person reviewing flags helps and when it hurts

The obvious fix for a reject bin full of good parts is to have a person look at each flag, return the good parts to the line and scrap only real defects. At the defaults that costs $12,832 a day at its best setting (94.2% catch, 1,914 flags), a little more than scrapping every flag. Review wins where the camera is weak: at an AUC of 0.95, review costs $16,297 a day against $20,347 for camera only. It also wins when escapes are cheap, $3,823 against $4,375 at $100 per escape.

It loses badly when escapes are expensive. At $10,000 per escape, camera plus review costs $165,466 a day against $51,372 for camera only. The reason sits in the model's one human parameter: a reviewer who misses 15% of real defects lets through defects the camera already caught. In this setup review can only remove defects from the reject bin, never add them, so the reviewer's miss rate on flagged parts is the number that decides whether review is worth paying for.

The 15% default is, if anything, kind to people. Judi See's 2014 summary of a Sandia National Laboratories literature review on visual inspection, going back to the 1950s, reports that error rates of 20% to 30% are common, that omissions occur more often than false rejections, and that no defect is detected by all inspectors. A review step is worth measuring on its own: seed known defects into the flagged stream and count how many come back as good.

A Kansas City scale check

Ford's Kansas City Assembly Plant in Claycomo builds the F-150, Transit and E-Transit and had about 9,205 employees in June 2026, by Ford's own count. At plants of that size, and at the Kansas City region's smaller suppliers, an inspection station's daily volume, defect rate and escape cost are known or measurable, which is all the threshold formula asks for. None of the figures in this piece come from Ford or any plant; they are the calculator's illustrative defaults, and the point is that the same three inputs decide the setting on any line.

The machine vision inspection calculator lets you change the parts, defect rate, AUC, costs and reviewer miss rate and see the cost curve and its minimum move. The same expected-dollar reasoning about two kinds of error shows up in sepsis alert math, where the false alarms are pages to a nurse, and in freight factoring fraud. More work like this sits in the machine learning and analytics research hub from Vector 1 in Kansas City.

Limits of these numbers

Every figure comes from a model with parameters I chose. Real camera scores are rarely two normal curves of equal spread; defect scores are often wider, with a tail of subtle defects that score like good parts, and an equal-variance model fit to the same AUC can then recommend the wrong setting. The model has one defect type, independent parts, a fixed defect rate and reviewers who never reject a good part. Real lines see new defect types the model never trained on, drift in lighting and fixtures, and reviewer performance that changes with volume and time on task. The threshold should be set from labeled scores collected on the line, and re-checked when the defect rate or the product mix changes.

The paid edition

The paid edition on Substack goes further: a script that sets the threshold from your own labeled validation scores, with a bootstrap interval on the chosen catch rate; how many labeled defects you need before the chosen setting is close to the best one (25 is not enough); what a cap on reviewer capacity does to the best plan; and how much an equal-variance assumption costs when defect scores are more spread out than good parts' scores. Subscribe free for new articles by email, or get a Team License for the whole quality and data science team.

Sources

Related research