从世界坐标系变换到相机坐标系
参考链接:相机矩阵
1:变换时用到的矩阵
2:相机内参:K和相机外参:R的使用与物理意义
3:从世界坐标系变换到相机坐标系的代码
% chose apropriate K matrix
if strcmp(cam, 'BB')
fx = 822.79041;
fy = 822.79041;
tx = 318.47345;
ty = 250.31296;
base = 120.054;
R_l = zeros(3, 4);
R_l(1, 1) = 1;
R_l(2, 2) = 1;
R_l(3, 3) = 1;
R_r = R_l;
R_r(1, 4) = -base;
K = diag([fx, fy, 1.0]);
K(1, 3) = tx;
K(2, 3) = ty;
else
fx = 607.92271;
fy = 607.88192;
tx = 314.78337;
ty = 236.42484;
K = diag([fx, fy, 1]);
K(1, 3) = tx;
K(2, 3) = ty;
K = [K zeros(3, 1)];
end
% get corresponding annotations
anno_xyz_l = handPara(:, :, im_id+1);
% left frame
anno_uv_l = K * R_l * [anno_xyz_l; ones(1, 21)];
for k=1:21
anno_uv_l(:, k) = anno_uv_l(:, k) ./ anno_uv_l(3, k);
end
% right frame
anno_xyz_r = R_r * [anno_xyz_l; ones(1, 21)];
anno_uv_r = K * anno_xyz_r;
for k=1:21
anno_uv_r(:, k) = anno_uv_r(:, k) ./ anno_uv_r(3, k);
end
anno_uv_r = anno_uv_r(1:2, :);
% write db
write_binary_record(file, img_l, anno_xyz_l, anno_uv_l)
%write_binary_record(file, img_r, anno_xyz_r, anno_uv_r)