-
Notifications
You must be signed in to change notification settings - Fork 2
Build on Linux [Ubuntu 16.04]
Prebuilt versions available for Windows/MacOS
- OpenCV 3 for video frame extraction & image processing
- CUDA for GPU optimization
- COLMAP for photogrammetry - sparse & dense reconstruction
Scripts are written for Python 2.7
- virtualenv optional, but recommended
- virtualenvwrapper optional, but recommended
- numpy
- piexif for reading/writing EXIF data
- fitparse for reading Garmin FIT data
- utm *for converting lat/long coordinates to UTM projection
- Garmin VIRB Edit for extracting FIT data for video & stitching 360° videos [Windows/MacOS only]
Adapted from https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/ and https://colmap.github.io/install.html
- Update existing packages & Libraries
$ sudo apt-get update
$ sudo apt-get upgrade
- Install developer tools
$ sudo apt-get install \
build-essential \
cmake \
pkg-config
- Install OpenCV image dependencies
$ sudo apt-get install \
libjpeg8-dev \
libtiff5-dev \
libjasper-dev \
libpng12-dev
- Install OpenCV video dependencies
$ sudo apt-get install \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev
- Install OpenCV GUI dependencies
$ sudo apt-get install libgtk-3-dev
- Install OpenCV Optimization dependencies
$ sudo apt-get install \
libatlas-base-dev \
gfortran
- Install Python Development Libraries
$ sudo apt-get install \
python2.7-dev \
python3.5-dev
- Install COLMAP Dependencies
$ sudo apt-get install \
libboost-all-dev \
libeigen3-dev \
libsuitesparse-dev \
libfreeimage-dev \
libgoogle-glog-dev \
libgflags-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev
- Install latest NVIDIA drivers
This must be done from the command-line environments -- installing with the GUI active will generally cause errors. Enable CLI with
ctrl+alt+f2
-- you will need to login with username + password ... Delete old drivers
$ sudo apt-get purge nvidia*
Install latest drivers
$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt update
$ sudo apt install nvidia-390
Verify driver installation
$ lsmod | grep nvidia
Reboot to GUI
$ sudo reboot
http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
- Verify CUDA-Capable GPU
$ lspci | grep -i NVIDIA
- Verify gcc is installed
$ gcc --version
- Install kernel headers & dev packages
$ sudo apt-get install linux-headers-$(uname -r)
- Download CUDA 9.1 Runfile Select "runfile (local)" option > Base Installer
- Install CUDA You can skip installing the NVIDA driver, as we have already updated to the latest version. Follow the text prompts & change path names accordingly.
$ cd ~/Downloads
$ sudo sh cuda_<version>_linux.run
Make sure virtualenv is activated with workon sg2018
- Install with
pip
$ pip install piexif fitparse
- Download & unzip OpenCV3 & OpenCV3 Contrib (contains proprietary librarys like SIFT/SURF)
Replace
3.4.1
with most current version
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.4.1.zip
$ unzip opencv.zip
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.1.zip
$ unzip opencv_contrib.zip
- Install
pip
$ cd ~
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ sudo rm -rf ~/get-pip.py ~/.cache/pip
If pip
is already installed, make sure it is up-to-date
python -m pip install --upgrade pip
- Install & Setup Virtual Environment Optional, but recommended
$ sudo pip install virtualenv virtualenvwrapper
Update ~/.bashrc
to include virtualenv commands
$ echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.bashrc
$ echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
$ echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
$ source ~/.bashrc
- Generate Python virtual environment
Here we are creating an environment named
sg2018
, but feel free to choose another name (and update code accordingly)
$ mkvirtualenv sg2018 -p python2
To enable the virtual environment (important for installing & building libraries) - you will see (sg2018)
before the command prompt if activated.
$ workon sg2018
To de-activate the virtual environment:
$ deactivate
- Install NumPy (make sure virtualenv is activated)
$ pip install numpy
- Install OpenCV (make sure virtualenv is activated)
$ cd ~/opencv-3.4.1
$ mkdir build && cd build
$ cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH = ~/opencv_contrib-3.4.1/modules \
-D PYTHON_EXECUTABLE=~/.virtualenvs/sg2018/bin/python \
-D BUILD_EXAMPLES=ON ..
Review output to ensure paths are provided for Python (2 or 3) "Interpreter", "Libraries", "numpy", and "packages path"
- Compile OpenCV (use
-j
flag to compile with more than one processor, eg.$ make -j4
will build with 4 processors)
$ make
$ sudo make install
$ sudo ldconfig
- Ensure OpenCV libraries are exposed to Python 2
$ cd ~/.virtualenvs/sg2018/lib/python2.7/site-packages
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
- Test OpenCV installation & Clean-up Open Python
$ cd ~
$ workon sg2018
$ python
Import OpenCV and check version
import cv2
cv2.__version__
Delete installation ZIP directories
$ cd ~
$ rm -rf opencv-3.4.1 opencv_contrib-3.4.1 opencv.zip opencv_contrib.zip
https://colmap.github.io/install.html
We will build the applications in the directory ~/DEV
, so adjust code if building elsewhere.
NOTE: Some functionality will not be available if CUDA is not installed prior to building COLMAP.
- Install Ceres Solver http://ceres-solver.org/
$ cd ~/DEV
$ sudo apt-get install \
libatlas-base-dev \
libsuitesparse-dev
$ git clone https://ceres-solver.googlesource.com/ceres-solver
$ cd ceres-solver
$ mkdir build
$ cd build
$ cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
$ make
$ sudo make install
- Build COLMAP
$ cd ~/DEV
$ git clone https://github.com/colmap/colmap
$ cd colmap
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install
- Run COLMAP If you run into issues/errors, close terminal and open a new window. Restarting may also be necessary.
Headless CLI mode
$ colmap -h
GUI Mode
$ colmap gui