Sorting coins by size with one camera is a calibration problem, not a pattern-matching problem. One camera, one lens and a backlight measure each coin's diameter to about ±0.02 mm in this build, and the decision logic routes it to a bin. This guide sets up that chain for 19, 21 and 24 mm coins: a pixel-per-mm scale from a single reference coin, a field of view and lens chosen with the arithmetic shown, bin boundaries with their error budget, and a relative thickness read from a tilted camera. The same chain sizes washers, caps and any flat, round part. You need thresholding and particle measurement in your vision software, and nothing else.
What one camera can and cannot measure
From one normal view you can measure diameter and area, and sort on them, as far as your scale is honest. Thickness is different: a face-on view hides the rim entirely, so a single camera reads thickness only relatively, from a tilted view compared against a reference coin. Pattern matching cannot measure size at all. A match returns a score and a position: how like the learned template the image is, and where it sits. It carries no pixel-to-mm scale, and a washer that resembles the coin scores highly at the wrong diameter. Use matching to verify the face after the size gate, with edge-based pattern matching that holds up when lighting changes. Use thresholding and particle measurements for size, as in measuring object size from a camera image.
Calibrate pixels to millimeters with one reference coin
Place a coin or gauge pin of known diameter in the seating plane, backlit, and measure its span in pixels with the same threshold you will run in production. The scale is one division:
A 20 mm gauge spanning 2,300 pixels sets the scale at 20 / 2,300 = 0.0087 mm/px. Calibrate in the seating plane, not on the bench top, because a part above or below the calibration plane changes magnification, with numbers below. For planning, the optics run through the thin-lens estimate m = f / (WD − f), the field FOV = sensor width / m, and pixel size = FOV / pixels across the sensor; the object-space pixel size guide works the same numbers from magnification. Backlight the coin so the edge is a clean silhouette; front light on bare metal spreads the edge with glare and adds nothing to a size read.
Worked example: sorting 19, 21 and 24 mm coins
Classes at 19, 21 and 24 mm put boundaries at the midpoints 20.0 and 22.5 mm, so the tightest half-gap is 1.0 mm. Target a worst-case error near 0.1 mm and the bins carry a 10× margin. The camera finder filters by resolution and shutter; this build takes the LS-CMR-0166, which resolves 4000 × 3000 over USB3 at 30 fps. A 1/1.7-inch format measures about 7.4 mm across, and the field must clear a 24 mm coin with margin on both sides, so aim near 35 mm wide.
At a 200 mm working distance, a 35 mm lens magnifies m = 35 / (200 − 35) = 0.212. The field is 7.4 / 0.212 = 34.9 mm wide and 5.6 / 0.212 = 26.4 mm tall, so the scale is 34.9 / 4000 = 0.0087 mm/px. The reference check agrees: a 20 mm gauge spans 20 / 0.0087 = 2,300 pixels, and measuring it back gives 20 / 2,300 = 0.0087 mm/px. Coin spans come out as 19 mm → 19 / 0.0087 = 2,180 pixels, 21 mm → 2,410 and the largest class → 2,760, leaving (34.9 − 24) / 2 = 5.4 mm of margin per side on the largest coin. The LS-FFL-0679 is a 35 mm, 2/3-inch, 6 MP C-mount lens with an 8-11 mm image circle. A 2/3-inch image circle covers the 9.3 mm diagonal of a 1/1.7-inch sensor with room to spare. Use the calculator below if your sensor or working distance differs.
Now the error budget. Edge thresholding costs about ±2 pixels per edge, so ±4 pixels = 4 × 0.0087 = 0.035 mm. A scale known to ±0.3% adds 0.07 mm on the largest coin. Seating scatter of ±0.2 mm in height magnifies by 0.2 / 165 = 0.12%, or 0.03 mm. Worst case is the sum, 0.14 mm; root-sum-square is sqrt(0.035² + 0.07² + 0.03²) = 0.084 mm. Both sit far inside the 1.0 mm half-gap, so boundaries at 20.0 and 22.5 mm hold.
Two parts cover this bench build:
- Sensor format
- 1/1.7"
- Interface
- USB3
- Type
- Machine vision fixed
- Sensor format
- 2/3"
Decision rules and rejection gates
Threshold the backlit frame, take the particle's area A, and compute the equivalent diameter d_eq = 2 × sqrt(A / π). Area beats a maximum-caliper read because a single nick spans few of the millions of pixels in the outline. The three classes cover A = 283.5 mm² for 19 mm, 346.4 mm² for 21 mm and 452.4 mm² for the largest class; at 0.0087 mm/px that is 3.7 and 6.0 million pixels for the smallest and largest coin, so threshold noise averages out at this pixel count.
Gate on circularity c = 4πA / P². A clean single coin scores above 0.95; two coins touching and merged score below 0.85. The merged case is worth the arithmetic: two coins of the largest class give A = 904.8 mm², which reads d_eq = 2 × sqrt(904.8 / π) = 33.9 mm, a phantom class that would fall outside every bin anyway. Reject on circularity and requeue. Then run the face verification for tokens and washers that pass the size gate. The routing is: below 20.0 mm to bin A, 20.0 to 22.5 mm to bin B, above to bin C.
Set-up: trigger, speed and light
On a fixture, trigger from the nest-present sensor and capture with the coin at rest; 30 fps caps the intake near 30 coins per second, so plan 15-20 with processing and reject time in the budget. On a moving belt at 100 mm/s, a 1 ms exposure smears the edge by 100 × 0.001 = 0.1 mm, which is 0.1 / 0.0087 = 11 pixels of grey ramp. Keep the smear inside 2 pixels: exposure ≤ 2 × 0.0087 / 100 = 0.17 ms. The 12 MP camera in this build rolls its shutter, so it belongs over a stopped coin; for on-the-belt capture, filter the area scan cameras for global shutter, and take the speed maths from sorting conveyor camera selection: pixels, speed and blur.
Light decides the edge. A diffuse backlight behind the nest gives a silhouette immune to wear, scratches and mint marks; front light is for the face image only. Exposures as short as 0.17 ms need a bright backlight driven hard, so keep it within its duty-cycle rating.
For the on-device version, the smart cameras category runs sensor, light and decision on one unit. The LS-SMC-0063 carries a fixed 16 mm lens, built-in white light with a transparent-light mode, and 60 fps at 1.6 MP. To plan its scale: at the 4:3 split typical of 1.6 MP, about 1460 × 1090 pixels, and a 1/3-class sensor about 4.8 mm wide, a 16 mm lens at 200 mm gives m = 16 / (200 − 16) = 0.087 and a field near 55 mm wide, so 55 / 1460 = 0.038 mm/px. A 19 mm coin then spans about 500 pixels and a 2 mm class gap about 53 pixels, enough for the same bins at 4× coarser scale. The reference-coin calibration sets the true scale in a minute, whatever the sensor turns out to be.
- Interface
- GigE
- Resolution
- Up to 3 MP
Thickness from a tilted view
Tilt the camera 30° off the coin axis over the nest and the rim enters the image. The face becomes an ellipse whose major axis still reads the true diameter and whose minor axis shortens to d × cos 30° = 0.87 d. The rim projects as a band along the minor axis of about t × sin 30° = t / 2: a 1.75 mm thick coin shows a band near 0.875 mm = 0.875 / 0.0087 = 100 pixels, a 2.00 mm coin about 115 pixels, so the pair separates by 15 pixels. Calibrate the band against one coin of known thickness seated in the nest and thickness classes close to ±0.1 to ±0.3 mm; with coins loose on a belt, seating scatter swamps that, and the band stays a relative thick-or-thin signal. Diameter from the tilted frame comes from the major axis through a rotated-rectangle fit, so one tilted camera can deliver both measurements. It is the same gauge-not-height argument that settles cap sorting by diameter rather than equal height: sort on diameter, and read thickness as the secondary, tilt-derived figure.
Checks before you trust the numbers
Measure one reference coin 20 times: the spread should stay inside ±2 pixels = ±0.02 mm; anything wider points at an unstable backlight or a drifting threshold. Slide the reference to the field corners: if the scale drifts beyond 0.4%, which is 0.1 mm on the largest coin, keep the nest centered on the optical axis or move to a telecentric lens, which removes the height term entirely. The field of view and lens coverage margin maths covers how much edge margin to keep. Height is the term people miss: a coin seated 2 mm closer to the lens than the calibration plane magnifies by 165 / 163 = 1.012, and a 24 mm coin reads 24.29 mm. Recalibrate after any lens, focus or height change; planar measurement with a calibrated camera shows how the scale carries into real coordinates.
When the usual answer is wrong
Pattern matching is not a size gauge: it scores similarity, and scale never enters the score. More pixels is not a cure either. Past about 0.05 mm/px the error budget belongs to seating height and calibration, not pixel count; how many pixels a high-resolution camera really buys puts numbers on that trade. Front light is the wrong tool for the size edge, because glare biases the silhouette boundary by pixels; backlight the measurement. And a telecentric lens is not automatic: it earns its keep when coins sit at varying heights or the nest drifts off-axis, while the fixed 35 mm lens at 0.21× handles a nested coin set.
Set-up checklist
- Field and scale: field of view = coin plus 20% margin per side, so 34.9 mm for the largest coin leaves 5.4 mm; pixel size at most class gap / 40, which is 0.05 mm/px for a 2 mm gap. This build runs 0.0087 mm/px.
- Calibration: reference coin or gauge in the seating plane, measured with the production threshold; scale good to ±0.3%; recalibrate after any lens, focus or height change.
- Capture: backlight silhouette for size, front light only for the face image; exposure inside 2 pixels of smear, 0.17 ms at 100 mm/s, or capture at rest on the nest.
- Measurement: equivalent diameter from area, d_eq = 2 × sqrt(A / π); circularity gate at 0.9 to catch merged coins before they create a phantom class.
- Decision: boundaries at class midpoints, 20.0 and 22.5 mm here; worst-case error 0.14 mm against a 1.0 mm half-gap keeps every bin honest.
Size the camera and lens as a pair in the camera configurator, or browse the machine vision lenses for another focal length and image circle. More measurement builds sit on the applications topic page, and the applications team answers set-up questions through the contact page.
Questions
Can pattern matching alone sort coins by size?
No. A pattern match returns a similarity score and a position, and neither carries a pixel-to-mm scale. A washer that resembles the coin can score highly at the wrong diameter. Learn the template for face verification only, and take size from thresholding plus particle measurements on a calibrated scale.
How many pixels do I need across the smallest coin?
Size the pixel from the class gap, not the coin. With a 2 mm gap between adjacent diameters and about ±4 pixels of edge uncertainty, keeping the error inside a tenth of the gap needs pixels of 0.05 mm or finer, which is at least 380 pixels across a 19 mm coin. The worked example reaches about 2,180.
How do I measure coin thickness with a single camera?
Tilt the camera about 30° off the coin axis. The rim then projects as a band of thickness × sin 30°, half the true thickness, while the ellipse major axis still reads the true diameter. Calibrate the band with one coin of known thickness seated in the nest; expect ±0.1 to ±0.3 mm repeatability.
What lighting shows a coin outline best for size measurement?
A diffuse backlight. The coin blocks the light, so the silhouette edge is crisp and unaffected by wear, scratches or mint marks that upset front lighting on bare metal. Keep front or low-angle light for the face-verification image; never judge diameter from a front-lit outline, where glare shifts the apparent edge by pixels.
Why does the measured diameter change when a coin sits higher in the nest?
Magnification varies with distance to the lens. A coin seated 2 mm closer than the calibration plane on a 200 mm, 35 mm lens setup magnifies by 165 / 163 = 1.012, so a 24 mm coin reads 24.29 mm. Seat every coin at the same height, or fit a telecentric lens to remove the term.
Can a smart camera do this sorting without a PC?
Yes, for diameter bands. A 1.6 MP smart camera with a fixed 16 mm lens reaches roughly 0.038 mm per pixel over a coin-sized field, so a 2 mm class gap spans about 53 pixels, enough for the same boundaries. Move to a 12 MP PC setup for finer scales, more throughput, or heavier matching libraries.


