This software implements a new multistage algorithm to compute the 3D motion and structure from two calibrated images (i.e. with known intrinsic parameters). The point matches can be obtained using techniques such as correlation and relaxation implemented in the software IMAGE-MATCHING.
The classical approach to this problem consists of two stages: (i) using the 8-point algorithm to estimate the 9 essential parameters defined up to a scale factor, which is a linear estimation problem; (ii) refining the motion estimation based on some statistically optimal criteria, which is a nonlinear estimation problem on a five-dimensional space. Unfortunately, the results obtained using this approach are often not satisfactory, especially when the motion is small or when the observed points are close to a degenerate surface (e.g. plane). The problem is that the second stage is very sensitive to the initial guess, and that it is very difficult to obtain a precise initial estimate from the first stage. This is because we perform a projection of a set of quantities which are estimated in a space of 8 dimensions, much higher than that of the real space which is five-dimensional. In our multistage algorithm, we introducing an intermediate stage which consists in estimating a 3x3 matrix defined up to a scale factor by imposing the zero-determinant constraint (the matrix has seven independent parameters, and is known as the fundamental matrix). The idea is to gradually project parameters estimated in a high dimensional space onto a slightly lower space, namely from 8 dimensions to 7 and finally to 5. The proposed approach has been tested with synthetic and real data, and a considerable improvement has been observed for the delicate situations mentioned above.
An example with a real data set is here.
Usage: sfm [-match File1 File2 | -match2 MatchFile] [-P P1 P2 | -A A1 A2] [-outliers File] [-cov] [-mvt | -mvt2 Mvt-to-save] [-3D | -3D2 Recons-to-save] [-outP outP1 outP2] [-verbose] [-max MaxNum] *** Motion and Structure from Motion from two sets of 2D points *** *** A Program of Zhengyou Zhang (email@example.com) *** o Input Point matches can be supplied in two formats: -match :- specifies two files containing 2D points in correspondences -match2 :- specifies the name of the match file (each match in one line) If the points are not in normalized image coordinates, then supplied the intrinsic parameters in either of the following two formats: -P :- supplies the intrinsic parameters in 3x4 projection matrix (Only the intrinsic parameters will matter) -A :- supplies the intrinsic parameters in 3x3 intrinsic matrix: alpha_u c u0 0 alpha_v v0 0 0 1 o Output -mvt :- specifies the file to save motion computed (L->R), given as (r,t) -mvt2:- specifies the file to save motion computed (R->L), given as (r,t) -3D :- specifies the file to save the 3D reconstruction w.r.t. 1st Camera -3D2 :- specifies the file to save the 3D reconstruction w.r.t. 2nd Camera -outP:- specifies the files to save the camera perspective projection matrices o Miscellaneous -outliers :- specifies the file to save the outliers detected (corresponding to indexes of points numbered from 0). Use this option only when the user knows that there are false matches. LMedS will be applied. -cov :- set this option if you also need the covariance matrix. -max :- specifies the maximum number of matches to be processed.  -verbose :- verbose mode