A stereo rig needs three numbers to turn disparity into millimetres: focal length, principal point and baseline. When the datasheet omits the sensor size and the focal length — as most module and webcam datasheets do — the instinct is to hunt for a sensor width in millimetres. That hunt is unnecessary. A calibration with a target of measured square size hands you everything in pixels and millimetres directly. This guide walks through the calibration steps, the depth formula with the arithmetic shown, the two fallback routes to a focal length in millimetres, and the checks that catch a wrong scale. The worked numbers follow a 640 × 360 USB camera pair; the method is identical at any resolution.
Do you need the sensor size at all for stereo reconstruction?
No: for metric stereo reconstruction you never need the physical sensor width or a focal length in millimetres, because a full calibration with a target of known square size gives the focal length in pixels, the principal point and the baseline, and distances come out in millimetres.
The pinhole model your stereo code solves lives entirely in pixels. The 3 × 3 camera matrix carries fx, fy, cx and cy in pixels, and the stereo step returns the rotation R and the translation T between the two cameras. Tx, the first component of T, is the baseline in millimetres — the millimetre scale entered through the target's measured square size, not through any sensor dimension.
That is the whole trick. A board printed with 20 mm squares teaches the solver what a millimetre looks like in pixels, and every distance afterwards inherits that scale. The datasheet values matter only when you must express a focal length in millimetres, for instance to order a replacement machine vision lens. Two guides cover the unit change from either side: why focal length ends up in pixels and reading the stereo depth scale factor per camera.
How do you calibrate the rig when the datasheet is silent?
Print a checkerboard whose square size you have measured with a rule, grab 15 to 25 simultaneous image pairs of it at different distances and tilts, and the stereo calibration returns the focal length in pixels plus the baseline.
What you need:
- a printed or purchased checkerboard target — for example a 9 × 6 corner grid with 20 mm squares
- both cameras bolted to one rigid bar
- even illumination so the corner detector fires on every frame
- the calibration functions of your vision library
Then run the steps:
- Measure the printed squares with a rule and enter that measured value, never the drawing's nominal size: office printers rescale by 1-2%. The calibration target size guide says how large the board must be for your working distance.
- Bolt both cameras to one bar and do not touch them afterwards; any movement at a mount invalidates the baseline.
- Grab 15 to 25 synchronized pairs. Hold the target between 0.3 and 2 times the working distance, tilt it up to about 45° in both axes, and let it fill the frame corners in at least a few views.
- Detect the corners on every frame and discard any partial detection.
- Calibrate each camera on its own to get fx, fy, cx, cy and the distortion coefficients.
- Run the stereo calibration to get R and T. The baseline is the magnitude |Tx|; the sign only records which camera sits on the left.
- Rectify the pair and confirm the target lands on the same image row in both rectified views.
- Read the RMS reprojection error: under about 0.5 px is a good pass. Above that, add views and rerun before blaming the hardware — the grid-pitch fix for checkerboard calibration errors is the usual first move.
No printer, or no board flat enough? The stereo calibration from surveyed scene points method replaces the pattern with measured points in the scene.
How does the calibration output become millimetres?
Depth comes from one line of arithmetic, Z = fx × B / d: with the focal length in pixels, the baseline in millimetres and the disparity in pixels, the answer is in millimetres, and no sensor dimension appears anywhere in it.
Z is the depth of a matched point, fx the focal length in pixels from the calibration, B the baseline |Tx| and d the disparity in pixels. Keep B and Z in one unit: a baseline in millimetres returns depths in millimetres. The second line is the depth resolution — how many millimetres one pixel of disparity error moves the answer at depth Z.
Those two numbers carry the design decision. To hold 10 mm of depth resolution at 1.13 m you need fx × B ≥ 1,131² / 10 ≈ 128,000 px·mm, which at fx 605.5 means a 211 mm baseline. Spread the cameras wider or raise fx with a longer focal length; resolution improves with both, and it improves fast as the part moves closer.
How do you get pixel pitch and focal length in millimetres anyway?
Divide the sensor diagonal in millimetres by the diagonal in pixels: a 1/1.7" format sensor is nominally 16 / 1.7 ≈ 9.4 mm across, so a 4000 × 3000 sensor, whose diagonal is 5,000 pixels, has 9.4 / 5,000 ≈ 1.9 µm pixels.
The inch classes are a carry-over from tube cameras: the fraction names a nominal diagonal of about 16 mm divided by the fraction, so 1" means roughly 16 mm across the diagonal, not 25.4 mm. Real active areas sit a few percent inside the nominal figure.
For that 4:3 sensor: sqrt(4,000² + 3,000²) = 5,000 pixels, so p = 9.4 / 5,000 ≈ 1.9 µm, and the rig from the worked example gets f = 605.5 × 0.00188 ≈ 1.14 mm. The figure looks absurd and is entirely normal for wide webcam optics — which is exactly why such datasheets quote a field of view instead of a focal length.
When you buy the imager as a machine vision camera, both inputs are printed and the reconstruction reduces to arithmetic:
- Sensor format
- 1/1.7"
- Interface
- USB3
- Resolution
- 12 MP
- Shutter
- Rolling
Pitch and focal length then fall out of the two lines above with no measurement at all. The same holds for glass, where a lens bought for machine vision work states its focal length and its sensor format outright:
- Type
- Machine vision fixed
- Sensor format
- 2/3"
- Mount
- C-mount
- Resolution
- 6-10 MP
With sensor width and focal length in hand, the remaining choice is the standard one. The sensor size and focal length relationship is fixed geometry, and the lens finder filters by both when a webcam module needs replacing with glass that declares itself. The calculator below turns a required field of view into a focal length:
What if the camera prints nothing at all?
Read the EXIF header first, then measure the sensor in a spare unit with a caliper, and if both fail, fit a module that prints its specifications — because every guessed value fed into the pipeline puts the scale error straight back in.
The EXIF block of a saved JPEG sometimes carries a focal length and an f-number, but usually as a 35 mm-equivalent figure rather than the true focal, and pixel pitch essentially never appears. Treat anything found there as a hint, not a measurement; plenty of modules store nothing beyond size, date and resolution.
The caliper route works on a spare unit: open the case, measure the active sensor width, and divide by the image width in pixels — a 3.6 mm active width across 640 pixels is 3.6 / 640 ≈ 5.6 µm per pixel.
One reassurance: if your pipeline consumes only fx in pixels and the calibrated baseline, a guessed pitch never enters the math. It matters only where a millimetre focal length feeds a projection step or a lens purchase — which is why a rig calibrated on 20 mm squares returns sane distances even when the sensor stays anonymous. Two guides attack the same problem from other angles: pixel pitch without a datasheet and deriving the active area from pixel size.
How do you check the distances before you trust them?
Hold a rule or metre stick at a measured distance and compare: with fx 605.5 px and a 59.8 mm baseline, the disparity at 1,000 mm must be 605.5 × 59.8 / 1,000 ≈ 36 px, and a measurement within a pixel or two validates the chain.
Run the same check at 500 mm and 300 mm: the prediction is 605.5 × 59.8 / 500 = 72.4 px and 605.5 × 59.8 / 300 = 120.7 px. Three ranges spanning 3:1 catch a scale error that a single distance hides.
The recurring mistakes, in order of how often they bite:
- A camera moved after calibration: depth scales with the baseline, so a 2% clamp shift is a 2% depth error everywhere. Recalibrate.
- An unmeasured print: a square 1% small makes every distance 1% short, uniformly — plausible numbers are what make this one sneaky.
- A board shown face-on only: the distortion terms stay loose and distances drift near the frame edges. Add tilted views.
- Using Tx as the baseline instead of |Tx|: the sign records direction; the formula wants the magnitude.
- A small target far away: corner detection error grows with range. The target size at distance guide gives the numbers behind that.
Which printed numbers on a bought camera end the guesswork?
Two printed lines — sensor format and resolution — give the pixel pitch by the diagonal arithmetic above, and the lens line gives the focal length in millimetres, so a camera that prints both ends the reverse-engineering entirely.
Shopping turns this guide into a spec-sheet read. The area scan cameras category and the camera finder filter on format, resolution, shutter and interface; 3D sensors cover factory-integrated stereo and structured-light depth if you would rather buy the chain calibrated.
A 20 MP mono camera on a 1" sensor, for when the pixels need to be bigger:
- Sensor format
- 1"
- Lens mount
- C-mount
- Interface
- USB3
- Resolution
- 16-25 MP
If you are specifying a rig rather than reverse-engineering one, start at the camera step of the configurator, choose parts that print their numbers, and spend the freed afternoon on target tilts instead of sensor archaeology. The 3D topic page lines up the calibration guides in the order you will need them.
Questions
How exact is the 16 mm-per-inch sensor format convention?
It is a naming convention, not a measurement. Optical formats describe a nominal diagonal near 16 mm divided by the fraction, and a 1" sensor is about 16 mm across the diagonal, not 25.4 mm. Real active areas sit a few percent inside the nominal figure, so a pitch derived this way is good to roughly ±5% — ample for turning a focal length in pixels into millimetres.
Do both cameras in a stereo rig need the same sensor and lens?
No. Each camera keeps its own fx in pixels, and depth uses the reference camera's focal length with the calibrated baseline, so a mixed pair still measures. Matching is easier when both images look alike, so similar formats and fields of view help in practice. The hard requirement is mechanical: the baseline must stay fixed, because every depth scales with it.
Does a rolling shutter camera ruin stereo depth?
Not for a static target. Rolling shutter skews an image row by row only while something moves during the exposure, so calibration frames taken with the rig still are unaffected. For moving parts, shorten the exposure until the target shows no skew, add light if the image darkens, or pick a global shutter model — the shop filters separate global from rolling shutter explicitly.
How much does a 60 mm baseline limit depth precision?
Depth resolution follows Z² / (fx × B). At fx 605.5 px that is about 6.9 mm per pixel of disparity at 500 mm and about 35 mm at 1.13 m. Widening the baseline to 160 mm cuts the 1.13 m figure to about 13 mm; a longer focal length helps by the same factor. Both changes trade against field of view and minimum working distance.
Can I move the rig after calibrating, as long as the cameras stay bolted together?
Yes, if the bar itself is what moves. Intrinsics describe the cameras alone and survive relocation, and the extrinsics describe one camera relative to the other, so a rigid pair keeps them. What breaks the calibration is change at a joint — a camera rotated in its clamp, a focus ring touched, a lens swapped. Recalibrate after any of those, and re-check with the metre-stick test.


