sudo apt-get build-dep libopencv-dev
Configure xstow. Follow these instructions using-xstow-for-local-installations
Clone repositories
cd ~/local/src/repos/gitlab/
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build
ccmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ../
Press "c" once
Search for CMAKE_INSTALL_PREFIX and fill it with
/home/<myuser>/local/DIR/opencv
Search for OPENCV_ENABLE_NONFREE and select "ON"
Press "c", then press "e" and then press "c" again and thenpress "g"
Build
make -j4
make install
cd ~/local/DIR
xstow opencv