Skip to content

Instantly share code, notes, and snippets.

@jerry73204
Last active May 23, 2020 07:38
Show Gist options
  • Select an option

  • Save jerry73204/d0bf5d5fa4af51b06e7086180686e56a to your computer and use it in GitHub Desktop.

Select an option

Save jerry73204/d0bf5d5fa4af51b06e7086180686e56a to your computer and use it in GitHub Desktop.
OpenCV 4.3.0 installation example
# Set the version we use
pkgver=4.3.0
# Download and unpack OpenCV source code
# Skip it if you already downloaded the file.
aria2c https://github.com/opencv/opencv/archive/$pkgver.tar.gz
tar -xf opencv-$pkgver.tar.gz
# Download and unpack OpenCV extra and plugins source code
# Skip it if you already downloaded the file.
aria2c https://github.com/opencv/opencv_contrib/archive/$pkgver.tar.gz
tar -xf opencv_contrib-$pkgver.tar.gz
# Create a designated dir for build
mkdir build
cd build
# Run cmake along with options
# It runs dependency checks and produce Makefile.
# You have to replace `$pkgver` with value above,
# the `../opencv-$pkgver` path points to the dir containing `CMakeLists.txt`.
cmake ../opencv-$pkgver \
-DWITH_OPENCL=ON \
-DWITH_OPENGL=ON \
-DWITH_TBB=ON \
-DWITH_VULKAN=ON \
-DWITH_QT=ON \
-DBUILD_WITH_DEBUG_INFO=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=ON \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DCMAKE_INSTALL_PREFIX=/opt/opencv$pkgver \
-DCPU_BASELINE_DISABLE=SSE3 \
-DCPU_BASELINE_REQUIRE=SSE2 \
-DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-$pkgver/modules" \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DOPENCV_ENABLE_NONFREE=ON \
-DOPENCV_JNI_INSTALL_PATH=lib \
-DOPENCV_GENERATE_SETUPVARS=OFF \
-DEIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=/usr/bin/gcc-8 \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-8
# Compile th package, the `-j16` means use up to 16 threads
make -j16
# Install the package.
# If the installed dir requires root (here is `/opt/opencv$pkgver`), place `sudo` beforehand.
sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment