function VALS = solve26( L, option_flag,N) % function VALS = solve26( L, option_flag,N) % % Code for solving the generalized camera relative pose problem % for 2 stations and 6 observed points. % % L is a cell structure with two elements each being a 6x6 matrix. % The matrices describres (in plucker coordinates) the % observation at corresponding time. Ech observation is a column. % % option_flag controls how the elimination is performed. % % N is usually set to 3. % % VALS is a 3x64 matrix where each column is the 3 first components of % a quaternion parameterizing this rotation. One way to work with these % is to download the "Quaternion Toolbox" from Mathworks homepage % (search for dcm2q if you are unable to find the toolbox. % % %% TEST AND EXAMPLE CODE: %% %load solve26_testvec %N= length( Lvec); %% N=60; %errvec = zeros(1,N); %tic %for i=1:N % VALS = solve26( Lvec{i}, 0, 3 ); % [err1,I] = min(abs( VALS(1,:) - Qtrue_vec{i}(1) )); % errvec(i)= err1; % errvec2(i)= norm( Qtrue_vec{i} - VALS(:,I)); %end %fprintf('Time for solving %i instances was:', N); %toc % % % % %Please refer to: % %@INPROCEEDINGS{stewenius-etal-omnivis-2005, % AUTHOR = {H. Stew\'enius and D. Nist\'er and M. Oskarsson and K. {\AA}str{\"o}m}, % TITLE = {Solutions to Minimal Generalized Relative Pose Problems}, % BOOKTITLE = {Workshop on Omnidirectional Vision}, % YEAR = 2005, % MONTH = OCT, % ADDRESS = {Beijing China}, % PDF = {http://www.vis.uky.edu/~stewe/publications/stewenius_05_omnivis_sm26gen.pdf} %} % %and/or % %@PHDTHESIS{stewenius-pdh-2005, % AUTHOR = {H. Stew\'enius}, % TITLE = {Gr{\"o}bner Basis Methods for Minimal Problems in Computer Vision}, % SCHOOL = {Lund University}, % YEAR = 2005, % MONTH = APR, % PDF = {http://www.maths.lth.se/matematiklth/personal/stewe/THESIS/stewenius_phd_2005.pdf} %} % % % If you use this program % % %% Henrik Stewenius 200407?? %% %% %% %% %% if( not((exist('build_eq2')==3) && (exist('first_row')==3) && (exist('initM')==3) && (exist('last_gb')==3) && (exist('mult_w_all')==3) )) fprintf(['On or more of the neded mexfiles are unavailable.\n'... 'Please compile all needed files and then try again\n'... 'Suggested way to do this in matlab (on Linux) is:\n'... ' mex -DMAIN_BUILD_EQ2 solve26.c -output build_eq2\n'... ' mex -DMAIN_MULT_WITH_ALL solve26.c -output mult_w_all\n'... ' mex -DMAIN_INITM solve26.c -output initM\n'... ' mex -DMAIN_LASTGB solve26.c -output last_gb\n'... ' mex -DMAIN_FIRST_ROW solve26.c -output first_row\n']); if( not(exist('solve26.c'))) error('File solve26.c is missing. You will not be able to compile'); end if(not(exist('solve26AFILE.c') )) error('File solve26AFILE.c is missing. You will not be able to compile'); end error('Unable to Run'); end A = build_eq2(L,N); if option_flag B = build_modmult2( A); U =B(1:56,:); else [L,U] = lu(A ) ; U = U(1:15,1:15)\U(1:15,:); B = mult_w_all( U); [L,U] = lu( B ) ; U = U(1:56,1:56)\U(1:56,:); end M= initM; last_gb_restrow = last_gb( U); restrow = first_row( U(1:56,:) , last_gb_restrow ); restrow = restrow( 57:end); M(1,:)= restrow; M(2:26,:)=-U([25 27 28 29 31 32 34 36 37 38 39 40 41 43 44 45 46 47 49 ... 50 51 52 54 55 56], 57:end); [V,D] = eig( M ) ; VALS = V( 61:63,:) ./(ones(3,1)*V(end,:));