leftImages = imageDatastore(fullfile(toolboxdir('vision'), 'visiondata', ...
'calibration', 'stereo', 'left'));
rightImages = imageDatastore(fullfile(toolboxdir('vision'), 'visiondata', ...
'calibration', 'stereo', 'right'));
I = readimage(leftImages,1);
imageSize = [size(I, 1), size(I, 2)];
[imagePoints, boardSize] = ...
detectCheckerboardPoints(leftImages.Files, rightImages.Files);
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
[params, imgused, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, ...
[leftparams, leftimageUsed, leftestimationErrors] = ...
estimateCameraParameters(imagePoints(:,:,:,1), worldPoints, ...
[rightparams, rightimageUsed, rightestimationErrors] = ...
estimateCameraParameters(imagePoints(:,:,:,2), worldPoints, ...
[StereoParams, StereoPairsUsed, StereoEstimationErrors] = ...
estimateStereoBaseline(imagePoints, worldPoints, ...
leftparams, rightparams, 'WorldUnits', 'millimeters');
disp("Stereo calibration without prior intrinsics")
Stereo calibration without prior intrinsics
disp("MRE of camera 1: " + num2str(params.CameraParameters1.MeanReprojectionError))
MRE of camera 1: 0.056842
disp("MRE of camera 2: " + num2str(params.CameraParameters2.MeanReprojectionError))
MRE of camera 2: 0.057644
disp("Average MRE: " + num2str(params.MeanReprojectionError))
showReprojectionErrors(params);
title('Mean Reprojection Error per Image (without intrinsics)')
disp("Mono calibrations")
disp("MRE of camera 1: " + num2str(leftparams.MeanReprojectionError))
disp("MRE of camera 2: " + num2str(rightparams.MeanReprojectionError))
MRE of camera 2: 0.044418
disp("Stereo calibration with prior intrinsics")
Stereo calibration with prior intrinsics
disp("MRE of camera 1: " + num2str(StereoParams.CameraParameters1.MeanReprojectionError))
MRE of camera 1: 0.071023
disp("MRE of camera 2: " + num2str(StereoParams.CameraParameters2.MeanReprojectionError))
MRE of camera 2: 0.072068
disp("Average MRE: " + num2str(StereoParams.MeanReprojectionError))
showReprojectionErrors(StereoParams);
title('Mean Reprojection Error per Image (with intrinsics)')