Cameras & sensorsExplainer

Measure object size from a camera image

Measure object size from a camera image using calibrated scale, perspective correction and height checks, with worked examples and validation steps.

LumaSpec Vision10 min read Share on LinkedIn

On this page 11 sections
  1. 01Choose the geometry before the measurement tool
  2. 02Separate detection from dimensional measurement
  3. 03Establish when a fixed scale is valid
  4. 04Correct perspective on a flat measurement plane
  5. 05Quantify the error caused by object height
  6. 06Use telecentric optics for the right reason
  7. 07Budget sampling separately from accuracy
  8. 08Choose camera and lens candidates without assuming accuracy
  9. 09Validate dimensions against independent references
  10. 10Recognize when one calibrated image is insufficient
  11. 11Questions

A detected object has an image width, but that width does not establish its physical dimensions. The same part occupies different numbers of pixels when its distance, orientation or imaging geometry changes. For inspection engineers, the first decision is therefore not which detector to use, but which geometric assumptions the station can maintain. You can then choose a fixed scale, planar calibration, telecentric imaging or a depth-aware method, and verify the dimensions against independent references.

Choose the geometry before the measurement tool

To measure object size from a camera image, you need a known relationship between image coordinates and physical coordinates. A calibrated reference can establish that relationship, but only within the conditions represented by the calibration.

Start by identifying the surface containing the dimensions you need. A label lying flat on a conveyor presents a different problem from a cylinder whose top edge changes height.

Inspection geometry Suitable starting method Main limitation
Flat surface, perpendicular view, fixed distance Calibrated pixel-to-unit scale Height changes and residual distortion
Flat surface viewed at an angle Lens correction and planar coordinate mapping Valid only on the calibrated plane
Height varies, but projected dimensions are needed Telecentric imaging within a validated range Focus, tilt and remaining optical errors
Unknown distance or unrestricted three-dimensional pose Depth information, multiple views or mechanical constraints A single image scale cannot describe the scene

The practical starting point for a flat inspection is the guide to measuring planar distances with a calibrated camera. It explains the coordinate mapping that connects visible features to a measurement plane.

Separate detection from dimensional measurement

An object detector typically reports a class, confidence and image coordinates. Those coordinates identify where to inspect; they do not establish a physical scale.

A bounding box also may not represent the engineering dimension you want. An axis-aligned box grows when a rectangular part rotates, even when the part itself remains unchanged. Shadows, occlusion and inconsistent training annotations introduce further differences between the box and the physical boundary.

Use detection to locate a region, then measure suitable features inside it. Depending on the part, those features might be fitted straight edges, circle boundaries or specific reference marks. A segmentation outline can help, but its boundary still needs validation against the required dimensional accuracy.

Keep coordinates consistent throughout the pipeline. If detection uses a resized or padded image, reverse that transformation before applying calibration from the original image. The same requirement applies to cropped regions: restore their coordinate offsets before mapping points into physical space.

Establish when a fixed scale is valid

A fixed scale works when the relevant surface stays at a fixed distance and orientation, and scale variation across the measurement region is acceptably small. Lens distortion must either be corrected or demonstrated to be negligible for the required accuracy.

Measure a known reference in the same plane as the inspected features. For a simple perpendicular-view estimate:

s = L_ref / p_ref L_object = p_object × s s = physical distance per pixel L_ref = known reference length p_ref = reference length in pixels p_object = measured object length in pixels

Suppose a reference spanning 100.00 mm measures 2000 pixels. The scale is 100.00 / 2000 = 0.05000 mm per pixel. An object spanning 760 pixels therefore measures 760 × 0.05000 = 38.00 mm.

That arithmetic does not prove the station is accurate to the displayed decimal places. Reference uncertainty, edge localization, distortion and height variation still contribute to the error.

Check reference lengths near the center and corners rather than calibrating from one central span alone. For the optical relationship between sensor sampling and magnification, use the explanation of pixel scale calculated from magnification.

How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

Correct perspective on a flat measurement plane

An angled camera produces position-dependent scale across a plane. A single millimeters-per-pixel value cannot generally convert every horizontal and vertical image distance correctly.

For a planar target, a homography maps image points to coordinates on the target plane. Establish the mapping from known, well-distributed reference points, usually after correcting lens distortion. Use more than the mathematical minimum when practical, and reserve additional points for independent verification.

Transform the measurement endpoints into plane coordinates, then calculate their separation:

L = sqrt((X2 - X1)^2 + (Y2 - Y1)^2)

