copyright 2012-2014 Kyle Wilson (wilsonkl@cs.cornell.edu)
based on the global structure from motion work with Noah Snavely
SfM Init is a toolkit for solving some parts of a global Stucture from Motion pipeline. Such a pipeline would typically reconstruct the 3D (sparse) geometry of some scene given many photos with the following steps:
SfM Init goes from pairwise geometry to a good guess of global geometry, which is then the initialization to bundle adjustment. SfM Init does not ship with a system for computing pairwise models or with a bundle adjustor.
SfM Init uses the excellent Rotations Graph Averaging package by Chatterjee and Govindu [2]. This is available from their project webpage. SfM Init only provides wrappers to call this code. [Update: this code is temporarily unavailable from the authors. Venu Govindu has given me permission to temporarily distribute it here until their server problem is fixed.]
SfM Init is distributed under a Simplified BSD / 2-clause license. If you use SfM Init for a publication, please cite the following paper:
Kyle Wilson and Noah Snavely. Robust Global Translations with 1DSfM. ECCV 2014.
SfM Init is distributed as a python package. Some of the key computations are written in C++ and are wrapped in via cython. This should be transparent to the user.
This toolkit includes a wrapper to Chatterjee and Govindu's rotations averaging code, as well 1DSfM translations problem outlier detection and a chordal distance based translations solver.
Examples of how to use SfM Init are in the scripts directory. In particular,
scripts/eccv_demo.py
shows how to run all the steps of the pipeline described in
[1] on the datasets provided at the 1DSfM project page.
Look in scripts/coords_demo.py
for some examples of how the coordinate systems
in 1DSfM are used.
SfM Init is python based, and depends on the following standard python packages --- python 2.7, numpy, and scipy. Additionally, to compile the C++ numeric routines, it requires cython.
The translations solver requires the Ceres Solver nonlinear least squares package.
Chatterjee and Govindu's rotations averaging code can be found at their project page. Unzip the contents of this tar file into the rotsolver directory.
Finally, to compile the numerics routines, run the following from SfM Init's root directory:
> python setup.py build_ext --inplace
If this fails, check the compile and link paths in setup.py to be sure that cython can see the Ceres include and lib files, as well as Eigen and the SuiteSparse libs that Ceres depends on.
The most common causes of build failure reported to the authors come down to very old versions of python/cython or libceres not being visible during linking.
Running the SfM Init pipeline in scripts/eccv_demo.py
requires several files
describing reconstructed two view models. Our datasets are available on our project
page. Note that the photos and data files are
distributed separately. The dataset files describe a single connected component, but
all images related to each Landmark are given, in case these are useful in another
context. If the following descriptions are insufficient, please also look at
scripts/coords_demo.py
for some further examples.
Input files:
<i> <j> <Rij> <tij>
where i and j are camera indices, Rij is a row-major
pairwise rotation matrix, and tij is the position of camera j in camera i's
coordinate system. If Ri and Rj are the rotation matrices of cameras i and
j (world-to-camera maps) then in the absence of noise Rij = Ri * Rj', ie
Rij is the pose of camera j in camera i's coordinate system (where a pose
is the transpose of a rotation matrix, a camera-to-world map). All of these
EGs are within the connected component.<key number> <x> <y> <ignore0> <ignore1> <R> <G> <B>
where R,G,B are a
sampled rgb color. The keys are numbered sequentially. The coordinates <x>
and <y>
are in a coordinate system from SIFT: the center of the upper
left pixel is (1,1), +x points right, and +y points down.Output formats:
<i> <j> <tij>
where tij is a unit
vector pointing from node i to node j.<i> <Xi>
where Xi is a 3-vector.<i> <Ri>
, where Ri is a 3-by-3 rotation matrix written row major.Other included files:
<image name> 0 <focal length>
, although when the focal length is unknown the latter two fields are
omitted. SfM Init ignores photos with unknown focal length. The line number
of an image in this file is its identifying index in the rest of the
toolkit. (Note that this list typically includes many more images than are in
connected component supplied above.)Please email Kyle Wilson (wilsonkl@cs.cornell.edu) with any questions, comments, or bug reports.
[1] Kyle Wilson and Noah Snavely. Robust Global Translations with 1DSfM. ECCV 2014.
[2] Avishek Chatterjee and Venu Madhav Govindu. Efficient and Robust Large-Scale Rotation Averaging. ICCV 2013.
[3] Noah Snavely, Steven M. Seitz, and Richard Szeliski. Photo Tourism: Exploring Photo Collections in 3D. SIGGRAPH Conf. Proc., 2006.