⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getfnpt.m

📁 图像 里面常用到的矩阵运算
💻 M
字号:
function F = getFnpt( F0, img1pts, img2pts )
% F = getFnpt( F0, img1pts, img2pts )
% refines F0 to get a better F. If F0 = [] it is computed
% with the 8 point method

if F0 == []
    F0 = getF7pt( img1pts, img2pts );
end

ep = null(F0'); % left null space of F
%ep = cross( F0(:,1), F0(:,3));
epx = [  0    -ep(3)  ep(2);
        ep(3)   0    -ep(1);
       -ep(2)  ep(1)   0    ]; 
M = epx * F0;
t = ep;
P = [M t]; 
x = img1pts;
x(:,3) = 1;
xp = img2pts;
xp(:,3) = 1;
options = optimset('Display','off');
[P err] = lsqnonlin( @sampsonErrf, P, [], [], options, x, xp );
M = P(:,1:3);
t = P(:,4);
tx = [  0   -t(3)  t(2);
       t(3)   0   -t(1);
      -t(2)  t(1)   0    ]; 
F = tx * M;
F = F / norm(F);



function err = sampsonErrf( P, x, xp )

% get F from P
M = P(:,1:3);
t = P(:,4);
tx = [  0   -t(3)  t(2);
       t(3)   0   -t(1);
      -t(2)  t(1)   0    ]; 
F = tx * M;
L = F * x';
Lp = F' * xp';
num = sum(xp' .* L).^2;
den = L(1,:).^2 + L(2,:).^2 + Lp(1,:).^2 + Lp(2,:).^2;
err = num ./ den;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -