Documentation Center

  • Trial Software
  • Product Updates

showReprojectionErrors

Visualize calibration errors

Syntax

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

Description

example

showReprojectionErrors(cameraParams) displays a bar graph that represents the calibration accuracy for a single camera or for a stereo pair. The bar graph displays the mean reprojection error per image. The cameraParams input contains either a cameraParameters or a stereoParameters object, which the estimateCameraParameters function returns.

example

showReprojectionErrors(cameraParams,view) displays the reprojection errors using the visualization style specified by the view input.

example

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

example

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

Examples

expand all

Visualize Reprojection Errors for a Single Camera

Create a cell array of calibration image file names.

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

Detect the calibration pattern.

    [imagePoints, boardSize] = detectCheckerboardPoints(imageFileNames);

Generate world coordinates for the corners of the squares.

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

Calibrate the camera.

    params = estimateCameraParameters(imagePoints, worldPoints);

Visualize errors as a bar graph.

    subplot(1, 2, 1);
    showReprojectionErrors(params);

Visualize errors as a scatter plot.

    subplot(1, 2, 2);
    showReprojectionErrors(params, 'ScatterPlot');

Visualize Reprojection Errors for a Stereo Pair of Cameras

Specify calibration images.

    numImages = 10;
    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 checkerboard patterns.

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

Specify world coordinates of checkerboard keypoints.

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

Calibrate the stereo camera system.

    params = estimateCameraParameters(imagePoints, worldPoints);

Visualize calibration accuracy.

    showReprojectionErrors(params);

Input Arguments

expand all

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

Object containing parameters of a 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 — Bar graph or scatter plot view'BarGraph' | 'ScatterPlot'

Bar graph or scatter plot view, specified as the character string 'BarGraph' or 'ScatterPlot'. The view input sets the visualization for the camera extrinsic parameters. Set view to 'BarGraph' to display the mean error per image as a bar graph. Set view to 'ScatterPlot' to display the error for each point as a scatter plot. The 'ScatterPlot' option applies only to the single camera case.

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: 'view','BarGraph' displays the mean error per image as a bar graph.

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

Highlight selection index, specified as a scalar or a vector of integers. When you set the view to 'BarGraph', the function highlights the bars corresponding to the selected images. When you set the view to 'ScatterPlot', the function highlights the points corresponding to the selected images with circle markers.

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

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

ax = showReprojectionErrors(cameraParams)


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

Example: showReprojectionErrors(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 = showReprojectionErrors(cameraParams)

See Also

| | | | | | |

Was this topic helpful?