Skip to content

Instantly share code, notes, and snippets.

@umanda
Last active February 24, 2020 13:23
Show Gist options
  • Save umanda/9bf6e2578cf57c8a35c1779324e0312a to your computer and use it in GitHub Desktop.
Save umanda/9bf6e2578cf57c8a35c1779324e0312a to your computer and use it in GitHub Desktop.
Install OpenCV on Ubuntu 18.04

Setup OpenCV On Ubuntu 18.04

Download Open CV Souce

  1. https://codeload.github.com/opencv/opencv/tar.gz/4.2.0
  2. https://codeload.github.com/opencv/opencv_contrib/tar.gz/4.2.0

Install Dependencies

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update

sudo apt-install cmake-qt-gui -y python-dev libgphoto2-dev python-numpy libv4l2rds0 libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev cmake-qt-gui build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libpng-dev libjasper1 libjasper-dev libjasper-dev python3-dev python3-numpy libv4l-dev libgtk-3-dev libgst-dev  libswscale-dev libtbb2 libtbb-dev libjpeg-dev libtiff-dev libdc1394-22-dev libavformat-dev ffmpeg -y
sudo pip install opencv-python

Configure CMKE

  1. Extract "opencv-4.2.0" and opencv_contrib-4.2.0
  2. Open CMake GUI
  3. Select OpenCV extracted path in "Where is the surce code: (/home/umanda/opencv/opencv-4.2.0 )
  4. Select OpenCV build path in "Where is the surce code: (/home/umanda/opencv/opencv-4.2.0/build ).If you can not find build folder create it.
  5. Search " OPENCV_EXRA_MODULES_PATH" in Serch box and add opencv_contrib-4.2.0/modules path (/home/umanda/opencv/opencv_contrib-4.2.0/modules)
  6. Click Configure
  7. Click Generate
  8. CD to opencv build directory. ( /home/umanda/opencv/opencv-4.2.0/build)
  9. make 10 sudo make install

Setup Clion

  1. Download Clion and Configure it (https://linuxhint.com/install_jetbrains_clion_ubuntu/ )
  2. Create a HelloWorld Project
  3. Edit CMakeLists.txt and Add;
cmake_minimum_required(VERSION 3.15)
project(project_name)

set(CMAKE_CXX_STANDARD 14)
find_package(OpenCV REQUIRED)
add_executable(project_name main.cpp)


include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(projects ${OpenCV_LIBS})

  1. Select "Relaod Changes"

Congrats, your done.!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment