Main Content


Convert a stereo parameters object into a struct



paramStruct = toStruct(stereoParams) returns a struct containing the stereo parameters in the stereoParams input object. You can use the struct to create an identical stereoParameters object. Use the struct for C code generation. You can call toStruct, and then pass the resulting structure into the generated code, which recreates the stereoParameters object.


collapse all

Specify calibration images.

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

Detect the checkerboards.

[imagePoints,boardSize] = ...

Specify the world coordinates of the checkerboard keypoints. Square size is in millimeters.

squareSize = 108;
worldPoints = generateCheckerboardPoints(boardSize,squareSize);

Calibrate the stereo camera system. Both cameras have the same resolution.

I = readimage(leftImages,1); 
imageSize = [size(I,1) size(I,2)];
params = estimateCameraParameters(imagePoints,worldPoints, ...

Visualize the calibration accuracy.


Visualize camera extrinsics.


Convert to structure.

paramsStruct = toStruct(params)
paramsStruct = struct with fields:
       CameraParameters1: [1x1 struct]
       CameraParameters2: [1x1 struct]
       RotationOfCamera2: [3x3 double]
    TranslationOfCamera2: [-119.8720 -0.4005 -0.0258]
                 Version: [1x1 struct]
     RectificationParams: [1x1 struct]

Input Arguments

collapse all

Stereo parameters, specified as a stereoParameters object. The object contains the parameters of the stereo camera system.

Output Arguments

collapse all

Stereo parameters, returned as a stereo parameters struct.

Version History

Introduced in R2015a