2016-06-08 1 views
1

카메라 보정 패턴 변환,좀 바둑판 패턴을 검출하도록 매트랩 카메라 보정을 사용

figure; showExtrinsics(cameraParams, 'CameraCentric'); 

enter image description here

후 이제 I가되도록 상기 X 축을 중심으로 바둑판 패턴을 회전 할 그들 모두는 카메라 프레임에서 거의 동일한 y 좌표를가집니다.

방법 : 카메라의 모든 프레임 위치가 표시됩니다. 그렇다면 목적 함수는 y의 분산을 최소화하는 것이고 변수는 x에서 360까지의 x에 대한 회전입니다.

문제 : 그러나 변환 된 y 좌표를 그릴 때도 거의 비슷합니다. 한 줄.

코드 :

얻기 checkerboad 포인트 :

%% Get rotation and translation matrices for each image; 
T_cw=cell(num_imgs,1); % stores camera to world rotation and translation for each image 
pixel_coordinates=zeros(num_imgs,2); % stores the pixel coordinates of each checkerboard origin 
for ii=1:num_imgs, 
    % Calibrate the camera 
    im=imread(list_imgs_path{ii}); 
    [imagePoints, boardSize] = detectCheckerboardPoints(im); 
    [r_wc, t_wc] = extrinsics(imagePoints, worldPoints, cameraParams); 
    T_wc=[r_wc,t_wc';0 0 0 1]; 
    % World to camera matrix 
    T_cw{ii} = inv(T_wc); 
    t_cw{ii}=T_cw{ii}(1:3,4); % x,y,z coordinates in camera's frame 
end 

데이터 (num_imgs = 10) :

t_cw 
[-1072.01388542262;1312.20387622761;-1853.34408157349] 
[-1052.07856598756;1269.03455126794;-1826.73576892251] 
[-1091.85978641218;1351.08261414473;-1668.88197803184] 
[-1337.56358084648;1373.78548638383;-1396.87603554914] 
[-1555.19509876309;1261.60428874489;-1174.63047408086] 
[-1592.39596647158;1066.82210015055;-1165.34417772659] 
[-1523.84307918660;963.781819272748;-1207.27444716506] 
[-1614.00792252030;893.962075837621;-1114.73528985018] 
[-1781.83112607964;708.973204727939;-797.185326205240] 
[-1781.83112607964;708.973204727939;-797.185326205240] 

홈페이지 코드 (최적화 및 변환) :

%% Get theta for rotation 
f_obj = @(x)var_ycors(x,t_cw); 
opt_theta = fminbnd(f_obj,0,360); 
%% Plotting (rotate ycor and check to fix theta) 
y_rotated=zeros(1,num_imgs); 
for ii=1:num_imgs, 
    y_rotated(ii)=rotate_cor(opt_theta,t_cw{ii}); 
end 
plot(1:numel(y_rotated),y_rotated); 


function var_computed=var_ycors(theta,t_cw) 
ycor=zeros(1,numel(t_cw)); 
for ii =1:numel(t_cw), 
    ycor(ii)=rotate_cor(theta,t_cw{ii}); 
end 
var_computed=var(ycor); 
end 

function ycor=rotate_cor(theta,mat) 
r_x=[1 0 0; 0 cosd(theta) -sind(theta); 0 sind(theta) cosd(theta)]; 
rotate_mat=mat'*r_x; 
ycor=rotate_mat(2); 
end 
+0

도움이 될 경우 답변 수락을 고려하십시오. –

답변

1

이것은 명확한 ei입니다. genvector 문제! 그들에

t_cw=[-1072.01388542262;1312.20387622761;-1853.34408157349 
-1052.07856598756;1269.03455126794;-1826.73576892251 
-1091.85978641218;1351.08261414473;-1668.88197803184 
-1337.56358084648;1373.78548638383;-1396.87603554914 
-1555.19509876309;1261.60428874489;-1174.63047408086 
-1592.39596647158;1066.82210015055;-1165.34417772659 
-1523.84307918660;963.781819272748;-1207.27444716506 
-1614.00792252030;893.962075837621;-1114.73528985018 
-1781.83112607964;708.973204727939;-797.185326205240 
-1781.83112607964;708.973204727939;-797.185326205240]; 
t_cw=reshape(t_cw,[3,10])'; 

컴퓨팅 PCA를, 그래서 우리는 주요 conponents을 알고 :

은 무게 중심을 가지고

[R]=pca(t_cw); 

을 그리고 .... 그것을 이잖아! R은 원래 점과 회전 된 좌표계 ​​간의 변환 행렬입니다. 예를 들어, 나는 빨간색 기존 포인트와 파란색 새에 그릴 것입니다 :

hold on 

plot3(t_cw(:,1),t_cw(:,2),t_cw(:,3),'ro') 
trans=t_cw*R; 
plot3(trans(:,1),trans(:,2),trans(:,3),'bo') 

enter image description here

은 이제 파란색 사람은 최상의 착용감과 함께 비행기에있는 것을 볼 수 있습니다 X 방향. 그들을 Y 방향으로 원하면 Z에서 90도 회전하십시오 (2 분 동안 Google을 사용하는 방법을 알 수있을 것입니다).

참고 : 이것은 수학적으로 가능한 최상의 적합입니다. 나는 그들이 "연속적"으로 좋아하는 것이 아니라는 것을 알고 있습니다. 그러나 이것이 데이터 때문입니다. 이것은 정직하게도 가능한 최상의 적합성입니다. 이것이 고유 벡터가되는 것입니다!