ApplicationsHow-to

Variable part diameter in camera locate: one calibrated model

Teach one camera locate, drive the part diameter from a variable: calibrate mm per pixel, convert, size the search region, and see when one model fails.

LumaSpec Vision11 min read Share on LinkedIn

On this page 9 sections
  1. 01Why does one camera locate per diameter fail?
  2. 02How do you locate every diameter with one teach?
  3. 03How do you convert a diameter in millimetres to pixels?
  4. 04How do you calibrate the millimetre-to-pixel scale?
  5. 05How does the operator set the diameter for each run?
  6. 06How large must the field of view and search region be?
  7. 07When does one calibrated model still fail?
  8. 08Which camera runs a variable-diameter locate?
  9. 09Questions

Families of rings, washers, spacers and bushings arrive with dozens of diameters sharing one fixture. The reflex of teaching one camera locate per size scales badly: every teach adds a model and program branches, and by around ninety sizes the pendant program runs long enough to slow down or crash. The better design is one calibrated circle model whose expected diameter arrives from a variable. This guide gives the millimetre-to-pixel arithmetic (a 40 mm ring is 533 px at 0.075 mm/px), the one-time scale calibration, the operator-entry workflow, the search-region sizing and the limits of a single model. You finish able to replace a folder of teaches with one locate and one number.

Why does one camera locate per diameter fail?

A program that holds one camera locate per size grows linearly with the size list, and by 93 teaches the pendant program is so long it can fail to run at all; every new diameter also costs a fixture session.

Each teach stores a full copy of the same geometry. The 40 mm and 41 mm circle models differ only in expected size, yet the program loads, evaluates and maintains both. Program length climbs with every new size, a diameter correction means hunting the right teach among ninety, and teach sessions multiply as the family grows.

The fix is to separate the model from the size. Edge polarity, circularity tolerance and contrast thresholds get taught once; the expected diameter becomes run-time data. Our article on vision locate with changing part sizes handles the case where the batch changes; this one handles sizes that change part to part.

How do you locate every diameter with one teach?

Teach the circle model once on a mid-range part, then write its expected-diameter parameter from a variable every cycle: 533 px for the 40 mm ring, 800 px for the 60 mm ring, computed the same way for any size in between.

A geometric circle finder matches edges against an expected radius, then fits a circle to the edge points it finds. The expected diameter does two jobs: it narrows the edge search, and it separates a ring's outer edge from its bore edge. Everything else in the model — polarity, circularity, contrast — is common to the family, and that common part is what one teach carries.

The locate step must accept the expected diameter as a settable per-run value. Smart cameras and controller-based vision expose it as a step parameter your program writes before the trigger. Where a teach interface bakes the size into the model, no variable reaches it; the fix is to run that locate on a platform that takes it per run — see the smart cameras and vision controllers ranges.

This differs from parametric teach, where the software rebuilds the model from parameters at teach time (Parametric teach for geometric parts). Here the model never changes and only the number written into it does, so a new size costs no teach session.

How do you convert a diameter in millimetres to pixels?

Divide the diameter by the calibrated scale in millimetres per pixel: at 120 mm of field of view across a 1600 px image the scale is 120/1600 = 0.075 mm/px, so a 40 mm ring is 40/0.075 = 533 px across.

scale = field of view width (mm) / image width (px) expected diameter (px) = part diameter (mm) / scale

Round the value before you write it, and compare sizes through the same scale: the 0.5 mm step from a 40.0 mm to a 40.5 mm ring is 0.5/0.075 = 6.7 px, which a 0.075 mm/px camera sorts without trouble. With clean edge contrast a circle fit repeats to roughly 0.1-0.3 px — 0.008-0.023 mm on this scale — and placement, height and lighting add the rest. This is the same pixels-to-millimetres path as sorting coins by size from one camera, driven in reverse: millimetres in, expected pixels out.

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.

How do you calibrate the millimetre-to-pixel scale?

Fix the camera, square it to the part plane, set one ring of known diameter at part height, and divide known millimetres by measured pixels: a 60 mm master ring reading 800 px sets the scale at 60/800 = 0.075 mm/px.

