From 164a41b399a2539b066cf741df6f2d911b01ea29 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 31 Aug 2017 19:13:07 +0300 Subject: [PATCH] fix CUDA build CUDA implementation wants to convert std::vector <-> GpuMat. There is no direct mapping from KeyPoint (mix of int/float fields) into cv::Mat element type, so this conversion must be avoided. Legacy mode is turned back for CUDA builds. --- cmake/OpenCVUtils.cmake | 6 ++++++ modules/core/CMakeLists.txt | 4 ++++ modules/cudaobjdetect/src/cascadeclassifier.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index e3a1358172..ab24750405 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -940,6 +940,12 @@ function(ocv_target_link_libraries target) endif() endfunction() +function(ocv_target_compile_definitions target) + _ocv_fix_target(target) + target_compile_definitions(${target} ${ARGN}) +endfunction() + + function(_ocv_append_target_includes target) if(DEFINED OCV_TARGET_INCLUDE_DIRS_${target}) target_include_directories(${target} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}}) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 4d6b7bbd82..0f4ccad68b 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -63,5 +63,9 @@ ocv_target_link_libraries(${the_module} LINK_PRIVATE "${OPENCV_HAL_LINKER_LIBS}" ) +if(HAVE_CUDA) + ocv_target_compile_definitions(${the_module} PUBLIC OPENCV_TRAITS_ENABLE_DEPRECATED) +endif() + ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/cudaobjdetect/src/cascadeclassifier.cpp b/modules/cudaobjdetect/src/cascadeclassifier.cpp index c3830ad1f1..bade19d237 100644 --- a/modules/cudaobjdetect/src/cascadeclassifier.cpp +++ b/modules/cudaobjdetect/src/cascadeclassifier.cpp @@ -186,7 +186,7 @@ namespace } BufferPool pool(stream); - GpuMat objectsBuf = pool.getBuffer(1, maxNumObjects_, DataType::type); + GpuMat objectsBuf = pool.getBuffer(1, maxNumObjects_, traits::Type::value); unsigned int numDetections; ncvSafeCall( process(image, objectsBuf, ncvMinSize, numDetections) ); @@ -220,7 +220,7 @@ namespace } CV_Assert( gpu_objects.rows == 1 ); - CV_Assert( gpu_objects.type() == DataType::type ); + CV_Assert( gpu_objects.type() == traits::Type::value ); Rect* ptr = gpu_objects.ptr(); objects.assign(ptr, ptr + gpu_objects.cols); @@ -533,7 +533,7 @@ namespace const float grouping_eps = 0.2f; BufferPool pool(stream); - GpuMat objects = pool.getBuffer(1, maxNumObjects_, DataType::type); + GpuMat objects = pool.getBuffer(1, maxNumObjects_, traits::Type::value); // used for debug // candidates.setTo(cv::Scalar::all(0)); @@ -625,7 +625,7 @@ namespace } CV_Assert( gpu_objects.rows == 1 ); - CV_Assert( gpu_objects.type() == DataType::type ); + CV_Assert( gpu_objects.type() == traits::Type::value ); Rect* ptr = gpu_objects.ptr(); objects.assign(ptr, ptr + gpu_objects.cols);