Skip to content
Proyek

Nannigalaxy/video-3d-reconstruction-gsplat

Lihat di GitHub

Tentang

a streamlined pipeline for converting videos into 3D Gaussian Splatting models

AI dan pembelajaran mesin

Cara angka ini diukur

62 bintang14 Fork +1 dalam 24 jam

Pertumbuhan bintang terukur

dalam 24 jam
+1
dalam 7 hari
+2
dalam 15 hari
+2
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Video to 3D Gaussian Splatting Pipeline

This repository provides a streamlined pipeline for converting videos into 3D Gaussian Splatting models using COLMAP for Structure-from-Motion (SfM) and Speedy-Splat for model training.

-> Blog post where I have shared my experience.

Prerequisites

Installation

  1. Clone this repository:
git clone --recursive https://github.com/nannigalaxy/video-3d-reconstruction-gsplat.git
cd video-3d-reconstruction-gsplat
  1. Make scripts executable:
chmod +x *.sh

Usage

Run the complete pipeline using:

./video_to_gsplat.sh <fps> <input_video_path> <sfm_output_dir> <gsplat_output_dir_path> [--disable_gpu] [--exhaustive]

Parameters:

  • fps: Frame rate for video extraction (e.g. 20)
  • input_video_path: Path to input video file
  • sfm_output_dir: Directory for COLMAP output
  • gsplat_output_dir_path: Directory for final 3D Gaussian Splatting model
  • --disable_gpu (optional): Run COLMAP on CPU. Use this if you have no CUDA-capable GPU.
  • --exhaustive (optional): Use exhaustive instead of sequential matching. Slower, but more robust on non-sequential footage.

Example:

./video_to_gsplat.sh 20 ./input.mp4 ./sfm_output ./gsplat_model

Pipeline Overview

The pipeline consists of three main steps:

  1. Frame Extraction: Extracts frames from input video at specified FPS
  2. Structure from Motion: Uses COLMAP to perform SfM and generate camera parameters
  3. 3D Gaussian Splatting: Trains a Speedy-Splat model using the processed data

Components

Frame Extraction

ffmpeg -i <input_video> -vf "fps=<target_fps>" "frames/frame_%04d.png"

COLMAP Processing

./colmap_undistorted_sfm_export.sh <input_images> <output_dir> [--exhaustive] [--disable_gpu]

Speedy-Splat Training

./train_speedy_splat.sh <sfm_input_dir> <gsplat_output_dir_path>

Training Parameters

Key Speedy-Splat training parameters:

  • Resolution: 1024
  • Iterations: 10000
  • Position Learning Rate: 0.001 (initial) to 0.0001 (final)
  • Feature Learning Rate: 0.0001
  • Densification Interval: 1000
  • Checkpoint Iterations: 500 (--checkpoint_iterations is a list of iterations at which to write a .pth checkpoint, not an interval)
  • Save Iterations: 2000 and 10000 (train.py always appends the final --iterations value)

Output Structure

SFM Output Directory (sfm_output_dir)

sfm_output_dir/
├── database.db            # COLMAP feature database
├── sparse/               # Sparse reconstruction
│   └── 0/               # First reconstruction
│       ├── cameras.bin  # Camera parameters
│       ├── images.bin   # Image parameters
│       └── points3D.bin # 3D point cloud
├── undistorted/         # Undistorted images
│   ├── images/         # Undistorted input images
│   └── sparse/         # Undistorted reconstruction
└── custom_export/      # Exported formats
    ├── scene.ply       # Point cloud in PLY format
    ├── cameras.txt     # Camera parameters in text
    ├── images.txt      # Image parameters in text
    └── points3D.txt    # 3D points in text format

GS Output Directory (gsplat_output_dir)

gsplat_output_dir/
├── chkpnt500.pth       # Training checkpoint (one per --checkpoint_iterations value)
├── cameras.json        # Camera parameters used for training
├── input.ply           # Initial sparse point cloud
├── cfg_args            # Training configuration
└── point_cloud/        # Trained Gaussians
    ├── iteration_2000/
    │   └── point_cloud.ply
    └── iteration_10000/
        └── point_cloud.ply

Viewing Results

Gaussian Splatting Output

You can view the trained Gaussian Splatting model using the SIBR viewer, found in speedy-splat dir or pull from source. Need to build this to use, follow its instructions.

Point Cloud Files

The PLY files (found in gsplat_output_dir/point_cloud/ directory) can be viewed using various 3D visualization tools:

Troubleshooting

COLMAP Issues

  1. CUDA/GPU Errors:

    • If COLMAP fails with CUDA errors, pass --disable_gpu (supported by both video_to_gsplat.sh and colmap_undistorted_sfm_export.sh)
    • Ensure CUDA drivers are up to date
    • Try reducing the maximum image resolution if GPU memory is insufficient
  2. Feature Matching Failures:

    • Increase image overlap by extracting more frames (higher FPS)
    • Try adjusting lighting or camera exposure for better feature detection
  3. Memory Management:

    • For high-resolution videos (2K+), reduce FPS to 8-15
    • Consider downscaling input images using: ffmpeg -i input.mp4 -vf "scale=1920:-1" output.mp4

Gaussian Splatting Issues

  1. Training Stability:

    • If training diverges, try reducing position_lr_init to 0.0005
    • Increase densification_interval to 2000 for complex scenes
    • Pass multiple values to --checkpoint_iterations (e.g. 500 2000 5000) for more frequent checkpoints
  2. Output Quality:

    • Poor reconstruction might indicate insufficient camera coverage
    • Try increasing iterations to 30000-50000 for complex scenes
    • Adjust percent_dense parameter (0.6-0.9) based on scene complexity
  3. Common Error Messages:

    • "CUDA out of memory": Reduce batch size or image resolution
    • "Invalid camera parameters": Check COLMAP reconstruction quality
    • "Missing sparse/0": Ensure COLMAP pipeline completed successfully

License

MIT License - See LICENSE file for details

Licensing Notice

This repository includes a submodule or dependency on the Gaussian Splatting project, which is licensed separately under a non-commercial, research-only license by Inria and MPII.
Please refer to Gaussian-Splatting-LICENSE for full details.
This code cannot be used for commercial purposes without explicit permission from the original authors.

References & Citation

This project builds on:

Speedy-Splat

Original 3D Gaussian Splatting that Speedy-Splat is based-on

Jelajahi proyek terkait

Memuat…