System designExplainer

How a machine vision system works: camera, lens, light and logic

How a machine vision system works: the light, lens, sensor and logic stages, the 3-4 pixels-per-feature rule that sizes them, and a worked 12 MP example.

LumaSpec Vision12 min read Share on LinkedIn

On this page 11 sections
  1. 01The four stages, in the order light travels
  2. 02The rule that sizes everything: 3-4 pixels per feature
  3. 03Stage 1: light creates the contrast
  4. 04Stage 2: the lens carries the detail
  5. 05Stage 3: the sensor turns light into numbers
  6. 06Worked example: 0.1 mm defects on a 100 mm by 75 mm part
  7. 07Stage 4: trigger, logic and the verdict
  8. 08Area scan, line scan or 3D: follow the motion
  9. 09When the usual answer is wrong
  10. 10Checklist before you order
  11. 11Questions

Every machine vision system does the same four things in the same order: light creates the contrast, the lens projects it, the sensor converts it to pixels, and software turns the pixels into a pass or a fail. The order is not negotiable, because no stage can recover what an earlier stage lost — software cannot sharpen contrast the lighting never made. This explainer walks that pipeline stage by stage and shows how one number — the smallest feature you must see — fixes the camera, the lens, the lighting and the controller. A worked example sizes a complete station for 0.1 mm defects on a 100 mm part. For the buying-side detail, the machine vision hardware selection guide goes deeper on each trade-off.

The four stages, in the order light travels

The light decides what is visible. The optics carry it at a scale the sensor can sample. The sensor turns photons into numbers. The logic compares those numbers against limits and raises a verdict. Around the four sit two timing parts: the trigger that says when to look, and the light controller that sets how bright and for how long. The machine vision system components buyer's guide lists the full bill of materials.

The coupling runs one way, upstream to downstream. Lighting sets the exposure the sensor needs; the sensor's format and pixel count set what the lens must cover and resolve; the lens sets where the camera sits and how big the field of view is. Work in that order and each choice has one defensible answer. Work backwards from a camera someone already owns, and every later choice is a compromise.

The rule that sizes everything: 3-4 pixels per feature

Write down one number before you open a catalogue: the smallest feature the system must not miss, in millimetres. Sampling theory puts the floor at two samples across a feature; working systems plan three to four, because real edges spread across neighbouring pixels, gray levels drift with the light, and a threshold needs margin. Below three pixels the detection rate collapses; past about six you pay for resolution the part cannot use, in bandwidth, lens cost and lost depth of field.

object-side pixel size = field of view / pixels across the sensor pixels needed across the field = (field of view / smallest feature) × pixels per feature

A 0.2 mm scratch on a 60 mm field needs 60 / 0.2 × 3 = 900 pixels across — about 0.6 MP in a 4:3 frame. Presence checks almost never stress a modern sensor; fine-defect work is where cameras earn their pixel counts.

That one number walks downstream through every choice. It fixes the sensor resolution; the sensor's format fixes the lens family; the field of view and working distance fix the focal length; the feature's contrast fixes the lighting geometry; the exposure that contrast needs fixes the controller and trigger timing.

Stage 1: light creates the contrast

The camera never sees the part; it sees the light the part sends it. So the first decision is geometry, not brightness. A backlight gives a silhouette and the cleanest edges for measurement. A directional front light — bar or ring — shows surface texture, print and finish. Dark field catches scratches and raised edges as bright marks on a dark background. A dome flattens the glare off shiny, curved surfaces. Ring light versus bar light breaks the most common choice down by part shape.

Surface finish moves the answer more than part colour does: the same scratch is invisible in one geometry and obvious in another, and part localization across surface finishes shows the geometry change that recovers it. As a working target, put at least about 30 of 255 gray levels between feature and background; below that, thresholds hunt between frames.

