3D reconstruction from smartphone videos

In this blog, we will show how tools, initially developed for aerial videos, can be used for general object 3D reconstruction. These tools are completely open-source and enable you to process your data locally, assuring their privacy.

We first estimate the camera poses and obtain a sparse reconstruction. Then, a dense model is produced in the form a of mesh with a high-resolution texture.

Resulting textured 3D mesh model. Click this image to explore the 3D model in your browser.

The Software – A Brief History

MAP-Tk / TeleSculptor

Let’s start with some history on the software use in this post. MAP-Tk (Motion-imagery Aerial Photogrammetry Toolkit) started as an open source C++ collection of libraries and tools for making measurements from aerial video. Initial capability focused on estimating the camera flight trajectory and a sparse 3D point cloud of a scene. Over time, additional features have been added, like dense depth map estimation and fusion of depth maps into full 3D mesh models.  A graphical desktop application named TeleSculptor was built on top of MAP-Tk to provide an easier user interface and visualization of results.  While aerial video is still a common use case today (you can explore such results here), MAP-Tk has expanded to support more general video.  This blog post provides an example of using the MAP-Tk algorithms and TeleSculptor application to build a model from mobile phone video.

Becoming KWIVER

The software architecture and algorithms developed for MAP-Tk are highly modular and configurable.  The MAP-Tk algorithm abstraction layer provides seamless interchange and run-time selection of algorithms from various other open source projects like OpenCV, VXL, Ceres Solver, and PROJ4. This framework was so useful that it became the foundation for KWIVER, Kitware’s computer vision toolkit handling a much broader array of vision tasks. Today, all of the software infrastructure and photogrammetry algorithms developed for MAP-Tk now reside within KWIVER.  Only the TeleSculptor application remains in the original MAP-Tk repository.

Since MAP-Tk has evaporated away leaving TeleSculptor behind, we will soon be renaming the MAP-Tk repository to “TeleSculptor” to make its contents more obvious.  Don’t worry, nothing is going away except the “MAP-Tk” name.  KWIVER will provide direct access to all of the algorithms and command line tools for developers and power users.  TeleSculptor will provide a more intuitive graphical interface for 3D reconstruction using KWIVER.

Reconstruction Pipeline

The only input needed is a video or a set of images showing a scene under different angles. For that, we took a video going around our scene.

We first use KWIVER to track image features. A feature is the 2D image coordinates of a distinguishable point in the scene that appears repeatedly across images. The software detects these features and associates them across multiple images forming a feature track. Each feature track has the potential to become a 3D landmark in the next step in the pipeline.

The high modularity of KWIVER enables the user to choose between different types of feature detectors, descriptors and tracking methods. We obtained our results with Speeded Up Robust Features (SURF) for detection and description. We used fundamental matrix based filtering to detect geometrically inconsistent outlier tracks.

A user can select and configure different algorithms with configuration file as shown below.  However, the default settings provided with TeleSculptor are a good starting point for most applications.

KWIVER then estimates the camera poses corresponding to each frame and triangulates 3D landmarks using structure-from-motion (SfM) algorithms.  Again, a configuration file specifies options, such as initial values for the camera intrinsic parameters (e.g. focal length), or the method used to bootstrap the camera’s locations.

To produce a denser reconstruction, we used a fork of PlaneSweepLib. PlaneSweepLib is the CUDA accelerated depth map estimation library developed by ETH Zurich, and our fork can directly use the camera calibration from MAP-Tk as input and output the required VTI format for the next step.  An upcoming release of TeleSculptor will include an alternate algorithm for dense reconstruction that is implemented directly in KWIVER and not subject to GPL licencing restriction like PlaneSweepLib.

We fuse the registered depth maps using a truncated signed distance function (TSDF) voxel volume. The fusion is highly parallelizable and implemented for the GPU with CUDA.

The final step is texture mapping. This enhances the visual aspect of the final reconstruction with a high-resolution texture created from a set of input images covering each side of the scene.

All these tools are available for free and are accessible through command-line programs.  Most, but not all, of the steps of this pipeline are also integrated into the TeleSculptor application for easier use. An upcoming release of TeleSculptor, currently undergoing testing, will include the entire end-to-end pipeline in the GUI with no requirement to use the command line.

The total computation time was less than 20 minutes for the complete pipeline. In total, accounting for human interaction, it took less than one wall-clock hour.

Computation time details:

  • Features tracking: ~5min
  • Poses estimation and sparse reconstruction: ~6min
  • Depth maps estimation: ~8min
  • Depth maps fusion: ~10s
  • Texture mapping: ~30s

The KWIVER abstract APIs allows for making other algorithms or implementations easily available. Indeed, the upcoming versions of KWIVER (algorithms) and TeleSculptor (reconstruction GUI) will have the CudaDepthMapIntegration built in, as well as our DTAM-like alternative to PlaneSweepLib. Stay tuned !

Questions or comments are always welcome!

X