From 71eeaa72765a7147a8ac11bb21c5015148da2930 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 17 Apr 2013 18:05:06 +0400 Subject: [PATCH] gpuarithm module fixes --- modules/gpuarithm/CMakeLists.txt | 18 ++- modules/gpuarithm/include/opencv2/gpuarithm.hpp | 5 +- modules/gpuarithm/perf/perf_core.cpp | 171 ++++++++++++++---------- modules/gpuarithm/perf/perf_precomp.hpp | 9 +- modules/gpuarithm/src/arithm.cpp | 76 ++++++++--- modules/gpuarithm/src/matrix_reductions.cpp | 26 ++-- modules/gpuarithm/src/precomp.hpp | 2 + modules/gpuarithm/test/test_core.cpp | 156 +++++++++++++-------- modules/gpuarithm/test/test_precomp.hpp | 9 +- modules/gpuarithm/test/test_threshold.cpp | 93 ------------- 10 files changed, 295 insertions(+), 270 deletions(-) delete mode 100644 modules/gpuarithm/test/test_threshold.cpp diff --git a/modules/gpuarithm/CMakeLists.txt b/modules/gpuarithm/CMakeLists.txt index c5ce723..4b09dc1 100644 --- a/modules/gpuarithm/CMakeLists.txt +++ b/modules/gpuarithm/CMakeLists.txt @@ -6,12 +6,24 @@ set(the_description "GPU-accelerated Operations on Matrices") ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations) -ocv_define_module(gpuarithm opencv_core OPTIONAL opencv_gpulegacy opencv_imgproc) +ocv_add_module(gpuarithm opencv_core OPTIONAL opencv_gpulegacy) + +ocv_module_include_directories() +ocv_glob_module_sources() + +set(extra_libs "") if(HAVE_CUBLAS) - CUDA_ADD_CUBLAS_TO_TARGET(${the_module}) + list(APPEND extra_libs ${CUDA_cublas_LIBRARY}) endif() if(HAVE_CUFFT) - CUDA_ADD_CUFFT_TO_TARGET(${the_module}) + list(APPEND extra_libs ${CUDA_cufft_LIBRARY}) endif() + +ocv_create_module(${extra_libs}) + +ocv_add_precompiled_headers(${the_module}) + +ocv_add_accuracy_tests(DEPENDS_ON opencv_imgproc) +ocv_add_perf_tests(DEPENDS_ON opencv_imgproc) diff --git a/modules/gpuarithm/include/opencv2/gpuarithm.hpp b/modules/gpuarithm/include/opencv2/gpuarithm.hpp index f65d2ec..2ebaf2a 100644 --- a/modules/gpuarithm/include/opencv2/gpuarithm.hpp +++ b/modules/gpuarithm/include/opencv2/gpuarithm.hpp @@ -43,6 +43,10 @@ #ifndef __OPENCV_GPUARITHM_HPP__ #define __OPENCV_GPUARITHM_HPP__ +#ifndef __cplusplus +# error gpuarithm.hpp header must be compiled as C++ +#endif + #include "opencv2/core/gpumat.hpp" namespace cv { namespace gpu { @@ -331,7 +335,6 @@ struct CV_EXPORTS ConvolveBuf static Size estimateBlockSize(Size result_size, Size templ_size); }; - //! computes convolution (or cross-correlation) of two images using discrete Fourier transform //! supports source images of 32FC1 type only //! result matrix will have 32FC1 type diff --git a/modules/gpuarithm/perf/perf_core.cpp b/modules/gpuarithm/perf/perf_core.cpp index fd388ed..8957d06 100644 --- a/modules/gpuarithm/perf/perf_core.cpp +++ b/modules/gpuarithm/perf/perf_core.cpp @@ -51,7 +51,7 @@ using namespace perf; ////////////////////////////////////////////////////////////////////// // Merge -PERF_TEST_P(Sz_Depth_Cn, Core_Merge, +PERF_TEST_P(Sz_Depth_Cn, Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) @@ -92,7 +92,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, ////////////////////////////////////////////////////////////////////// // Split -PERF_TEST_P(Sz_Depth_Cn, Core_Split, +PERF_TEST_P(Sz_Depth_Cn, Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) @@ -134,7 +134,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Split, ////////////////////////////////////////////////////////////////////// // AddMat -PERF_TEST_P(Sz_Depth, Core_AddMat, +PERF_TEST_P(Sz_Depth, AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -170,7 +170,7 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, ////////////////////////////////////////////////////////////////////// // AddScalar -PERF_TEST_P(Sz_Depth, Core_AddScalar, +PERF_TEST_P(Sz_Depth, AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -205,7 +205,7 @@ PERF_TEST_P(Sz_Depth, Core_AddScalar, ////////////////////////////////////////////////////////////////////// // SubtractMat -PERF_TEST_P(Sz_Depth, Core_SubtractMat, +PERF_TEST_P(Sz_Depth, SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -241,7 +241,7 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, ////////////////////////////////////////////////////////////////////// // SubtractScalar -PERF_TEST_P(Sz_Depth, Core_SubtractScalar, +PERF_TEST_P(Sz_Depth, SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -276,7 +276,7 @@ PERF_TEST_P(Sz_Depth, Core_SubtractScalar, ////////////////////////////////////////////////////////////////////// // MultiplyMat -PERF_TEST_P(Sz_Depth, Core_MultiplyMat, +PERF_TEST_P(Sz_Depth, MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -312,7 +312,7 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, ////////////////////////////////////////////////////////////////////// // MultiplyScalar -PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, +PERF_TEST_P(Sz_Depth, MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -347,7 +347,7 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, ////////////////////////////////////////////////////////////////////// // DivideMat -PERF_TEST_P(Sz_Depth, Core_DivideMat, +PERF_TEST_P(Sz_Depth, DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -383,7 +383,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, ////////////////////////////////////////////////////////////////////// // DivideScalar -PERF_TEST_P(Sz_Depth, Core_DivideScalar, +PERF_TEST_P(Sz_Depth, DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -418,7 +418,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalar, ////////////////////////////////////////////////////////////////////// // DivideScalarInv -PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, +PERF_TEST_P(Sz_Depth, DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -453,7 +453,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, ////////////////////////////////////////////////////////////////////// // AbsDiffMat -PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, +PERF_TEST_P(Sz_Depth, AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -489,7 +489,7 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, ////////////////////////////////////////////////////////////////////// // AbsDiffScalar -PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, +PERF_TEST_P(Sz_Depth, AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { @@ -524,7 +524,7 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, ////////////////////////////////////////////////////////////////////// // Abs -PERF_TEST_P(Sz_Depth, Core_Abs, +PERF_TEST_P(Sz_Depth, Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV_32F))) { @@ -552,7 +552,7 @@ PERF_TEST_P(Sz_Depth, Core_Abs, ////////////////////////////////////////////////////////////////////// // Sqr -PERF_TEST_P(Sz_Depth, Core_Sqr, +PERF_TEST_P(Sz_Depth, Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { @@ -580,7 +580,7 @@ PERF_TEST_P(Sz_Depth, Core_Sqr, ////////////////////////////////////////////////////////////////////// // Sqrt -PERF_TEST_P(Sz_Depth, Core_Sqrt, +PERF_TEST_P(Sz_Depth, Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { @@ -612,7 +612,7 @@ PERF_TEST_P(Sz_Depth, Core_Sqrt, ////////////////////////////////////////////////////////////////////// // Log -PERF_TEST_P(Sz_Depth, Core_Log, +PERF_TEST_P(Sz_Depth, Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { @@ -644,7 +644,7 @@ PERF_TEST_P(Sz_Depth, Core_Log, ////////////////////////////////////////////////////////////////////// // Exp -PERF_TEST_P(Sz_Depth, Core_Exp, +PERF_TEST_P(Sz_Depth, Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { @@ -678,7 +678,7 @@ PERF_TEST_P(Sz_Depth, Core_Exp, DEF_PARAM_TEST(Sz_Depth_Power, cv::Size, MatDepth, double); -PERF_TEST_P(Sz_Depth_Power, Core_Pow, +PERF_TEST_P(Sz_Depth_Power, Pow, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F), Values(0.3, 2.0, 2.4))) @@ -716,7 +716,7 @@ CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE) DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CmpCode); -PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, +PERF_TEST_P(Sz_Depth_Code, CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, CmpCode::all())) @@ -754,7 +754,7 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, ////////////////////////////////////////////////////////////////////// // CompareScalar -PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, +PERF_TEST_P(Sz_Depth_Code, CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, CmpCode::all())) @@ -791,7 +791,7 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, ////////////////////////////////////////////////////////////////////// // BitwiseNot -PERF_TEST_P(Sz_Depth, Core_BitwiseNot, +PERF_TEST_P(Sz_Depth, BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { @@ -823,7 +823,7 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseNot, ////////////////////////////////////////////////////////////////////// // BitwiseAndMat -PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, +PERF_TEST_P(Sz_Depth, BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { @@ -859,7 +859,7 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, ////////////////////////////////////////////////////////////////////// // BitwiseAndScalar -PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, +PERF_TEST_P(Sz_Depth_Cn, BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4)) @@ -899,7 +899,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, ////////////////////////////////////////////////////////////////////// // BitwiseOrMat -PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, +PERF_TEST_P(Sz_Depth, BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { @@ -935,7 +935,7 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, ////////////////////////////////////////////////////////////////////// // BitwiseOrScalar -PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, +PERF_TEST_P(Sz_Depth_Cn, BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4)) @@ -975,7 +975,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, ////////////////////////////////////////////////////////////////////// // BitwiseXorMat -PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, +PERF_TEST_P(Sz_Depth, BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { @@ -1011,7 +1011,7 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, ////////////////////////////////////////////////////////////////////// // BitwiseXorScalar -PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, +PERF_TEST_P(Sz_Depth_Cn, BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4)) @@ -1051,7 +1051,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, ////////////////////////////////////////////////////////////////////// // RShift -PERF_TEST_P(Sz_Depth_Cn, Core_RShift, +PERF_TEST_P(Sz_Depth_Cn, RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4)) @@ -1085,7 +1085,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_RShift, ////////////////////////////////////////////////////////////////////// // LShift -PERF_TEST_P(Sz_Depth_Cn, Core_LShift, +PERF_TEST_P(Sz_Depth_Cn, LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4)) @@ -1119,7 +1119,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_LShift, ////////////////////////////////////////////////////////////////////// // MinMat -PERF_TEST_P(Sz_Depth, Core_MinMat, +PERF_TEST_P(Sz_Depth, MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { @@ -1155,7 +1155,7 @@ PERF_TEST_P(Sz_Depth, Core_MinMat, ////////////////////////////////////////////////////////////////////// // MinScalar -PERF_TEST_P(Sz_Depth, Core_MinScalar, +PERF_TEST_P(Sz_Depth, MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { @@ -1190,7 +1190,7 @@ PERF_TEST_P(Sz_Depth, Core_MinScalar, ////////////////////////////////////////////////////////////////////// // MaxMat -PERF_TEST_P(Sz_Depth, Core_MaxMat, +PERF_TEST_P(Sz_Depth, MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { @@ -1226,7 +1226,7 @@ PERF_TEST_P(Sz_Depth, Core_MaxMat, ////////////////////////////////////////////////////////////////////// // MaxScalar -PERF_TEST_P(Sz_Depth, Core_MaxScalar, +PERF_TEST_P(Sz_Depth, MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { @@ -1263,7 +1263,7 @@ PERF_TEST_P(Sz_Depth, Core_MaxScalar, DEF_PARAM_TEST(Sz_3Depth, cv::Size, MatDepth, MatDepth, MatDepth); -PERF_TEST_P(Sz_3Depth, Core_AddWeighted, +PERF_TEST_P(Sz_3Depth, AddWeighted, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F), @@ -1310,7 +1310,7 @@ CV_FLAGS(GemmFlags, 0, GEMM_1_T, GEMM_2_T, GEMM_3_T) DEF_PARAM_TEST(Sz_Type_Flags, cv::Size, MatType, GemmFlags); -PERF_TEST_P(Sz_Type_Flags, Core_GEMM, +PERF_TEST_P(Sz_Type_Flags, GEMM, Combine(Values(cv::Size(512, 512), cv::Size(1024, 1024)), Values(CV_32FC1, CV_32FC2, CV_64FC1), ALL_GEMM_FLAGS)) @@ -1356,7 +1356,7 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, ////////////////////////////////////////////////////////////////////// // Transpose -PERF_TEST_P(Sz_Type, Core_Transpose, +PERF_TEST_P(Sz_Type, Transpose, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1))) { @@ -1393,7 +1393,7 @@ CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y) DEF_PARAM_TEST(Sz_Depth_Cn_Code, cv::Size, MatDepth, MatCn, FlipCode); -PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, +PERF_TEST_P(Sz_Depth_Cn_Code, Flip, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4, @@ -1431,7 +1431,7 @@ PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, ////////////////////////////////////////////////////////////////////// // LutOneChannel -PERF_TEST_P(Sz_Type, Core_LutOneChannel, +PERF_TEST_P(Sz_Type, LutOneChannel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC3))) { @@ -1466,7 +1466,7 @@ PERF_TEST_P(Sz_Type, Core_LutOneChannel, ////////////////////////////////////////////////////////////////////// // LutMultiChannel -PERF_TEST_P(Sz_Type, Core_LutMultiChannel, +PERF_TEST_P(Sz_Type, LutMultiChannel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC3))) { @@ -1501,7 +1501,7 @@ PERF_TEST_P(Sz_Type, Core_LutMultiChannel, ////////////////////////////////////////////////////////////////////// // MagnitudeComplex -PERF_TEST_P(Sz, Core_MagnitudeComplex, +PERF_TEST_P(Sz, MagnitudeComplex, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -1534,7 +1534,7 @@ PERF_TEST_P(Sz, Core_MagnitudeComplex, ////////////////////////////////////////////////////////////////////// // MagnitudeSqrComplex -PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, +PERF_TEST_P(Sz, MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -1560,7 +1560,7 @@ PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, ////////////////////////////////////////////////////////////////////// // Magnitude -PERF_TEST_P(Sz, Core_Magnitude, +PERF_TEST_P(Sz, Magnitude, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -1594,7 +1594,7 @@ PERF_TEST_P(Sz, Core_Magnitude, ////////////////////////////////////////////////////////////////////// // MagnitudeSqr -PERF_TEST_P(Sz, Core_MagnitudeSqr, +PERF_TEST_P(Sz, MagnitudeSqr, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -1626,7 +1626,7 @@ PERF_TEST_P(Sz, Core_MagnitudeSqr, DEF_PARAM_TEST(Sz_AngleInDegrees, cv::Size, bool); -PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, +PERF_TEST_P(Sz_AngleInDegrees, Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { @@ -1662,7 +1662,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, ////////////////////////////////////////////////////////////////////// // CartToPolar -PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, +PERF_TEST_P(Sz_AngleInDegrees, CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { @@ -1702,7 +1702,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, ////////////////////////////////////////////////////////////////////// // PolarToCart -PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, +PERF_TEST_P(Sz_AngleInDegrees, PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { @@ -1742,7 +1742,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, ////////////////////////////////////////////////////////////////////// // MeanStdDev -PERF_TEST_P(Sz, Core_MeanStdDev, +PERF_TEST_P(Sz, MeanStdDev, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -1780,7 +1780,7 @@ PERF_TEST_P(Sz, Core_MeanStdDev, DEF_PARAM_TEST(Sz_Depth_Norm, cv::Size, MatDepth, NormType); -PERF_TEST_P(Sz_Depth_Norm, Core_Norm, +PERF_TEST_P(Sz_Depth_Norm, Norm, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S, CV_32F), Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))) @@ -1820,7 +1820,7 @@ PERF_TEST_P(Sz_Depth_Norm, Core_Norm, DEF_PARAM_TEST(Sz_Norm, cv::Size, NormType); -PERF_TEST_P(Sz_Norm, Core_NormDiff, +PERF_TEST_P(Sz_Norm, NormDiff, Combine(GPU_TYPICAL_MAT_SIZES, Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))) { @@ -1857,7 +1857,7 @@ PERF_TEST_P(Sz_Norm, Core_NormDiff, ////////////////////////////////////////////////////////////////////// // Sum -PERF_TEST_P(Sz_Depth_Cn, Core_Sum, +PERF_TEST_P(Sz_Depth_Cn, Sum, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4)) @@ -1894,7 +1894,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Sum, ////////////////////////////////////////////////////////////////////// // SumAbs -PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, +PERF_TEST_P(Sz_Depth_Cn, SumAbs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4)) @@ -1927,7 +1927,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, ////////////////////////////////////////////////////////////////////// // SumSqr -PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, +PERF_TEST_P(Sz_Depth_Cn, SumSqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4)) @@ -1960,7 +1960,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, ////////////////////////////////////////////////////////////////////// // MinMax -PERF_TEST_P(Sz_Depth, Core_MinMax, +PERF_TEST_P(Sz_Depth, MinMax, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F))) { @@ -1998,7 +1998,7 @@ PERF_TEST_P(Sz_Depth, Core_MinMax, ////////////////////////////////////////////////////////////////////// // MinMaxLoc -PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, +PERF_TEST_P(Sz_Depth, MinMaxLoc, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F))) { @@ -2038,7 +2038,7 @@ PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, ////////////////////////////////////////////////////////////////////// // CountNonZero -PERF_TEST_P(Sz_Depth, Core_CountNonZero, +PERF_TEST_P(Sz_Depth, CountNonZero, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F))) { @@ -2077,7 +2077,7 @@ CV_ENUM(ReduceDim, Rows, Cols) DEF_PARAM_TEST(Sz_Depth_Cn_Code_Dim, cv::Size, MatDepth, MatCn, ReduceCode, ReduceDim); -PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, +PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Reduce, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S, CV_32F), Values(1, 2, 3, 4), @@ -2118,7 +2118,7 @@ PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, DEF_PARAM_TEST(Sz_Depth_NormType, cv::Size, MatDepth, NormType); -PERF_TEST_P(Sz_Depth_NormType, Core_Normalize, +PERF_TEST_P(Sz_Depth_NormType, Normalize, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(NormType(cv::NORM_INF), @@ -2163,7 +2163,7 @@ CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMP DEF_PARAM_TEST(Sz_Flags, cv::Size, DftFlags); -PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, +PERF_TEST_P(Sz_Flags, MulSpectrums, Combine(GPU_TYPICAL_MAT_SIZES, Values(0, DftFlags(cv::DFT_ROWS)))) { @@ -2197,7 +2197,7 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, ////////////////////////////////////////////////////////////////////// // MulAndScaleSpectrums -PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, +PERF_TEST_P(Sz, MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -2227,7 +2227,7 @@ PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, ////////////////////////////////////////////////////////////////////// // Dft -PERF_TEST_P(Sz_Flags, ImgProc_Dft, +PERF_TEST_P(Sz_Flags, Dft, Combine(GPU_TYPICAL_MAT_SIZES, Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))) { @@ -2258,14 +2258,12 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, } } -#ifdef HAVE_OPENCV_IMGPROC - ////////////////////////////////////////////////////////////////////// // CopyMakeBorder DEF_PARAM_TEST(Sz_Depth_Cn_Border, cv::Size, MatDepth, MatCn, BorderMode); -PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, +PERF_TEST_P(Sz_Depth_Cn_Border, CopyMakeBorder, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4, @@ -2303,7 +2301,7 @@ PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, ////////////////////////////////////////////////////////////////////// // Integral -PERF_TEST_P(Sz, ImgProc_Integral, +PERF_TEST_P(Sz, Integral, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -2334,7 +2332,7 @@ PERF_TEST_P(Sz, ImgProc_Integral, ////////////////////////////////////////////////////////////////////// // IntegralSqr -PERF_TEST_P(Sz, ImgProc_IntegralSqr, +PERF_TEST_P(Sz, IntegralSqr, GPU_TYPICAL_MAT_SIZES) { const cv::Size size = GetParam(); @@ -2362,7 +2360,7 @@ PERF_TEST_P(Sz, ImgProc_IntegralSqr, DEF_PARAM_TEST(Sz_KernelSz_Ccorr, cv::Size, int, bool); -PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, +PERF_TEST_P(Sz_KernelSz_Ccorr, Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool())) @@ -2405,4 +2403,41 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, } } -#endif +////////////////////////////////////////////////////////////////////// +// Threshold + +CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV) +#define ALL_THRESH_OPS ValuesIn(ThreshOp::all()) + +DEF_PARAM_TEST(Sz_Depth_Op, cv::Size, MatDepth, ThreshOp); + +PERF_TEST_P(Sz_Depth_Op, Threshold, + Combine(GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F, CV_64F), + ALL_THRESH_OPS)) +{ + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int threshOp = GET_PARAM(2); + + cv::Mat src(size, depth); + declare.in(src, WARMUP_RNG); + + if (PERF_RUN_GPU()) + { + const cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat dst; + + TEST_CYCLE() cv::gpu::threshold(d_src, dst, 100.0, 255.0, threshOp); + + GPU_SANITY_CHECK(dst, 1e-10); + } + else + { + cv::Mat dst; + + TEST_CYCLE() cv::threshold(src, dst, 100.0, 255.0, threshOp); + + CPU_SANITY_CHECK(dst); + } +} diff --git a/modules/gpuarithm/perf/perf_precomp.hpp b/modules/gpuarithm/perf/perf_precomp.hpp index bee3780..0b50ab0 100644 --- a/modules/gpuarithm/perf/perf_precomp.hpp +++ b/modules/gpuarithm/perf/perf_precomp.hpp @@ -54,14 +54,9 @@ #include "opencv2/ts.hpp" #include "opencv2/ts/gpu_perf.hpp" -#include "opencv2/core.hpp" #include "opencv2/gpuarithm.hpp" - -#include "opencv2/opencv_modules.hpp" - -#ifdef HAVE_OPENCV_IMGPROC -# include "opencv2/imgproc.hpp" -#endif +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" #ifdef GTEST_CREATE_SHARED_LIBRARY #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined diff --git a/modules/gpuarithm/src/arithm.cpp b/modules/gpuarithm/src/arithm.cpp index f5af24e..cc85cc7 100644 --- a/modules/gpuarithm/src/arithm.cpp +++ b/modules/gpuarithm/src/arithm.cpp @@ -234,7 +234,7 @@ void cv::gpu::gemm(const GpuMat& src1, const GpuMat& src2, double alpha, const G { if (tr3) { - transpose(src3, dst, stream); + gpu::transpose(src3, dst, stream); } else { @@ -638,13 +638,13 @@ void cv::gpu::normalize(const GpuMat& src, GpuMat& dst, double a, double b, int { double smin = 0, smax = 0; double dmin = std::min(a, b), dmax = std::max(a, b); - minMax(src, &smin, &smax, mask, norm_buf); + gpu::minMax(src, &smin, &smax, mask, norm_buf); scale = (dmax - dmin) * (smax - smin > std::numeric_limits::epsilon() ? 1.0 / (smax - smin) : 0.0); shift = dmin - smin * scale; } else if (norm_type == NORM_L2 || norm_type == NORM_L1 || norm_type == NORM_INF) { - scale = norm(src, norm_type, mask, norm_buf); + scale = gpu::norm(src, norm_type, mask, norm_buf); scale = scale > std::numeric_limits::epsilon() ? a / scale : 0.0; shift = 0; } @@ -779,7 +779,7 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom void cv::gpu::integral(const GpuMat& src, GpuMat& sum, Stream& s) { GpuMat buffer; - integralBuffered(src, sum, buffer, s); + gpu::integralBuffered(src, sum, buffer, s); } namespace cv { namespace gpu { namespace cudev @@ -891,6 +891,8 @@ void cv::gpu::sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& s) ////////////////////////////////////////////////////////////////////////////// // mulSpectrums +#ifdef HAVE_CUFFT + namespace cv { namespace gpu { namespace cudev { void mulSpectrums(const PtrStep a, const PtrStep b, PtrStepSz c, cudaStream_t stream); @@ -898,9 +900,20 @@ namespace cv { namespace gpu { namespace cudev void mulSpectrums_CONJ(const PtrStep a, const PtrStep b, PtrStepSz c, cudaStream_t stream); }}} +#endif + void cv::gpu::mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB, Stream& stream) { - (void)flags; +#ifndef HAVE_CUFFT + (void) a; + (void) b; + (void) c; + (void) flags; + (void) conjB; + (void) stream; + throw_no_cuda(); +#else + (void) flags; typedef void (*Caller)(const PtrStep, const PtrStep, PtrStepSz, cudaStream_t stream); @@ -913,11 +926,14 @@ void cv::gpu::mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flag Caller caller = callers[(int)conjB]; caller(a, b, c, StreamAccessor::getStream(stream)); +#endif } ////////////////////////////////////////////////////////////////////////////// // mulAndScaleSpectrums +#ifdef HAVE_CUFFT + namespace cv { namespace gpu { namespace cudev { void mulAndScaleSpectrums(const PtrStep a, const PtrStep b, float scale, PtrStepSz c, cudaStream_t stream); @@ -925,8 +941,20 @@ namespace cv { namespace gpu { namespace cudev void mulAndScaleSpectrums_CONJ(const PtrStep a, const PtrStep b, float scale, PtrStepSz c, cudaStream_t stream); }}} +#endif + void cv::gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, float scale, bool conjB, Stream& stream) { +#ifndef HAVE_CUFFT + (void) a; + (void) b; + (void) c; + (void) flags; + (void) scale; + (void) conjB; + (void) stream; + throw_no_cuda(); +#else (void)flags; typedef void (*Caller)(const PtrStep, const PtrStep, float scale, PtrStepSz, cudaStream_t stream); @@ -939,6 +967,7 @@ void cv::gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, Caller caller = callers[(int)conjB]; caller(a, b, scale, c, StreamAccessor::getStream(stream)); +#endif } ////////////////////////////////////////////////////////////////////////////// @@ -947,15 +976,12 @@ void cv::gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, void cv::gpu::dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags, Stream& stream) { #ifndef HAVE_CUFFT - - OPENCV_GPU_UNUSED(src); - OPENCV_GPU_UNUSED(dst); - OPENCV_GPU_UNUSED(dft_size); - OPENCV_GPU_UNUSED(flags); - OPENCV_GPU_UNUSED(stream); - + (void) src; + (void) dst; + (void) dft_size; + (void) flags; + (void) stream; throw_no_cuda(); - #else CV_Assert(src.type() == CV_32F || src.type() == CV_32FC2); @@ -1094,16 +1120,22 @@ Size cv::gpu::ConvolveBuf::estimateBlockSize(Size result_size, Size /*templ_size void cv::gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr) { ConvolveBuf buf; - convolve(image, templ, result, ccorr, buf); + gpu::convolve(image, templ, result, ccorr, buf); } void cv::gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr, ConvolveBuf& buf, Stream& stream) { - using namespace ::cv::gpu::cudev::imgproc; - #ifndef HAVE_CUFFT + (void) image; + (void) templ; + (void) result; + (void) ccorr; + (void) buf; + (void) stream; throw_no_cuda(); #else + using namespace cv::gpu::cudev::imgproc; + CV_Assert(image.type() == CV_32F); CV_Assert(templ.type() == CV_32F); @@ -1129,8 +1161,8 @@ void cv::gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, cufftSafeCall( cufftSetStream(planC2R, StreamAccessor::getStream(stream)) ); GpuMat templ_roi(templ.size(), CV_32F, templ.data, templ.step); - copyMakeBorder(templ_roi, templ_block, 0, templ_block.rows - templ_roi.rows, 0, - templ_block.cols - templ_roi.cols, 0, Scalar(), stream); + gpu::copyMakeBorder(templ_roi, templ_block, 0, templ_block.rows - templ_roi.rows, 0, + templ_block.cols - templ_roi.cols, 0, Scalar(), stream); cufftSafeCall(cufftExecR2C(planR2C, templ_block.ptr(), templ_spect.ptr())); @@ -1144,13 +1176,13 @@ void cv::gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, std::min(y + dft_size.height, image.rows) - y); GpuMat image_roi(image_roi_size, CV_32F, (void*)(image.ptr(y) + x), image.step); - copyMakeBorder(image_roi, image_block, 0, image_block.rows - image_roi.rows, - 0, image_block.cols - image_roi.cols, 0, Scalar(), stream); + gpu::copyMakeBorder(image_roi, image_block, 0, image_block.rows - image_roi.rows, + 0, image_block.cols - image_roi.cols, 0, Scalar(), stream); cufftSafeCall(cufftExecR2C(planR2C, image_block.ptr(), image_spect.ptr())); - mulAndScaleSpectrums(image_spect, templ_spect, result_spect, 0, - 1.f / dft_size.area(), ccorr, stream); + gpu::mulAndScaleSpectrums(image_spect, templ_spect, result_spect, 0, + 1.f / dft_size.area(), ccorr, stream); cufftSafeCall(cufftExecC2R(planC2R, result_spect.ptr(), result_data.ptr())); diff --git a/modules/gpuarithm/src/matrix_reductions.cpp b/modules/gpuarithm/src/matrix_reductions.cpp index dbb6c09..6ffde17 100644 --- a/modules/gpuarithm/src/matrix_reductions.cpp +++ b/modules/gpuarithm/src/matrix_reductions.cpp @@ -155,12 +155,12 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev, GpuMat double cv::gpu::norm(const GpuMat& src, int normType) { GpuMat buf; - return norm(src, normType, GpuMat(), buf); + return gpu::norm(src, normType, GpuMat(), buf); } double cv::gpu::norm(const GpuMat& src, int normType, GpuMat& buf) { - return norm(src, normType, GpuMat(), buf); + return gpu::norm(src, normType, GpuMat(), buf); } double cv::gpu::norm(const GpuMat& src, int normType, const GpuMat& mask, GpuMat& buf) @@ -171,14 +171,14 @@ double cv::gpu::norm(const GpuMat& src, int normType, const GpuMat& mask, GpuMat GpuMat src_single_channel = src.reshape(1); if (normType == NORM_L1) - return absSum(src_single_channel, mask, buf)[0]; + return gpu::absSum(src_single_channel, mask, buf)[0]; if (normType == NORM_L2) - return std::sqrt(sqrSum(src_single_channel, mask, buf)[0]); + return std::sqrt(gpu::sqrSum(src_single_channel, mask, buf)[0]); // NORM_INF double min_val, max_val; - minMax(src_single_channel, &min_val, &max_val, mask, buf); + gpu::minMax(src_single_channel, &min_val, &max_val, mask, buf); return std::max(std::abs(min_val), std::abs(max_val)); } @@ -232,12 +232,12 @@ namespace sum Scalar cv::gpu::sum(const GpuMat& src) { GpuMat buf; - return sum(src, GpuMat(), buf); + return gpu::sum(src, GpuMat(), buf); } Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf) { - return sum(src, GpuMat(), buf); + return gpu::sum(src, GpuMat(), buf); } Scalar cv::gpu::sum(const GpuMat& src, const GpuMat& mask, GpuMat& buf) @@ -278,12 +278,12 @@ Scalar cv::gpu::sum(const GpuMat& src, const GpuMat& mask, GpuMat& buf) Scalar cv::gpu::absSum(const GpuMat& src) { GpuMat buf; - return absSum(src, GpuMat(), buf); + return gpu::absSum(src, GpuMat(), buf); } Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf) { - return absSum(src, GpuMat(), buf); + return gpu::absSum(src, GpuMat(), buf); } Scalar cv::gpu::absSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf) @@ -324,12 +324,12 @@ Scalar cv::gpu::absSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf) Scalar cv::gpu::sqrSum(const GpuMat& src) { GpuMat buf; - return sqrSum(src, GpuMat(), buf); + return gpu::sqrSum(src, GpuMat(), buf); } Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf) { - return sqrSum(src, GpuMat(), buf); + return gpu::sqrSum(src, GpuMat(), buf); } Scalar cv::gpu::sqrSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf) @@ -381,7 +381,7 @@ namespace minMax void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask) { GpuMat buf; - minMax(src, minVal, maxVal, mask, buf); + gpu::minMax(src, minVal, maxVal, mask, buf); } void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf) @@ -431,7 +431,7 @@ namespace minMaxLoc void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, const GpuMat& mask) { GpuMat valBuf, locBuf; - minMaxLoc(src, minVal, maxVal, minLoc, maxLoc, mask, valBuf, locBuf); + gpu::minMaxLoc(src, minVal, maxVal, minLoc, maxLoc, mask, valBuf, locBuf); } void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, diff --git a/modules/gpuarithm/src/precomp.hpp b/modules/gpuarithm/src/precomp.hpp index 05493aa..ce497ee 100644 --- a/modules/gpuarithm/src/precomp.hpp +++ b/modules/gpuarithm/src/precomp.hpp @@ -45,6 +45,8 @@ #include +#include "cvconfig.h" + #include "opencv2/gpuarithm.hpp" #include "opencv2/core/utility.hpp" #include "opencv2/core/core_c.h" diff --git a/modules/gpuarithm/test/test_core.cpp b/modules/gpuarithm/test/test_core.cpp index dd8f854..aea7086 100644 --- a/modules/gpuarithm/test/test_core.cpp +++ b/modules/gpuarithm/test/test_core.cpp @@ -104,7 +104,7 @@ GPU_TEST_P(Merge, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Merge, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Merge, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -171,7 +171,7 @@ GPU_TEST_P(Split, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Split, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Split, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -237,7 +237,7 @@ GPU_TEST_P(Add_Array, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Add_Array, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Add_Array, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -299,7 +299,7 @@ GPU_TEST_P(Add_Array_Mask, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Add_Array_Mask, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Add_Array_Mask, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -387,7 +387,7 @@ GPU_TEST_P(Add_Scalar, WithMask) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Add_Scalar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Add_Scalar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -452,7 +452,7 @@ GPU_TEST_P(Subtract_Array, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Subtract_Array, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Subtract_Array, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -514,7 +514,7 @@ GPU_TEST_P(Subtract_Array_Mask, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Subtract_Array_Mask, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Subtract_Array_Mask, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -602,7 +602,7 @@ GPU_TEST_P(Subtract_Scalar, WithMask) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Subtract_Scalar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Subtract_Scalar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -696,7 +696,7 @@ GPU_TEST_P(Multiply_Array, WithScale) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Multiply_Array, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Multiply_Array, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -796,7 +796,7 @@ GPU_TEST_P(Multiply_Array_Special, Case_16SC4x_32FC1) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Multiply_Array_Special, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Multiply_Array_Special, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, WHOLE_SUBMAT)); @@ -882,7 +882,7 @@ GPU_TEST_P(Multiply_Scalar, WithScale) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Multiply_Scalar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Multiply_Scalar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -976,7 +976,7 @@ GPU_TEST_P(Divide_Array, WithScale) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Divide_Array, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Divide_Array, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -1076,7 +1076,7 @@ GPU_TEST_P(Divide_Array_Special, Case_16SC4x_32FC1) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Divide_Array_Special, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Divide_Array_Special, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, WHOLE_SUBMAT)); @@ -1161,7 +1161,7 @@ GPU_TEST_P(Divide_Scalar, WithScale) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Divide_Scalar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Divide_Scalar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -1217,7 +1217,7 @@ GPU_TEST_P(Divide_Scalar_Inv, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Divide_Scalar_Inv, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Divide_Scalar_Inv, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, DEPTH_PAIRS, @@ -1302,7 +1302,7 @@ GPU_TEST_P(AbsDiff, Scalar) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, AbsDiff, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, AbsDiff, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -1341,7 +1341,7 @@ GPU_TEST_P(Abs, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Abs, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Abs, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_16S), MatDepth(CV_32F)), @@ -1381,7 +1381,7 @@ GPU_TEST_P(Sqr, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Sqr, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Sqr, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -1451,7 +1451,7 @@ GPU_TEST_P(Sqrt, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, depth < CV_32F ? 1.0 : 1e-5); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Sqrt, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Sqrt, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -1521,7 +1521,7 @@ GPU_TEST_P(Log, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, depth < CV_32F ? 1.0 : 1e-6); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Log, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Log, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -1601,7 +1601,7 @@ GPU_TEST_P(Exp, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, depth < CV_32F ? 1.0 : 1e-2); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Exp, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Exp, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -1664,7 +1664,7 @@ GPU_TEST_P(Compare_Array, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Compare_Array, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Compare_Array, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -1775,7 +1775,7 @@ GPU_TEST_P(Compare_Scalar, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Compare_Scalar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Compare_Scalar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, TYPES(CV_8U, CV_64F, 1, 4), @@ -1847,7 +1847,7 @@ GPU_TEST_P(Bitwise_Array, Xor) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Bitwise_Array, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Bitwise_Array, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, TYPES(CV_8U, CV_32S, 1, 4))); @@ -1913,7 +1913,7 @@ GPU_TEST_P(Bitwise_Scalar, Xor) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Bitwise_Scalar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Bitwise_Scalar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32S)), @@ -1988,7 +1988,7 @@ GPU_TEST_P(RShift, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, RShift, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, RShift, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -2068,7 +2068,7 @@ GPU_TEST_P(LShift, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, LShift, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, LShift, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32S)), @@ -2152,7 +2152,7 @@ GPU_TEST_P(Min, Scalar) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Min, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Min, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -2235,7 +2235,7 @@ GPU_TEST_P(Max, Scalar) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Max, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Max, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -2294,7 +2294,7 @@ GPU_TEST_P(Pow, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Pow, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Pow, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -2357,7 +2357,7 @@ GPU_TEST_P(AddWeighted, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, AddWeighted, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, AddWeighted, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -2437,7 +2437,7 @@ GPU_TEST_P(GEMM, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, GEMM, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, GEMM, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatType(CV_32FC1), MatType(CV_32FC2), MatType(CV_64FC1), MatType(CV_64FC2)), @@ -2495,7 +2495,7 @@ GPU_TEST_P(Transpose, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, Transpose, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Transpose, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatType(CV_8UC1), @@ -2547,7 +2547,7 @@ GPU_TEST_P(Flip, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Flip, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Flip, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatType(CV_8UC1), @@ -2614,7 +2614,7 @@ GPU_TEST_P(LUT, MultiChannel) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, LUT, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, LUT, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatType(CV_8UC1), MatType(CV_8UC3)), @@ -2699,7 +2699,7 @@ GPU_TEST_P(Magnitude, Sqr_Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 1e-1); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Magnitude, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Magnitude, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, WHOLE_SUBMAT)); @@ -2744,7 +2744,7 @@ GPU_TEST_P(Phase, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, angleInDegrees ? 1e-2 : 1e-3); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Phase, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Phase, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(AngleInDegrees(false), AngleInDegrees(true)), @@ -2788,7 +2788,7 @@ GPU_TEST_P(CartToPolar, Accuracy) EXPECT_MAT_NEAR(angle_gold, angle, angleInDegrees ? 1e-2 : 1e-3); } -INSTANTIATE_TEST_CASE_P(GPU_Core, CartToPolar, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, CartToPolar, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(AngleInDegrees(false), AngleInDegrees(true)), @@ -2832,7 +2832,7 @@ GPU_TEST_P(PolarToCart, Accuracy) EXPECT_MAT_NEAR(y_gold, y, 1e-4); } -INSTANTIATE_TEST_CASE_P(GPU_Core, PolarToCart, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, PolarToCart, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(AngleInDegrees(false), AngleInDegrees(true)), @@ -2889,7 +2889,7 @@ GPU_TEST_P(MeanStdDev, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, MeanStdDev, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, MeanStdDev, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, WHOLE_SUBMAT)); @@ -2930,7 +2930,7 @@ GPU_TEST_P(Norm, Accuracy) EXPECT_NEAR(val_gold, val, depth < CV_32F ? 0.0 : 1.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Norm, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Norm, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -2975,7 +2975,7 @@ GPU_TEST_P(NormDiff, Accuracy) EXPECT_NEAR(val_gold, val, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_Core, NormDiff, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, NormDiff, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(NormCode(cv::NORM_L1), NormCode(cv::NORM_L2), NormCode(cv::NORM_INF)), @@ -3113,7 +3113,7 @@ GPU_TEST_P(Sum, Sqr) EXPECT_SCALAR_NEAR(val_gold, val, CV_MAT_DEPTH(type) < CV_32F ? 0.0 : 0.5); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Sum, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Sum, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, TYPES(CV_8U, CV_64F, 1, 4), @@ -3230,7 +3230,7 @@ GPU_TEST_P(MinMax, NullPtr) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, MinMax, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, MinMax, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -3396,7 +3396,7 @@ GPU_TEST_P(MinMaxLoc, NullPtr) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, MinMaxLoc, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, MinMaxLoc, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -3451,7 +3451,7 @@ GPU_TEST_P(CountNonZero, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_Core, CountNonZero, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, CountNonZero, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -3529,7 +3529,7 @@ GPU_TEST_P(Reduce, Cols) EXPECT_MAT_NEAR(dst_gold, dst, dst_depth < CV_32F ? 0.0 : 0.02); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Reduce, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Reduce, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatDepth(CV_8U), @@ -3600,7 +3600,7 @@ GPU_TEST_P(Normalize, WithMask) EXPECT_MAT_NEAR(dst_gold, dst, 1e-6); } -INSTANTIATE_TEST_CASE_P(GPU_Core, Normalize, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Normalize, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, ALL_DEPTH, @@ -3658,7 +3658,7 @@ GPU_TEST_P(MulSpectrums, Scaled) EXPECT_MAT_NEAR(c_gold, c, 1e-2); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MulSpectrums, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, MulSpectrums, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS)))); @@ -3791,7 +3791,7 @@ GPU_TEST_P(Dft, R2CThenC2R) testR2CThenC2R("single row 1", cols + 1, 1, true); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Dft, ALL_DEVICES); +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Dft, ALL_DEVICES); //////////////////////////////////////////////////////// // Convolve @@ -3873,14 +3873,12 @@ GPU_TEST_P(Convolve, Accuracy) EXPECT_MAT_NEAR(dst, dst_gold, 1e-1); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Convolve, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Convolve, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(KSize(3), KSize(7), KSize(11), KSize(17), KSize(19), KSize(23), KSize(45)), testing::Values(Ccorr(false), Ccorr(true)))); -#ifdef HAVE_OPENCV_IMGPROC - ////////////////////////////////////////////////////////////////////////////// // CopyMakeBorder @@ -3925,7 +3923,7 @@ GPU_TEST_P(CopyMakeBorder, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, CopyMakeBorder, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatType(CV_8UC1), @@ -3973,11 +3971,57 @@ GPU_TEST_P(Integral, Accuracy) EXPECT_MAT_NEAR(dst_gold, dst, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Integral, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Integral, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, WHOLE_SUBMAT)); -#endif +/////////////////////////////////////////////////////////////////////////////////////////////////////// +// Threshold + +CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV) +#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV)) + +PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi) +{ + cv::gpu::DeviceInfo devInfo; + cv::Size size; + int type; + int threshOp; + bool useRoi; + + virtual void SetUp() + { + devInfo = GET_PARAM(0); + size = GET_PARAM(1); + type = GET_PARAM(2); + threshOp = GET_PARAM(3); + useRoi = GET_PARAM(4); + + cv::gpu::setDevice(devInfo.deviceID()); + } +}; + +GPU_TEST_P(Threshold, Accuracy) +{ + cv::Mat src = randomMat(size, type); + double maxVal = randomDouble(20.0, 127.0); + double thresh = randomDouble(0.0, maxVal); + + cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi); + cv::gpu::threshold(loadMat(src, useRoi), dst, thresh, maxVal, threshOp); + + cv::Mat dst_gold; + cv::threshold(src, dst_gold, thresh, maxVal, threshOp); + + EXPECT_MAT_NEAR(dst_gold, dst, 0.0); +} + +INSTANTIATE_TEST_CASE_P(GPU_Arithm, Threshold, testing::Combine( + ALL_DEVICES, + DIFFERENT_SIZES, + testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)), + ALL_THRESH_OPS, + WHOLE_SUBMAT)); #endif // HAVE_CUDA diff --git a/modules/gpuarithm/test/test_precomp.hpp b/modules/gpuarithm/test/test_precomp.hpp index 800ed31..f9d3ad4 100644 --- a/modules/gpuarithm/test/test_precomp.hpp +++ b/modules/gpuarithm/test/test_precomp.hpp @@ -54,13 +54,8 @@ #include "opencv2/ts.hpp" #include "opencv2/ts/gpu_test.hpp" -#include "opencv2/core.hpp" #include "opencv2/gpuarithm.hpp" - -#include "opencv2/opencv_modules.hpp" - -#ifdef HAVE_OPENCV_IMGPROC -# include "opencv2/imgproc.hpp" -#endif +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" #endif diff --git a/modules/gpuarithm/test/test_threshold.cpp b/modules/gpuarithm/test/test_threshold.cpp deleted file mode 100644 index 52ebd7f..0000000 --- a/modules/gpuarithm/test/test_threshold.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2009, Willow Garage Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "test_precomp.hpp" - -#ifdef HAVE_CUDA - -using namespace cvtest; - -CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV) - -PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi) -{ - cv::gpu::DeviceInfo devInfo; - cv::Size size; - int type; - int threshOp; - bool useRoi; - - virtual void SetUp() - { - devInfo = GET_PARAM(0); - size = GET_PARAM(1); - type = GET_PARAM(2); - threshOp = GET_PARAM(3); - useRoi = GET_PARAM(4); - - cv::gpu::setDevice(devInfo.deviceID()); - } -}; - -GPU_TEST_P(Threshold, Accuracy) -{ - cv::Mat src = randomMat(size, type); - double maxVal = randomDouble(20.0, 127.0); - double thresh = randomDouble(0.0, maxVal); - - cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi); - cv::gpu::threshold(loadMat(src, useRoi), dst, thresh, maxVal, threshOp); - - cv::Mat dst_gold; - cv::threshold(src, dst_gold, thresh, maxVal, threshOp); - - EXPECT_MAT_NEAR(dst_gold, dst, 0.0); -} - -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Threshold, testing::Combine( - ALL_DEVICES, - DIFFERENT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)), - ThreshOp::all(), - WHOLE_SUBMAT)); - -#endif // HAVE_CUDA -- 2.7.4