Skip to content

Instantly share code, notes, and snippets.

@devernay
Forked from kwea123/colmap_colab.ipynb
Created April 15, 2021 00:29
Show Gist options
  • Save devernay/6aa106400dbdc4b6bcbb32bee16b8808 to your computer and use it in GitHub Desktop.
Save devernay/6aa106400dbdc4b6bcbb32bee16b8808 to your computer and use it in GitHub Desktop.
colmap_colab.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "colmap_colab.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyPm82PiwqyzEJ6i0yaFnrIX",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/kwea123/f0e8f38ff2aa94495dbfe7ae9219f75c/colmap_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "SpaQWAQg1VtD",
"colab_type": "text"
},
"source": [
"# Installation"
]
},
{
"cell_type": "code",
"metadata": {
"id": "eGdRYPFIzvFs",
"colab_type": "code",
"colab": {}
},
"source": [
"!sudo apt-get install \\\n",
" git \\\n",
" cmake \\\n",
" build-essential \\\n",
" libboost-program-options-dev \\\n",
" libboost-filesystem-dev \\\n",
" libboost-graph-dev \\\n",
" libboost-regex-dev \\\n",
" libboost-system-dev \\\n",
" libboost-test-dev \\\n",
" libeigen3-dev \\\n",
" libsuitesparse-dev \\\n",
" libfreeimage-dev \\\n",
" libgoogle-glog-dev \\\n",
" libgflags-dev \\\n",
" libglew-dev \\\n",
" qtbase5-dev \\\n",
" libqt5opengl5-dev \\\n",
" libcgal-dev \\\n",
" libcgal-qt5-dev"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "yptHICvs1evY",
"colab_type": "text"
},
"source": [
"## Install Ceres-solver (takes 10~20 minutes...)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "gAwEYpOk0Irw",
"colab_type": "code",
"colab": {}
},
"source": [
"!sudo apt-get install libatlas-base-dev libsuitesparse-dev\n",
"!git clone https://ceres-solver.googlesource.com/ceres-solver\n",
"%cd ceres-solver\n",
"!git checkout $(git describe --tags) # Checkout the latest release\n",
"%mkdir build\n",
"%cd build\n",
"!cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF\n",
"!make\n",
"!sudo make install"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "lmePvOPY3dof",
"colab_type": "text"
},
"source": [
"## Install colmap (takes another 10~20 minutes...)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "gKTtduYW3LpH",
"colab_type": "code",
"colab": {}
},
"source": [
"!git clone https://github.com/colmap/colmap\n",
"%cd colmap\n",
"!git checkout dev\n",
"%mkdir build\n",
"%cd build\n",
"!cmake ..\n",
"!make\n",
"!sudo make install\n",
"!CC=/usr/bin/gcc-6 CXX=/usr/bin/g++-6 cmake .."
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "AH2TnXfE8rCV",
"colab_type": "text"
},
"source": [
"Next, we need to prepare the images to run colmap.\n",
"First, create a folder in your google drive and a subfolder named `images`, and put your images inside."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "GqVrYev0313H",
"colab_type": "text"
},
"source": [
"## Mount your drive (to access data)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "4rH78spM2Rn-",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 124
},
"outputId": "0b4a48e5-6e6d-4001-fd25-d184acff6c91"
},
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive/', force_remount=True)"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": [
"Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly\n",
"\n",
"Enter your authorization code:\n",
"··········\n",
"Mounted at /content/drive/\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0QbTfCds1yy_",
"colab_type": "text"
},
"source": [
"## Clone LLFF util"
]
},
{
"cell_type": "code",
"metadata": {
"id": "QTt2JDhV0QQA",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 173
},
"outputId": "1026caae-c17b-47ba-d160-e6fda96d6f26"
},
"source": [
"%cd /content\n",
"!git clone https://github.com/Fyusion/LLFF"
],
"execution_count": 18,
"outputs": [
{
"output_type": "stream",
"text": [
"/content\n",
"Cloning into 'LLFF'...\n",
"remote: Enumerating objects: 11, done.\u001b[K\n",
"remote: Counting objects: 100% (11/11), done.\u001b[K\n",
"remote: Compressing objects: 100% (10/10), done.\u001b[K\n",
"remote: Total 759 (delta 1), reused 5 (delta 1), pack-reused 748\u001b[K\n",
"Receiving objects: 100% (759/759), 31.94 MiB | 26.72 MiB/s, done.\n",
"Resolving deltas: 100% (403/403), done.\n",
"/content/LLFF\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Zvxe5vDL7blW",
"colab_type": "text"
},
"source": [
"# Run COLMAP! (depending on number of images, this takes 10~20 minutes)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "d9ryuCQt2hEv",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 224
},
"outputId": "b5bccfb5-7ba8-44fd-fe93-eeae82be7fa9"
},
"source": [
"%cd /content/LLFF\n",
"# change the path below to your data folder (the folder containing the `images` folder)\n",
"!python imgs2poses.py \"/content/drive/My Drive/colab/nerf/my/silica/\""
],
"execution_count": 19,
"outputs": [
{
"output_type": "stream",
"text": [
"/content/LLFF\n",
"Need to run COLMAP\n",
"Features extracted\n",
"Features matched\n",
"Sparse map created\n",
"Finished running COLMAP, see /content/drive/My Drive/colab/nerf/my/silica/colmap_output.txt for logs\n",
"Post-colmap\n",
"Cameras 5\n",
"Images # 65\n",
"Points (3181, 3) Visibility (3181, 65)\n",
"Depth stats 1.9465594577666598 62.523538453729515 4.761593846905955\n",
"Done with imgs2poses\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "MLP3_P9q8M9d",
"colab_type": "text"
},
"source": [
"After running colmap, you will get a `poses_bounds.npy` file under your data folder, once you got that, you're ready to train!"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment