Created
April 29, 2021 18:02
-
-
Save stjernstrom/e398576733e17a9196396b6768934098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. | |
# | |
# NVIDIA Corporation and its licensors retain all intellectual property | |
# and proprietary rights in and to this software, related documentation | |
# and any modifications thereto. Any use, reproduction, disclosure or | |
# distribution of this software and related documentation without an express | |
# license agreement from NVIDIA Corporation is strictly prohibited. | |
# | |
version="4.5.0" | |
folder="workspace" | |
echo "** Remove other OpenCV first" | |
sudo sudo apt-get purge *libopencv* | |
echo "** Install requirement" | |
sudo apt-get update | |
sudo apt-get install -y build-essential cmake git libgtk2.0-dev libgtk-3-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev | |
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libx264-dev libxvidcore-dev | |
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp qt5-default libgl1 libglvnd-dev zlib1g-dev | |
sudo apt-get install -y curl | |
echo "** Install python requirement" | |
# Python 3.6 | |
sudo apt-get install -y python3-dev python3-numpy python3-py python3-pytest | |
echo "** Install gstreamer requirement" | |
# GStreamer support | |
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev | |
echo "** Download opencv-"${version} | |
mkdir $folder | |
cd ${folder} | |
curl -L https://github.com/opencv/opencv/archive/${version}.zip -o opencv-${version}.zip | |
curl -L https://github.com/opencv/opencv_contrib/archive/${version}.zip -o opencv_contrib-${version}.zip | |
unzip opencv-${version}.zip | |
unzip opencv_contrib-${version}.zip | |
cd opencv-${version}/ | |
# export OPENBLAS_CORETYPE=ARMV8 | |
# export CUDA_HOME=/usr/local/cuda-10.2/ | |
echo "** Building..." | |
mkdir release | |
cd release/ | |
cmake -D WITH_CUDA=ON \ | |
-D WITH_CUDNN=ON \ | |
-D WITH_QT=ON \ | |
-D WITH_OPENGL=ON \ | |
-D WITH_TBB=ON \ | |
-D CUDA_ARCH_BIN="7.2" \ | |
-D CUDA_ARCH_PTX="" \ | |
-D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \ | |
-D CUDA_FAST_MATH=ON \ | |
-D OPENCV_GENERATE_PKGCONFIG=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${version}/modules \ | |
-D WITH_GSTREAMER=ON \ | |
-D WITH_LIBV4L=ON \ | |
-D WITH_V4L=ON \ | |
-D BUILD_opencv_python2=OFF \ | |
-D BUILD_opencv_python3=ON \ | |
-D BUILD_TESTS=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D BUILD_EXAMPLES=OFF \ | |
-D ENABLE_FAST_MATH=ON \ | |
-D BUILD_NEW_PYTHON_SUPPORT=ON \ | |
-D BUILD_opencv_python3=ON \ | |
-D PYTHON3_NUMPY_INCLUDE_DIRS=/home/stjernstrom/.local/lib/python3.6/site-packages/numpy/core/include \ | |
-D PYTHON3_INCLUDE_PATH=/usr/include/python3.6m \ | |
# -D HAVE_opencv_python3=ON \ | |
#-D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3.6 \ | |
#-D PYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.6m.so \ | |
-D CPACK_BINARY_DEB=ON \ | |
-D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
.. | |
make -j$(nproc) | |
sudo make install | |
sudo ldconfig | |
NUM_CPU=$(nproc) | |
time sudo make package -j$(($NUM_CPU - 1)) | |
echo "** Install opencv-"${version}" successfully" | |
echo "** Bye :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment