Main Content


Estimate baseline of stereo camera



[stereoParams,pairsUsed,estimationErrors] = estimateStereoBaseline(imagePoints,worldPoints,intrinsics1,intrinsics2) estimates the translation and orientation between two cameras of the same resolution.

The estimateStereoBaseline function is best used for a stereo system with a wide baseline when the cameras are so far apart that you cannot capture the complete calibration pattern in the field-of-view of each camera. This function estimates extrinsic parameters using fixed camera intrinsics that have been estimated independently for each camera. Calibrating each camera independently results in more precise estimates of the intrinsics.

[stereoParams,pairsUsed,estimationErrors] = estimateStereoBaseline(imagePoints,worldPoints,intrinsics1,intrinsics2,'WorldUnits',units) specifies the units in which worldPoints are measured.


collapse all

Load camera intrinsic parameters.

ld = load('wideBaselineStereo');

Specify stereo calibration images.

leftImages = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
rightImages = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...

Detect the checkerboards.

[imagePoints, boardSize] = ...

Specify world coordinates of checkerboard keypoints.

squareSize = 29; % in millimeters
worldPoints = generateCheckerboardPoints(boardSize,squareSize);

Estimate the baseline and extrinsic parameters.

params = estimateStereoBaseline(imagePoints,worldPoints, ...
params = 
  stereoParameters with properties:

   Parameters of Two Cameras
        CameraParameters1: [1x1 cameraParameters]
        CameraParameters2: [1x1 cameraParameters]

   Inter-camera Geometry
              PoseCamera2: [1x1 rigidtform3d]
        FundamentalMatrix: [3x3 double]
          EssentialMatrix: [3x3 double]

   Accuracy of Estimation
    MeanReprojectionError: 0.2586

   Calibration Settings
              NumPatterns: 6
              WorldPoints: [54x2 double]
               WorldUnits: 'mm'

Visualize calibration accuracy.


Visualize camera extrinsics.


Input Arguments

collapse all

Key points of calibration pattern, specified as an M-by-2-by-numPairs-by-2 array. The array contains the [x,y] intrinsic image coordinates of key points in the calibration pattern.

  • numPairs is the number of stereo image pairs containing the calibration pattern. Must be greater than 2.

  • The number of keypoint coordinates in each pattern, M, must be greater than 3.

  • imagePoints(:,:,:,1) are the points from camera 1.

  • imagePoints(:,:,:,2) are the points from camera 2.

Data Types: single | double

Key points of calibration pattern in world coordinates, specified as an M-by-2 array of M number of [x,y] world coordinates. The pattern must be planar; therefore, z-coordinates are zero.

Data Types: single | double

Intrinsic parameters of camera 1, specified as a cameraIntrinsics object. The intrinsics object stores information about a camera’s intrinsic calibration parameters, including lens distortion.

Intrinsic parameters of camera 2, specified as a cameraIntrinsics object. The intrinsics object stores information about a camera’s intrinsic calibration parameters, including lens distortion.

World points units, specified as a string representing units.

Output Arguments

collapse all

Camera parameters for stereo system, returned as a stereoParameters object. The object contains the intrinsic, extrinsic, and lens distortion parameters of the stereo camera system.

Image pairs used to estimate camera parameters, returned as a numPairs-by-1 logical array. A logical true value in the vector indicates which that the image pairs was used to estimate the camera parameters. An image pair will not be used for estimation if the algorithm fails to estimate a homography between the world points and the points detected in that pair of images.

Standard errors of estimated parameters, returned as a stereoCalibrationErrors object.

Version History

Introduced in R2018a