Do not convert an image-space bounding-box width using a scale measured somewhere else in the image. Mapping the relevant endpoints addresses perspective more directly and avoids confusing projected width with the intended feature length.

The guide to length calibration using image markers covers the reference geometry behind this approach. Remember that a plane mapping does not become a three-dimensional measurement merely because its calibration fits well.

Quantify the error caused by object height

With a conventional lens, a feature moving toward the camera usually appears larger. Calibrating at the conveyor surface and measuring a raised top face therefore introduces a predictable scale error.

For an ideal pinhole model, let D be the calibration-plane distance from the effective projection center. Let h be the feature height toward the camera:

L_reported / L_true = D / (D - h) relative scale error = h / (D - h)

This is an estimate that omits lens distortion and other optical effects. D is not automatically the working distance measured from the front of a lens.

For example, take D = 500 mm and h = 10 mm. The scale factor becomes 500 / 490 = 1.0204. A true width of 50 mm would be reported as approximately 51.02 mm, an error of about 1.02 mm or 2.04%.

That error can dominate any benefit from more pixels or subpixel edge fitting. If height is known and the camera model is valid, geometry can sometimes compensate. If height is unknown, use a fixture, measure depth, add another view or reconsider the optics.

Surface tilt introduces another limitation: the visible projection of a sloped feature is not its full surface length. Neither a fixed scale nor a planar mapping recovers an unknown out-of-plane slope.

Use telecentric optics for the right reason

Telecentric lenses reduce magnification changes as an object moves along the optical axis within the lens's useful operating range. They are valuable when projected width or diameter must remain stable despite limited height variation.

Perspective with a standard lens compared with a telecentric lens Left: the same part at two distances appears at two sizes through a standard lens. Right: a telecentric lens accepts only rays parallel to its axis, so the part appears the same size at both distances.Standard lensfarnearsensorThe same part looks bigger when nearer:its measured size depends on distanceTelecentric lensOnly rays parallel to the axis enter:the same size at any distance
Perspective with a standard lens compared with a telecentric lens. Left: the same part at two distances appears at two sizes through a standard lens. Right: a telecentric lens accepts only rays parallel to its axis, so the part appears the same size at both distances.

Telecentric imaging does not remove every measurement error. Finite telecentricity, distortion, defocus, illumination changes and part tilt still matter. It also does not reveal hidden surfaces or recover arbitrary three-dimensional dimensions.

Use the guide on when telecentric optics are appropriate for gauging to decide whether the geometry justifies that approach. Then validate both image sharpness and dimensional stability through the expected height range, following the distinction explained in telecentric focus range and measurement accuracy.

A sharply focused image alone is not proof that magnification is sufficiently stable for your tolerance.

Budget sampling separately from accuracy

For a perpendicular view with approximately uniform scale, field width divided by horizontal pixel count gives nominal sampling. This helps size the camera, but it is not a complete accuracy specification.

Suppose the required field width is 120 mm and the selected sampling target is 0.05 mm per pixel:

required horizontal pixels = field width / sampling target required horizontal pixels = 120 / 0.05 = 2400
Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

The sampling target must leave room for edge uncertainty and other error sources. As an illustrative assumption, if each endpoint can shift by 0.2 pixel, the worst-case separation error from those shifts is 0.4 pixel. At 0.05 mm per pixel, that contribution is 0.4 × 0.05 = 0.02 mm.

This example assumes the endpoint behavior has actually been established. It does not claim that any edge algorithm routinely achieves that value. Correlated errors, asymmetric illumination and uncertain physical boundaries can produce bias that averaging does not remove.

The discussion of camera resolution and measurement accuracy in motion explains why pixel count must be considered alongside blur and acquisition conditions.

Choose camera and lens candidates without assuming accuracy

Select area scan cameras by the required pixel dimensions, shutter behavior, triggering and acquisition needs. The camera finder helps narrow those choices, but catalog resolution alone does not establish dimensional performance.

The MV-CU020-90GC is a global-shutter, C-mount camera candidate. Application suitability still depends on sampling, exposure and the complete optical setup.

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
Up to 3 MP
$309.00View partBuild a system with it

For machine vision lenses, check sensor coverage, mount, field coverage, working distance and usable image quality. Browse the lens finder only after defining the measurement region and available space.

The LS-FFL-0679 is a C-mount machine vision lens candidate. A conventional lens can suit a constrained measurement plane when the resulting errors fit the application budget.

Machine vision lenses35 mm, 2/3", 6 MP, C-mount machine vision lens (LS-FFL-0679)LS-FFL-0679
Type
Machine vision fixed
Sensor format
2/3"
Mount
C-mount
Resolution
6-10 MP
$219.00View partBuild a system with it

