-
Notifications
You must be signed in to change notification settings - Fork 1
/
CalibrateCamera.m
47 lines (39 loc) · 1.75 KB
/
CalibrateCamera.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%% Info
%{
owners: mertkosan (Mert Kosan), mbenlioglu(Muhammed Mucahid Benlioglu)
created date: 10.01.2017
Camera Calibration using computer vision toolbox
%}
%% Calibration
% Define images to process
imageFileNames = {'CalibrationImages/2/20170110_233339.jpg',...
'CalibrationImages/2/20170110_233343.jpg',...
'CalibrationImages/2/20170110_233347.jpg',...
'CalibrationImages/2/20170110_233350.jpg',...
'CalibrationImages/2/20170110_233352.jpg',...
'CalibrationImages/2/20170110_233409.jpg',...
'CalibrationImages/2/20170110_233411.jpg',...
'CalibrationImages/2/20170110_233412.jpg',...
'CalibrationImages/2/20170110_233415.jpg',...
'CalibrationImages/2/20170110_233416.jpg',...
'CalibrationImages/2/20170110_233418.jpg',...
'CalibrationImages/2/20170110_233422.jpg',...
'CalibrationImages/2/20170110_233424.jpg',...
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Generate world coordinates of the corners of the squares
squareSize = 10; % 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, 'BarGraph');
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, 'CameraCentric');
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);