Raspbian/Ubuntu - Opencv installation
- RaviKumar Uthirapathy
- Jul 5, 2020
- 1 min read
Updated: Apr 26, 2021
There are two ways to install opencv on ubuntu
Direct method(opencv Package )
install from source
Building the OpenCV library from source is the recommended way of installing OpenCV. The following steps should follow for installation.
Step 1.
sudo apt install build-essential cmake git pkg-config libgtk-3-dev \ libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \ gfortran openexr libatlas-base-dev python3-dev python3-numpy \ libtbb2 libtbb-dev libdc1394-22-dev
Step2.
git clone https://github.com/opencv/opencv.gitgit clone https://github.com/opencv/opencv_contrib.git
Step3.
mkdir ~/opencv_build && cd ~/opencv_build
cd ~/opencv_build/opencv
mkdir build && cd build
Step4.
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_GENERATE_PKGCONFIG=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..
Step5.
sudo make -j4
sudo make install
step6; To check installed version
pkg-config --modversion opencv4
Thats all , Before installation of opencv python3 environment must be installed.
Comments