Skip to content

Dipankar1997161/GeoFuse-SFM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

46 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GeoFuse-SFM

Geometry-Aware Dense Reconstruction from Sparse Structure-from-Motion

GeoFuse-SFM Pipeline

GeoFuse-SFM is a modular Structure-from-Motion pipeline that produces sparse 3D reconstructions from multi-view images. It supports both calibrated multi-camera rigs (like the BBM dataset) and sequential single-camera captures (like the Fountain dataset). The sparse reconstruction serves as seed geometry for downstream dense fusion.


โœจ Key Features

  • Unified Pipeline - Single codebase handles both multicam and singlecam setups
  • Textureless Surface Support - Adaptive SIFT parameters for smooth/plastic objects
  • Calibrated Rig Support - Leverages known camera poses for multicam datasets
  • Modular Architecture - Clean separation of matching, triangulation, BA, and cleanup
  • Configurable - All parameters in dataclass configs with presets
  • Silhouette Integration - Contour matching + filtering for challenging objects

๐Ÿš€ Quick Start

Installation

git clone https://github.com/yourusername/geofuse-sfm.git
cd geofuse-sfm
pip install -r requirements.txt

Run Sparse Reconstruction

Multicam (calibrated rig):

python -m scripts.run_multicam \
    --images_dir Data/bird/images \
    --cameras_dir Data/bird/calib \
    --masks_dir Data/bird/silhouettes \
    --feature_preset textureless \
    --visualize

Singlecam (sequential images):

python -m scripts.run_multicam \
    --images_dir Data/fountain/images \
    --K_file Data/fountain/K.txt \
    --visualize

Output

output/<scene_name>/
โ”œโ”€โ”€ sparse_points.ply          # Sparse point cloud
โ”œโ”€โ”€ checkpoint_sfm.pkl         # Full reconstruction state
โ”œโ”€โ”€ sfm_diagnostics/           # Per-stage diagnostics
โ””โ”€โ”€ all_proj_overlays/         # Reprojection visualizations

๐Ÿ“Š Pipeline Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                           GeoFuse-SFM Pipeline                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                 โ”‚
โ”‚  โ”‚ Images  โ”‚    โ”‚ K / Camsโ”‚    โ”‚ Masks   โ”‚  (optional)                     โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜                                 โ”‚
โ”‚       โ”‚              โ”‚              โ”‚                                       โ”‚
โ”‚       โ–ผ              โ–ผ              โ–ผ                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚                 FEATURE EXTRACTION                        โ”‚              โ”‚
โ”‚  โ”‚  SIFT with configurable contrast (textureless preset)     โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚                  PAIRWISE MATCHING                        โ”‚              โ”‚
โ”‚  โ”‚  Multicam: Epipolar filter + Contour matching             โ”‚              โ”‚
โ”‚  โ”‚  Singlecam: E-RANSAC verification                         โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚                   TRACK BUILDING                          โ”‚              โ”‚
โ”‚  โ”‚  Union-find to link matches across views                  โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚                  INITIALIZATION                           โ”‚              โ”‚
โ”‚  โ”‚  Select best pair โ†’ Triangulate seed points               โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚              INCREMENTAL REGISTRATION                     โ”‚              โ”‚
โ”‚  โ”‚  For each image:                                          โ”‚              โ”‚
โ”‚  โ”‚    โ€ข PnP pose estimation (singlecam)                      โ”‚              โ”‚
โ”‚  โ”‚    โ€ข Use known pose (multicam)                            โ”‚              โ”‚
โ”‚  โ”‚    โ€ข Triangulate new points (min 3 views for multicam)    โ”‚              โ”‚
โ”‚  โ”‚    โ€ข Local bundle adjustment (singlecam only)             โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚                 OUTLIER REMOVAL                           โ”‚              โ”‚
โ”‚  โ”‚  Strict reprojection filter + Spatial filter              โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚                    OUTPUT                                 โ”‚              โ”‚
โ”‚  โ”‚  Sparse point cloud + Camera poses + Tracks               โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                            โ”‚                                                โ”‚
โ”‚                            โ–ผ                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚              DENSE FUSION (Coming Soon)                   โ”‚              โ”‚
โ”‚  โ”‚  Seed-based depth propagation using sparse geometry       โ”‚              โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                                                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ Project Structure

