System designHow-to

Template matching a part larger than the field of view

Teach a printed stand-in of one feature when the part is larger than the field of view: template matching steps, scale limits, repeatability checks.

LumaSpec Vision12 min read Share on LinkedIn

On this page 11 sections
  1. 01The decision up front
  2. 02Run the pixel budget first
  3. 03Size the view and the lens
  4. 04Pick a feature that cannot lie
  5. 05Print the stand-in at true scale
  6. 06Teach and refine the template
  7. 07Verify score and scatter before it steers anything
  8. 08What a scale error actually costs
  9. 09When one feature is the wrong answer
  10. 10Checks before you commit
  11. 11Questions

A 260 mm housing and a 55 mm field of view do not negotiate. At the magnification your tolerance demands, the camera cannot see the whole part, so template tools refuse to learn it. The fix is to teach one distinguishing feature instead of the whole part, and when the feature itself is awkward to teach in place, bootstrap the template from a print of that feature at true scale, then refine it on the real part. This guide gives the full sequence for a PC-based camera or a smart camera: the pixel budget that forces the small view, the lens arithmetic, the print rules, the teaching steps, and the repeatability numbers that say you are done.

The decision up front

Teach one feature, printed at exactly 100% scale, then refine the template on the real part. That sentence carries two scale limits, and you pick one before touching a printer:

  • The feature guides a tool (robot pick, dispense path, drilling): print at 100% scale and hold the printed feature within 1% of true size, which is 0.3 mm on a 30 mm logo. Refinement on the real part is mandatory.
  • The feature is only checked for presence: the match survives a scale error up to about 10%, with scores in the mid-90s. Use that headroom for print and part variation, never for guidance.

A scale mismatch does not just lower the score. It flattens the correlation peak and lets the reported position wander between runs. Detection tolerates that; guidance does not.

Run the pixel budget first

The small view is usually forced by resolution, not by an inability to back the camera off. Two rules settle it:

  1. The smallest detail you must detect needs at least 2 pixels across it; a detail you must measure needs 3.
  2. A tolerance you must hold should span at least 10 pixels, so subpixel noise, distortion and presentation stay an order of magnitude below it.

Apply them to the running example: a 260 mm housing, a 30 mm logo on it, a glue path that must track the logo edge to ±0.1 mm, and the part presented in a nest to ±3 mm.

Fit the whole 260 mm housing on a 20 MP sensor 5472 pixels wide and the object pixel is 260 / 5472 = 0.0475 mm, about 47 µm. The ±0.1 mm tolerance then spans 0.1 / 0.0475 = 2.1 pixels, five times coarser than the 10-pixel rule allows. Holding ±0.1 mm needs an object pixel of 10 µm or finer, so the field of view may span at most 5472 × 0.010 = 54.7 mm. A 260 mm part does not fit in 55 mm. You are matching one feature by arithmetic, not by preference.

If your own numbers pass with the whole part in view, teach the whole part and stop here; planning views and measurements around the full part, as in small round part inspection: planning views and measurements, is the simpler system.

Size the view and the lens

m = sensor width / field of view f = WD × m / (1 + m) object pixel = field of view / pixels across the sensor

Take a 1"-type sensor, about 13.2 × 8.8 mm, in a 20 MP camera: 5472 × 3648 pixels of 2.4 µm. Target a 52 mm-wide view, which holds the 30 mm logo, the ±3 mm nest tolerance and margin:

  • Magnification: m = 13.2 / 52 = 0.254.
  • At 250 mm of working distance: f = 250 × 0.254 / 1.254 = 50.6 mm, so fit a 50 mm lens.
  • Check with the real lens: m = 50 / (250 − 50) = 0.250, giving a view of 13.2 / 0.250 = 52.8 × 35.2 mm.
  • Object pixel: 52.8 / 5472 = 0.0097 mm, about 10 µm. The ±0.1 mm tolerance now spans 10 pixels.
  • The logo fills 30 / 0.0097 ≈ 3100 pixels, 57% of the frame, inside the healthy one-third to two-thirds band.
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.
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

The lens must cover the sensor: a 1"-type sensor has a 16 mm diagonal, so filter machine vision lenses by 50-100 mm focal length and an image circle of 16 mm or more; the lens finder does both in one pass. The same view also exists at close range, because a 16 mm lens at 80 mm gives the identical width: m = 16 / (80 − 16) = 0.250. Long stand-off leaves room for a dispense nozzle; short stand-off keeps the station compact. Distortion matters at this precision: a lens with 0.3% distortion displaces a feature by 0.003 × 52.8 = 0.16 mm at the edge of the view, more than the whole ±0.1 mm tolerance, so calibrate the distortion out or keep the feature near the center. The LS-FFL-0567 is a 16 mm C-mount lens rated to 1.1" sensors and 20 MP, with distortion held under 0.3%.

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

