我正在尝试使用边条件(在MatLab中)从相机图片中的2D像素坐标重建3D坐标.我确实有外在和内在的相机参数.
使用同质变换,我可以将3D坐标从初始世界坐标系转换为我的相机坐标系.所以我在变换矩阵R_world_to_Camera中有我的外部参数:
R_world_to_Camera = [ r_11, r_12, r_13, t1;
r_21, r_22, r_23, t2;
r_31, r_32, r_33, t3;
0, 0, 0, 1];
对于内在参数,我使用了Caltech的“MatLab相机校准工具箱”并获得了以下参数:
Calibration results (with uncertainties):
Focal Length: fc = [ 1017.21523 1012.54901 ] ± [ NaN NaN ]
Principal point: cc = [ 319.50000 239.50000 ] ± [ NaN NaN ]
Skew: alpha_c = [ 0.00000 ] ± [ NaN ] => angle of pixel axes = 90.00000 ± NaN degrees
Distortion: kc = [ 0.00000 0.00000 0.00000 0.00000 0.00000 ] ± [ NaN NaN NaN NaN NaN ]
Pixel error: err = [ 0.11596 0.14469 ]
Note: The numerical errors are approximately three times the standard deviations (for reference).
所以我得到了Camera-Calibration-Matrix K(3×3)
K = [1.017215234570303e+03, 0, 3.195000000000000e+02;
0, 1.012549014668498e+03,2.395000000000000e+02;
0, 0, 1.0000];
并使用这个我可以计算3D – > 2D – 投影 – 矩阵P(3×4):
P = K * [eye(3), zeros(3,1)];
在世界坐标[X,Y,Z] _World中转换点时,我首先将其转换为相机坐标,然后将其投影到2D:
% Transformation
P_world = [X; Y; Z; 1]; % homogenous coordinates in World coordinate System
P_camera = R_world_to_Camera * [X; Y; Z; 1];
% Projection
P_pixels = P * camera;
P_pixels = P_pixels / P_pixels(3); % normalize coordinates
所以我现在的问题是如何扭转这些步骤?作为边条件,我想设置Z坐标(世界坐标为零).我尝试了here on Stackoverflow提出的解决方案,但不知怎的,我得到了错误的坐标.任何的想法?每一个帮助都很受欢迎!!