% Auto-generated by cameraCalibrator app on 11-Nov-2021
%-------------------------------------------------------
% Define images to process
imageFileNames = {'C:\Users\YuanQuan\Desktop\1\IMG_0915.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0916.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0917.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0918.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0919.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0920.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0921.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0922.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0923.JPG',...
'C:\Users\YuanQuan\Desktop\1\IMG_0924.JPG',...
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Generate world coordinates of the corners of the squares
squareSize = 25; % in units of 'mm'
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, ...
'EstimateSkew', true, 'EstimateTangentialDistortion', true, ...
'NumRadialDistortionCoefficients', 3, 'WorldUnits', 'mm', ...
'InitialIntrinsicMatrix', [], 'InitialRadialDistortion', []);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams, 'BarGraph');
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, 'CameraCentric');
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
originalImage = imread(imageFileNames{1});
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo('MeasuringPlanarObjectsExample')
% showdemo('StructureFromMotionExample')
% Auto-generated by cameraCalibrator app on 11-Nov-2021%-------------------------------------------------------% Define images to processimageFileNames = {'C:\Users\YuanQuan\Desktop\1\IMG_0915.JPG',... 'C:\Users\YuanQuan\Desktop\1\IMG_0916.JPG',...