Open ccl-private opened 4 years ago
below is buildOpencv .sh, i hope help you
OPENCV_VERSION=4.4.0
ARCH_BIN=6.2
INSTALL_DIR=/usr/local
DOWNLOAD_OPENCV_EXTRAS=YES
OPENCV_SOURCE_DIR=$HOME WHEREAMI=$PWD
CLEANUP=true
function usage { echo "usage: ./buildOpenCVTX1.sh [[-s sourcedir ] | [-h]]" echo "-s | --sourcedir Directory in which to place the opencv sources (default $HOME)" echo "-i | --installdir Directory in which to install opencv libraries (default /usr/local)" echo "-h | --help This message" }
while [ "$1" != "" ]; do case $1 in -s | --sourcedir ) shift OPENCV_SOURCE_DIR=$1 ;; -i | --installdir ) shift INSTALL_DIR=$1 ;; -h | --help ) usage exit ;;
CMAKE_INSTALL_PREFIX=$INSTALL_DIR
source scripts/jetson_variables.sh
echo "Build configuration: " echo " NVIDIA Jetson $JETSON_BOARD" echo " Operating System: $JETSON_L4T_STRING [Jetpack $JETSON_JETPACK]" echo " Current OpenCV Installation: $JETSON_OPENCV" echo " OpenCV binaries will be installed in: $CMAKE_INSTALL_PREFIX" echo " OpenCV Source will be installed in: $OPENCV_SOURCE_DIR"
if [ $DOWNLOAD_OPENCV_EXTRAS == "YES" ] ; then echo "Also installing opencv_extras" fi
sudo add-apt-repository "deb http://ports.ubuntu.com/ubuntu-ports xenial-security main"
sudo apt-add-repository universe sudo apt-get update
cd $WHEREAMI sudo apt-get install -y \ cmake \ libavcodec-dev \ libavformat-dev \ libavutil-dev \ libeigen3-dev \ libglew-dev \ libgtk2.0-dev \ libgtk-3-dev \ libpostproc-dev \ libswscale-dev \ libtbb-dev \ libtiff5-dev \ libv4l-dev \ libxvidcore-dev \ libx264-dev \ qt5-default \ zlib1g-dev \ libjasper-dev \ libjpeg-dev \ libpng-dev \ pkg-config
cd /usr/local/cuda/include sudo patch -N cuda_gl_interop.h $WHEREAMI'/patches/OpenGLHeader.patch'
cd /usr/lib/aarch64-linux-gnu/ sudo ln -s libGL.so.1 libGL.so
sudo apt-get install -y python-dev python-numpy python-py python-pytest
sudo apt-get install -y python3-dev python3-numpy python3-py python3-pytest
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
cd $OPENCV_SOURCE_DIR git clone https://github.com/opencv/opencv.git cd opencv git checkout -b v${OPENCV_VERSION} ${OPENCV_VERSION} if [ $OPENCV_VERSION = 3.4.1 ] ; then
git merge ec0bb66
git cherry-pick 549b5df fi
if [ $DOWNLOAD_OPENCV_EXTRAS == "YES" ] ; then echo "Installing opencv_extras"
cd $OPENCV_SOURCE_DIR
git clone https://github.com/opencv/opencv_contrib.git cd opencv_contrib git checkout -b v${OPENCV_VERSION} ${OPENCV_VERSION} fi
cd $OPENCV_SOURCE_DIR/opencv mkdir build cd build
time cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \ -D WITH_CUDA=ON \ -D CUDA_ARCH_BIN=${ARCH_BIN} \ -D CUDA_ARCH_PTX="" \ -D ENABLE_FAST_MATH=ON \ -D CUDA_FAST_MATH=ON \ -D WITH_CUBLAS=ON \ -D WITH_LIBV4L=ON \ -D WITH_GSTREAMER=ON \ -D WITH_GSTREAMER_0_10=OFF \ -D WITH_QT=ON \ -D WITH_OPENGL=ON \ -D OPENCV_EXTRA_MODULES_PATH=/home/nvidia/opencv_contrib/modules \ -D CUDNN_LIBRARY=/usr/local/cuda/lib64/libcudnn.so.8.0.0 \ -D CUDNN_VERSION='8.0' \ ../
if [ $? -eq 0 ] ; then echo "CMake configuration make successful" else
echo "CMake issues " >&2 echo "Please check the configuration being used" exit 1 fi
NUM_CPU=$(nproc) time make -j$(($NUM_CPU - 1)) if [ $? -eq 0 ] ; then echo "OpenCV make successful" else
echo "Make did not build " >&2 echo "Retrying ... "
make if [ $? -eq 0 ] ; then echo "OpenCV make successful" else
echo "Make did not successfully build" >&2
echo "Please fix issues and retry build"
exit 1
fi fi
echo "Installing ... " sudo make install if [ $? -eq 0 ] ; then echo "OpenCV installed in: $CMAKE_INSTALL_PREFIX" else echo "There was an issue with the final installation" exit 1 fi
IMPORT_CHECK="$(python -c "import cv2 ; print cv2.version")" if [[ $IMPORT_CHECK != $OPENCV_VERSION ]]; then echo "There was an error loading OpenCV in the Python sanity test." echo "The loaded version does not match the version built here." echo "Please check the installation." echo "The first check should be the PYTHONPATH environment variable." fi
opencv‘s dnn moudle is now support for Nvidia cuda, and needs opencv version of 4.2.0. Can you updata the opencv version and build opencv with DNN_CUDA support? Please~