forked from AbdullahAZaidi/Stereo_Calibration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matlab_StereoCal.mat
64 lines (42 loc) · 1.85 KB
/
matlab_StereoCal.mat
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Stereo Camera Calibration
Specify calibration images.
clear;
leftImages = imageDatastore(fullfile('C:\Users\abdul\OneDrive\Pictures\Camera Roll\stereo_calib\blur_left_cam_0.5_new'));
% leftImages = imageDatastore(fullfile( 'C:\Users\abdul\OneDrive\Pictures\Camera Roll\stereo_calib\left_new'));
rightImages = imageDatastore(fullfile('C:\Users\abdul\OneDrive\Pictures\Camera Roll\stereo_calib\right_new'));
% destdirectory1 = 'C:\Users\abdul\OneDrive\Pictures\Camera Roll\stereo_calib\blur_left_cam_0.5_new'
% % Perturb the images on the left_camera
% for i = 1:1:6
% leftImages_a = readimage(leftImages,i)
% h3 = fspecial('gaussian', [64 64], 4);
% leftImages_b = imfilter(leftImages_a, h3, 'replicate')
% % leftImages_b = imrotate(leftImages_a,1)
% baseFileName1 = sprintf('Image #%d.png', i);
% fullFileName1 = fullfile(destdirectory1, baseFileName1);
% imwrite(leftImages_b, fullFileName1);
%
% end
Detect the checkerboards.
[imagePoints,boardSize] = ...
detectCheckerboardPoints(leftImages.Files,rightImages.Files);
Specify the world coordinates of the checkerboard keypoints. Square size is in millimeters.
squareSize = 25;
worldPoints = generateCheckerboardPoints(boardSize,squareSize);
Calibrate the stereo camera system. Both cameras have the same resolution.
I = readimage(leftImages,5);
I_r = readimage(rightImages,5);
% I = imgaussfilt(I_o,4)
I_blur = imgaussfilt(I,1.2)
imagesc(I_blur)
imageSize = [size(I,1),size(I,2)];
params = estimateCameraParameters(imagePoints,worldPoints, ...
'ImageSize',imageSize);
[J1_valid,J2_valid] = rectifyStereoImages(I,I_r,params, ...
'OutputView','valid');
figure;
imshow(stereoAnaglyph(J1_valid,J2_valid));
Visualize the calibration accuracy.
showReprojectionErrors(params);
Visualize camera extrinsics.
figure;
showExtrinsics(params);