System designExplainer

Scale compensation for part height variation in vision picking

Teach at one documented height, rescale the match by the height ratio, and compute the pick error a height swing causes before it reaches the robot.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 01Why part height rescales the whole image
  2. 02The correction: one ratio applied to everything
  3. 03Worked example: a part 15 mm taller at a 300 mm stand-off
  4. 04Where the run-time height value comes from
  5. 05How much variation your pick tolerance absorbs
  6. 06Focus moves with the part too
  7. 07When a ratio is not the fix
  8. 08Set-up checks before the next changeover
  9. 09The decision, and where to start
  10. 10Questions

A pattern model taught at one height returns oversize features and outward-drifted pick points when the next run's parts sit higher or lower on the line. The fix is one ratio: teach at a documented reference height, read the run's actual height from the line controller, and divide every size and position the matcher reports by the magnification ratio. This page shows where the error comes from, the arithmetic that sizes it, a worked example at a 300 mm stand-off, and the limits the ratio cannot fix — focus first among them. It is written for anyone wiring an external height input into a 2D vision-guided picking cell.

Why part height rescales the whole image

Every coordinate the camera returns starts life in pixels, and pixels become millimetres through one number: the object-space pixel scale. That scale comes from magnification, and magnification comes from working distance. A lens images an object of true width L to L × m on the sensor, with m = f / (WD − f). Raise the part top by Δh and the working distance falls to WD − Δh, so m grows and every feature in the image grows with it. In a single top-down 2D image, a taller part is indistinguishable from a bigger part: size and height trade one for the other.

The same factor moves positions. A feature D mm off the image axis is projected outward by m, so its reported offset scales by exactly the factor its size scales by. Height variation therefore shows up twice: features read oversize, and pick points drift toward the image edges. The geometry is the same working distance and field of view formula you use to size a lens, and the object-space pixel size page turns m into the mm-per-pixel figure your calibration stores.

The correction: one ratio applied to everything

Teach the model with the part at a documented reference height and record three numbers with the job: the teach working distance WD_teach, the focal length f, and the pixel scale your calibration produced. At run time a height source — the line controller's recipe, a sensor over the line, or a measured master value — supplies the actual part height, and the vision side computes:

m_teach = f / (WD_teach - f) m_run = f / (WD_run - f) k = m_run / m_teach = (WD_teach - f) / (WD_run - f) size and position corrected = measured / k

When f is small next to the working distance this collapses to the quick rule k ≈ WD_teach / WD_run. Keep the exact form whenever f exceeds about 5% of the working distance: in the worked example below, a 35 mm lens at a 300 mm stand-off is 12% of WD, and the quick rule would report +5.3% where the true shift is +6.0%. A part higher than the teach height gives k > 1, so sizes read large and offsets read wide; a part lower gives k < 1. One division, applied to every match result, closes both.

Worked example: a part 15 mm taller at a 300 mm stand-off

Take a 2/3" camera with 2448 × 2048 pixels — about 3.6 µm pixels, from the 8.8 mm nominal sensor width divided by 2448 — fitted with a 35 mm lens and mounted so the working distance at the teach height is 300 mm. The calibration at teach and the taller run then give:

  • m_teach = 35 / (300 − 35) = 0.132, field of view = 8.8 / 0.132 = 66.6 mm, scale = 66.6 / 2448 = 0.0272 mm per pixel
  • WD_run = 285 mm, so m_run = 35 / (285 − 35) = 0.140 and the scale becomes 0.0257 mm per pixel
  • k = 0.140 / 0.132 = 1.06: everything images about 6.0% larger than at teach
  • a Ø20 mm bore spans 20 / 0.0257 = 778 pixels, read back at the teach scale as 778 × 0.0272 = 21.2 mm — oversize by 1.2 mm
  • a feature 60 mm off the image axis reads 60 × 1.06 = 63.6 mm — a 3.6 mm pick error before correction
  • dividing sizes and offsets by k returns the bore to 20.0 mm and the offset to 60.0 mm; what remains is lens distortion and calibration scatter, typically a few tenths of a millimetre at this scale
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 example lens is a 35 mm, 6 MP model for 2/3" sensors:

