-
Notifications
You must be signed in to change notification settings - Fork 5
/
webotsCameraProcess.m
executable file
·38 lines (28 loc) · 1022 Bytes
/
webotsCameraProcess.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
clear all; clc;
% L = R1*R2^(-1)*R + T1-R1*R2^(-1)*T2
% --------
% R = R1*R2^(-1)
% T = T1-R1*R2^(-1)*T2
camera_intrinc_path = './webots/cameraParams.mat';
load(camera_intrinc_path);
[~,~, cam_all_num] = size(cameraParams.RotationMatrices);
for i = 1 : cam_all_num
rotation_matrix{i} = cameraParams.RotationMatrices(:,:,i);
position(i,:) = cameraParams.TranslationVectors(i,:)';
end
% get [R T] between two cameras
cam1 = 2;
cam2 = 3;
camera.cam{1}.K = cameraParams.IntrinsicMatrix';
camera.cam{2}.K = cameraParams.IntrinsicMatrix';
camera.cam{1}.R = rotation_matrix{cam1};
camera.cam{1}.T = position(cam1,:)';
camera.cam{2}.R = rotation_matrix{cam2};
camera.cam{2}.T = position(cam2,:)';
camera.camera_number = 2;
% save file
save('./webots/camera.mat', 'camera', 'cameraParams');
% ===========================================================================
% visualize all cameras relationship, the original point is center
figure
showExtrinsics(cameraParams, 'patternCentric', 'HighlightIndex', []);