How to calibrate a camera

How to calibrate a camera
— · 0 votes

Calibrating a camera means measuring how its lens and sensor bend light, then storing those numbers so software can correct the image. You photograph a known target such as a checkerboard from several angles and let software solve for the camera intrinsics and lens distortion. The same idea applies to phone cameras, machine-vision setups, and the cameras used by driver assistance systems.

  • A checkerboard or similar target of known geometry is the reference that makes calibration possible.
  • Cover the full frame with target views at different tilts and distances to constrain the solution.
  • Calibration returns intrinsic parameters plus distortion coefficients that describe how the lens bends straight lines.
  • Extrinsic parameters describe where the camera sits relative to the world, not how its lens behaves.
  • A calibration is only as good as its input images, so blurry or repeated views weaken the result.

What camera calibration actually measures

Camera calibration is the process of estimating the numbers that describe how a specific lens and sensor form an image. The main outputs are the focal length in pixels, the principal point, and coefficients that model lens distortion. Together these form the camera intrinsics.

The focal length in pixels tells software how strongly the lens compresses the scene onto the sensor. The principal point marks where the optical axis meets the image plane, which is rarely the exact center. Distortion coefficients describe how straight lines bow outward or inward near the edges.

Extrinsic parameters are the camera position and orientation relative to a scene or a vehicle. Intrinsic calibration measures the lens alone, so it does not depend on where the camera is mounted. Extrinsics come later, once you know how the camera sees.

Build or choose a calibration target

A calibration target is a flat pattern with features at known positions, and a checkerboard is the classic choice. Print the board on a rigid, flat surface so it cannot warp, because a curved target gives false results. Laminate or mount it on a board to keep it flat.

The squares must be true squares, and you need to know the real size of one square in millimeters. Measure the printed square with a ruler and record the value, since the software scales the whole solution from it. A printer that stretches the pattern will bias the focal length estimate.

Calibration targets also include dot grids, charuco boards, and circle patterns. A charuco board mixes checkerboard squares with markers, which helps software find the corners when part of the board is hidden. Any target works if its geometry is known and its features are sharp.

Capture images that constrain the solution

Calibration software needs several views of the target, and the poses must differ enough to separate focal length from distortion. Tilt the board forward, back, left, and right, and place it in the corners of the frame. Keep the whole board visible in each shot.

Aim for a spread of distances, from a view where the board fills the frame to a view where it sits small in the center. Sharp images matter more than a large count, because a blurred corner cannot be located precisely. Avoid motion blur by holding the board still or resting it on a support.

Photograph the board in the lighting you expect to work in, and avoid glare on a glossy print. Filling the frame with views that all look alike leaves the distortion model poorly constrained. A handful of varied, sharp views serves you better than many near-identical ones.

Run checkerboard calibration in software

Checkerboard calibration works by finding the inner corners of the squares in every image, then solving for the camera model. OpenCV calibration is the reference implementation, and many tools wrap it. The procedure is the same whatever library you use.

First, tell the software the board dimensions in inner corners, not squares. Then detect the corners in each image and check that the detected grid lines up with the print. Finally, feed the point sets and the square size into the calibration routine.

The routine returns the camera matrix, the distortion coefficients, and an error value for each view. Inspect the error per image and drop views that are far out of line with the rest. Re-run the calibration after removing bad views and compare the result.

  • Print the checkerboard on rigid material and measure one square.
  • State the board size in inner corners, not in squares.
  • Detect corners in every image and confirm the overlay matches.
  • Pass the corner points plus the real square size to the solver.
  • Review the per-view error and discard poor captures.
  • Re-run and keep the coefficients that fit the remaining views.

Read intrinsic parameters and distortion

The camera matrix holds the focal length in pixels and the principal point as a small grid of numbers. Distortion coefficients sit beside it and describe radial and tangential error. Radial distortion bows lines outward or inward from the center.

Tangential distortion comes from the lens not sitting parallel to the sensor. These coefficients let software remap each pixel so the image behaves like an ideal pinhole camera. The corrected image is what you feed to measurement or detection code.