Average three readings of the master ring, then cross-check against the geometry: 1600 px × 0.075 mm/px = 120 mm of field of view, which a ruler across the image at part height confirms. The scale moves with working distance — how camera field of view changes with working distance gives the relationship, and the working distance and field of view formula works it through for an inspection cell. A checkerboard or concentric-circle calibration plate returns the same scale plus lens distortion, worth doing below about 0.05 mm/px or with short wide-angle lenses.

Keep the camera perpendicular. Tilt turns the circle into an ellipse and gives the x and y axes different scales, so the fit reports a diameter that drifts with part rotation. Calibrate at the height the parts actually occupy: teaching pattern matching at final part height shows what happens when the teach height and the run height disagree.

How does the operator set the diameter for each run?

The program reads one numeric variable before each cycle, converts it to pixels, writes the result into the locate step's expected-diameter input, and only then triggers the camera: the operator enters 40 and the program runs the locate at 40/0.075 = 533 px.

You need a fixed camera, one master ring of known diameter, and a variable the operator can reach. The sequence:

  1. Mount the camera at a fixed working distance and square it to the fixture.
  2. Calibrate the scale with the master ring as above.
  3. Teach the circle model once on a mid-range part; set edge polarity to the outer edge and a circularity tolerance that covers the family.
  4. Create a numeric variable, part_diameter_mm, and clamp it in the program to the taught range, 40.0 to 60.0 here.
  5. Before each trigger, compute expected_diameter_px = part_diameter_mm / 0.075 and write it to the locate step's expected-diameter input.
  6. Size the search region around the expected position from the largest part, as the next section works out.
  7. Accept the locate only above the score threshold tuned on good parts, and log the diameter and score every cycle; logging the detection score variable keeps the robot side honest.
  8. On a new size, enter the number and run — no teach, no program edit.

The variable can come from the pendant screen, an HMI field or a scanned job code; keep one source of truth so the paperwork and the program agree.

How large must the field of view and search region be?

Keep the largest diameter plus its placement spread inside about 70% of the field of view, and size the search region as expected diameter + spread + margin: 800 + 134 + 40 = 974 px for the 60 mm ring at ±5 mm placement on the 1600 px sensor.

The pieces: 60 mm at 0.075 mm/px is an 800 px diameter; ±5 mm of placement spread is ±5/0.075 = ±67 px; 20 px of margin each side. Sum: 800 + 134 + 40 = 974 px of search width, round to 1000 px, and the largest ring spans half of the 1600 px width against the 70% budget, so the whole family fits one field of view.

Resolution also needs the wall, not just the outline. A 2 mm wall is 2/0.075 = 27 px wide, well above the 3 px a stable edge wants, and even the smallest ring spans 533 px — thousands of edge points for the fit. To check a different family, the camera resolution calculator turns your smallest feature and tolerance into the pixel count you need.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

When does one calibrated model still fail?

One model holds while every part stays circular, flat and inside the field of view: a ±2.5 mm height swing at a 250 mm working distance moves the scale 1%, which is ±5 px on a 533 px ring and about ±0.4 mm of apparent diameter.

  • Height variation. 2.5 mm at 250 mm is a 1% scale error — 5 px and 0.4 mm on this ring. Fixture the part height, or keep one scale per height step.
  • Tilt. 5° of tilt shortens one axis by 1 − cos 5° ≈ 0.4%, about 2 px here. The fit still converges but the centre biases; square the camera, or calibrate in the pose the parts always take.
  • Broken edges. Keyways, etch or chamfers interrupt the outer edge. Keep the expected diameter — it stops the fit wandering to the bore — and skip the angular samples over the broken sector.
  • Family outgrows the frame. Largest diameter plus spread must stay inside the 70% budget; past it, add a second position or a wider field of view and recalibrate.
  • Geometry changes with size. When wall widths or features change with diameter, scale is no longer the only variable: split the family by geometry class. The vision locate feasibility checklist is the screen to run before teaching anything.

Which camera runs a variable-diameter locate?

Any vision platform whose circle-find step accepts the expected diameter as a per-run value does this: a vision sensor for one fixed position, a smart camera for onboard logic, or a camera plus vision controller when several cameras and light channels share one cycle.