Drive the light properly and the image stays put. Constant-current drive stops the warm-up drift that moves gray levels during the first minutes of a shift. Strobing overdrives the LED for tens of microseconds, so a short exposure still collects photons and motion freezes. Both need a real light controller rather than a bench supply — why a vision light needs a controller covers the timing side.

Stage 2: the lens carries the detail

The lens must clear three bars at once. Its image circle has to cover the sensor's format, or the corners go dark. Its printed resolution has to meet or beat the sensor's pixel count — a 12 MP sensor behind a 5 MP lens gives a soft image at 12 MP cost. And its focal length has to place your field of view at the working distance you actually have. Lens selection by feature size and MTF covers the resolution side; here is the geometry:

m = sensor width / field of view f = WD × m / (1 + m)

where m is magnification and WD is the working distance from lens to part.

How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

Watch the aperture at the same time. The diffraction spot grows with f-number: at F8 and a 0.55 µm wavelength it is 2.44 × 0.55 × 8 = 10.7 µm across — several pixels on a small-format sensor. The Airy disk and diffraction limit guide sizes it for your pixel pitch, and aperture, f-number and depth of field covers the trade between sharpness and depth.

Stage 3: the sensor turns light into numbers

Area scan cameras grab the whole field per trigger, which is the right answer whenever the part stops — or can be frozen by a strobe — under the lens. Two sensor properties then decide most of the image.

Shutter first. A rolling shutter reads the sensor line by line, so a part that moves during exposure skews and stretches; a global shutter samples every pixel in the same instant. The rule is simple: part moving and no strobe, buy global; part fixtured or strobe-frozen, rolling costs you nothing. Then interface. USB3 suits single-camera stations at a few metres of cable; GigE reaches 100 m and networks several cameras on one switch; 10GigE and CoaXPress are for frame rates that outgrow both. Sorting conveyor camera selection works the pixels-versus-speed trade for moving product.

One camera still only sees the faces presented to it, and how camera count follows visible face coverage plans that split. When the pixel rule pushes you up a resolution class, format climbs too: a step from a 12 MP 1/1.7" sensor to a 20 MP 1" sensor also demands a lens with a bigger image circle. Here is that step side by side:

Specification LS-CMR-0166 MV-CS200-10UM
Sensor model Sony IMX226 Sony® IMX183
Resolution 4000 × 3000 (12MP) 5472 × 3648
Max. frame rate 30 fps 19.2 fps @ 5472 × 3648 Mono 8
Pixel size 1.85 μm 2.4 μm × 2.4 μm
Sensor size 1/1.7" 1"
Data interface USB 3.0 USB3.0, compatible with USB2.0
Price $560.00 $759.00

Values as printed in each product's data sheet; open a part for its drawing and full specifications.

Worked example: 0.1 mm defects on a 100 mm by 75 mm part

The inputs, from a typical assembly-inspection station:

  • Field of view to cover: 100 mm × 75 mm, one face of a matte electronics assembly.
  • Smallest defect that must not pass: 0.1 mm, a stray solder ball or a hairline scratch.
  • Part is fixtured and stationary; about 230 mm of working distance is available; the host has USB3.
  • Rule: 4 pixels across the feature, for margin.

The arithmetic, in the order the stages run:

  1. Object-side pixel size: 0.1 mm / 4 = 0.025 mm, or 25 µm per pixel.
  2. Pixels needed: 100 mm / 0.025 mm = 4000 across, 75 mm / 0.025 mm = 3000 down. That is 4000 × 3000 = 12 MP.
  3. Camera. The LS-CMR-0166 prints 4000 × 3000 pixels — 12 MP — on a 1/1.7" sensor, at 30 fps over USB3, rolling shutter. Over the 100 mm field that is 100 / 4000 = 25 µm per pixel, so the 0.1 mm defect spans 0.1 / 0.025 = 4 pixels. Rolling shutter costs nothing on a fixtured part.
Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it
  1. Lens. A 1/1.7" sensor is about 7.4 mm wide, so the pixel pitch is 7.4 mm / 4000 = 1.85 µm. Magnification m = 7.4 / 100 = 0.074. Focal length at 230 mm: f = 230 × 0.074 / 1.074 = 15.9 mm — a 16 mm lens. The LS-FFL-0567 is a 16 mm C-mount lens for 1.1" formats, rated 20 MP, F2.8-22, with <0.3% distortion. The 20 MP rating clears a 12 MP sensor, and the 1.1" format with its 16-22 mm image circle clears the sensor's roughly 9 mm diagonal, corners included.
Machine vision lenses16 mm, 1.1", 20 MP, C-mount machine vision lens, F2.8-22, <0.3% distortion (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it
  1. Aperture. At F4 the diffraction spot is 2.44 × 0.55 µm × 4 = 5.4 µm, about three of those 1.85 µm pixels. Run the iris between F2.8 and F4 while checking fine features, and stop down only until the depth of field covers the part's height variation.
  2. Light and timing. The board is matte, so a bright-field bar light at roughly 45° is the geometry. Indexing can leave 50 mm/s of drift as the fixture settles: one pixel of blur allows an exposure of 25 µm / 50 mm/s = 500 µs, and a 100 µs strobe pulse holds smear at 50 mm/s × 100 µs = 5 µm — a fifth of a pixel. Strobing and repeatable dimming need a controller; the LS-CTL-0322 is a 4-channel digital unit at 16-24 V with 8 A total output, so one channel drives the bar light and three stay free.
Light controllers4-Channel Digital LED light controller, 16-24V, AC100-240V 50/60 Hz, 8 A total output (LS-CTL-0322)LS-CTL-0322
Output
Constant voltage 24 V
Channels
4 channels
Control
Digital
$539.00View partBuild a system with it

Order list: a 12 MP USB3 area scan camera, a 16 mm 20 MP lens at about 230 mm working distance, a bright-field bar light strobed to 100 µs, and a 4-channel controller. Run the same arithmetic with your own numbers:

Lens focal length, field of view and working distance
Units
Solve for
Focal length
– mm
Field of view
– mm
Working distance
– mm
Magnification
– x
Angle of view
– °
Pixel on the part
– mm

Thin-lens model: m = sensor width / field of view, f = WD × m / (1 + m). Accurate to a few percent above about 150 mm; check the lens's minimum object distance.

Find lenses with this focal length Open the full calculator

Stage 4: trigger, logic and the verdict

The logic stage is smaller than the software catalogue makes it look: find the part, measure or classify the region you care about, compare against limits, raise the verdict. Three habits keep it stable. Anchor the search to a fixture or a pattern, so a shifted part does not shift your tolerances. Put thresholds on quantities the image controls — gray level, edge position, area — never on screen coordinates. And time the whole chain: at 30 parts a minute you have 60 / 30 = 2 s per part, so hold trigger-to-verdict under about 200 ms and the line never waits on vision.

The chain has four links. A part sensor triggers the camera; the camera gates the strobe through the controller; the exposure freezes the motion; the verdict goes to the PLC as a digital line. Triggering a camera from a part sensor wires the front of that chain, and when the PLC handshake becomes the bottleneck, a buffer relay between camera and strobe isolates the timing.

Area scan, line scan or 3D: follow the motion

Situation Right sensor Why
Part stops under the camera, or a strobe freezes it Area scan One trigger, one image; the whole field is judged in a single shot
Product flows continuously: web, extrusion, full wrap Line scan The image is built line by line as the part passes; no field-of-view limit along travel
Height, volume or fit is the inspection 3D profile sensor Depth comes from triangulation, not gray levels
A robot picks the part 2D or 3D, by grip tolerance Flat parts pick on 2D; stacked or varying parts need depth

