Rev | Line | |
---|
[37] | 1 | function F = u2Fdlt(u,do_norm) |
---|
| 2 | % u2Fdlt linear estimation of the Fundamental matrix |
---|
| 3 | % from point correspondences |
---|
| 4 | % |
---|
| 5 | % H = u2Fdlt(u,{do_norm=1}) |
---|
| 6 | % u ... {4|6}xN corresponding coordinates |
---|
| 7 | % do_norm .. do isotropic normalization of points? |
---|
| 8 | % |
---|
| 9 | % F ... 3x3 fundamental matrix |
---|
| 10 | % |
---|
| 11 | % $Id: u2Fdlt.m,v 1.1 2005/05/23 16:16:01 svoboda Exp $ |
---|
| 12 | |
---|
| 13 | NoPoints = size(u,2); |
---|
| 14 | |
---|
| 15 | if nargin < 2 |
---|
| 16 | do_norm=1; |
---|
| 17 | end |
---|
| 18 | |
---|
| 19 | u = u'; |
---|
| 20 | |
---|
| 21 | % parse the input parameters |
---|
| 22 | if NoPoints<8 |
---|
| 23 | error('Too few correspondences') |
---|
| 24 | end |
---|
| 25 | |
---|
| 26 | if size(u,2) == 4, |
---|
| 27 | % make the homogenous coordinates |
---|
| 28 | u = [u(:,1:2), ones(size(u(:,1))), u(:,3:4), ones(size(u(:,1)))]; |
---|
| 29 | end |
---|
| 30 | |
---|
| 31 | u1 = u(:,1:3); |
---|
| 32 | u2 = u(:,4:6); |
---|
| 33 | |
---|
| 34 | if do_norm |
---|
| 35 | [u1,T1] = pointnormiso(u1'); |
---|
| 36 | u1 = u1'; |
---|
| 37 | [u2,T2] = pointnormiso(u2'); |
---|
| 38 | u2 = u2'; |
---|
| 39 | end |
---|
| 40 | |
---|
| 41 | % create the data matrix |
---|
| 42 | A = zeros(NoPoints,9); |
---|
| 43 | for i=1:NoPoints % create equations |
---|
| 44 | for j=1:3 |
---|
| 45 | for k=1:3 |
---|
| 46 | A(i,(j-1)*3+k)=u2(i,j)*u1(i,k); |
---|
| 47 | end |
---|
| 48 | end |
---|
| 49 | end |
---|
| 50 | |
---|
| 51 | [U,S,V] = svd(A); |
---|
| 52 | f = V(:,size(V,2)); |
---|
| 53 | F = reshape(f,3,3)'; |
---|
| 54 | |
---|
| 55 | if do_norm |
---|
| 56 | F = inv(T2)*F*T1; |
---|
| 57 | end |
---|
| 58 | |
---|
| 59 | return; |
---|
Note: See
TracBrowser
for help on using the repository browser.