Documentation

stereoParameters class

Object for storing stereo camera system parameters

Syntax

stereoParams = stereoParameters(cameraParameters1,cameraParameters2,rotationOfCamera2,translationOfCamera2)
stereoParams = stereoParameters(paramStruct)

Construction

stereoParams = stereoParameters(cameraParameters1,cameraParameters2,rotationOfCamera2,translationOfCamera2) returns an object that contains the parameters of a stereo camera system.

stereoParams = stereoParameters(paramStruct) returns a stereoParameters object containing the parameters specified by paramStruct input. paramStruct is returned by the toStruct method.

Code Generation Support:
Supports Code Generation: Yes
Supports MATLAB Function block: No
Code Generation Support, Usage Notes, and Limitations
Use the toStruct method to pass a stereoParameters object into generated code. See the Code Generation for Depth Estimation From Stereo Video example.

Input Arguments

expand all

cameraParameters1 — Parameters of camera 1cameraParameters object

Parameters of camera 1, specified as a cameraParameters object. You can return this object using the estimateCameraParameters function or the Camera Calibrator app. This object contains the intrinsic, extrinsic, and lens distortion parameters of camera 1.

cameraParameters2 — Parameters of camera 2cameraParameters object

Parameters of camera 2, specified as a cameraParameters object. You can return this object using the estimateCameraParameters function or the Camera Calibrator app. This object contains the intrinsic, extrinsic, and lens distortion parameters of camera 2.

rotationOfCamera2 — Rotation of camera 23-by-3 matrix

Rotation of camera 2 relative to camera 1, specified as a 3-by-3 matrix.

translationOfCamera2 — Translation of camera 23-element vector

Translation of camera 2 relative to camera 1, specified as a 3-element vector.

Properties

expand all

Intrinsic and extrinsic parameters of the two cameras:

CameraParameters1Parameters of camera 1cameraParameters object

Parameters of camera 1 , specified as a cameraParameters object. The object contains the intrinsic, extrinsic, and lens distortion parameters of a camera.

CameraParameters2Parameters of camera 2cameraParameters object

Parameters of camera 2 , specified as a cameraParameters object. The object contains the intrinsic, extrinsic, and lens distortion parameters of a camera.


Geometric relationship between the two cameras

RotationOfCamera2Rotation of camera 23-by-3 matrix

Rotation of camera 2 relative to camera 1, specified as a 3-by-3 matrix.

TranslationOfCamera2Translation of camera 23-element vector

Translation of camera 2 relative to camera 1, specified as a 3-element vector.

FundamentalMatrixFundamental matrix3-by-3 matrix

Fundamental matrix, stored as a 3-by-3 matrix. The fundamental matrix relates the two stereo cameras, such that the following equation must be true:

[P21]*FundamentalMatrix*[P11]'=0

P1, the point in image 1 in pixels, corresponds to the point, P2, in image 2.

EssentialMatrixEssential matrix3-by-3 matrix

Essential matrix, stored as a 3-by-3 matrix. The essential matrix relates the two stereo cameras, such that the following equation must be true:

[P21]*EssentialMatrix*[P11]'=0

P1, the point in image 1, corresponds to P2, the point in image 2. Both points are expressed in normalized image coordinates, where the origin is at the camera's optical center. The x and y pixel coordinates are normalized by the focal length fx and fy.


Accuracy of estimated parameters:

MeanReprojectionErrorAverage Euclidean distancenumber of pixels

Average Euclidean distance between reprojected points and detected points over all image pairs, specified in pixels.


Accuracy of estimated parameters:

NumPatternsNumber of calibrated patternsinteger

Number of calibration patterns that estimate the extrinsics of the two cameras, stored as an integer.

WorldPointsWorld coordinatesM-by-2 array

World coordinates of key points in the calibration pattern, specified as an M-by-2 array. M represents the number of key points in the pattern.

WorldUnitsWorld points units'mm' (default) | string

World points units, specified as a string. The string describes the units of measure.

Methods

toStructConvert a stereo parameters object into a struct

Output Arguments

expand all

stereoParams — Stereo parameters stereoParameters object

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

Examples

expand all

Stereo Camera Calibration

Specify calibration images.

imageDir = fullfile(toolboxdir('vision'),'visiondata','calibration','stereo');
leftImages = imageSet(fullfile(imageDir,'left'));
rightImages = imageSet(fullfile(imageDir,'right'));
images1 = leftImages.ImageLocation;
images2 = rightImages.ImageLocation;

Detect the checkerboards.

[imagePoints, boardSize] = detectCheckerboardPoints(images1,images2);

Specify the world coordinates of the checkerboard keypoints.

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

Calibrate the stereo camera system.

im = read(leftImages,1);
params = estimateCameraParameters(imagePoints,worldPoints);

Visualize the calibration accuracy.

showReprojectionErrors(params);

References

[1] Zhang, Z. "A Flexible New Technique for Camera Calibration". IEEE Transactions on Pattern Analysis and Machine Intelligence.Vol. 22, No. 11, 2000, pp. 1330–1334.

[2] Heikkila, J, and O. Silven. "A Four-step Camera Calibration Procedure with Implicit Image Correction." IEEE International Conference on Computer Vision and Pattern Recognition. 1997.

Introduced in R2014a

Was this topic helpful?