Skip to content

lynux0906/OpenCv-pp-Ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to build Opencv C++ on Ubuntu

Everyone can install Opencv C++ follow as:

Step 1: Update the ubuntu system packages

sudo apt-get update && sudo apt-get upgrade

Screenshot from 2021-05-23 22-59-15

Step 2: Install required tools and packages

sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

Screenshot from 2021-05-23 23-02-59

Step 3: Download Opencv sources using git

sudo -s

cd /opt

Screenshot from 2021-05-23 23-04-18

git clone https://github.com/Itseez/opencv.git

git clone https://github.com/Itseez/opencv_contrib.git

Screenshot from 2021-05-23 23-10-23

Step 4: Building and Install OpenCv

cd opencv

mkdir release

cd release

Screenshot from 2021-05-23 23-11-44

cmake -D BUILD_TIFF=ON -D WITH_CUDA=OFF -D ENABLE_AVX=OFF -D WITH_OPENGL=OFF -D WITH_OPENCL=OFF -D WITH_IPP=OFF -D WITH_TBB=ON -D BUILD_TBB=ON -D WITH_EIGEN=OFF -D WITH_V4L=OFF -D WITH_VTK=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib/modules /opt/opencv/

Screenshot from 2021-05-23 23-13-38

Screenshot from 2021-05-23 23-14-27

make -j4

Screenshot from 2021-05-23 23-27-30

Screenshot from 2021-05-23 23-28-09

make install

Screenshot from 2021-05-23 23-28-49

Screenshot from 2021-05-23 23-29-26

ldconfig

exit

cd ~

Screenshot from 2021-05-23 23-31-06

Step 5: Find and Set "opencv.pc" file path

ls /usr/local/lib/pkgconfig/

sudo cp /usr/local/lib/pkgconfig/opencv4.pc /usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc

Screenshot from 2021-05-23 23-32-20

Step 6: Check Opencv version

pkg-config --modversion opencv

Screenshot from 2021-05-23 23-33-21

Step 7: Compile and run test.cpp

  • Compile code:

    g++ test.cpp -o test -std=c++11 `pkg-config --cflags --libs opencv`

  • Execute code:

    ./test

About

Build Opencv C++ on Ubuntu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published