You calibrated the camera, remapped the distortion out of the frames, and now you want to measure parts with the simple projection equation x = fX/Z. The answer here is written for single-camera metrology after an OpenCV-style calibration: when the undistorted image behaves as a pinhole camera, which camera matrix to use on it afterwards, and where every term of the equation lives. A worked projection at 400 mm gives the scale, field of view and sensitivity numbers, and the closing sections name the cases — fisheye, telecentric, through-glass — where the equation must not be used at all.
The short answer: yes, with two conditions
Once a calibrated remap has removed the radial and tangential distortion, the undistorted image is consistent with the pinhole camera model, and projection is:
The equation you started from, x = fX/Z, is this same relation in centered, normalized coordinates. It is true only when x is measured from the principal point (cx, cy) rather than the image corner, and when (X, Y, Z) are coordinates in the camera frame: Z along the optical axis, X to the right, Y down, origin at the projection center. Get either wrong and every coordinate silently shifts by tens of pixels.
The second condition is the lens. A rectilinear lens, remapped with its own distortion coefficients, lands exactly on the pinhole model. A fisheye lens and an object-side telecentric lens never do, whatever you remove from their images.
Note also what the remap does not do: the default behavior of the OpenCV undistortion functions leaves the principal point alone, so the matrix you calibrated is still the matrix of the undistorted image. Keep fx, fy, cx and cy, add the offsets, divide by Z. Only if you ask the undistortion for a changed output matrix — rescaled or cropped — do you carry new values forward, and how the principal point moves after undistortion shows which.
What each term of the equation is
fx and fy are focal lengths in pixels, not millimeters. The conversion is the pixel pitch:
with f the focal length in mm and p the pixel pitch in mm. A 16 mm lens on a 2.0 µm pitch gives fx = 16 / 0.002 = 8000 px. The pitch comes from the sensor data, not from the pixel count alone — a camera such as the LS-CMR-0166, a 12 MP USB3 camera with a 4000 × 3000 grid, is the known pixel geometry these equations want.
- Sensor format
- 1/1.7"
- Interface
- USB3
- Resolution
- 12 MP
- Shutter
- Rolling
cx and cy locate where the optical axis meets the sensor: near the image center, not on it. Calibration measures them; assuming the exact center costs accuracy, and principal point uncertainty and when to distrust your calibration says how far is too far. For the full forward and inverse routines, projecting a 3D point to pixel coordinates with a calibrated camera walks through the code.
What the remap changes and what it leaves alone
Calibration returns two things: the intrinsic matrix (fx, fy, cx, cy) and the distortion coefficients — radial and tangential, the Brown-Conrady family. initUndistortRectifyMap() plus remap() resamples the frame so straight lines in the world are straight in the image; undistort() does the same in one call, and undistortPoints() maps individual coordinates back to rays. The default of these functions keeps cx and cy where they were, which is why the old matrix stays valid for the new image.
If your calibration call fixed the aspect ratio, assumed zero tangential distortion or pinned the principal point, those assumptions are folded into the matrix you now hold. For measurement work, leave them free unless the fit refuses to converge.
Two practical notes. Remapping resamples, so measure edges on the undistorted frame, never on the raw one. And the remap leaves black borders where it had to invent pixels; when you crop them away, subtract the crop offset from cx and cy — black borders after undistortion covers where to cut. When the coefficients themselves are in doubt, Brown-Conrady distortion fitting from point pairs alone refits them without a checkerboard, and recalibrating lens distortion coefficients lists the triggers.
Worked example: 20 mm feature at 400 mm with a 16 mm lens
Example inputs: a 4000 × 3000 sensor with a 2.0 µm pixel pitch, a 16 mm lens, a part at Z = 400 mm, and a calibration that returned cx = 2000 px and cy = 1500 px. Values this close to the center are typical; yours come from your own calibration file.
- Sensor size: 4000 × 0.0020 mm = 8.0 mm wide, 3000 × 0.0020 mm = 6.0 mm high.
- fx = fy = 16 mm / 0.0020 mm = 8000 px.
- Scale at the part: fx / Z = 8000 / 400 = 20 px per mm, so 1 px of image is 0.05 mm of object.
- Field of view: 400 mm × 8.0 mm / 16 mm = 200 mm wide and 150 mm high. Cross-check: 4000 px ÷ 20 px/mm = 200 mm.
Projecting a corner at (X, Y, Z) = (15, 10, 400) mm:
Measuring instead of projecting: two edges land at 2200 px and 2600 px, so the feature is (2600 − 2200) / 20 = 20.0 mm wide. Depth from known size inverts the equation: a 25 mm gauge spanning 520 px sits at Z = fx × W / w = 8000 × 25 / 520 ≈ 385 mm — 15 mm nearer than the nominal 400 mm.
Sensitivity decides the method. Each pixel of edge noise moves that depth estimate by fx × W / w² = 200,000 / 270,400 ≈ 0.74 mm, so a two-edge measurement wanders by about 1.5 mm. Working distance cuts the other way: 1 mm of Z error at 400 mm is a 0.25% scale error, 0.05 mm on a 20 mm feature.
The decision: use the single camera for planar X-Y measurement, where 1 px is 0.05 mm, and do not use size-based depth when you need better than about 1 mm — add a second view or a distance sensor instead. The lens focal length calculator sizes the field of view before you commit to the working distance.
Scaling, binning and cropping
When an image is scaled by a factor, fx, fy, cx and cy scale by that same factor and the distortion coefficients stay unchanged. That one rule covers the common re-uses of a calibration: 2×2 binning halves the four intrinsic values, and a crop by (x0, y0) subtracts x0 from cx and y0 from cy while the focal lengths stay put. Neither forces a recalibration. Physical change does — refocusing moves the effective focal length, and a different lens or working-distance regime needs its own fit.
When the pinhole model stops being true
Fisheye and very wide lenses map angle, not tangent. The Brown-Conrady family fitted to a fisheye leaves large residuals, and forcing a pinhole remap stretches the corners badly. Use the fisheye distortion model and project with the matrix it returns; matching the fisheye distortion model shows what breaks when the two get mixed.
Object-side telecentric lenses image X at constant magnification: x = m · X + cx, with no division by Z. That is precisely why metrology uses them — size does not drift with standoff inside the depth of field. A fixed-magnification lens such as the LS-TCL-0574, a 0.4x design with a 227 mm working distance, works this way; keep the pinhole equation away from its images.
- Sensor format
- 1.2"
- Mount
- C-mount
- Image circle
- 16-22 mm
A refractive interface — a glass window or a water layer — bends the ray, and no lens distortion coefficient absorbs that. Underwater stereo calibration against the pinhole model quantifies the drift a port introduces; the same physics applies to an inspection window on a washdown cell.
Residual calibration error: the remap is only as good as its coefficients. Hold reprojection error at or below a few tenths of a pixel. At this example's 0.05 mm per pixel, 0.3 px of residual is about 0.015 mm of geometry — an order of magnitude below the 1 px of edge noise you already accept.
Motion during exposure: a rolling-shutter camera reads the part row by row, so a moving part is photographed at slightly different instants top and bottom. The projection equation is untouched, but the (X, Y, Z) it refers to is no longer one moment. Freeze the part with a strobe or use a global-shutter camera.
When you can skip the remap
If the distortion you would remove is smaller than your tolerance, the remap is optional, and you save a resampling step. The LS-FFL-0567 is a 16 mm C-mount lens for 1.1" sensors, rated at 20 MP with distortion below 0.3%.
- Type
- Machine vision fixed
- Sensor format
- 1.1"
- Mount
- C-mount
- Resolution
- 16-25 MP
At the worked example's 200 mm field, 0.3% of the 100 mm half-field is about 0.3 mm of corner displacement, falling to zero at the center. Inside a ±0.5 mm tolerance you can measure on the raw frame; at ±0.05 mm, calibrate and remap. The machine vision lenses category and the lens finder list distortion class alongside focal length, so you can filter for lenses that keep you on the right side of that line.
Checks before you trust the numbers
Run these once, before the first production measurement:
- Reprojection error of the calibration at or below a few tenths of a pixel, taken at the focus and working distance you will use.
- A known gauge re-measured: place a 25 mm artifact, read Z = fx × W / w, and compare with a tape or laser measure — the worked example's 385 mm against 400 mm shows what a 15 mm miss looks like.
- cx and cy read from the calibration file, never assumed to be the image center; a principal point fitted far outside the frame is itself a red flag — principal point outside the image says when the calibration is still usable.
- One source of truth: the same matrix that built the remap is the one you project with.
- The part stationary during exposure, or the exposure short enough that it is.
- Nothing refractive between lens and part.
When all six close, x = fx · X / Z + cx is trustworthy down to your edge noise. To size the camera and lens for a target field of view first, start at the lens step of the configurator, browse area scan cameras by resolution and mount, or read the wider systems topic. For a specific measurement cell, the contact page reaches our applications team.
Questions
After the remap, which camera matrix do I use for the projection?
The one your calibration returned, unchanged. The default OpenCV undistortion does not move the principal point, so the fx, fy, cx and cy you calibrated are exactly the matrix of the undistorted image. Only if you told the undistortion to write a different output matrix — to rescale or crop the result — do you project with that output instead.
Can I write x = fX/Z without cx if I center my coordinates first?
Yes. Subtract cx and cy from your pixel coordinates and the equation reduces to x_c = fx·X/Z and y_c = fy·Y/Z, the normalized pinhole form. That is all the bare formula ever meant: camera-frame coordinates and a pixel origin at the principal point. In corner-origin pixel coordinates, the + cx and + cy terms are mandatory.
Does 2x2 binning force a recalibration?
No. Scaling an image by a factor scales fx, fy, cx and cy by that same factor and leaves the distortion coefficients unchanged, so binning by two just halves the four intrinsic values. Recalibrate when something physical changes — a refocus, a different lens, a new working-distance regime — or when the check on a known gauge stops closing.
Does the pinhole equation hold through an inspection window or under water?
No. A flat port or water layer refracts the ray, so a single straight line from point to pixel no longer describes the geometry, and no lens distortion coefficient absorbs the effect. Keep the port out of the optical path, or model the refraction explicitly as a ray-traced system the way underwater stereo calibration does.
How accurate is depth from object size with one camera?
Treat it as a millimeter-class estimate. In the worked example (fx = 8000 px, a 25 mm gauge spanning 520 px), one pixel of edge noise moves the depth by fx·W/w², about 0.74 mm, so a two-edge measurement wanders by roughly 1.5 mm. Planar X and Y at the same geometry cost 0.05 mm per pixel — twenty times better.