Machine vision lenses35 mm, 2/3", 6 MP, C-mount machine vision lens (LS-FFL-0679)LS-FFL-0679
Type
Machine vision fixed
Sensor format
2/3"
Mount
C-mount
Resolution
6-10 MP
$219.00View partBuild a system with it

Where the run-time height value comes from

Most reliable first: the line controller's recipe, the height measured on the master part at changeover and written once per run. Second: a height sensor over the line — a Class 2 laser rangefinder, safe for accidental eye exposure but never to be stared into, handles most surfaces — measuring each part and shipping the value with the trigger. Third: a stop-and-measure station ahead of the pick window. Vision packages that take the height from outside lock the height entry in the teach dialog when you select the external method; the locked field is the reference the runtime value is compared against, so the height you teach at is a number you measure and record, not one the software remembers for you.

Timing kills more cells than plumbing does. A height value left over from the previous part is worse than no compensation at all — the same failure mode as stale pick data on a moving conveyor. Cells that pick flat plate stock often take a different road entirely and keep Z out of the image, as in why plate picking handles Z outside the image.

How much variation your pick tolerance absorbs

Work backwards from the pick tolerance. The uncorrected position error is D_off × (k − 1) ≈ D_off × Δh / WD_teach, so the height swing you can safely ignore is:

Δh_max ≈ tol × WD_teach / D_off

With a ±1 mm tolerance, features reaching 80 mm off-axis and a 300 mm teach stand-off, Δh_max = 1 × 300 / 80 = 3.75 mm. Past that, compensate every run.

Teach at the mid-height of the expected range, never at one extreme. Parts sitting between 45 and 75 mm taught at 60 mm leave ±15 mm as the worst case; teaching at 45 mm leaves the full 30 mm on every run. The same discipline applies to hanging cameras, where the plane you teach is a documented reference rather than whatever the first part presents — see teaching the work plane to a hanging robot vision system. With a per-run k applied, the residual error follows the height sensor: ±1 mm of height error on a 300 mm stand-off is a 0.33% scale error, about 0.27 mm at 80 mm off-axis — an order of magnitude under the uncompensated 3.6 mm of the worked example.

Guidance needs far fewer pixels than inspection does, so a compact smart camera or a GigE area scan camera both close this loop. For finer scales, the two 12 MP, 1/1.7" rolling-shutter cameras below come in GigE and USB3 versions:

Area scan cameras12 MP GigE area scan camera, IMX226, 1/1.7" rolling shutter, 9 fps (LS-CMR-0053)LS-CMR-0053
Sensor format
1/1.7"
Lens mount
C-mount
$560.00View 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
$560.00View part

Focus moves with the part too

The ratio fixes scale, not focal plane: a part 15 mm closer to the lens is 15 mm out of focus if you focused at teach. Total depth of field at magnification m is approximately 2 × N × c × (1 + m) / m², with N the f-number and c the blur you accept — take c as two pixels, 0.0072 mm here. At m = 0.132:

  • f/4: 2 × 4 × 0.0072 × 1.132 / 0.0174 = 3.7 mm total, ±1.9 mm
  • f/8: 7.5 mm total, ±3.7 mm
  • f/11: 10.3 mm total, ±5.1 mm — with the Airy disc already about four pixels across on 3.6 µm pixels, so edges soften

A ±15 mm range cannot be absorbed by aperture alone at this magnification. Either drive a motorized-focus lens from the height value each run, or hold the range inside about ±3.7 mm and run at f/8 — which costs two stops over f/4, so budget four times the exposure or more light from the line and bar lights over the belt.

Depth of field and diffraction
Units
Depth of field
– mm
About the focus plane
– mm
Diffraction limit
– F/#
Blur limit
– µm
Diffraction spot
– µm
At this F-number
–