Setup Fits when Watch for
Vision sensor, fixed M12 lens One fixture, one locate, tight cell The fixed lens sets the working distance
Smart camera on GigE Small bores, several rings per frame Rolling shutter needs a settled part
X86 smart camera, C-mount Your own code writes the parameter You own the calibration code
Camera + vision controller Several cameras, lights, robot handshake One scale table per camera and height

For a single fixture and a single locate, a compact vision sensor is the shortest path: fixed M12-mount lens, global shutter, Fast Ethernet, with manual focus set once at the working distance on the color model.

Smart cameras & vision sensorsHikrobot MV-SCB007EC-12S-WBN SCB vision sensor, 1.6 MP, Color, 12 mm lens, Manual focusMV-SCB007EC-12S-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
$1,989.00 · quotedView and quote
Smart cameras & vision sensorsHikrobot HK-TD032-12-WBN 1.6 MP mono vision sensorHK-TD032-12-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
$1,699.00View part

When the bore needs more pixels, the MV-SC5060XM-08M-WBN is a 6 MP mono smart camera with an 8 mm M12-mount lens on GigE. Its rolling shutter wants the part settled before the trigger.

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
Sensor format
1/2.4"
Shutter
Rolling
$1,629.00View part

Where your own program should own the conversion, the LS-SMC-0017 is an 8.8 MP smart camera on an X86 platform with a C-mount: read the variable, divide by the scale, write the model, run the fit. The bookkeeping is the same as mapping image axes to world units, which imagesc axis coordinates walks through.

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
Sensor format
1"
Shutter
Global
$1,359.00View part

Multi-camera cells put the locate logic where the lights and the robot handshake live. The MV-VC3301H-128G66 vision controller has 4 built-in light channels, an Intel Core i3 processor and 8 GB of memory, with the VM6200Pro license included.

Vision controllersHikrobot MV-VC3301H-128G66 I3-8100, 8GB+128G SSD, No PoE, PCIe expansion supported, Incl. VM6200Pro licenseMV-VC3301H-128G66
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
Light outputs
4 built-in channels
Memory
8 GB
$2,419.00View partBuild a system with it

Pick the platform around the family and the cycle, then size camera, lens and light together: the configurator filters parts to your working distance and field of view, and the camera finder lists by resolution, shutter and mount. More worked locate setups sit in the applications topic.

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 light controller

Questions

How repeatable is a circle locate driven from a variable?

The fit itself repeats to about 0.1-0.3 px under clean contrast, which is 0.008-0.023 mm at 0.075 mm/px. A full cell adds placement spread, height change and lighting, so budget ±0.05-0.2 mm of centre repeatability for a fixed camera, then confirm on 30 good parts before promising a tighter figure.

Can the diameter be changed while the program is running?

Yes, when the locate step reads its expected-diameter input at run time rather than only at teach time: write the converted pixel value before each cycle's trigger. If a tool bakes the diameter into the teach, no variable reaches it, and that locate belongs on a platform that takes the value per run.

Does changing the light require recalibrating the scale?

No. The scale comes from the working distance and the sensor, not from brightness. A large exposure change can move the edge threshold by a fraction of a pixel and shift the score, so run the master ring after any lighting change and confirm the reported diameter sits within about 1 px of nominal.

How wide a diameter range does one calibrated model survive?

While the parts keep the same edge character and the largest size fits the field of view with its placement spread. The worked family spans 40-60 mm, a 1.5:1 range, both ends above 500 px across. Past roughly 2:1 the small end loses contrast or the large end loses margin — split the family in two at that point.

How do you check the conversion before production?

Run two known sizes through the full program path: variable in, locate out, diameter reported. Each should land within about 1 px of its known value, which is ±0.075 mm on this scale. If one size passes and the next is off by several pixels, the camera moved or tilted: re-square the mount and recalibrate the scale.

Does the same method work for bores and holes?

Yes. Reverse the edge polarity so the finder locks the inner edge and enter the bore diameter; the same scale conversion applies. One image of a ring can carry two finds — the 40 mm outer diameter at 533 px and a 24 mm bore at 24/0.075 = 320 px — as long as both edges sit inside their search regions.