Main Content

showExtrinsics

Visualize extrinsic camera parameters

Description

example

showExtrinsics(cameraParams) renders a 3-D visualization of extrinsic parameters of a single calibrated camera or a calibrated stereo pair. The function plots a 3-D view of the calibration patterns with respect to the camera. The cameraParams input contains either a cameraParameters, fisheyeParameters, or a stereoParameters object, which the estimateCameraParameters or estimateFisheyeParameters function returns.

The showExtrinsics function shows the 3-D view of the calibration pattern as a convex polygon containing all the detected keypoints of the pattern in the original calibration image.

example

showExtrinsics(cameraParams,view) displays visualization of the camera extrinsic parameters using the style specified by the view input.

example

showExtrinsics(___,Name,Value) uses additional options specified by one or more Name,Value pair arguments, using any of the preceding syntaxes.

example

ax = showExtrinsics(___) returns the plot axis, using any of the preceding syntaxes.

Examples

collapse all

Create a set of calibration images.

images = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
  'calibration','webcam'));
imageFileNames = images.Files(1:5);

Detect calibration pattern.

[imagePoints,boardSize] = detectCheckerboardPoints(imageFileNames);

Generate world coordinates of the corners of the squares. The square size is in millimeters.

squareSide = 25;
worldPoints = generateCheckerboardPoints(boardSize,squareSide);

Calibrate the camera.

I = readimage(images,1); 
imageSize = [size(I, 1), size(I, 2)];
cameraParams = estimateCameraParameters(imagePoints,worldPoints, ...
                                  'ImageSize',imageSize);

Visualize pattern locations.

figure
showExtrinsics(cameraParams);

Figure contains an axes object. The axes object with title Extrinsic Parameters Visualization, xlabel X (mm), ylabel Z (mm) contains 15 objects of type patch, text, line.

Visualize camera locations.

figure
showExtrinsics(cameraParams,'patternCentric');

Figure contains an axes object. The axes object with title Extrinsic Parameters Visualization, xlabel X (mm), ylabel Y (mm) contains 27 objects of type patch, text, line.

Specify calibration images.

imageDir = fullfile(toolboxdir('vision'),'visiondata',...
        'calibration','circleGrid','stereo');
leftImages = imageDatastore(fullfile(imageDir,'left'));
rightImages = imageDatastore(fullfile(imageDir,'right'));
leftImageFileNames = leftImages.Files(2:2:10);
rightImageFileNames = rightImages.Files(2:2:10);

Define the circle grid pattern dimensions, and detect the pattern in the images.

patternDims = [4 11];
imagePoints = detectCircleGridPoints(leftImageFileNames,...
        rightImageFileNames,patternDims);

Specify the world coordinates for the circle grid keypoints. Center distance is in millimeters.

centerDistance = 36.5;
worldPoints = generateCircleGridPoints(patternDims,centerDistance);

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

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

Visualize pattern locations.

figure
showExtrinsics(cameraParams)

Figure contains an axes object. The axes object with title Extrinsic Parameters Visualization, xlabel X (mm), ylabel Z (mm) contains 18 objects of type patch, text, line.

Visualize camera locations.

figure
showExtrinsics(cameraParams,'patternCentric')

Figure contains an axes object. The axes object with title Extrinsic Parameters Visualization, xlabel X (mm), ylabel Y (mm) contains 62 objects of type patch, text, line.

Input Arguments

collapse all

Object containing parameters of single camera or stereo pair, specified as either a cameraParameters, fisheyeParameters, or stereoParameters object. You can create the single camera or stereo pair input object using the estimateCameraParameters function. The fisheye parameters input object is created using estimateFisheyeParameters.

You can also use the Camera Calibrator app to create the cameraParameters input object, or use Stereo Camera Calibrator app to create the stereoParameters input object. See Using the Single Camera Calibrator App and Using the Stereo Camera Calibrator App.

Camera or pattern-centric view, specified as 'CameraCentric' or 'PatternCentric'. The view input sets the visualization for the camera extrinsic parameters. If you keep your camera stationary while moving the calibration pattern, set view to 'CameraCentric'. If the pattern is stationary while you move your camera, set it to 'PatternCentric'.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'HighlightIndex', [1, 4] sets the 'HighlightIndex' to patterns 1 and 4.

Highlight selection index, specified as a scalar or a vector of integers. For example, if you want to highlight patterns 1 and 4, use [1, 4]. Doing so increases the opacity of patterns 1 and 4 in contrast to the rest of the patterns.

Output axes, specified as the comma-separated pair consisting of 'Parent' and an axes. You can obtain the current axes handle by returning the function to an output variable:

ax = showExtrinsics(cameraParams)

You can also use the gca function to get the current axes handle.

Example: showExtrinsics(cameraParams,'Parent',ax)

Output Arguments

collapse all

Current axes handle, returned as a scalar value. The function returns the handle to the current axes for the current figure.

Example: ax = showExtrinsics(cameraParams)

Version History

Introduced in R2014a