Skip to content

Commit 164a41b

Browse files
committed
fix CUDA build
CUDA implementation wants to convert std::vector<KeyPoint> <-> 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.
1 parent 0451629 commit 164a41b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

cmake/OpenCVUtils.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,12 @@ function(ocv_target_link_libraries target)
940940
endif()
941941
endfunction()
942942

943+
function(ocv_target_compile_definitions target)
944+
_ocv_fix_target(target)
945+
target_compile_definitions(${target} ${ARGN})
946+
endfunction()
947+
948+
943949
function(_ocv_append_target_includes target)
944950
if(DEFINED OCV_TARGET_INCLUDE_DIRS_${target})
945951
target_include_directories(${target} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})

modules/core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,9 @@ ocv_target_link_libraries(${the_module} LINK_PRIVATE
6363
"${OPENCV_HAL_LINKER_LIBS}"
6464
)
6565

66+
if(HAVE_CUDA)
67+
ocv_target_compile_definitions(${the_module} PUBLIC OPENCV_TRAITS_ENABLE_DEPRECATED)
68+
endif()
69+
6670
ocv_add_accuracy_tests()
6771
ocv_add_perf_tests()

modules/cudaobjdetect/src/cascadeclassifier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ namespace
186186
}
187187

188188
BufferPool pool(stream);
189-
GpuMat objectsBuf = pool.getBuffer(1, maxNumObjects_, DataType<Rect>::type);
189+
GpuMat objectsBuf = pool.getBuffer(1, maxNumObjects_, traits::Type<Rect>::value);
190190

191191
unsigned int numDetections;
192192
ncvSafeCall( process(image, objectsBuf, ncvMinSize, numDetections) );
@@ -220,7 +220,7 @@ namespace
220220
}
221221

222222
CV_Assert( gpu_objects.rows == 1 );
223-
CV_Assert( gpu_objects.type() == DataType<Rect>::type );
223+
CV_Assert( gpu_objects.type() == traits::Type<Rect>::value );
224224

225225
Rect* ptr = gpu_objects.ptr<Rect>();
226226
objects.assign(ptr, ptr + gpu_objects.cols);
@@ -533,7 +533,7 @@ namespace
533533
const float grouping_eps = 0.2f;
534534

535535
BufferPool pool(stream);
536-
GpuMat objects = pool.getBuffer(1, maxNumObjects_, DataType<Rect>::type);
536+
GpuMat objects = pool.getBuffer(1, maxNumObjects_, traits::Type<Rect>::value);
537537

538538
// used for debug
539539
// candidates.setTo(cv::Scalar::all(0));
@@ -625,7 +625,7 @@ namespace
625625
}
626626

627627
CV_Assert( gpu_objects.rows == 1 );
628-
CV_Assert( gpu_objects.type() == DataType<Rect>::type );
628+
CV_Assert( gpu_objects.type() == traits::Type<Rect>::value );
629629

630630
Rect* ptr = gpu_objects.ptr<Rect>();
631631
objects.assign(ptr, ptr + gpu_objects.cols);

0 commit comments

Comments
 (0)