This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Visualize calibration errors


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

Create a set of calibration images.

images = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
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.

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

Calibrate the camera.

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

Visualize the errors as a bar graph.


Visualize the errors as a scatter plot.


Specify calibration images

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

Detect the checkerboards.

[imagePoints, boardSize] = detectCheckerboardPoints(...

Specify world coordinates of checkerboard keypoints. The square size is in millimeters.

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

Calibrate the stereo camera system. Here both cameras have the same resolution.

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

Visualize calibration accuracy.


Input Arguments

collapse all

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.

Bar graph or scatter plot view, specified as the character vector '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.

collapse all

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.

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

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?