You run a cell that receives five cylinder diameters and must pick them in delivery order. The usual answer is five fixed-template locates chained in fallback order: try size one, on failure try size two, and so on. It works, but every part pays for the attempts before its own, and a sixth size means a new template and a new retry. Measure instead. One calibrated camera, one exposure, one diameter number, and the size class falls out of a threshold table. This guide works the error budget, the calibration that keeps it honest, a worked example from 40 to 80 mm, and the steps that hand a class number to the robot.
Measure once, classify five times
A fallback chain identifies a size by which template matched. Each failed attempt costs imaging and processing time, and a size-five part pays for four misses before it is found. Templates also lock a scale: your five cylinders differ precisely along the axis a fixed template is weakest on, as covered in cascade classifier rotation and scale limits for flat objects.
A measurement replaces all five matchers. Segment the part, fit its rim as a circle, convert the pixel diameter to millimetres with a calibrated scale, and compare against thresholds set midway between nominal sizes. The arithmetic behind any effort to measure an object's size from a camera image does the sorting in one pass:
A sixth diameter adds a row to the threshold table. No new template, no new retry chain, and the measured value goes to your log for traceability.
What the measurement must achieve
Two numbers decide everything: the gap between classes and the spread of your measurement.
- Let the five nominal diameters be spaced by a gap g, which is 10 mm in the example below. Class boundaries sit at midpoints: 45, 55, 65 and 75 mm.
- Hold six standard deviations of the measured diameter inside half the gap: 6σ ≤ g/2. For a 10 mm gap that is σ ≤ 0.83 mm. This is a generous budget on purpose; a fixtured station beats it by a wide margin.
Edge detection localizes a rim edge to about 0.3 px with even lighting, and a circle fit averaged over a thousand edge points lands well under 0.1 px of scatter. Pixel noise is never the limiter at millimetre gaps; geometry is, and the next two sections handle it. As a floor for image quality, keep at least 100 px across the smallest diameter. The reasoning is the same as in camera resolution for defect detection: size it by the pixel rule.
Choose the camera and lens
Size the field of view first: largest cylinder plus placement scatter plus margin. For an 80 mm part centered within ±25 mm, a 150 mm field leaves room for the fixture.
On pixels, the 100 px floor needs a scale of at most 40 mm / 100 px = 0.4 mm per pixel, so a 150 mm field needs only 375 px. Every camera in the camera finder clears that. A 4000-px-wide sensor at a 150 mm field works out to 150/4000 = 0.0375 mm per pixel, and the smallest cylinder then spans 40 / 0.0375 = 1067 px. The decision: sorting alone does not drive the camera choice. Buy pixels for the station's other duties.
For a station that will also read codes or inspect surfaces on the same image, an area scan camera behind a C-mount lens is the flexible choice.
- Sensor format
- 1/1.7"
- Interface
- USB3
- Sensor format
- 1"
- Lens mount
- C-mount
The LS-CMR-0166 is a 12 MP USB3 camera with a 4000 × 3000 grid. When you want the same field on a bigger sensor, the MV-CS200-10UM is a 20 MP camera with a 1-inch sensor and C-mount.
If sizing is the station's only job, run it on a smart camera: measurement, thresholds and the result all execute in the device and reach the robot over Ethernet.
- Interface
- GigE
- Resolution
- Up to 3 MP
The LS-SMC-0063 is a 1.6 MP smart camera with a 16 mm lens and white light. A 1.6 MP sensor lays about 1,400 px across a 150 mm field, roughly 0.1 mm per pixel, so a 40 mm cylinder still spans about 400 px, four times the floor.
For the lens, work from your standoff:
With the camera 500 mm above the table, a sensor about 7.4 mm wide (typical of a 1/1.7-inch format) and a 150 mm field: f = 500 × 7.4 / 150 = 24.7 mm, so order a 25 mm lens. Distortion under 0.3% moves an 80 mm rim edge by 0.24 mm, inside a 10 mm budget, and the gauge calibration below cancels most of what remains. Any low-distortion C-mount lens rated for your sensor format serves; the LS-FFL-0567 is a 16 mm C-mount lens rated for 20 MP on sensors to 1.1-inch.
- Type
- Machine vision fixed
- Sensor format
- 1.1"
- Mount
- C-mount
- Resolution
- 16-25 MP
Shutter and exposure: with the part static in a fixture, a rolling shutter is fine. If cylinders arrive on a conveyor, use a global shutter and cap exposure at one pixel of motion blur: t = 0.0375 mm per pixel ÷ 250 mm/s = 150 µs, and stop near f/8 for depth over the seating spread.
Calibrate the scale in the plane you measure
Calibrate against a reference of known size sitting where the rim sits:
A gauge cylinder stood in the same fixture does it in one image.
This step is where diameter sorting lives or dies, because a lens sees higher planes at a larger scale. Calibrate on the table, measure a rim h above it, and the reading inflates:
With the lens 500 mm above the table (L) and the rim 100 mm up (h): 80 × 500 / 400 = 100 mm. The largest cylinder reports past every threshold, and a 50 mm part reads 62.5 mm, one class high. A calibration made on a flat target must be applied to an elevated, curved rim with this correction in mind; the gauge-at-rim-height method removes the whole effect at a stroke.
What remains is seating variation. A height spread of ±2 mm around the calibrated plane changes scale by 2 / 400 = 0.5%, which is 0.40 mm on an 80 mm rim. Double the working distance to L − h = 900 mm and it falls to 0.22%, or 0.18 mm. Keep L − h at 400 mm or more for 10 mm classes. The scale itself is plain magnification; the deeper derivation is in object-space pixel size from magnification.
A telecentric lens pins magnification across depth and deletes the height error entirely, but its front aperture must exceed the field of view, so it suits one fixtured part, not a 150 mm staging area.
Worked example: five cylinders from 40 to 80 mm
Inputs:
- Five nominal diameters, 40 / 50 / 60 / 70 / 80 mm: the question's five sizes, given a typical 10 mm step.
- Presentation: upright in a fixture, rim 100 mm above the table, seating spread ±2 mm, part static.
- Camera: 4000 × 3000 px, mounted overhead.
- Field of view 150 mm; standoff 500 mm from lens to table.
Rule in words: six sigma of the measured diameter stays inside half the class gap.
Arithmetic:
- Scale: s = 150 mm / 4000 px = 0.0375 mm per pixel.
- Smallest rim: 40 / 0.0375 = 1067 px, ten times the 100 px floor.
- Thresholds at midpoints: 45, 55, 65, 75 mm, which is 1200, 1467, 1733 and 2000 px.
- Worst-case error on the largest part: seating 0.5% of 80 mm = 0.40 mm; edge fit under 1 px = 0.04 mm; lighting and finish wander about 0.20 mm. Sum: 0.64 mm.
- Check: 0.64 mm against 5 mm of room to the nearest threshold, a margin of 7.8 times. Nothing crosses a boundary.
| Class | Nominal | Accept window | In pixels |
|---|---|---|---|
| 1 | 40 mm | 35–45 mm | 933–1200 px |
| 2 | 50 mm | 45–55 mm | 1200–1467 px |
| 3 | 60 mm | 55–65 mm | 1467–1733 px |
| 4 | 70 mm | 65–75 mm | 1733–2000 px |
| 5 | 80 mm | 75–85 mm | 2000–2267 px |
| 0 | — | anything else | reject |
Decision: one overhead camera at 0.0375 mm per pixel sorts all five sizes with a 7.8-times margin, and a 1.6 MP sensor would still clear the floor fourfold. Buy resolution for the station's other work, not for this sorting.
Set-up in eight steps
- Fixture the part: one cylinder at a time against a stop, rim up. Hold seating height within ±2 mm, or shrink the budget numbers above to match what your fixture holds.
- Mount the camera with its axis within 5 degrees of vertical. A 5-degree tilt compresses one axis by 1 − cos 5° = 0.4%, worth 0.30 mm on an 80 mm rim, inside the budget; the circle fit's ellipticity flags the drift when it grows.
- Light the rim flat: a dome light or flat panel larger than the part, polarized if the tops are machined and specular. A bright streak crossing the rim is the main source of edge wander.
- Calibrate: stand a gauge cylinder of known diameter in the fixture. A 50.00 mm gauge fitting 1333 px gives s = 50 / 1333 = 0.0375 mm per pixel.
- Program the measurement: edge detection around the rim, least-squares circle fit, then D = k × s.
- Classify with the threshold table. Return class 0 and stop the cell when D falls outside every window: that is a wrong part delivered, not a size six.
- Hand the result to the robot: one integer class with a result-valid strobe over Ethernet or PLC I/O. The robot maps class to gripper opening and pick program. Sequencing the picks without collisions is covered in configuring camera locate for collision-safe picking, and the guidance side is treated in 2D vision pick and place: selecting a planar guidance system.
- Log D with every pick. A slow drift in one class's mean flags lighting or seating trouble before it becomes a mispick.
Verify before release
Run each size at least 20 times, seated at the worst allowed position and height. For each class, compute the mean and the spread; the run passes when 6σ ≤ 5 mm and no single measurement crosses a threshold. Cross-check five parts per size against a micrometer and accept a vision mean within 0.5 mm. A pin gage and a vision silhouette can disagree on an out-of-round rim, and the silhouette is the feature your gripper meets, so treat it as the reference.
When one measurement is the wrong answer
- Classes 1 mm apart: 6σ ≤ 0.5 mm demands seating control near ±0.4 mm at a 400 mm working distance, or a telecentric lens on a single fixtured part. Possible, but earn it with the verification runs first.
- Parts lying down, tilted or overlapping: the silhouette edge then sits near the cylinder's top surface rather than a fixed plane, and a lying cylinder's visible width is not a clean diameter. Calibrate with a gauge in the same pose, or move up to 3D bin picking for flat parts: choosing a vision approach.
- Same diameter, different material or lot: diameter cannot separate them. Classify appearance instead, as in classifying irregular objects by appearance reliably.
- A sixth size arrives next quarter: add a threshold row and a window. The hardware does not change.
Ordering checklist
- Camera: smallest diameter at least 100 px at your field of view; global shutter only if parts move during exposure; mono is enough for size.
- Lens: image circle rated for your sensor format; focal length f = WD × sensor width / FOV; distortion 0.3% or less unless the gauge calibration covers it.
- Light: dome or flat panel oversized relative to the rim; polarizer for machined tops.
- Reference: one gauge cylinder of known diameter, certified tighter than your class gap.
- Mount: rigid overhead stand holding the working distance fixed at the value you budgeted above.
- Output: one class integer plus a valid strobe to the controller.
Start the numbers in the camera configurator, or send the five diameters and your standoff to the applications desk and we will run the budget with you.
Questions
How close can two cylinder diameters be and still be sorted reliably?
The working rule is six sigma inside half the gap. A fixtured overhead station with diffuse light holds one-sigma near 0.1 to 0.2 mm, so diameters 2 mm apart sort cleanly, and a 1 mm gap is realistic with a telecentric lens or a long standoff that suppresses height error. Below that, stop sorting on diameter alone: add a separating feature such as color, a cap or a marking, and classify appearance instead.
Do I need a telecentric lens for cylinder sizing?
Not for classes millimetres apart. A telecentric lens fixes magnification across depth and removes the height error, but its front aperture must be at least as large as the field of view, so it suits one fixtured part rather than a wide staging area. Calibrating with a gauge cylinder at rim height achieves the same correction with a normal lens, as long as seating height varies by only millimetres.
Rolling or global shutter for a sizing station?
Rolling is fine while the cylinder stands still: the scene is static and the fit sees an undistorted circle. Switch to a global shutter when parts move during exposure, because a rolling shutter shears a moving circle into an ellipse and biases the fit. For scale, one pixel of blur at 250 mm/s and 0.0375 mm per pixel caps exposure at 150 microseconds.
How does the size class reach the robot controller?
Send one integer per part, class 1 through 5, plus a result-valid strobe over Ethernet or PLC I/O. The robot maps the class to a gripper opening and a pick program; a value of 0 means reject and stop. Keep the mapping in one table so a sixth size adds a row instead of new logic, and log the measured diameter beside the class.
What changes if the cylinders lie on their sides?
The edge you measure then lies near the cylinder's top surface, not on the table, so a table-level calibration inflates the reading by L/(L − h) with h near the cylinder height. Calibrate with a gauge cylinder lying in the same pose. Once parts overlap or tilt more than about 10 degrees from either axis, move to a 3D sensor.



