Documentation Center

  • Trial Software
  • Product Updates

showExtrinsics

Visualize extrinsic camera parameters

Syntax

  • showExtrinsics(cameraParams) example
  • showExtrinsics(cameraParams,view) example
  • ax = showExtrinsics(___) example
  • showExtrinsics(___,Name,Value) example

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 or a stereoParameters object, which the estimateCameraParameters function returns.

example

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

example

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

example

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

Examples

expand all

Visualize Single Camera Extrinsic Parameters

Create a cell array of file names of calibration images.

    for i = 1:5
        imageFileName = sprintf('image%d.tif', i);
        imageFileNames{i} = fullfile(matlabroot, 'toolbox', 'vision',...
            'visiondemos', 'calibration', 'webcam', imageFileName);
    end

Detect calibration pattern.

    [imagePoints, boardSize] = detectCheckerboardPoints(imageFileNames);

Generate world coordinates of the corners of the squares,(squares are in mm).

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

Calibrate the camera.

    cameraParams = estimateCameraParameters(imagePoints, worldPoints);

Visualize pattern locations.

    figure; showExtrinsics(cameraParams);

Visualize camera locations.

    figure; showExtrinsics(cameraParams, 'patternCentric');

Visualize Stereo Pair of Camera Extrinsic Parameters

Specify calibration images.

    numImages = 5;
    images1 = cell(1, numImages);
    images2 = cell(1, numImages);
    for i = 1:numImages
      images1{i} = fullfile(matlabroot, 'toolbox', 'vision', 'visiondemos', 'calibration', 'stereo', sprintf('left%02d.jpg', i));
      images2{i} = fullfile(matlabroot, 'toolbox', 'vision', 'visiondemos', 'calibration', 'stereo', sprintf('right%02d.jpg', i));
    end

Detect the checkerboards.

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

Specify world coordinates of checkerboard keypoints, (squares are in mm).

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

Calibrate the stereo camera system.

    cameraParams = estimateCameraParameters(imagePoints, worldPoints);

Visualize pattern locations.

    figure; showExtrinsics(cameraParams);

Visualize camera locations.

    figure; showExtrinsics(cameraParams, 'patternCentric');

Input Arguments

expand all

cameraParams — Object containing parameters of single camera or stereo paircameraParameters object | stereoParameters object

Object containing parameters of single camera or stereo pair, specified as either a cameraParameters or stereoParameters object. You can create the single camera or stereo pair input object using the estimateCameraParameters function. You can also use the cameraCalibrator app to create the single camera input object. See Find Camera Parameters with the Camera Calibrator.

view — Camera- or pattern-centric view'CameraCentric' | 'PatternCentric'

Camera or pattern-centric view, specified as the character string '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 Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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

'HighlightIndex' — Highlight selection index[] (default) | vector | scalar

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.

'Parent' — Output axescurrent axes (default) | scalar value

Output axes, specified as the comma-separated pair consisting of 'Parent' and a scalar value. Specify an output axes for displaying the visualization. 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

expand all

ax — Current axes handlescalar value

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)

See Also

| | | | | | |

Was this topic helpful?