Note: OpenCV is not officially supported nor is it optimized on the Drive platform. These instructions are provided only to help with porting/prototyping and is not maintained by NVIDIA. It is recommended to utilize NVIDIA APIs moving forward.
Cross compiling OpenCV on host
Pre-Conditions:
- Drive Software 10.0 is installed on the host machine via SDKManager (both host and device).
- cmake is installed (min version 3.10)
The instructions to build OpenCV on Host machine for Drive AGX Linux (V4L) platform:
- Download attached file “FindCUDA.cmake” FindCUDA.cmake.zip (21.3 KB)
- cd <the_folder_where_FindCUDA.cmake_was_downloaded_to>
- execute the following commands:
curl -L https://github.com/opencv/opencv/archive/4.1.1.zip -o opencv-4.1.1.zip
curl -L https://github.com/opencv/opencv_contrib/archive/4.1.1.zip -o opencv_contrib-4.1.1.zip
curl -L https://github.com/opencv/opencv_extra/archive/4.1.1.zip -o opencv_extra-4.1.1.zip
unzip opencv-4.1.1.zip
unzip opencv_extra-4.1.1.zip
unzip opencv_contrib-4.1.1.zip
cd opencv-4.1.1/
echo "** Apply patch"
sed -i 's/include <Eigen\/Core>/include <eigen3\/Eigen\/Core>/g' modules/core/include/opencv2/core/private.hpp
cp ../FindCUDA.cmake cmake/
cp /usr/local/driveworks/samples/cmake/FindCUDA/* cmake/FindCUDA/
cp /usr/local/driveworks/samples/cmake/CMakeParseArguments.cmake cmake/
cp /usr/local/driveworks/samples/cmake/FindPackageHandleStandardArgs.cmake cmake/
cp /usr/local/driveworks/samples/cmake/FindPackageMessage.cmake cmake/
echo "** Building..."
mkdir release
cd release/
export CUDA_PATH=/usr/local/cuda-10.2
cmake \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.1/modules \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2 \
-DCUDA_64_BIT_DEVICE_CODE=ON \
-DCUDA_ARCH_BIN=7.2 \
-DCUDA_ARCH_PTX="" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/driveworks/samples/cmake/Toolchain-V5L.cmake \
-DCMAKE_INSTALL_PREFIX=./install \
-DVIBRANTE_PDK:STRING=<path_to_drive-t186ref-linux_location>/drive-t186ref-linux \
-DBUILD_PNG=ON \
-DBUILD_TIFF=ON \
-DBUILD_TBB=OFF \
-DBUILD_WEBP=OFF \
-DBUILD_JPEG=ON \
-DBUILD_JASPER=ON \
-DBUILD_ZLIB=ON \
-DBUILD_EXAMPLES=ON \
-DBUILD_FFMPEG=ON \
-DBUILD_opencv_java=OFF \
-DBUILD_opencv_python2=OFF \
-DBUILD_opencv_python3=OFF \
-DBUILD_opencv_videoio=OFF \
-DBUILD_opencv_cudaimgproc=OFF \
-DBUILD_opencv_highgui=OFF \
-DBUILD_opencv_freetype=OFF \
-DENABLE_NEON=ON \
-DWITH_PROTOBUF=OFF \
-DWITH_PTHREADS_PF=OFF \
-DWITH_OPENCL=OFF \
-DWITH_OPENMP=OFF \
-DWITH_FFMPEG=ON \
-DWITH_GSTREAMER=OFF \
-DWITH_GSTREAMER_0_10=OFF \
-DWITH_CUDA=ON \
-DWITH_CUDNN=ON \
-DCUDNN_INCLUDE_DIR=/usr/include/aarch64-linux-gnu \
-DWITH_GTK=OFF \
-DWITH_VTK=OFF \
-DWITH_TBB=OFF \
-DWITH_1394=OFF \
-DWITH_OPENEXR=OFF \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_TESTS=OFF \
-DVIBRANTE=TRUE \
VERBOSE=1 \
-DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=TRUE \
-DOPENCV_TEST_DATA_PATH=../opencv_extra-4.1.1/testdata \
../
make -j8
make install
native compiling OpenCV on AGX Drive
Pre-Conditions:
- Drive AGX hardware: Xavier or Pegasus.
- The latest Nvidia Drive Software is installed, SDK can be downloaded from : https://developer.nvidia.com/nvidia-drive-downloads
The instructions to build OpenCV on Drive AGX Linux (V4L) platform:
- Execute the command: sudo apt update
- Execute the command: sudo dpkg -i /var/cuda-repo-10-2-local-10.2.19/cuda-toolkit-10-2_10.2.19-1_arm64.deb
- Execute the command: sudo apt --fix-broken -y install
- Run the script “install_oprncv4.11_Jeston.sh” attached here.install_opencv4.1.1.zip (1.3 KB)