实验准备

- 准备相机,此处使用PC自带相机
- 准备标定图像,此处使用IPad显示标定板图像,使用相机拍摄不同方向的标定板照片共20张

标定过程
- 在matlab中选择Camera Calibrator APP

- 导入图像并设置棋盘格的宽度为20
- 由于光线及拍摄原因,部分图像中棋盘格的数量识别出错,可用的图像共计13张

实验结果
- Extrinsic Parameters Visualization






val(:,:,1) =
0.9987 -0.0122 0.0496
0.0083 0.9969 0.0782
-0.0504 -0.0777 0.9957
val(:,:,2) =
0.9519 0.0484 0.3026
-0.0464 0.9988 -0.0139
-0.3029 -0.0008 0.9530
val(:,:,3) =
0.9352 -0.3501 0.0530
0.3504 0.9366 0.0054
-0.0515 0.0135 0.9986
val(:,:,4) =
0.9032 0.1725 -0.3930
-0.1000 0.9750 0.1982
0.4174 -0.1398 0.8979
val(:,:,5) =
0.9070 0.0598 -0.4170
-0.0180 0.9945 0.1036
0.4209 -0.0865 0.9030
val(:,:,6) =
0.9915 -0.0094 0.1299
0.0032 0.9989 0.0478
-0.1301 -0.0470 0.9904
val(:,:,7) =
0.9824 0.1535 0.1061
-0.1614 0.9844 0.0702
-0.0937 -0.0861 0.9919
val(:,:,8) =
0.9742 -0.2075 0.0890
0.2055 0.9782 0.0302
-0.0933 -0.0111 0.9956
val(:,:,9) =
0.9899 0.0799 0.1174
-0.0874 0.9944 0.0599
-0.1119 -0.0695 0.9913
val(:,:,10) =
0.9143 -0.2046 0.3496
0.2421 0.9679 -0.0669
-0.3247 0.1458 0.9345
val(:,:,11) =
0.8366 -0.3250 0.4410
0.4657 0.8459 -0.2601
-0.2885 0.4229 0.8590
val(:,:,12) =
0.9434 -0.3305 -0.0265
0.3316 0.9413 0.0631
0.0041 -0.0683 0.9977
val(:,:,13) =
0.9609 0.2743 -0.0373
-0.2434 0.9014 0.3582
0.1319 -0.3351 0.9329





- MATLAB代码
% Define images to process
imageFileNames = {'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_55_29_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_58_42_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_56_11_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_58_35_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_58_39_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_55_57_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_55_59_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_56_02_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_56_06_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_58_44_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_58_47_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_55_37_Pro.jpg',...
'D:\Documents\NewWork\Codes\MATLAB\calibrationExp\Images\WIN_20231207_10_55_49_Pro.jpg',...
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Generate world coordinates of the corners of the squares
squareSize = 20; % in units of 'mm'
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, ...
'EstimateSkew', false, 'EstimateTangentialDistortion', false, ...
'NumRadialDistortionCoefficients', 2, 'WorldUnits', 'mm', ...
'InitialIntrinsicMatrix', [], 'InitialRadialDistortion', []);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams, 'PatternCentric');
% 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);
提高校准精度的方法
- 修改标定设置。尝试使用 3 个径向畸变系数,估计切向畸变或偏斜。
- 拍摄更多标定图像。图像中的图案必须处于不同的 3D 方向,并且其位置应确保在视野的所有部分都有关键点。特别是让关键点靠近图像的边缘和角落非常重要,以便更好地估计失真系数。
- 排除重投影错误高的图像并重新标定。
参考内容