[37] | 1 | %M2Fe Estimate epipolar geometry of MM in sequence or using the central image. |
---|
| 2 | % |
---|
| 3 | % [F,e,rows,nonrows] = M2Fe(M, central) |
---|
| 4 | % |
---|
| 5 | % Parametres: |
---|
| 6 | % central ... If zero, the concept of sequence is used otherwise the |
---|
| 7 | % concept of the central image is used with central |
---|
| 8 | % image number ``central''. |
---|
| 9 | |
---|
| 10 | function [F,ep,rows,nonrows] = M2Fe(M, central) |
---|
| 11 | |
---|
| 12 | m = size(M,1)/3; nonrows = []; F = []; ep = []; |
---|
| 13 | |
---|
| 14 | if central, rows = [1:central-1, central+1:m]; |
---|
| 15 | else, rows = [2:m]; end |
---|
| 16 | |
---|
| 17 | %estimate the fundamental matrices and epipoles with the method of [Har95] |
---|
| 18 | for k = rows |
---|
| 19 | if central, j = central; |
---|
| 20 | else, j = k-1; end |
---|
| 21 | G = u2FI([M(3*k-2:3*k,:);M(3*j-2:3*j,:)], 'donorm'); |
---|
| 22 | if G==0 |
---|
| 23 | rows = setdiff(rows,k); |
---|
| 24 | nonrows = [nonrows k]; |
---|
| 25 | else |
---|
| 26 | %ep=null(G'); %it must be transposed otherwise it's the second epipole |
---|
| 27 | % sometimes returns empty matrix => compute it "by hand" by svd |
---|
| 28 | [u,s,v] = svd(G); |
---|
| 29 | epip = u(:,3); |
---|
| 30 | |
---|
| 31 | F(k,j,1:3,1:3) = G; |
---|
| 32 | ep(k,j,1:3) = epip; |
---|
| 33 | end |
---|
| 34 | end |
---|
| 35 | |
---|
| 36 | if central, rows = union(rows, central); |
---|
| 37 | else rows = [1 rows]; end |
---|
| 38 | |
---|
| 39 | if ~isempty(nonrows) & ~central % find the longest continuous subsequence |
---|
| 40 | I_(rows,1) = 1; |
---|
| 41 | [b, len] = subseq_longest(I_); |
---|
| 42 | rows = b:b+len-1; |
---|
| 43 | nonrows = setdiff(1:m, rows); |
---|
| 44 | end |
---|