カメラの回転角,位置が既知の場合のEpipolar Line の求め方
2 views (last 30 days)
Show older comments
今現在,カメラの回転角(ω,φ,κ)と位置(X,Y,Z)が既知の場合のエピポーララインの導出をしています.
matlabでは推定にて基礎行列,基本行列を計算していますが,自分でそれらを計算してエピポーララインを作成しても,本来通るべきところを通りません.
どのようにすればいいのでしょうか.
個人的に,F(基礎行列の位置が違うように思います)
OriImage1 = imread('');
OriImage2 = imread('');
I11 = rgb2gray(OriImage1);
I22 = rgb2gray(OriImage2);
I1 = cast(I11,'double');
I2 = cast(I22,'double');
%template
[x1, y1] = meshgrid(2457:2477,12560:12580);
matchedPoints1 = ([x1(:) y1(:)]);
%rotationMatrix [ω=o] [φ=p] [κ=k]
%Fuji103
o1 = -(0.07989);
p1 = -(-0.01121);
k1 = -(-89.34728);
R103 = [cosd(k1) -sind(k1) 0;sind(k1) cosd(k1) 0;0 0 1]*[cosd(p1) 0 sind(p1);0 1 0;-sind(p1) 0 cosd(p1)]*[1 0 0;0 cosd(o1) -sind(o1);0 sind(o1) cosd(o1)];
%Fuji104
o2 = -(0.11281);
p2 = -(-0.02592);
k2 = -(-89.34460);
R104 = [cosd(k2) -sind(k2) 0;sind(k2) cosd(k2) 0;0 0 1]*[cosd(p2) 0 sind(p2);0 1 0;-sind(p2) 0 cosd(p2)]*[1 0 0;0 cosd(o2) -sind(o2);0 sind(o2) cosd(o2)];
%translationVector T = -R[Xw;Yw;Zw]
%cameraPosition
X01 = 20640.561;
Y01 = -71011.741;
Z01 = 4233.861;
X02 = 20639.541;
Y02 = -70897.979;
Z02 = 4235.093;
t103 = -R103*[X01 ; Y01 ; Z01];
t104 = -R104*[X02 ; Y02 ; Z02];
% t103 = [X01 ; Y01 ; Z01];
% t104 = [X02 ; Y02 ; Z02];
%%カメラ103を原点に置くとする
%rotationMatrix103wを単位行列にするために逆行列をかける
RelativeR103 = R103/R103 ;
RelativeR104 = R104/R103 ;
Relativet103 = t103-t103 ;
%103から見た104
Relativet104 = t104-t103 ;
%%%K(内部パラメータ)%%%
ImageSizeW = size(OriImage2,2);
ImageSizeH = size(OriImage2,1);
focalLength = 100.500000000000; %mm
PIXEL_SIZE_WIDTH = 4.000000; %micron
PIXEL_SIZE_HEIGHT = 4.000000;
fx = ((1/PIXEL_SIZE_WIDTH)*1000)*focalLength;
fy = ((1/PIXEL_SIZE_HEIGHT)*1000)*focalLength;
%cx,cy - 光学中心
% cx = round(rdivide(resizedImageSizeW,2));
% cy = round(rdivide(resizedImageSizeH,2));
cx = rdivide(ImageSizeW,2);
cy = rdivide(ImageSizeH,2);
K = [fx 0 cx;0 fy cy;0 0 1];
%%%基本行列(Essential Matrix)%%%
E = [0 -Relativet104(3) Relativet104(2);Relativet104(3) 0 -Relativet104(1);-Relativet104(2) Relativet104(1) 0]*RelativeR104;
%%%基礎行列(Fundamental Matrix)%%%
F = ((K)')\E/K;
figure;
subplot(121);
imshow(OriImage1);
title('Inliers and Epipolar Lines in Second Image'); hold on;
plot(matchedPoints1(:,1),matchedPoints1(:,2),'go')
truesize;
figure;
subplot(121);
imshow(OriImage2);
title('Inliers and Epipolar Lines in First Image'); hold on;
plot(matchedPoints1(:,1),matchedPoints1(:,2),'go')
%104
epiLines103 = epipolarLine(F,matchedPoints1);
points103 = lineToBorderPoints(epiLines103,size(OriImage2));
line(points103(:,[1,3])',points103(:,[2,4])');
truesize;
0 Comments
Answers (0)
See Also
Categories
Find more on オブジェクト解析 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!