Visualize calibration errors


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



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.


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


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


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


collapse 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','visiondata','calibration','webcam',imageFileName);

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);

Visualize errors as a scatter plot.


Visualize Reprojection Errors for Stereo Pair of Cameras

Specify the 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 checkerboard patterns.

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

Specify the world coordinates of the checkerboard keypoints.

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

Calibrate the stereo camera system.

params = estimateCameraParameters(imagePoints,worldPoints);

Visualize the calibration accuracy.


Input Arguments

collapse 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 Camera Calibrator app to create the cameraParameters input object, or use Stereo Camera Calibrator app to create the stereoParameters input object. See Single Camera Calibration App and Stereo Calibration App.

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

collapse 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)

Introduced in R2014a

Was this topic helpful?