This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

stereoParameters

Object for storing stereo camera system parameters

Description

The stereoParameters object stores the intrinsic and extrinsic parameters of two cameras and their geometric relationship.

Creation

You can create a stereoParameters object using the stereoParameters function described here. You can also create a stereoParameters object by using the estimateCameraParameters with an M-by-2-by-numImages-by-2 array of input image points, where M is the number of keypoint coordinates in each pattern.

Syntax

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

Description

example

stereoParams = stereoParameters(cameraParameters1,cameraParameters2,rotationOfCamera2,translationOfCamera2) creates a stereoParameters object that contains the parameters of a stereo camera system, and sets the CameraParameters1, CameraParameters2, RotationOfCamera2, and TranslationOfCamera2 properties.

stereoParams = stereoParameters(paramStruct) creates an identical stereoParameters object from an existing stereoParameters object with parameters stored in paramStruct.

Input Arguments

expand all

Stereo parameters, specified as a stereo parameters struct. To get a paramStruct from an existing stereoParameters object, use the toStruct function.

Properties

expand all

Intrinsic and extrinsic parameters of the two cameras

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

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

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

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

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.

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

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

Settings for camera parameter estimation

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

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.

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

Object Functions

toStructConvert a stereo parameters object into a struct

Examples

collapse all

Specify calibration images.

leftImages = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
    'calibration','stereo','left'));
rightImages = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
    'calibration','stereo','right'));

Detect the checkerboards.

[imagePoints,boardSize] = ...
  detectCheckerboardPoints(leftImages.Files,rightImages.Files);

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, ...
                                  'ImageSize',imageSize);

Visualize the calibration accuracy.

  showReprojectionErrors(params);

Visualize camera extrinsics.

figure;
showExtrinsics(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.

Extended Capabilities

Introduced in R2014a