A robust Structure from Motion (SfM) implementation for 3D reconstruction from image sequences.
- SIFT feature detection and matching
- Incremental reconstruction with intelligent image ordering
- Graph-based image selection
- Export to COLMAP and PLY formats
# Python version
Python 3.8 or higher
# Required packages
pip install -r requirements.txt
The pipeline can be run in three modes:
python main.py preprocess \
--data_dir ./bunny_data \
--start_idx 0 \
--end_idx 35 \
--min_matches 150
python main.py reconstruct \
--data_dir ./bunny_data \
--output_dir ./bunny_data \
--num_images 36 \
--export_colmap
python main.py pipeline \
--data_dir ./bunny_data \
--output_dir ./bunny_data \
--start_idx 0 \
--end_idx 35 \
--num_images 36
--log_level
: Logging level (DEBUG/INFO/WARNING/ERROR)
--data_dir
: Input data directory--start_idx
: Starting image index (0-999)--end_idx
: Ending image index (0-999)--min_matches
: Minimum feature matches (20-1000)--visualize
: Show visualizations--mask
: Path to mask image
--data_dir
: Preprocessed data directory--output_dir
: Output directory--num_images
: Number of images (2-1000)--export_colmap
: Export to COLMAP format--export_meshlab
: Export to MeshLab format
sfm/
├── main.py # Main entry point
├── utils/
│ ├── image_matcher.py # Feature matching
│ └── image_selector.py # Graph-based selection
│ └── sfm_reconstruction.py # Core SfM pipeline
│ └── export.py # Export utilities
- SIFT features with ratio test
- Mutual nearest neighbor matching
- Geometric verification
- Match filtering
Feature Matching between Images 7 and 24
- Initial pair selection based on:
- Number of matches
- Inlier ratio
- Baseline length
- Feature distribution
Graph Network for next best image selection
output_dir/
├── reconstruction/
│ ├── poses.json # Camera poses
│ └── points3D.json # 3D points
└── exports/
├── colmap/ # COLMAP format
└── reconstruction.ply # Point cloud
- Use appropriate batch sizes
- Enable point filtering
- Adjust feature parameters
- Use GPU acceleration
- Adjust bundle adjustment frequency
- Tune RANSAC parameters
- Ensure image overlap
- Use high-quality images
- Adjust thresholds
Apache License. See LICENSE file.
For issues and feature requests, use the GitHub issue tracker.