Cameras & sensorsTroubleshooting

Camera focus during calibration: set a repeatable position

Diagnose camera focus during calibration, separate capture-setting changes from optical faults, and verify stable focus before collecting images.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 01Identify what changes when calibration starts
  2. 02Compare the viewer and calibration capture paths
  3. 03Establish a repeatable focus position
  4. 04Measure sharpness on the images you will save
  5. 05Separate defocus from inadequate sampling and motion
  6. 06Control exposure without confusing it with focus
  7. 07Verify persistence before collecting calibration poses
  8. 08Check hardware requirements before replacing parts
  9. 09Final checks before the calibration run
  10. 10Questions

A camera can look sharp in its normal viewer yet produce blurred calibration images because the capture program applies different focus settings. That does not, by itself, establish a lens fault. For an adjustable-focus camera, the useful setting belongs to that particular optical assembly and target distance. Start by comparing the two capture paths, then establish a repeatable focus position and verify the saved images before collecting a full calibration dataset.

Identify what changes when calibration starts

The first diagnostic split is between an optical change and a display difference. Does the actual captured image lose detail, or does only the calibration preview look softer?

Save an image from each application at the same target position. Compare them at native resolution, without display scaling or sharpening. Record the active camera, image dimensions, focus mode, focus command if available, exposure, gain, and aperture where adjustable.

Work through these causes in order, moving mechanical faults higher if the assembly recently changed.

Likely cause Test Corrective action
Calibration applies a different focus command Compare reported settings before and after calibration starts Supply a verified position through the documented configuration
Autofocus remains active or restarts Watch target sharpness and available focus readback over several captures Establish focus, then disable autofocus before recording
Preview and saved images use different processing Compare native saved frames rather than application windows Evaluate the stream actually used by calibration
Exposure or target motion creates apparent defocus Capture a stationary target with adequate illumination Reduce motion blur before adjusting focus again
Working distance, mounting, or optical adjustment is wrong Check focus range and mounting without changing software Correct the optical setup or seek documented service

A calibration detector finding no corners or markers is not proof of defocus. Incorrect target configuration, clipping, glare, or excessive perspective can produce the same symptom.

Compare the viewer and calibration capture paths

Use the same camera identity and target distance for both tests. In a multi-camera assembly, verify each image channel independently. A sharp image from one channel says nothing about another channel's focus mechanism.

Check which controls the hardware actually supports. A fixed-focus assembly has no software focus adjustment. An electronically adjustable assembly may expose autofocus, a manual position command, and possibly position readback. An interchangeable lens may instead require mechanical adjustment. Do not infer those capabilities from a generic control panel.

Inspect documented startup settings, configuration files, and control logs. Look for a focus command applied after streaming begins, a saved preset loaded by calibration, or an automatic mode restored during initialization. Read settings again after startup completes, not only before it.

A manual focus number is normally a device-specific command, not a distance measurement. A value that works on another optical assembly is not a useful reference unless the manufacturer documents that relationship.

If the lens cannot reach the required distance even outside calibration, follow the close-distance focus diagnosis. If adapters or mounts changed, check adapter fit and flange distance before blaming the capture application.

Establish a repeatable focus position

Choose the working distance that represents the intended measurement setup. Place a flat, high-contrast target near the center of the useful depth range. Keep its orientation, illumination, and camera position unchanged during the initial focus search.

For supported electronic focus controls, use the manufacturer's documented control interface and permitted command range. Do not copy an unexplained preset or drive beyond documented limits.

  1. Confirm the capture stream. Select the image dimensions and processing path that calibration will actually use.
  2. Stabilize the image. Hold the target still and avoid brightness clipping. Keep exposure and gain unchanged during the focus comparison when practical.
  3. Find an initial position. Use supported autofocus or a coarse manual sweep. Autofocus is a starting aid, not evidence that the position will remain fixed.
  4. Switch to a fixed setting. Disable continuous autofocus and apply the chosen manual position, if the device supports that sequence.
  5. Allow adjustment to settle. Use documented status feedback where available, then confirm that consecutive images stop changing.
  6. Refine locally. Compare a small set of nearby permitted positions using saved images, approaching them consistently if direction affects repeatability.
  7. Record the setting. Save the command, available readback, target distance, image dimensions, aperture, and initialization order.

For a mechanically focused lens, use the same image-based method while adjusting its focus mechanism. Secure it only with the locking provisions and procedure specified for that lens. Fixed focal length does not mean that focus cannot be adjusted.

Measure sharpness on the images you will save

Use a consistent image region containing several target edges. Exclude glare, clipped areas, and large blank regions. Keep the region fixed while comparing positions; moving it onto stronger contrast can falsely suggest better focus.

A gradient-based sharpness score can help rank images, but its absolute value is not transferable between cameras or scenes. Noise and sharpening can also increase it. The focus-metric selection guide explains how to choose a measure that matches the image content.

For a practical search, take five stationary frames at each of ten permitted focus positions. That produces 10 × 5 = 50 images. Compare the median score at each position, then test five nearby positions with five frames each: another 5 × 5 = 25 images. The complete search uses 75 images, not 75 calibration poses.

Suppose neighboring positions produce median scores of 120, 150, and 147 in arbitrary units. The last score is 147 / 150 = 0.98, or 98% of the largest score. This suggests a broad peak worth examining, not an automatic acceptance threshold. Check whether the difference persists across repeated captures and whether corners remain equally usable.

Judge the center and outer target regions separately. A high central score can hide a tilted target, field curvature, or poor edge performance. Do not refocus for every target pose merely to maximize its score: changing optical geometry between poses undermines a single calibration model.

Separate defocus from inadequate sampling and motion

A target can be correctly focused yet contain features too small for reliable detection. Calculate image sampling before treating every failed detection as an optical problem.

For an illustrative setup, assume a 240 mm horizontal field of view spans 1920 image pixels. The object-space sampling is:

Object-space sampling = horizontal field of view / horizontal pixels Object-space sampling = 240 mm / 1920 pixels = 0.125 mm/pixel Feature width in pixels = feature width / object-space sampling Feature width in pixels = 0.5 mm / 0.125 mm/pixel = 4 pixels

Four pixels across a feature does not guarantee reliable calibration detection. Target layout, contrast, blur, perspective, and the detector's documented requirements still matter. Use the target coverage and margins guide when selecting target size and framing.

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

Motion can imitate defocus. At 20 mm/s target motion and 10 ms exposure, travel during exposure is 20 × 0.010 = 0.2 mm. With the example sampling above, that is 0.2 / 0.125 = 1.6 pixels of smear. Pause the target before capture, or shorten exposure with suitable illumination.

Keep target construction in the diagnosis too. A warped sheet can place different regions at different distances. The calibration-target flatness guide helps distinguish a suitable printed target from one that needs a more stable substrate.

Control exposure without confusing it with focus

Focus stability and brightness stability are separate requirements. Locking focus does not automatically require disabling every automatic image control. Follow the calibration software's documented requirements, then verify that target features remain detectable throughout the pose sequence.

For the focus search, fixed exposure and gain make comparisons easier. Otherwise, changes in noise or contrast can move the sharpness score without improving optical focus. Keep sharpening and denoising consistent too.

During calibration capture, automatic exposure may be acceptable if it preserves usable target contrast and avoids excessive motion blur. Manual exposure may be preferable under controlled illumination. Neither choice corrects a badly focused lens.

Avoid universal advice to disable or enable white balance. Its relevance depends on the image channel and detector. The immediate checks are unclipped features, adequate contrast, and consistent processing. For a separate treatment of these controls, use the exposure, gain, and balance guide.

Verify persistence before collecting calibration poses

A successful focus adjustment in a viewer is only the first check. Close the viewer, start calibration from its normal entry point, and save several stationary target images. Confirm that startup has not replaced the chosen setting.

As a practical screening test, perform three independent application launches and save five frames from each. Compare all 15 images using the same region and processing. This is not a universal qualification requirement; it is a compact way to expose settings that disappear between sessions.

Then test the nearest and farthest target positions required by the calibration procedure without changing focus. Both must provide usable features. If they do not, reconsider target distances, aperture where adjustable, target size, or the optical design rather than refocusing between captures.

Record corner-detection success as well as visual sharpness. After fitting calibration, inspect residual patterns and verify independent measurements at representative positions. A low fitting error alone does not establish dimensional accuracy across the working volume.

If the camera, lens, focus, or mounting later changes, use the calibration recovery checks to decide what must be revalidated. Save the optical configuration alongside the calibration data so the two cannot be confused.

Check hardware requirements before replacing parts

Do not replace a camera solely because one application's manual focus preset produces blur. First establish whether the device can form a sharp image at the required distance through its documented controls.

When evaluating replacement area scan cameras, use the camera finder to narrow interface, shutter, and sensor requirements. Confirm focus-control capability separately; those filters do not establish it.

For interchangeable machine vision lenses, use the lens finder to check mount, sensor coverage, focal length, and working-distance requirements. These catalog examples illustrate different focal-length options, not drop-in replacements for an integrated optical assembly.

The LS-FFL-0602 is an 8.5 mm, C-mount machine vision lens.

Machine vision lenses8.5 mm, 1", 10 MP, C-mount machine vision lens (LS-FFL-0602)LS-FFL-0602
Type
Machine vision fixed
Sensor format
1"
Mount
C-mount
Resolution
6-10 MP
$429.00View partBuild a system with it

The LS-FFL-0567 is a 16 mm, C-mount machine vision lens.

Machine vision lenses16 mm, 1.1", 20 MP, C-mount machine vision lens, F2.8-22, <0.3% distortion (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it

Neither focal length alone establishes suitability. Confirm mechanical clearance, image-circle coverage, required field of view, focus range, and the method for securing the final adjustment before ordering.

Final checks before the calibration run

  • Correct channel: the saved image comes from the camera you adjusted, not another channel or preview stream.
  • Known optical state: focus, aperture where adjustable, and target distance are recorded.
  • Stable startup: the calibration application preserves the intended focus setting after initialization.
  • Usable images: target edges remain distinct without clipping, motion smear, or aggressive processing artifacts.
  • Adequate depth coverage: required target poses remain usable without changing focus.
  • Persistent records: calibration files identify the camera, stream configuration, and optical setting used to create them.

If the setup cannot pass these checks, stop before collecting more poses. More blurred images rarely clarify the fault. For a new optical setup, start with the lens configurator; for an unresolved focus mismatch, send the configuration and representative saved images through applications support.

Questions

Why is the viewer sharp but the calibration image blurry?

A viewer may use autofocus while calibration loads a manual preset or a different stream configuration. Compare saved images at native resolution and read the active settings after initialization. Also check exposure and target motion, since motion smear can resemble an optical focus error.

Should autofocus remain enabled during calibration?

Generally, establish focus before collecting images and hold it constant throughout the dataset. Refocusing can change the camera's effective optical geometry. If required target poses become unusable at that setting, revise the capture distances or optical setup rather than adjusting focus between poses.

Can the same manual focus value be used on another camera?

Do not assume that the same command represents the same distance on another camera or lens assembly. Use the documented control range and find the position experimentally at the intended working distance. Record the camera identity and configuration together with the successful setting.

Does changing focus require a new calibration?

A focus change can alter effective focal length, magnification, and distortion, even when the mounting stays untouched. Revalidate calibration after an adjustment and repeat calibration when the previous model no longer meets the application's accuracy requirements. Keep the intended focus state fixed during that assessment.