Ubuntu 18.04 install opencv

Time:2020-1-21

Unbuntu 18.04 with OpenCV

  • This time, when doing mathematical modeling, problem a involves image processing, so it’s time to install an OpenCV. I wanted to learn it before. This time, it’s a chance for practice.

Installation dependency

sudo apt install cmake
sudo apt install build-essential cmake git libgtk2.0-dev pkg-config libavcodev-dev libavformat-dev libswscale-dev libjasper
  • Error: unable to locate libjasper package
  • Resolvent
sudo add-apt-reposity "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
  • Install common image Toolkit
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
  • Install video I / O pack
sudo apt install libavcodev-dev libavformat-dev libswscale-dev libv4l-dev
  • Install gtk2.0
sudo apt install libgtk2.0-dev
  • Install optimization function package
sudo apt install libatlas-base-dev gfortran

Install opencv

  • From the opencv official website, pull down the corresponding version of source, unzip it, and enter the directory after unzip
  • Create and enter under the unzip folder
Cmkae environment
cmake -D CMAKE_BUILD_TYPE=Rlease -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) -D WITH_TBB=ON -D WITH_EIGEN=ON ..

sudo make
//If it's too slow
sudo make -j2