xxxxxxxxxx
// 1) Clone the OpenCV’s and OpenCV contrib repositories:
mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
// 2) Once the download is complete, create a temporary build directory, and navigate to it:
cd ~/opencv_build/opencv
mkdir -p build && cd build
// 3) Set up the OpenCV build with CMake:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=OFF ..
// 4) Start the compilation process:
make -j8
// 5) Install OpenCV with:
sudo make install