The LS-TCL-1390 is an object-side telecentric lens candidate. Consider it when reduced sensitivity to axial position is relevant to the measurement.

Telecentric lenses0.179x, WD 260 mm, 2/3", C-mount telecentric lens (LS-TCL-1390)LS-TCL-1390
Sensor format
2/3"
Mount
C-mount
Image circle
8-11 mm
Type
Object-side telecentric
$2,219.00View partBuild a system with it

These parts illustrate component choices, not a validated measuring system. Confirm the complete combination against the required field, detail, height range and tolerance before committing to hardware.

Keep lighting stable during evaluation. An edge threshold that moves with glare or exposure can change the reported dimension even when the mechanical geometry remains fixed.

Validate dimensions against independent references

Calibration estimates the mapping; validation tests whether it is adequate for the inspection. Do not use only the same reference points that fitted the mapping to judge its performance.

Use a short acceptance checklist covering the operating envelope:

  • Reference quality: use known dimensions with uncertainty comfortably below the measurement requirement. Record the reference and its condition.
  • Field position: check the center, corners and any region where parts will actually appear. Look for location-dependent bias.
  • Size range: test short and long dimensions. A mapping can appear satisfactory on one span while failing elsewhere.
  • Height range: evaluate the lowest and highest permitted feature planes. Include fixture variation rather than testing only the nominal position.
  • Orientation: rotate representative parts through expected angles. Confirm that the algorithm measures the intended dimension, not an enclosing box.
  • Repeatability: capture, for example, 30 stationary images, then repeat after removing and replacing the part. Keep imaging variation separate from positioning variation.
  • Motion and lighting: repeat at operating speed and under expected illumination changes. A stationary bench check does not validate moving inspection.
  • Configuration control: record focus, aperture, camera settings, image dimensions and calibration version. Revalidate after changes that affect geometry or edge appearance.

Report signed error against the reference as well as repeatability. A tight cluster of readings can still be consistently wrong.

For an illustrative maximum-error budget of 0.20 mm, you might allocate 0.10 mm to residual geometry, 0.05 mm to edge extraction and 0.05 mm to remaining contributions. Those allocations sum to 0.20 mm; they are design limits to verify, not measured performance or a statistical uncertainty calculation.

Recognize when one calibrated image is insufficient

The usual fixed-camera answer fails when the part can change distance unpredictably, rotate freely in three dimensions or hide the features defining its true dimension. Adding a more capable detector does not supply the missing geometry.

A known-size reference can help only when its geometric relationship to the measured feature is established. A marker on the table does not automatically calibrate the top of a tall object. Likewise, estimating range from an assumed object size cannot independently verify that same size.

Choose the simplest constraint that makes the measurement observable: flatten the measurement plane, control height, add depth information or introduce another calibrated view. Define which physical dimension is being measured before choosing the algorithm.

For a fixed inspection station, start the lens configuration process with your field dimensions, tolerance and expected height variation. If the geometry remains uncertain, send those details through applications support before selecting components.

Questions

Can an object detector directly report dimensions in millimeters?

A detector usually supplies image coordinates rather than traceable physical dimensions. You need a calibrated geometric relationship to convert those coordinates into units. For tight tolerances, use detection to locate the inspection region, then measure defined edges or features with a separately validated method.

Is one millimeters-per-pixel value enough for the whole image?

One scale can be sufficient for a fixed, approximately perpendicular view of a single measurement plane, provided distortion and field variation meet the accuracy requirement. Test that assumption at several positions and heights. An angled view generally needs a planar mapping rather than one global scale.

Will a telecentric lens solve errors from changing object height?

Telecentric optics can reduce size changes caused by limited axial movement, but they still have operating limits and residual errors. Verify dimensional stability across the permitted height range. They do not recover hidden features, unknown surface slopes or unrestricted three-dimensional dimensions from a single view.

Does a higher-resolution camera automatically improve measurement accuracy?

Extra pixels can improve sampling when the optics and exposure preserve useful detail. They do not correct an incorrect measurement plane, perspective errors, unstable illumination or a biased boundary definition. Establish the geometry first, then choose sampling that leaves adequate room in the error budget.

When should a camera measurement setup be recalibrated?

Revalidate after changes to focus, lens position, camera pose, image cropping, resizing or the physical measurement plane. Also investigate calibration after unexpected dimensional drift. Keep configuration records so you can distinguish geometric changes from altered lighting, exposure or feature-extraction behavior.