About

This repo contains examples of computer vision methods mostly with OpenCV in C++, curated from

  • OpenCV examples https://docs.opencv.org/4.x/d9/df8/tutorial_root.html and
  • the book Visual SLAM: From Theory to Practice, by X. Gao et al.

Pre-requisites

Work environment: Ubuntu 22.0

OpenCV

Option 1 (core library):

  • install OpenCV
sudo apt install libopencv-dev
  • check installation
dpkg -l libopencv-dev

Option 2 (with required contrib modules):

Install minimal prerequisites

sudo apt update && sudo apt install -y cmake g++ wget unzip libcanberra-gtk-module

Download and unpack sources

wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.x.zip
unzip opencv.zip
unzip opencv_contrib.zip

Create build directory and switch into it

mkdir -p build && cd build

Configure (with contrib path and non-free modules enabled)

cmake -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/optflow\;../opencv_contrib/modules/sfm\;../opencv_contrib/modules/plot\;../opencv_contrib/modules/shape\;../opencv_contrib/modules/stereo\;../opencv_contrib/modules/viz\;../opencv_contrib/modules/ximgproc\;../opencv_contrib/modules/xobjdetect\;../opencv_contrib/modules/xfeatures2d\;../opencv_contrib/modules/xphoto -D OPENCV_ENABLE_NONFREE=ON ../opencv

Build

cmake --build . -j 5

Install

sudo make install

Pangolin

Clone Pangolin along with it's submodules

git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Run these two commands in your terminal to add Homebrew to your PATH:

(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/varora/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

Install recommended packages for Pangolin

./scripts/install_prerequisites.sh -m brew recommended

Install Ninja

sudo apt install ninja-build

Configure and build (with Ninja for faster builds)

 cmake -B build -GNinja
cmake --build build

Eigen

Install Eigen

sudo apt−get install libeigen3−dev