The most common failure in vision selection is not "cannot capture it clearly" but capturing it clearly yet not measuring it accurately. Pixel accuracy, magnification, depth of field and diffraction all constrain each other: to see a larger object you need a short focal length, and a short focal length makes the pixel accuracy coarse; to extend the depth of field you stop down, and stopping down blurs the edges through diffraction. Below we use a dimensional inspection case of a 50×30 mm stamping part, calculating from the field of view through to the aperture in six steps, and then expand into the formulas.
| Item | Value | Source |
|---|---|---|
| Object size | 50 × 30 mm (outline + two locating holes) | Part drawing |
| Measurement accuracy requirement | 0.05 mm | Tolerance band ÷ 3 |
| Working distance WD | 225 mm | Measured from the conveyor surface to the camera mounting flange |
| Takt | ≥ 15 pieces/second | Line takt |
| Surface being viewed | Stamped steel part, with an oil film producing reflections | On site |
If any one of these five numbers is missing, nothing after it can be calculated. The accuracy requirement must come from the tolerance band, not from writing down 0.01 mm off the top of your head — raising the accuracy by one band quadruples the number of pixels and triples the price.
FOVX = 50 × 1.1 = 55 mm FOVY = 30 × 1.1 = 33 mm
That 10% is not waste; it is reserved for positioning error: 2 mm of cylinder loading offset, 3 mm of belt tracking drift, 1 mm of fixture wear, which together eat more than 5 mm. Without a margin the direct consequence is that a part occasionally lands at the edge of the frame and the inspection station starts missing parts at random.
By the Nyquist sampling rule, one accuracy unit must fall on at least 2 pixels:
Calculating all the criteria gives very different answers:
| Criterion | Meaning | Required resolution | Corresponding camera |
|---|---|---|---|
| 2 px/accuracy | The Nyquist floor, the theoretical minimum | 2200 × 1320 | 3MP 2048×1536 (barely) |
| 3 px/accuracy | Common for production inspection, allowing for edge uncertainty | 3300 × 1980 | 6MP 3072×2048 (slightly short) |
| 4 px/accuracy | High-reliability measurement, where repeatability must be assessed | 4400 × 2640 | 8MP and above |
This example takes the 2 px floor plus a sub-pixel edge algorithm, and selects a 6MP 3072 × 2048, pixel 2.4 μm, 1/1.8″. Why not 3 px? Select the lens first and then come back to this — resolution is not the only variable.
Many references give f = WD × sensor ÷ FOV directly, which is the thin-lens approximation and only holds when the magnification is much less than 1. In this case the magnification is 1:8 and the error is already 12%, so the exact formula must be used:
6MP sensor (effective imaging area) = 3072 × 2.4 μm = 7.373 mm (height 4.915 mm)
m = 7.373 ÷ 55 = 0.1340
f = 225 × 0.1340 ÷ 1.1340 = 26.6 mm → select the standard 25 mm
Lateral = 58.98 ÷ 3072 = 0.0192 mm/px (19.2 μm)
Vertical = 39.32 ÷ 2048 = 0.0192 mm/px ✓ the two directions agree (the 3:2 sensor matches the 3:2 FOV)
How many pixels does each 0.05 mm accuracy unit fall on:
2.60 px clears the 2 px floor but does not reach the 3 px safe value. This result shows that adding more pixels is useless — an 8MP camera with a 35 mm lens only reaches 18.7 μm, still 2.67 px, because the larger sensor forces a longer focal length and the FOV grows with it, cancelling out on both sides. To genuinely improve the accuracy you must reduce the FOV or move to a larger sensor with a longer WD, not simply pile on pixels.
| Configuration | Sensor | Required focal length | Selected focal length | Actual FOV | Pixel accuracy | px/accuracy |
|---|---|---|---|---|---|---|
| 2MP 1620×1220 | 7.13×5.37 | 25.8 | 25 | 57.0×42.9 | 35.2 μm | 1.42 ✗ |
| 3MP 2048×1536 | 7.07×5.30 | 25.6 | 25 | 56.5×42.4 | 27.6 μm | 1.81 ✗ |
| 5MP 2448×2048 | 8.45×7.07 | 30.0 | 25 | 67.6×56.5 | 27.6 μm | 1.81 ✗ |
| 6MP 3072×2048 | 7.37×4.92 | 26.6 | 25 | 59.0×39.3 | 19.2 μm | 2.60 ✓ |
| 8MP 4096×3000 | 14.13×10.35 | 46.0 | 35 | 76.7×56.2 | 18.7 μm | 2.67 |
The magnification m = 25 ÷ (225 − 25) = 0.125 (1:8), and the circle of confusion is taken as 2 pixels c = 2 × 19.2 μm = 0.0384 mm.
| Aperture N | Depth of field DOF | Airy disc diameter | As a fraction of a pixel | Assessment |
|---|---|---|---|---|
| F1.4 | 7.7 mm | 1.88 μm | 0.78 px | Depth of field rather thin |
| F2.0 | 11.1 mm | 2.68 μm | 1.12 px | Usable, small margin |
| F2.8 | 15.5 mm | 3.76 μm | 1.57 px | Selected in this example |
| F4.0 | 22.2 mm | 5.37 μm | 2.24 px | The edges begin to blur |
| F5.6 | 31.0 mm | 7.52 μm | 3.13 px | Diffraction eats the accuracy |
The part has an 8 mm flange height difference, and adding 2 mm of belt bounce the depth of field needs to be at least 10 mm. The 11.1 mm of F2.0 just scrapes past, while the 15.5 mm of F2.8 leaves a 50% margin and the 1.57 px diffraction spot is still within an acceptable range. F2.8 is the sweet spot for this set of parameters.
The diffraction limit expression:
The criterion: the Airy disc diameter ≤ 2 pixels. Beyond 2 px the edge transition band widens and the accuracy of the sub-pixel algorithm falls away sharply. Enough depth of field ≠ the smaller the aperture the better — the two are squeezed from opposite directions.
The surface has an oil film, and forward lighting produces random highlights on the workpiece so the edge position drifts with them. Parallel backlighting turns the part into a pure black silhouette, maximising the edge contrast so that the sub-pixel algorithm is stable. Hole detection benefits in the same way — a hole is a bright void in the silhouette.
3072 × 2048 × 1 B × 15 fps = 94 MB/s, and the practical bandwidth of GigE is about 110 MB/s, so it is enough.
But if the output is 12 bit (1.5 B/px): 94 × 1.5 = 142 MB/s, over the Gigabit Ethernet limit. Either switch to 8 bit or go to 10GigE / Camera Link. If this step is skipped, the symptom after installation is dropped frames, corrupted images and occasional timeouts, which is extremely tedious to diagnose.
| Component | Specification | Key reason |
|---|---|---|
| Camera | 6MP 3072×2048, 2.4 μm, 1/1.8″, global shutter, GigE | 2.60 px/accuracy; the global shutter avoids motion smear |
| Lens | 25 mm prime, C-mount, F2.8, maximum image circle ≥ 1/1.8″ | f=26.6 can only be rounded down; an insufficient image circle darkens the corners |
| Working distance | 225 mm (FOV 59.0 × 39.3 mm) | Leaves an 18% lateral margin |
| Light source | Parallel backlight 90 × 90 mm, white (or red 625 nm) | Silhouette measurement, suppresses oil-film reflections |
| Light controller | 2-channel digital dimming, 256 levels | Calibratable brightness, no re-tuning when the batch changes |
| Aperture | F2.8 (depth of field 15.5 mm, diffraction 1.57 px) | The balance point between depth of field and sharpness |
Acceptance criteria: repeatability ≤ 0.005 mm (about 1/4 of a pixel), and a deviation of ≤ 0.02 mm against a vernier caliper. After installation, run 30 standard parts through a GR&R study first — do not simply judge whether a single image looks clear.
For the same 5 megapixels, a 2/3″ sensor gives a 3.45 μm pixel while a 1/1.8″ sensor may be only 2.4 μm. Smaller pixels mean lower sensitivity, a smaller full-well capacity and a narrower dynamic range, but better accuracy over the same field of view. The larger the sensor, the more expensive the lens and the shallower the depth of field — this is a complete cost chain.
| Sensor | Width × height (mm) | Diagonal | Typical pairing |
|---|---|---|---|
| 1/3″ | 4.8 × 3.6 | 6.0 | Small FOV, low-cost inspection |
| 1/2″ | 6.4 × 4.8 | 8.0 | General entry level |
| 1/1.8″ | 7.18 × 5.32 | 8.93 | The mainstream for 2~6MP |
| 2/3″ | 8.8 × 6.6 | 11.0 | The 5MP industrial standard |
| 1″ | 12.8 × 9.6 | 16.0 | High-accuracy measurement |
| 4/3″ | 18.0 × 13.5 | 22.5 | Large format, defect inspection |
| Type | Characteristics | Applications | Price order |
|---|---|---|---|
| Prime | Low distortion, large aperture, simple construction | Fixed station batch inspection, 90% of cases | 1× |
| Zoom | The FOV can be adjusted on site, but distortion changes with the focal range | Prototype commissioning, many varieties in small batches | 2~3× |
| Telecentric | The chief rays are parallel, no perspective error, the magnification stays constant over the depth of field | Precision dimensional measurement, parts with a height difference | 8~20× |
The f = WD·m/(1+m) formula cannot be applied to a telecentric lens: its magnification is determined by the double telecentric optical structure, so the nominal 0.5×, 1× and 2× are selected directly and the working distance is also fixed in a few discrete steps. Using the ordinary lens formula for a telecentric lens always gives a wrong answer.
| Lighting method | What you see | Typical applications |
|---|---|---|
| Parallel backlight | A pure silhouette, the sharpest edges | Outline dimensions, hole positions, gap measurement |
| Ring light | Surface texture, scratches | Appearance defects, characters |
| Coaxial light | Specular reflection, suppresses reflections | Polished metal surfaces, glass, chips |
| Low-angle light | Highlights raised features and pits | Embossing, scratches, raised characters |
| Dome light | Shadow-free uniform illumination | Curved surfaces, complex highly reflective parts |
The order must not be reversed: first decide the lighting method by the feature you need to see, then size it by the field of view, and only then adjust the brightness. Doing it the other way round usually ends up buying a very bright lamp with the feature still not visible.
| Interface | Practical bandwidth | Cable length | Applications |
|---|---|---|---|
| USB 3.0 | ~350 MB/s | ≤ 5 m | Standalone, low cost, below 2MP |
| GigE | ~110 MB/s | ≤ 100 m | Multiple machines on a line, long distances (the most common) |
| 10GigE | ~1000 MB/s | ≤ 100 m | High frame rate, large sensors |
| Camera Link | ~680 MB/s | ≤ 10 m | High-speed line scan, retrofitting older lines |
k=2 is the Nyquist floor, k=3 the production-safe value, and k=4 is used for precision measurement where repeatability is assessed.
The approximation f ≈ WD × sensor ÷ FOV has a negligible error only when m < 0.05. At m ≥ 0.1 the exact form must be used, otherwise the selected focal length comes out too long and the field of view is insufficient.
Both the lateral and the vertical must be calculated and the two values must be close, otherwise the sensor aspect ratio does not match the field of view aspect ratio and pixels are wasted.
The more precise form (near and far object distances):
In this example at F2.8: DOF = 15.48 mm, near 217.5 mm, far 233.0 mm, which differs from the approximate form by 0.02 mm, showing that the approximation is sufficient when m < 0.2.
For white light take λ = 0.55 μm. At F4 it is 5.37 μm, already occupying 2.24 pixels, and the edges begin to go soft. So the depth of field is not something you stack up by stopping down.
| Application | k value | Explanation |
|---|---|---|
| Presence/absence judgement, coarse positioning | 1~2 | No dimensional measurement |
| General dimensional measurement | 2~3 | Combined with a sub-pixel edge algorithm |
| Precision measurement, GR&R assessment | 3~4 | Fixture and thermal drift have to be considered |
| Defect inspection (based on the defect size) | 3~5 | The smallest defect must occupy at least 3×3 pixels |
| Accuracy requirement | Pixels needed at k=3 | Recommended camera | Pixel accuracy |
|---|---|---|---|
| 0.10 mm | 1800 | 2MP 1620×1220 | 37 μm |
| 0.05 mm | 3600 | 6MP 3072×2048 | 19 μm |
| 0.02 mm | 9000 | 12MP 4096×3000 | 15 μm |
| 0.01 mm | 18000 | 20MP + telecentric lens | 6 μm |
| Aperture | Depth of field | Diffraction as a fraction of a pixel | Recommended scenario |
|---|---|---|---|
| F1.4~F2 | 7.7~11.1 mm | <1.2 px | Thin sheet and flat parts, where the sharpest edges are needed |
| F2.8 | 15.5 mm | 1.57 px | The general first choice |
| F4 | 22.2 mm | 2.24 px | Height differences, relaxed accuracy requirements |
| F5.6 and above | >31 mm | >3 px | Not recommended for measurement |
| Wrong practice | Consequence | Correct practice |
|---|---|---|
| Using the approximation f = WD×sensor/FOV for the focal length and then taking the "closest" standard lens | The approximation is 12% long, and stepping up one more size shrinks the FOV from 59 mm to 40 mm, so the part does not fit in the frame | Use f = WD·m/(1+m) and only round down to a standard focal length, then back-calculate the FOV to check |
| Using the package code to look up the sensor size (1/1.8″ = 7.18 mm) | The focal length is 3% off and parts at the edge occasionally fall out of frame | Calculate the real imaging area from resolution × pixel size |
| Selecting the camera at 2 px/accuracy and considering it done | Just enough in theory, but the measured repeatability is poor and GR&R fails | Take 3 px for production and 4 px for precision measurement, or explicitly use a sub-pixel algorithm and verify the repeatability |
| Estimating the depth of field as "aperture number × pixel accuracy × a constant" | This example gives 19 mm when the actual value is only 11 mm, and the mechanism is designed for 19 mm, so half the parts are out of focus after installation | DOF = 2Nc(1+m)/m² with c taken as 2 pixels; the larger m is, the shallower the depth of field, and it is not a linear relation with the pixel accuracy |
| Stopping all the way down to F8 to extend the depth of field | The 10.7 μm Airy disc occupies 4.5 pixels, the edges blur into a gradient and the sub-pixel accuracy collapses | Calculate the diffraction first, with dAiry ≤ 2 pixels as the limit; if the depth of field is insufficient, change the mechanism or move to a telecentric lens |
| Calculating only the resolution and not the bandwidth | 6MP 12 bit at 17 fps needs 160 MB/s while Gigabit Ethernet only provides 110 MB/s, so frames are dropped and images are corrupted after installation | Bandwidth = resolution×bit depth/8×frame rate with a 20% margin; if it exceeds the limit, use 8 bit or move to 10GigE |
| Using ring forward lighting to measure the dimensions of a reflective metal part | The oil-film highlights drift randomly and the edge position moves by more than 0.05 mm | Switch to parallel backlighting to form a silhouette, which maximises the edge contrast and stabilises the sub-pixel result |