DOF ≈ 2 × N × c × (1 + m) / m², c = allowed blur × pixel size. Diffraction spot (Airy disk) ≈ 2.44 × wavelength × N × (1 + m); past the diffraction limit it is larger than the blur you allowed.

Browse lenses by aperture and format Open the full calculator

When a ratio is not the fix

Three cases break the single-ratio approach. Height changing part to part inside one run: a single k is wrong for every part that differs from the recipe, so ship the height with each trigger or restrict the method to stable runs. Tilt: a leaning part changes the working distance across its own footprint, and one factor cannot correct a gradient — fix the presentation or move to a 3D sensor. Z-critical picks: the ratio repairs XY and size only; the top-surface Z still travels to the robot over its own path, the way tool TCP configuration absorbs Z at the gripper.

Telecentric lenses change the trade instead of the arithmetic. A fixed-magnification lens such as the LS-TCL-0574 holds 0.4x at a 227 mm working distance on a 1.2" sensor, so apparent size stops tracking height while the part top stays inside the telecentric depth printed on its data sheet — match that depth to your height range and the correction disappears.

Set-up checks before the next changeover

  1. Measure and record the teach height, WD_teach and f with the job file.
  2. Calibrate the scale with a target sitting on a part at the teach height, not on the bare belt; one reference target is enough for the recheck.
  3. Verify the direction of k: lift a test part 10 mm above the teach height and confirm sizes grow by (300 − 35) / (290 − 35) − 1 = 3.9%.
  4. Confirm the height value refreshes with every part, or every run, before the trigger — not after it.
  5. Check focus at both height extremes at the running f-number.
  6. Re-derive the tolerance budget whenever the part, gripper or stand-off changes.

The decision, and where to start

Teach at the mid-height of the range, take the run height from the controller, divide every size and offset by k = (WD_teach − f) / (WD_run − f), and add a per-run refocus once the swing exceeds the depth of field at your f-number. On the worked geometry that decision turns a 3.6 mm pick error into a few tenths of a millimetre. Size the camera and lens pair in the camera configurator or the machine vision lens finder, browse the systems guides for the matching calibration and timing pages, and bring unusual height data to the contact page before ordering hardware.

Questions

At what height should I teach the model?

At the mid-height of the range you expect across runs. If part tops sit between 45 and 75 mm and the camera stands 360 mm above the belt, teaching at 60 mm puts the working distance at 300 mm for the midpoint, so no run deviates more than ±15 mm. Teaching at 45 mm instead leaves a 30 mm worst case and every run carries an error. Record the teach height in the job file.

How large a height swing can I leave uncompensated?

Work backwards from the pick tolerance: Δh_max ≈ tol × WD_teach / D_off. With a ±1 mm tolerance, a 300 mm working distance and features reaching 80 mm off-axis, an uncompensated swing past ±3.75 mm already costs a full millimetre at the edge. Apply compensation whenever the expected range exceeds a third of that limit, and re-derive the number whenever the part or gripper changes.

Does a telecentric lens remove the need for height compensation?

Only inside its telecentric depth. A fixed-magnification lens such as the LS-TCL-0574 holds 0.4x at its 227 mm working distance on a 1.2" sensor, so apparent size stops changing while the part top stays within that depth. Outside it, magnification drifts like any ordinary lens. Match the printed telecentric depth to your full height range before you commit.

Where should the runtime height value come from?

From the line controller: the recipe height measured on the master part at changeover and written once per run, or a height sensor over the line that measures each part and sends the value with the trigger. The vision side computes the ratio from it. When the height source is external, the teach dialog locks its height field — the value you taught with is the reference, so write it down.

Does the height correction also fix focus?

No. The ratio corrects scale only; focus error equals the height error. At the worked example's magnification a 35 mm lens holds about ±1.9 mm of focus at f/4, ±3.7 mm at f/8 and ±5.1 mm at f/11, so a ±15 mm range needs a motorized-focus lens driven from the height value, a tighter height specification, or more light to afford the smaller aperture.