For line scan the key number is line rate: belt speed divided by the object-side pixel size. At 0.5 m/s with 50 µm pixels that is 500 mm/s / 0.05 mm = 10,000 lines per second. Line scan system design balances camera, lens, light and motion for that case, and choosing between 2D and 3D for conveyor pick and place settles the last row.

When the usual answer is wrong

  • More pixels as a fix for weak contrast. Pixels sample contrast; they do not create it. A defect two gray levels from its background stays invisible at 40 MP. Change the geometry or the wavelength first, then re-count pixels.
  • The 3-4 pixel rule applied to gauging. Sub-pixel edge interpolation places an edge to about a fifth of a pixel, so a width check needs strong contrast and a clean edge, not four pixels on the edge itself. Detection needs the rule; measurement needs contrast.
  • Rolling shutter on a moving part. The image skews and every dimension bends. Strobe it, stop it, or buy global.
  • Line scan on stopped parts. A line camera images one line per trigger; with no motion there is no image. Line scan pays off only when motion is continuous and unavoidable.
  • Resolution bought ahead of need. Past the rule, pixels get smaller and gather less light each, demand a better lens and a fatter data pipe, and shrink the depth of field. Stable 2D vision inspection systems orders it plainly: light, lens, exposure — then pixels.

Checklist before you order

  • Smallest feature size written down, with its 3-4 pixel budget computed.
  • Field of view with 10-20 % margin for placement tolerance.
  • Lens image circle and megapixel rating clear the sensor's format and count.
  • Focal length checked against the working distance you have, with the formula or the calculator.
  • Shutter type matches motion: global if the part moves un-strobed.
  • Interface bandwidth carries the full-resolution frame rate, and cable length fits the standard.
  • Lighting geometry chosen against the surface finish, with a strobe length inside the blur budget.
  • Controller has a channel per light, plus one spare.
  • Trigger source and verdict timing written as a number of milliseconds.

With the numbers on paper, the choices are short: the system configurator walks camera, lens, light and controller in one pass, the camera finder and lens finder filter by format and resolution, and the systems topic page collects the deeper articles. If a feature size will not behave, send it with the field of view through the contact page and we will size the station with you.

Questions

How many pixels do I need across a defect?

Plan 3-4 pixels across the smallest feature you must catch. Two pixels is the sampling floor, but real edges spread across neighbouring pixels and gray levels drift with the light, so detection rates collapse near two. Dimensional measurement is the exception: sub-pixel edge fitting places an edge to about a fifth of a pixel, so two pixels with strong contrast is enough for a width check.

Do I need a global shutter camera?

Only if the part moves during exposure and you cannot strobe it. A rolling shutter reads the sensor line by line, so a moving part skews and stretches in the image; a global shutter samples every pixel at the same instant. A part that stops in a fixture, or is frozen by a short strobe pulse, makes rolling shutter a non-issue at any resolution.

Why design the lighting before choosing the camera?

Because software cannot recover contrast that was never captured. Lighting geometry decides whether a scratch reads bright on dark (dark field), a surface texture shows (directional front light), or a silhouette gets measured (backlight). Changing geometry is usually the cheapest fix for a marginal image; adding pixels to the camera keeps the same weak contrast and just moves more data.

What does a light controller add over wiring LEDs to a power supply?

Constant-current output stops brightness drifting as the LEDs warm up, digital channels give repeatable dimming, and strobe outputs overdrive the light for tens of microseconds so a short exposure still collects photons. Sequencing several lights from one box also keeps multi-angle shots in sync frame to frame. A plain supply gives none of that timing, and the drift shows up later as threshold drift.

Area scan or line scan for a moving conveyor?

If the part can be stopped or strobe-frozen for a few milliseconds, area scan: one trigger, one image. If product flows continuously — webs, extrusions, full-wrap inspection — line scan, and the line rate follows the belt: belt speed divided by the object-side pixel size, exactly the arithmetic shown in the line scan section of this guide.