On the camera side, area scan cameras around 20 MP with a C-mount are the natural fit for this job. The MV-CS200-10GC is one such: a 20 MP camera with a 1" sensor and a C-mount. A rolling shutter is fine for a part resting in a nest; on a moving conveyor, filter the camera finder for a global shutter instead.

Area scan camerasHikrobot MV-CS200-10GC 20 MP Area Scan Camera, GigE, IMX183, Color, BasicMV-CS200-10GC
Sensor format
1"
Lens mount
C-mount
Interface
GigE
Resolution
16-25 MP
$739.00View partBuild a system with it

Smart cameras run the same teach-and-match cycle on the device. Two onboard options: a C-mount model that takes the lens your field of view needs, and a fixed-lens unit for presence checks. The LS-SMC-0017 carries a 1" sensor, a C-mount and a global shutter, so it accepts exactly the lens arithmetic above. The MV-SC5060XM-08M-WBN integrates an 8 mm lens on a 6 MP sensor, a presence-check build with no lens decision left to make.

Smart cameras & vision sensorsSC / SC smart camera (X86 platform), 8.8 MP, USB3, Color/Mono, global shutter (LS-SMC-0017)LS-SMC-0017
Interface
USB 2.0
Resolution
6-10 MP
$1,359.00View part
Smart cameras & vision sensorsHikrobot MV-SC5060XM-08M-WBN SC5000X series Smart Camera, 6 MP, Mono, 8 mm focal length, M12-mountMV-SC5060XM-08M-WBN
Interface
GigE
Resolution
6-10 MP
$1,629.00View part

Pick a feature that cannot lie

  • Unique. Asymmetric in both axes, with no twin elsewhere on the part. Repeated shapes are how a rotated or mirrored false hit wins; the failure mode and its tolerance settings are covered in pattern match flips 180 degrees: fix false hits and tolerance settings.
  • Fixed to the datum. Molded, machined or engraved. A label applied anywhere within ±1.5 mm cannot locate the part better than ±1.5 mm, whatever the matcher scores.
  • Rich in edges, both axes. Corners and bores beat smooth curves, because they pin the fit in X and Y at once.
  • One-third to two-thirds of the view. Smaller loses discrimination; larger leaves no room for presentation tolerance.
  • Stable under your light. Matte beats glossy. The considerations in color pattern matching for reliable part localization apply to grayscale teaching too: a finish that changes appearance with lighting will drag the score with it.

The print is a bootstrap, not the finished template. Its job is to give the matcher a clean first learn of the feature alone, on a background you control.

  • Print at 100% scale. Turn off "fit to page" and every printer scaling option.
  • Measure the print with calipers and hold the error under 1%: ±0.3 mm on a 30 mm logo.
  • Use matte stock. Gloss paper throws specular highlights the real part never shows.
  • Match the background: print or mount the feature on stock the same color and finish as the production nest, because the template learns the background as part of the pattern.
  • Mount it flat in the nest, exactly where the real part will sit.

Teach and refine the template

  1. Fix the optics first. Set focus and aperture, then lock the iris and focus ring. Any later change to focus, aperture or working distance invalidates the template.
  2. Place the print in the nest, on the production background, lit exactly as production will be.
  3. Teach from four to six images of the print, nudged a few millimeters and a few degrees between shots, so the template learns the feature rather than one static background.
  4. Bound the search region to where the feature can appear: the ±3 mm nest tolerance plus margin.
  5. Swap in the real part and run the refinement pass. The matcher re-learns contrast and edges on the real surface; a stand-in-taught template refined this way lands in the mid-to-high 90s, with about 97% a representative score.
  6. Set the accept threshold roughly ten points below the score you observe on known-good parts.
  7. Freeze and back up the job. Re-teach only after a lighting, lens or fixture change.

Verify score and scatter before it steers anything

Score first: known-good parts should repeat within about a point of each other. If healthy parts scatter more than two or three points, fix the print, the focus or the background before touching the threshold.

Then scatter, the number that matters. Have the robot or nest present the part 20 times, log the returned feature coordinates, and compute the standard deviation. Keep it under one-tenth of the tolerance band: against ±0.1 mm, a 0.2 mm band, that is σ ≤ 0.02 mm, or 2 pixels at the 10 µm object pixel. Run the test with the cell guarding in place and the part presented by fixture or robot, never by hand into a live work volume.

Distortion and calibration close it out. Undistort or hold the feature central, remembering the 0.16 mm corner figure above, and leave field-of-view margin for your calibration target the way calibration target field of view and lens coverage margins lays out. Converting feature coordinates to robot frame then follows the standard hand-eye chain in robot vision for locating part center points; the wider integration order is in building a robot vision system for object location and gripping.

What a scale error actually costs

Teach a logo printed 10% oversize, 33 mm instead of 30 mm, and the rim of the real feature sits 1.5 mm from where the template expects it: about 150 pixels at a 10 µm object pixel. The correlation peak survives, which is the mid-90s score, but it flattens, and the reported position can jump several pixels between identical presentations.

Price that wander against the view. At 10 µm per pixel, 3 pixels is 30 µm, a third of the ±0.1 mm budget, spent before calibration and presentation spend theirs. On a coarser whole-part view of 47 µm per pixel, 3 pixels is 0.14 mm and the tolerance is gone. The finer the view, the more forgiving a mismatch becomes; no view makes it free.

What the match does Maximum scale error Reason
Guides a tool 1% position wander must stay under a tenth of the tolerance
Presence or assembly check 10% score only, position unused
Tells variants apart exact, one template each the score gap is the signal

When one feature is the wrong answer

  • The feature is looser than the part tolerance. A logo silkscreened anywhere within ±1.5 mm locates the logo, not the housing datum. Locate a machined datum feature instead, or measure the logo-to-datum offset on a sample and correct for it.
  • The feature repeats. Bolt circles and vent grids breed false hits; pick the asymmetric neighbor.
  • Variants differ in size. Teach one template per variant at exact scale. One stretched template across a 10% family puts every part in detection-only territory.
  • The whole part fits after all. If the pixel budget passes with the full part in view, teach the part and keep the system simple.
  • The part never stands still. A moving part on a rolling shutter smears the feature; choose a global shutter with strobed light. For a continuous web the framing question itself changes, and line scan camera field of view: how to calculate it is the right starting point.

Checks before you commit

  • Field of view covers the feature, the presentation tolerance and the tool approach, with the feature spanning one-third to two-thirds of the frame.
  • Lens image circle at least the sensor diagonal; distortion calibrated or the feature held central.
  • Object pixel no larger than one-tenth of the tolerance.
  • Print measured with calipers, error under 1% for any guidance use.
  • Refinement pass run on the real part; accept threshold ten points under the observed score.
  • 20-run repeatability at σ under one-tenth of the tolerance band.
  • Global shutter or strobe if the part moves.

When the numbers are settled, the system configurator walks the camera, lens and light in one pass, and if the housing still dwarfs every option, send the numbers to the applications team through the contact page.

Build the whole station

The configurator matches a camera, lens, light, light controller and cables to each other, step by step, and lists only parts that fit what you already picked.

Start with the camera

Questions

How far off scale can the printed feature be and still match?

Most normalized-correlation matchers still lock on when the taught feature is about 10% off true scale, typically scoring in the mid-90s, and scores collapse quickly beyond that. Treat 10% purely as a detection limit for presence checks. When the located feature steers a robot or a dispense path, print at 100% and hold the error under 1%, which is 0.3 mm on a 30 mm feature, then run the refinement pass on the real part.

Why teach from a print instead of the real part?

Because the real part will not fit the view. At the magnification your tolerance demands, the camera sees a 50 mm window, not a 260 mm housing, and the matcher cannot build a template from an object that overflows the background. The print puts the feature alone on a controllable background so the first learn is clean. The real part still gets the last word: the refinement pass re-learns true contrast and edge sharpness on the actual surface.

What match score should I set as the accept threshold?

After refining on the real part, a well-taught feature scores in the mid-to-high 90s and should repeat within about a point. Set the accept threshold roughly ten points below what known-good parts actually score, around 85% when healthy parts read 95%, so lighting drift and surface variation do not scrap good parts. If healthy parts score below 90%, fix the print scale, focus or background before lowering the threshold further.

How large should the feature be inside the field of view?

Aim for the feature to span a third to two-thirds of the longer side of the view. Below about a quarter, the score loses discrimination and false hits on similar texture multiply; above about three-quarters, presentation tolerance and tool approach eat your margin. Work backwards from the numbers: a 30 mm feature presented to ±3 mm wants a field of roughly 45 to 55 mm, which is what the worked example uses.

Can one template cover several part variants?

Only when the variants share the taught feature at the same scale and the same position tolerance. If housings differ by 5 to 15% in size, teach one template per variant at exact scale and let the job select it, or use the score gap to classify the variant. Stretching a single template across a 10% family pushes every part into detection-only territory, which is the wrong regime for anything that guides a tool.

Does the printed background have to match production?

Yes. The template learns the background as part of the pattern, so a stand-in shot on white card while production runs on anodized blue loses score on the first real part. Print or mount the feature on stock the same color and finish as the production nest background, keep the paper matte to avoid specular highlights the real part never shows, and still run the refinement pass on the real part before trusting the score.