geofuse-sfm/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ pipeline/              # Core SfM pipeline modules
โ”‚   โ”‚   โ”œโ”€โ”€ config.py          # Configuration dataclasses
โ”‚   โ”‚   โ”œโ”€โ”€ state.py           # Reconstruction state management
โ”‚   โ”‚   โ”œโ”€โ”€ matching.py        # Feature extraction & matching
โ”‚   โ”‚   โ”œโ”€โ”€ triangulation.py   # Multi-view triangulation
โ”‚   โ”‚   โ”œโ”€โ”€ initialize.py      # Initial pair selection
โ”‚   โ”‚   โ”œโ”€โ”€ registration.py    # Incremental image registration
โ”‚   โ”‚   โ”œโ”€โ”€ ba_runner.py       # Bundle adjustment
โ”‚   โ”‚   โ””โ”€โ”€ cleanup.py         # Outlier removal
โ”‚   โ”œโ”€โ”€ features.py            # SIFT/ORB feature detection
โ”‚   โ”œโ”€โ”€ tracks.py              # Track building (union-find)
โ”‚   โ”œโ”€โ”€ geometry.py            # Geometric utilities
โ”‚   โ”œโ”€โ”€ ba.py                  # Bundle adjustment solver
โ”‚   โ”œโ”€โ”€ diagnostics/           # Analysis & statistics
โ”‚   โ”œโ”€โ”€ filter_utils/          # Outlier filtering
โ”‚   โ”œโ”€โ”€ geometry_utils/        # Projection, triangulation helpers
โ”‚   โ”œโ”€โ”€ mulitcam_utils/        # Multicam-specific utilities
โ”‚   โ””โ”€โ”€ visualization/         # Overlay generation
โ”œโ”€โ”€ datasets/
โ”‚   โ”œโ”€โ”€ multicam.py            # Multicam dataset loader
โ”‚   โ””โ”€โ”€ singlecam.py           # Singlecam dataset loader
โ”œโ”€โ”€ data_io/
โ”‚   โ”œโ”€โ”€ camera.py              # Camera I/O & decomposition
โ”‚   โ”œโ”€โ”€ images.py              # Image loading utilities
โ”‚   โ””โ”€โ”€ pointcloud_io.py       # PLY export
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ run_multicam.py        # Main runner script
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ checkpoint.py          # Checkpoint save/load
โ”‚   โ””โ”€โ”€ logging_utils.py       # Logging utilities
โ””โ”€โ”€ docs/
    โ””โ”€โ”€ assets/                # Documentation images

โš™๏ธ Configuration

All parameters are organized in dataclass configs:

from src.pipeline import SfMConfig, get_textureless_config

# Use a preset
config = get_textureless_config()

# Or customize
config = SfMConfig()
config.matching.feature.sift_contrastThreshold = 0.004  # For textureless
config.triangulation.min_views_accept = 3               # Require 3 views
config.ba.mode = "local+global_end"                     # Enable BA

Feature Presets

Preset Use Case SIFT Contrast
default Textured scenes (buildings, outdoor) 0.04
textureless Smooth surfaces (plastic, skin) 0.004
high_detail Maximum feature extraction 0.02
python -m scripts.run_multicam --feature_preset textureless ...

๐Ÿงช Tested Datasets

Dataset Type Cameras Status
Fountain Singlecam 11 โœ… Working
TempleRing Singlecam 47 โœ… Working
Bird (BBM) Multicam 27 โœ… Working
Pig (BBM) Multicam 27 โœ… Working

๐Ÿ”ฎ Roadmap

  • Sparse SfM pipeline
  • Multicam support with calibrated poses
  • Textureless surface handling
  • Modular config system
  • Dense fusion from seed points
  • Multi-view stereo integration
  • Mesh reconstruction

๐Ÿ“š Documentation


๐Ÿ™ Acknowledgments

  • BBM Multi-camera dataset
  • OpenCV SIFT implementation
  • SciPy optimization for bundle adjustment

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages