From 12518eb6c488a63bd698cfeaef98bdf94d9d7c7c Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Thu, 22 Aug 2024 20:27:25 +0200 Subject: [PATCH] Fix build on Jetpack 5.1.3 --- cmake/OpenCVDetectCUDA.cmake | 5 ++ cmake/OpenCVDetectOpenCL.cmake | 1 - cmake/OpenCVFindOpenEXR.cmake | 116 ++++++++++------------------ contrib/modules/face/CMakeLists.txt | 24 +++--- debian/changelog | 6 ++ debian/control | 46 +++++++++++ debian/rules | 15 +++- debian/shlibs.local | 27 +++++++ doc/header.html | 2 +- 9 files changed, 152 insertions(+), 90 deletions(-) create mode 100644 debian/shlibs.local diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index 509f417e4727..369757efa5f5 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -28,6 +28,11 @@ endif() if(CUDA_FOUND) set(HAVE_CUDA 1) + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + # CUDA 11.0 removes nppicom + ocv_list_filterout(CUDA_nppi_LIBRARY "nppicom") + ocv_list_filterout(CUDA_npp_LIBRARY "nppicom") + endif() if(WITH_CUFFT) set(HAVE_CUFFT 1) diff --git a/cmake/OpenCVDetectOpenCL.cmake b/cmake/OpenCVDetectOpenCL.cmake index 5349d12b690c..3b2afc692ebd 100644 --- a/cmake/OpenCVDetectOpenCL.cmake +++ b/cmake/OpenCVDetectOpenCL.cmake @@ -5,7 +5,6 @@ if(APPLE) else() set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library") set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory") - ocv_install_3rdparty_licenses(opencl-headers "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/LICENSE.txt") endif() mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY) diff --git a/cmake/OpenCVFindOpenEXR.cmake b/cmake/OpenCVFindOpenEXR.cmake index fb6c2fa14690..c0a46806e150 100644 --- a/cmake/OpenCVFindOpenEXR.cmake +++ b/cmake/OpenCVFindOpenEXR.cmake @@ -15,94 +15,60 @@ file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH) if(WIN32) SET(OPENEXR_ROOT "C:/Deploy" CACHE STRING "Path to the OpenEXR \"Deploy\" folder") - if(X86_64) + if(CMAKE_CL_64) SET(OPENEXR_LIBSEARCH_SUFFIXES x64/Release x64 x64/Debug) elseif(MSVC) SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug) endif() +else() + set(OPENEXR_ROOT "") endif() -SET(SEARCH_PATHS - "${OPENEXR_ROOT}" - /usr - /usr/local - /sw - /opt - "${ProgramFiles_ENV_PATH}/OpenEXR") +SET(LIBRARY_PATHS + /usr/lib + /usr/local/lib + /sw/lib + /opt/local/lib + "${ProgramFiles_ENV_PATH}/OpenEXR/lib/static" + "${OPENEXR_ROOT}/lib") -MACRO(FIND_OPENEXR_LIBRARY LIBRARY_NAME LIBRARY_SUFFIX) - string(TOUPPER "${LIBRARY_NAME}" LIBRARY_NAME_UPPER) - FIND_LIBRARY(OPENEXR_${LIBRARY_NAME_UPPER}_LIBRARY - NAMES ${LIBRARY_NAME}${LIBRARY_SUFFIX} - PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} - NO_DEFAULT_PATH - PATHS "${SEARCH_PATH}/lib" "${SEARCH_PATH}/lib/static") -ENDMACRO() +FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h + PATH_SUFFIXES OpenEXR + PATHS + /usr/include + /usr/local/include + /sw/include + /opt/local/include + "${ProgramFiles_ENV_PATH}/OpenEXR/include" + "${OPENEXR_ROOT}/include") -FOREACH(SEARCH_PATH ${SEARCH_PATHS}) - FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h - PATH_SUFFIXES OpenEXR - NO_DEFAULT_PATH - PATHS - "${SEARCH_PATH}/include") +FIND_LIBRARY(OPENEXR_HALF_LIBRARY + NAMES Half + PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} + PATHS ${LIBRARY_PATHS}) - IF (OPENEXR_INCLUDE_PATH) - SET(OPENEXR_VERSION_FILE "${OPENEXR_INCLUDE_PATH}/OpenEXRConfig.h") - IF (EXISTS ${OPENEXR_VERSION_FILE}) - FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_MAJOR ") - IF (${contents} MATCHES "#define OPENEXR_VERSION_MAJOR ([0-9]+)") - SET(OPENEXR_VERSION_MAJOR "${CMAKE_MATCH_1}") - ENDIF () - FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_MINOR ") - IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)") - SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}") - ENDIF () - ENDIF () - ENDIF () +FIND_LIBRARY(OPENEXR_IEX_LIBRARY + NAMES Iex + PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} + PATHS ${LIBRARY_PATHS}) - IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR) - set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}") - ENDIF () +FIND_LIBRARY(OPENEXR_IMATH_LIBRARY + NAMES Imath + PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} + PATHS ${LIBRARY_PATHS}) - SET(LIBRARY_SUFFIXES - "-${OPENEXR_VERSION}" - "-${OPENEXR_VERSION}_s" - "-${OPENEXR_VERSION}_d" - "-${OPEXEXR_VERSION}_s_d" - "" - "_s" - "_d" - "_s_d") +FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY + NAMES IlmImf + PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} + PATHS ${LIBRARY_PATHS}) - FOREACH(LIBRARY_SUFFIX ${LIBRARY_SUFFIXES}) - FIND_OPENEXR_LIBRARY("Half" ${LIBRARY_SUFFIX}) - FIND_OPENEXR_LIBRARY("Iex" ${LIBRARY_SUFFIX}) - FIND_OPENEXR_LIBRARY("Imath" ${LIBRARY_SUFFIX}) - FIND_OPENEXR_LIBRARY("IlmImf" ${LIBRARY_SUFFIX}) - FIND_OPENEXR_LIBRARY("IlmThread" ${LIBRARY_SUFFIX}) - IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) - SET(OPENEXR_FOUND TRUE) - BREAK() - ENDIF() - UNSET(OPENEXR_IMATH_LIBRARY) - UNSET(OPENEXR_ILMIMF_LIBRARY) - UNSET(OPENEXR_IEX_LIBRARY) - UNSET(OPENEXR_ILMTHREAD_LIBRARY) - UNSET(OPENEXR_HALF_LIBRARY) - ENDFOREACH() +FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY + NAMES IlmThread + PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} + PATHS ${LIBRARY_PATHS}) - IF (OPENEXR_FOUND) - BREAK() - ENDIF() - - UNSET(OPENEXR_INCLUDE_PATH) - UNSET(OPENEXR_VERSION_FILE) - UNSET(OPENEXR_VERSION_MAJOR) - UNSET(OPENEXR_VERSION_MINOR) - UNSET(OPENEXR_VERSION) -ENDFOREACH() - -IF (OPENEXR_FOUND) +IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) + SET(OPENEXR_FOUND TRUE) SET(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATH} CACHE PATH "The include paths needed to use OpenEXR") SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR" FORCE) ENDIF () diff --git a/contrib/modules/face/CMakeLists.txt b/contrib/modules/face/CMakeLists.txt index ce3d88874e60..1d2f32856da8 100644 --- a/contrib/modules/face/CMakeLists.txt +++ b/contrib/modules/face/CMakeLists.txt @@ -10,18 +10,18 @@ ocv_define_module(face opencv_core set(__commit_hash "8afa57abc8229d611c4937165d20e2a2d9fc5a12") set(__file_hash "7505c44ca4eb54b4ab1e4777cb96ac05") -ocv_download( - FILENAME face_landmark_model.dat - HASH ${__file_hash} - URL - "${OPENCV_FACE_ALIGNMENT_URL}" - "$ENV{OPENCV_FACE_ALIGNMENT_URL}" - "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${__commit_hash}/" - DESTINATION_DIR "${CMAKE_BINARY_DIR}/${OPENCV_TEST_DATA_INSTALL_PATH}/cv/face/" - ID "data" - RELATIVE_URL - STATUS res -) +#ocv_download( +# FILENAME face_landmark_model.dat +# HASH ${__file_hash} +# URL +# "${OPENCV_FACE_ALIGNMENT_URL}" +# "$ENV{OPENCV_FACE_ALIGNMENT_URL}" +# "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${__commit_hash}/" +# DESTINATION_DIR "${CMAKE_BINARY_DIR}/${OPENCV_TEST_DATA_INSTALL_PATH}/cv/face/" +# ID "data" +# RELATIVE_URL +# STATUS res +#) if(NOT res) message(WARNING "Face: Can't get model file for face alignment.") endif() diff --git a/debian/changelog b/debian/changelog index b0cb01454aa0..bf706c5e3a48 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +opencv (4.2.0+dfsg-5ubuntu1.1cuda11.4) unstable; urgency=medium + + * Add CUDA. + + -- Martin Pecka Thu, 22 Aug 2024 12:11:00 +0200 + opencv (4.2.0+dfsg-5) unstable; urgency=medium [ Mo Zhou ] diff --git a/debian/control b/debian/control index 041e4966b5d6..ec6f9f001a8e 100644 --- a/debian/control +++ b/debian/control @@ -1294,3 +1294,49 @@ Description: Python 3 bindings for the computer vision library of high level functionalities for video acquisition, image processing and analysis, structural analysis, motion analysis and object tracking, object recognition, camera calibration and 3D reconstruction. + +Package: libopencv-cuda-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Depends: + libopencv-core-dev (= ${binary:Version}), + libopencv-cuda4.2 (= ${binary:Version}), + ${misc:Depends}, +Description: development files for libopencv-cuda4.2 + This package contains the header files and static library needed to compile + applications that use OpenCV (Open Computer Vision) CUDA API. + . + The Open Computer Vision Library is a collection of algorithms and sample + code for various computer vision problems. The library is compatible with + IPL (Intel's Image Processing Library) and, if available, can use IPP + (Intel's Integrated Performance Primitives) for better performance. + . + OpenCV provides low level portable data types and operators, and a set + of high level functionalities for video acquisition, image processing and + analysis, structural analysis, motion analysis and object tracking, object + recognition, camera calibration and 3D reconstruction. + +Package: libopencv-cuda4.2 +Section: libs +Architecture: any +Multi-Arch: same +Pre-Depends: + ${misc:Pre-Depends}, +Depends: + libopencv-core4.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends}, +Description: computer vision CUDA API + This package contains the OpenCV (Open Computer Vision) CUDA API. + . + The Open Computer Vision Library is a collection of algorithms and sample + code for various computer vision problems. The library is compatible with + IPL (Intel's Image Processing Library) and, if available, can use IPP + (Intel's Integrated Performance Primitives) for better performance. + . + OpenCV provides low level portable data types and operators, and a set + of high level functionalities for video acquisition, image processing and + analysis, structural analysis, motion analysis and object tracking, object + recognition, camera calibration and 3D reconstruction. + diff --git a/debian/rules b/debian/rules index eacc768059ae..6deed10d8798 100755 --- a/debian/rules +++ b/debian/rules @@ -84,7 +84,7 @@ CMAKE_FLAGS = \ -DPROTOBUF_UPDATE_FILES=ON \ -DWITH_ADE=OFF \ -DWITH_CAROTENE=OFF \ - -DWITH_CUDA=OFF \ + -DWITH_CUDA=ON \ -DWITH_EIGEN=ON \ -DWITH_FFMPEG=ON \ -DWITH_GDAL=ON \ @@ -109,6 +109,19 @@ CMAKE_FLAGS = \ -DWITH_UNICAP=OFF \ -DWITH_VTK=ON \ -DWITH_XINE=OFF \ + -DOPENCV_ENABLE_NONFREE=ON \ + -DENABLE_FAST_MATH=ON \ + -DCUDA_FAST_MATH=ON \ + -DWITH_CUBLAS=ON \ + -DBUILD_opencv_python3=ON \ + -DWITH_OPENMP=ON \ + -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.4 \ + -DCUDNN_INCLUDE_DIR=/usr/include \ + -DCUDNN_LIBRARY=/usr/lib/aarch64-linux-gnu/libcudnn.so.8.6.0 \ + -DCUDNN_VERSION=8.6 \ + -DCUDA_ARCH_BIN="7.2 8.7" \ + -DCUDA_ARCH_PTX="8.7" \ + -DOPENCV_DNN_CUDA=ON \ $(CMAKE_ARCH_FLAGS) %: diff --git a/debian/shlibs.local b/debian/shlibs.local new file mode 100644 index 000000000000..dfbef43524ca --- /dev/null +++ b/debian/shlibs.local @@ -0,0 +1,27 @@ +libcublas 11 libcublas-11-4 (>= 10.0.0) +libcublasLt 11 libcublas-11-4 (>= 10.0.0) +libnvblas 11 libcublas-11-4 (>= 10.0.0) +libcudnn 8 libcudnn8 (>= 8.0.0) +libcudnn_adv_infer 8 libcudnn8 (>= 8.0.0) +libcudnn_adv_train 8 libcudnn8 (>= 8.0.0) +libcudnn_cnn_infer 8 libcudnn8 (>= 8.0.0) +libcudnn_cnn_train 8 libcudnn8 (>= 8.0.0) +libcudnn_ops_infer 8 libcudnn8 (>= 8.0.0) +libcudnn_ops_train 8 libcudnn8 (>= 8.0.0) +libcufft 10 libcufft-11-4 (>= 10.0.0) +libcufftw 10 libcufft-11-4 (>= 10.0.0) +libcurand 10 libcurand-11-4 (>= 10.0.0) +libcusolver 11 libcusolver-11-4 (>= 10.0.0) +libcusolverMg 11 libcusolver-11-4 (>= 10.0.0) +libcusparse 11 libcusparse-11-4 (>= 10.0.0) +libnppc 11 libnpp-11-4 (>= 10.0.0) +libnppial 11 libnpp-11-4 (>= 10.0.0) +libnppicc 11 libnpp-11-4 (>= 10.0.0) +libnppidei 11 libnpp-11-4 (>= 10.0.0) +libnppif 11 libnpp-11-4 (>= 10.0.0) +libnppig 11 libnpp-11-4 (>= 10.0.0) +libnppim 11 libnpp-11-4 (>= 10.0.0) +libnppist 11 libnpp-11-4 (>= 10.0.0) +libnppisu 11 libnpp-11-4 (>= 10.0.0) +libnppitc 11 libnpp-11-4 (>= 10.0.0) +libnpps 11 libnpp-11-4 (>= 10.0.0) diff --git a/doc/header.html b/doc/header.html index 69e8c0df1713..946e083b7999 100644 --- a/doc/header.html +++ b/doc/header.html @@ -9,7 +9,7 @@ $title - + $treeview