clear
close all
imageFileNames = {'C:\ece564\stereo\stereo2\cam1_image_1.jpg',...
'C:\ece564\stereo\stereo2\cam1_image_3.jpg',...
'C:\ece564\stereo\stereo2\cam1_image_6.jpg',...
'C:\ece564\stereo\stereo2\cam1_image_8.jpg',...
};
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
squareSize = 3;
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
cameraParams = estimateCameraParameters(imagePoints, worldPoints, ...
'EstimateSkew', false, 'EstimateTangentialDistortion', false, ...
'NumRadialDistortionCoefficients', 2, 'WorldUnits', 'in');
h1=figure; showReprojectionErrors(cameraParams, 'BarGraph');
h2=figure; showExtrinsics(cameraParams, 'CameraCentric');
originalImage = imread(imageFileNames{1});
undistortedImage = undistortImage(originalImage, cameraParams);
Warning: The checkerboard must be asymmetric:
one side should be even, and the other should
be odd. Otherwise, the orientation of the board
may be detected incorrectly.