Top Related Projects
COLMAP - Structure-from-Motion and Multi-View Stereo
open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motion.
Photogrammetric Computer Vision Framework
Repository for OpenCV's extra modules
Quick Overview
OpenSfM is an open-source Structure from Motion (SfM) library developed by Mapillary. It's designed to reconstruct 3D scenes from multiple 2D images, providing tools for feature detection, matching, and bundle adjustment. OpenSfM is particularly useful for photogrammetry, 3D reconstruction, and computer vision applications.
Pros
- Highly customizable and extensible, allowing users to modify and adapt the pipeline to their specific needs
- Supports various input formats and camera models, making it versatile for different types of projects
- Includes advanced features like GPS data integration and distributed processing for large datasets
- Well-documented and actively maintained by the community
Cons
- Steep learning curve for beginners due to its complex nature and numerous configuration options
- Computationally intensive, especially for large datasets, which may require significant processing time and resources
- Limited built-in visualization tools, often requiring additional software for viewing results
- Dependency management can be challenging, particularly on Windows systems
Code Examples
- Importing and initializing OpenSfM:
import opensfm
from opensfm import dataset
# Create a dataset
data = dataset.DataSet('/path/to/dataset')
- Running the SfM pipeline:
# Run feature detection and matching
opensfm.commands.extract_metadata.run_dataset(data)
opensfm.commands.detect_features.run_dataset(data)
opensfm.commands.match_features.run_dataset(data)
# Run reconstruction
opensfm.commands.reconstruct.run_dataset(data)
- Accessing reconstruction results:
# Load reconstruction
reconstruction = data.load_reconstruction()
# Access camera poses and 3D points
for shot in reconstruction[0].shots.values():
print(f"Camera position: {shot.pose.get_origin()}")
for point in reconstruction[0].points.values():
print(f"3D point: {point.coordinates}")
Getting Started
- Install OpenSfM:
git clone https://github.com/mapillary/OpenSfM.git
cd OpenSfM
pip install -r requirements.txt
python setup.py install
-
Prepare your dataset:
- Create a directory for your project
- Place your images in an
images
subdirectory - Create a
config.yaml
file with desired settings
-
Run the SfM pipeline:
bin/opensfm_run_all /path/to/dataset
- View results:
- Use external software like Meshlab to visualize the 3D reconstruction
- Check the
reconstruction.json
file for detailed output
Competitor Comparisons
COLMAP - Structure-from-Motion and Multi-View Stereo
Pros of COLMAP
- More comprehensive and feature-rich, offering a wider range of algorithms and options
- Better documentation and user interface, making it more accessible for beginners
- Actively maintained with regular updates and improvements
Cons of COLMAP
- Slower processing speed, especially for large datasets
- Higher memory consumption, which can be limiting for some hardware setups
- Less flexible for integration into custom pipelines or workflows
Code Comparison
OpenSfM:
reconstruction = opensfm.Reconstruction()
reconstruction.add_camera('SIMPLE_RADIAL', 1600, 1200)
reconstruction.add_shot('image1.jpg', 'camera1')
reconstruction.add_point([0, 0, 0], [255, 255, 255])
reconstruction.add_observation('image1.jpg', '1', [100, 200])
COLMAP:
colmap::Reconstruction reconstruction;
colmap::Camera camera;
camera.SetModelIdFromName("SIMPLE_RADIAL");
camera.SetWidth(1600);
camera.SetHeight(1200);
reconstruction.AddCamera(camera);
Both libraries offer similar functionality for reconstruction, but COLMAP's C++ implementation may provide better performance in some cases, while OpenSfM's Python-based approach offers more flexibility for customization and integration with other Python libraries.
open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motion.
Pros of openMVG
- More comprehensive and feature-rich, offering a wider range of algorithms and tools
- Better documentation and extensive wiki with detailed explanations
- Stronger focus on accuracy and precision in 3D reconstruction
Cons of openMVG
- Steeper learning curve due to its complexity and extensive feature set
- Slower processing times, especially for large datasets
- Less focus on scalability for very large-scale reconstructions
Code Comparison
OpenMVG:
#include "openMVG/sfm/sfm.hpp"
using namespace openMVG;
using namespace openMVG::sfm;
SfMData sfm_data;
if (!Load(sfm_data, sfm_data_filename, ESfM_Data(ALL))) {
std::cerr << "Error: cannot load SfM_Data file." << std::endl;
return EXIT_FAILURE;
}
OpenSfM:
import opensfm
from opensfm import dataset
data = dataset.DataSet('/path/to/dataset')
reconstruction = data.load_reconstruction()
OpenMVG provides a more low-level, C++ based approach with fine-grained control over the SfM process, while OpenSfM offers a higher-level Python interface that's easier to use but potentially less flexible. OpenMVG's code is more verbose but allows for more detailed customization, whereas OpenSfM's Python API is more concise and user-friendly for quick implementations.
Photogrammetric Computer Vision Framework
Pros of AliceVision
- More comprehensive pipeline, including mesh reconstruction and texturing
- Better support for large-scale reconstructions
- More active development and community support
Cons of AliceVision
- Steeper learning curve due to more complex pipeline
- Higher computational requirements for full pipeline execution
- Less flexibility for customization in certain pipeline stages
Code Comparison
AliceVision (C++):
#include <aliceVision/sfmData/SfMData.hpp>
#include <aliceVision/sfmDataIO/sfmDataIO.hpp>
aliceVision::sfmData::SfMData sfmData;
aliceVision::sfmDataIO::Load(sfmData, sfmDataFilepath, aliceVision::sfmDataIO::ESfMData::ALL);
OpenSfM (Python):
from opensfm import dataset
from opensfm import reconstruction
data = dataset.DataSet('/path/to/dataset')
reconstructions = reconstruction.reconstruct(data)
AliceVision offers a more structured C++ approach with explicit data loading, while OpenSfM provides a simpler Python interface for reconstruction. AliceVision's code reflects its comprehensive pipeline, whereas OpenSfM's code showcases its ease of use for basic reconstruction tasks.
Repository for OpenCV's extra modules
Pros of opencv_contrib
- Broader scope: Covers a wide range of computer vision tasks beyond SfM
- Larger community: More contributors and users, leading to better support
- Integration: Seamlessly works with the main OpenCV library
Cons of opencv_contrib
- Less specialized: SfM functionality may not be as advanced as OpenSfM
- Steeper learning curve: Due to its extensive feature set
Code Comparison
OpenSfM:
reconstruction = opensfm.Reconstruction()
reconstruction.add_camera('SIMPLE_RADIAL', 1600, 1200)
reconstruction.add_shot('image1.jpg', 'camera1')
reconstruction.add_point([0, 0, 0], [255, 255, 255])
opencv_contrib:
detector = cv2.xfeatures2d.SIFT_create()
matcher = cv2.BFMatcher()
sfm = cv2.sfm.reconstruct(images, K, detector, matcher)
OpenSfM provides a more specialized API for SfM tasks, while opencv_contrib offers a more general approach within its broader computer vision framework. OpenSfM may be easier to use for specific SfM projects, but opencv_contrib provides more flexibility for integrating SfM with other computer vision tasks.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
OpenSfM 
Overview
OpenSfM is a Structure from Motion library written in Python. The library serves as a processing pipeline for reconstructing camera poses and 3D scenes from multiple images. It consists of basic modules for Structure from Motion (feature detection/matching, minimal solvers) with a focus on building a robust and scalable reconstruction pipeline. It also integrates external sensor (e.g. GPS, accelerometer) measurements for geographical alignment and robustness. A JavaScript viewer is provided to preview the models and debug the pipeline.
Checkout this blog post with more demos
Getting Started
License
OpenSfM is BSD-style licensed, as found in the LICENSE file. See also the Facebook Open Source Terms of Use and Privacy Policy
Top Related Projects
COLMAP - Structure-from-Motion and Multi-View Stereo
open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motion.
Photogrammetric Computer Vision Framework
Repository for OpenCV's extra modules
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot