Configurable Docker setup to run COLMAP for 3D reconstruction based on video files or images. This setup leverages NVIDIA GPUs for accelerated processing.
- Docker with Docker Compose support
- NVIDIA Docker runtime (for GPU acceleration)
- Linux system (tested on Ubuntu 22.04; Windows may require modifications)
git clone git@github.com:fabianpfitzner/colmap_docker.git
cd colmap_docker
Important: Add execute permissions to the run script:
chmod +x drone-reconstruction/scripts/run.sh
- Navigate to
drone-reconstruction/projects/and create a directory for your project - Navigate inside your project directory and create a
videos/directory - Copy all videos of your project into the
videos/directory. These will be used for the COLMAP reconstruction - OPTIONAL: Repeat steps 2-3 for additional projects
Your folder structure should look like this:
projects/
├─ your_project/
│ └─ videos/
│ ├─ proj_video_1.mp4
│ ├─ proj_video_2.mp4
│ └─ ...
├─ optional_other_project/
│ └─ videos/
│ ├─ other_proj_video_1.mp4
│ ├─ other_proj_video_2.mp4
│ └─ ...
└─ ...
You can control how many frames are extracted from videos by modifying the --x_frame parameter in drone-reconstruction/scripts/run.sh.
Every n-th frame will be extracted. For example, to extract every 30th frame:
python /home/drone-reconstruction/scripts/video2img.py --x_frame 30Lower values extract more frames (higher quality but slower processing), while higher values extract fewer frames (faster but potentially lower quality reconstruction).
IMPORTANT: Before running, you must configure drone-reconstruction/docker/docker-compose.yml
Set the Docker container user to match your host machine's UID and GID. This ensures proper file ownership for bind-mounted volumes.
- Get your UID and GID:
id
- Update the
userfield indocker-compose.yml:user: <your_UID>:<your_GID>
Specify which CPU cores the container can use:
cpuset: "0-63" # Example: uses cores 0-63Specify which GPU(s) the container can access:
environment:
- NVIDIA_VISIBLE_DEVICES=0 # Use GPU 0, or "all" for all GPUsNavigate to drone-reconstruction/docker/ and run:
docker compose upThis will build and start the container. The process will:
- Extract frames from all video files in each project
- Run COLMAP reconstruction for each project sequentially
IMPORTANT - Container Management:
- DO NOT press
Ctrl+Cto stop the container, as this may corrupt the process - To detach from the running container: simply close the terminal window
- To reattach and view progress: run
docker attach <container-name>in a new terminal - To safely detach from an attached terminal: press
Ctrl+P, thenCtrl+Q
Results are automatically available on your host system via bind mounts in the drone-reconstruction/projects/ directory.
Each project directory will contain:
extracted_frames/- Individual frames extracted from videoscolmap/- COLMAP reconstruction results, including:database.db- Feature databasesparse/- Sparse 3D reconstructiondense/- Dense reconstruction and point cloud (fused.ply)
Important cleanup steps before reusing project folders:
- Delete the
colmap/directory if you want to re-run reconstruction - Delete the
extracted_frames/directory if you want to re-extract frames with different settings- If
extracted_frames/already exists and contains files, frame extraction will be skipped
- If
- Remove old project folders that are no longer needed to avoid unnecessary processing
- If the container fails to start, verify that NVIDIA Docker runtime is properly installed
- Ensure your UID/GID in
docker-compose.ymlmatches your host user - Check that the specified GPU index exists on your system
- Verify that video files have
.mp4or.MP4extensions