Store the camera matrix and distortion coefficients together with the image resolution they were measured at. Changing resolution or cropping the frame invalidates the numbers, so rescale them deliberately. A calibration file without its resolution is easy to misuse.

Calibrate a phone camera

A phone camera can be calibrated with the same checkerboard method, using an app or a desktop tool that reads photos. The camera intrinsics of a phone lens are fixed, so one careful session covers that lens. Switch lenses and you need a separate calibration for each one.

How to calibrate the camera on an iPhone or an Android phone comes down to capturing varied views and running the solver. Use the native camera app without digital zoom, and lock focus if the app allows it. Digital zoom, stabilization crops, and portrait blur all change the geometry.

Phone software already corrects the image before you see it, so calibrating the raw stream gives different numbers than the processed output. Decide which stream your application uses and calibrate that one. For augmented reality or measurement work, the raw stream matters.

Calibrate a camera in LightBurn

LightBurn uses a camera to align laser work with the material bed, and it has a built-in calibration wizard. How to calibrate the camera in LightBurn runs through that wizard rather than a checkerboard solver. The wizard asks you to place a printed pattern on the bed and capture it.

Mount the camera rigidly first, because any movement after calibration spoils the alignment. Follow the wizard prompts to capture the pattern, then let the software compute the correction. Use the overlay preview to check that the captured image lines up with the bed.

LightBurn's pattern corrects the view for alignment with the laser, and it is not an intrinsic calibration in the OpenCV sense. Re-run the wizard after moving the camera, changing its lens, or changing the bed height. A loose mount is the main reason an alignment drifts.

Calibrate where driver assistance depends on it

Driver assistance systems rely on cameras whose aim and lens behavior must be known before lane or distance estimates are trusted. A forward camera needs both intrinsic calibration and an extrinsic alignment to the vehicle. Windshield replacement or a changed ride height can shift the mounting.

Intrinsic work on a vehicle camera uses the same target-based method, sometimes with a target held in front of the lens. Extrinsic alignment aims the camera at a known target position relative to the vehicle axis. Many vehicles require a diagnostic tool to store the new alignment.

Calibration of an ADAS camera can affect braking and steering assistance, so a trained technician should perform it. Aiming a forward camera by eye is not safe, and the vehicle may need a level floor and correct tire pressure. Leave the procedure to a shop with the right targets and scan tool.

Camera Calibration Questions

How many images do I need to calibrate a camera?

A calibration needs enough varied views to constrain focal length, principal point, and distortion together. A small set of sharp, diverse poses can work, but more views spread across the frame and tilt range make the result steadier. Judge the set by its error values, not by its count alone.

Can I calibrate a camera with a checkerboard printed at home?

Yes, a home-printed checkerboard works if the print is flat, sharp, and accurately measured. Glue the sheet to a rigid board so it cannot bend, and measure one square with a ruler. A warped or stretched print biases the camera intrinsics.

What is the difference between intrinsic and extrinsic parameters?

Intrinsic parameters describe the camera itself: focal length in pixels, principal point, and lens distortion. Extrinsic parameters describe where the camera is placed and how it is rotated relative to a scene or vehicle. Calibrate the intrinsics first, then determine the extrinsics for the mount.

Why does my camera calibration error stay high?

A high error points to bad input, such as blurred corners, a warped target, or repeated board poses. Check that the board size is given in inner corners and that the square size is correct. Remove the worst views and re-run before changing anything else.

Does calibrating a phone camera improve photo quality?

No, calibrating a phone camera does not change how the camera app saves everyday photos. It produces numbers for software that measures or corrects the image, such as computer vision or augmented reality code. The phone's own processing still shapes the photos you see.

Can I calibrate a camera used for Govee TV lights?

Govee TV light cameras use their own setup routine in the companion app, and that routine handles the alignment for the light strip. Follow the app's placement and calibration steps rather than a checkerboard solver. Moving the camera after setup requires running the alignment again.

Read next

Latest articles