A caliper tool — a narrow measure rectangle swept across the part — is how most vision libraries measure connector pin pitch, pin width and row position. The frustration is familiar: Length1 is longer than Length2, Sigma and Threshold look sensible, and the tool still returns no edges, or the wrong ones, on some pins. The cause is almost never the rectangle's size. It is the rectangle's angle Phi, the smoothing Sigma, the Threshold against the gray step your lighting actually produced, or the rectangle sitting on the wrong spot because nothing located the part first. Below are the numbers for all four, a worked camera calculation, and the repeatability test that tells you when a 0.1-pixel claim is believable.
Why does a hand-drawn rectangle with Length1 > Length2 still miss the edges?
Because Length1 and Length2 only set the rectangle's shape — the tool looks for a gray transition along the main axis defined by Phi, so a rectangle whose long axis runs parallel to the pin edge never crosses a transition and returns an empty result.
gen_measure_rectangle2(Row, Column, Phi, Length1, Length2, Width, Height, Interpolation) builds the measurement handle; measure_pos or measure_pairs then samples gray-value profiles along that main axis, spread across the strip width Length2, and reports an edge wherever the smoothed profile steps by more than Threshold. Rectangle length wins nothing here. Direction and gray step win everything.
Ranked by how often each explains a missing pin edge:
- Phi points the main axis along the edge instead of across it.
- Threshold sits above the smoothed gradient peak on that edge.
- Sigma is wide enough that the peak has fallen below Threshold.
- The rectangle sits on molding because the part drifted and no locate ran.
Test: cursor-read the raw gray profile along the main axis. No step means Phi or position; a step smaller than Threshold means sigma and threshold, covered next.
How do you set Phi, Length1 and Length2 on a pin row?
Build the rectangle from a fitted line, not from your eye: read the line's centre, angle and length, then set Phi to that angle, Length1 to half the row span plus about 10 pixels of margin, and Length2 to a 3-5 pixel strip across each edge.
- Locate the part with a pattern match and hang the measurement coordinates on the located pose. Placement drift of a few pixels puts a fixed rectangle on the molding, which reads as random failure.
- Rough pass: one rectangle with Length1 spanning the whole row and a low Threshold returns first edge points on every pin.
- Fit a line to those points; some libraries combine fit and measure in one metrology object (add_metrology_object_line_measure is the pattern to look for).
- Final rectangle: Row and Column from the fitted centre, Phi from the fitted angle, Length1 = row span / 2 + 10 pixels, Length2 = 3-5 pixels, Interpolation bilinear.
- Re-run at the working Sigma and Threshold.
What sigma matches the blur on your edges?
Read the 10-90% gray transition width off a raw profile and set Sigma to about transition / 2.6: a crisp 3-pixel edge gives sigma 1-1.2, a blurred 6-pixel edge needs sigma 2.3, and each doubling of sigma halves the gradient peak your threshold must catch.
Sigma should match the blur the optics already put on the edge. Smooth wider than the transition and the gradient peak — the exact number Threshold compares — drops without buying anything; narrower, and noise survives into the peak. Measure the 10-90% width once per station with the cursor. Defocus, vibration and motion all widen it: motion blur alone can stretch a 3-pixel edge to 6-10 pixels, and no filter repairs that (the motion blur guide covers the optics).
A 120-gray-level step then peaks near 48 at σ 1, 24 at σ 2 and 16 at σ 3 — same part, same light, three different usable thresholds. The 0.4 is 1/√(2π), exact for an ideal step.
How high should the edge threshold be?
Set Threshold at about one third of the smoothed peak: the 120-gray-level step between a white pin and dark molding peaks near 48 at sigma 1, so a threshold of 15-16 clears it with margin, while a copied default of 30 survives only while nothing else degrades.
Threshold must clear the pixel noise floor, typically 2-5 gray levels at normal exposure, and stay below the peak. Cursor-measure Δgray on each edge type on a real part: pin-to-molding, pin-to-body and pin-to-background are three different steps on one connector.
| Edge | Gray step Δgray | Sigma | Peak | Threshold |
|---|---|---|---|---|
| White pin to dark molding | 120 | 1 | 48 | 15-16 |
| Same edge at sigma 2 | 120 | 2 | 24 | 8 |
| Shaded pin to body wall | 40 | 1 | 16 | 5-6 |
Why does lighting decide whether an edge is measurable at all?
Every number above multiplies contrast you create with the light: a bar light laid along the pin row at a grazing angle holds the pin-to-molding step above 100 gray levels, while flat overhead light on glossy plastic can shrink the same edge below 30 and no threshold saves it.
Lay the bar light parallel to the row and tilt it so light rakes across the pins: bright tops, dark gaps, maximum slope at every side wall. Polarize if the housing is glossy, because glare fills the dark gaps and eats the step (the cross-polarization guide shows before-and-after images). Backlight the outer profile through a glass plate. Strobe the bar during exposure so line speed and ambient light cannot move your gray levels between shifts (the ambient light variation guide explains that drift).
The bar lights category runs from under 50 mm to over 400 mm long. The LS-BAR-1047 is a 290 x 30 mm, 24 V standard bar light.
- Size
- 200-400 mm
- Type
- Standard
- Voltage
- 24 V
Where a separate lamp will not fit the fixture, the LS-SMC-0063 is a 1.6 MP GigE smart camera with a 16 mm lens, integrated polarized white light and 60 fps.
- Interface
- GigE
- Resolution
- Up to 3 MP
Which camera, lens and pixel size do you need for pin pitch?
Work backwards from tolerance: 9.8 µm per pixel from a 6 MP, 3072 × 2048 camera over a 30 mm field repeats edges to about 4 µm, so a 2.00 mm pitch spans 204 pixels and a ±0.05 mm tolerance keeps more than a 10× margin.
Worked example — 15 pins on a 2.00 mm pitch, row about 28 mm, tolerance ±0.05 mm, target field 30 mm:
- Sensor: 2/3-inch, 8.8 mm wide, 3072 × 2048 pixels.
- Working distance: 30 × 35 / 8.8 = 119.3 mm with a 35 mm lens, so set WD near 120 mm.
- Scale: 30 / 3072 = 0.0098 mm per pixel.
- Pitch: 2.00 / 0.0098 = 204 pixels per pitch.
- Budget: 0.4 pixel × 9.8 µm ≈ 4 µm repeatability, against a 5 µm allowance at 10% of tolerance. Pass — go finer if you want 3× headroom.
The camera resolution pixel rule sizes pixels from the smallest feature; the pixel-width ranging guide runs the same division backwards to read distance. Shoot mono — color interpolation softens the exact slope you threshold. The smart cameras and machine vision lenses categories filter by resolution, shutter, mount and image circle; the camera finder narrows it further.
For a parked part, the MV-SC5060XM-08M-WBN is a 6 MP mono smart camera, GigE interface, 1/2.4" sensor, 8 mm M12-mount lens, rolling shutter — fine once the part stops under the camera.
- Interface
- GigE
- Resolution
- 6-10 MP
- Sensor format
- 1/2.4"
- Shutter
- Rolling
On a C-mount camera, the LS-FFL-0679 is a 35 mm, 2/3", 6 MP, C-mount machine vision lens — the 35 mm class of the worked example.
- Type
- Machine vision fixed
- Sensor format
- 2/3"
- Mount
- C-mount
- Resolution
- 6-10 MP
How do you verify subpixel accuracy before you trust it?
Log 30 static frames and require a 3-sigma edge spread under 0.5 pixels, then move the part a known 1.00 mm on a stage and require the reading back within ±0.01 mm — at 9.8 µm per pixel that is 5 µm and about one pixel.
Run the three checks in order. Static repeatability: same part, 30 grabs, nothing moves — the spread is tool noise plus vibration. Relocation: ten parts through, including the worst placement you allow; the spread now includes locate error, which is why the pattern-match step earns its keep. Scale: image a known pitch or a glass scale — 20.00 mm across 2,040 pixels gives 0.0098 mm per pixel — and repeat at the field corners; keep measurement lines inside the central 60% of the field or calibrate the full distortion model.
A physical cross-check transfers straight from dimensional metrology: confirm the vision number on a feature whose size you already trust, the way a machined slot is verified with CMM and pin gauges. The subpixel cutting-tool guide runs the same profile math at a much tighter tolerance.
When is one top-down view the wrong tool?
A top-down caliper measures pitch, width and in-plane position; it cannot see height, so coplanarity — whether the pin bottoms lie on one line — needs a side-on camera or a 3D profiler, while simple presence checks run faster as thresholded blobs than as subpixel edges.
For coplanarity, add a side view: camera looking along the pin row, macro or telecentric optics, bar light raking from above so each tip reads as a bright point on dark molding. Measure every tip's height coordinate and fit a line — the same Phi, Sigma and Threshold rules, applied down the row's height instead of across its width. For rough pitch or presence checks, threshold the bright pins, filter blobs by area with select_shape-style rules, sort by column and take centres: far faster to configure, but binarized to roughly half a pixel and biased by the threshold. Caliper for numbers, blobs for yes-or-no, side view or 3D for height — choose by the dimension that carries the tolerance.
Start with the light, because every threshold number above is contrast the light made. Sketch the layout in the lights finder, work through the light and camera configurator with your field of view and working distance, and send part photos and tolerances through the contact page if you want the layout checked before you order.
Questions
Can one measure_pairs call return every pin pitch at once?
Yes. Build one rectangle whose main axis crosses the whole pin row: measure_pairs returns both edges of each pin, IntraDistance for pin width and InterDistance for pitch, all in pixels. Divide by your calibrated millimetres per pixel. Evenly spaced rows suit this best; for irregular groups, run one rectangle per group.
Does a 3 x 3 mean filter before the measure hurt accuracy?
It trades noise for blur. A 3 x 3 box adds about 0.8 pixels of Gaussian-equivalent blur, so total sigma becomes √(σ² + 0.8²) — sigma 1 turns into about 1.3 — and the gradient peak drops roughly 20%. Recompute the threshold from the new peak or drop the filter and add light instead.
Why do different connectors need different thresholds on one station?
Mold gloss, resin whiteness and regrind change the gray step from part to part: a step of 120 gray levels on one lot can read 70 on the next. Cursor-measure the step per part number, store Sigma and Threshold in each product recipe, and warn when a live amplitude falls below about twice the stored threshold — that also catches a fading LED bar.
Why do mid-row pin edges fail while the outer pins measure fine?
Usually the connector body wall shadows the grazing bar light, cutting the gray step at those edges below the threshold. Re-measure the step there; if it has fallen from 120 to 40 gray levels, add a second bar from the opposite side or raise exposure, then reset the threshold to about one third of the new peak.



