From 1d57911646b82e2b271bc3dfb5b984624f17cd48 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 22 May 2012 10:29:58 +0000 Subject: [PATCH] updated gpu-vs-cpu performance tests --- cmake/OpenCVModule.cmake | 2 +- modules/gpu/CMakeLists.txt | 2 +- modules/gpu/perf_cpu/perf_arithm.cpp | 442 ++++-------- modules/gpu/perf_cpu/perf_calib3d.cpp | 154 +--- modules/gpu/perf_cpu/perf_cpu_precomp.cpp | 1 + ...{perf_precomp.hpp => perf_cpu_precomp.hpp} | 12 +- modules/gpu/perf_cpu/perf_features2d.cpp | 119 ++-- modules/gpu/perf_cpu/perf_filters.cpp | 68 +- modules/gpu/perf_cpu/perf_imgproc.cpp | 657 +++--------------- modules/gpu/perf_cpu/perf_main.cpp | 2 +- modules/gpu/perf_cpu/perf_matop.cpp | 95 +-- modules/gpu/perf_cpu/perf_objdetect.cpp | 11 +- modules/gpu/perf_cpu/perf_precomp.cpp | 1 - modules/gpu/perf_cpu/perf_utility.cpp | 10 +- modules/gpu/perf_cpu/perf_video.cpp | 235 +------ 15 files changed, 411 insertions(+), 1400 deletions(-) create mode 100644 modules/gpu/perf_cpu/perf_cpu_precomp.cpp rename modules/gpu/perf_cpu/{perf_precomp.hpp => perf_cpu_precomp.hpp} (59%) delete mode 100644 modules/gpu/perf_cpu/perf_precomp.cpp diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 125a68b7a5..ee00d7a51e 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -513,7 +513,7 @@ macro(ocv_add_precompiled_headers the_target) if("${the_target}" MATCHES "^opencv_test_.*$") SET(pch_path "test/test_") elseif("${the_target}" MATCHES "opencv_perf_gpu_cpu") - SET(pch_path "perf_cpu/perf_") + SET(pch_path "perf_cpu/perf_cpu_") elseif("${the_target}" MATCHES "^opencv_perf_.*$") SET(pch_path "perf/perf_") else() diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index 140583d5b7..dc7fc5d9d1 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -125,7 +125,7 @@ ocv_add_perf_tests() set(perf_cpu_path "${CMAKE_CURRENT_SOURCE_DIR}/perf_cpu") if(BUILD_PERF_TESTS AND EXISTS "${perf_cpu_path}") # opencv_highgui is required for imread/imwrite - set(perf_deps ${the_module} opencv_ts opencv_highgui) + set(perf_deps ${the_module} opencv_ts opencv_highgui opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_nonfree) ocv_check_dependencies(${perf_deps}) if(OCV_DEPENDENCIES_FOUND) diff --git a/modules/gpu/perf_cpu/perf_arithm.cpp b/modules/gpu/perf_cpu/perf_arithm.cpp index 2ab720cb80..da2754a1f8 100644 --- a/modules/gpu/perf_cpu/perf_arithm.cpp +++ b/modules/gpu/perf_cpu/perf_arithm.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA @@ -7,28 +7,24 @@ GPU_PERF_TEST(Transpose, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::transpose(src, dst); + cv::transpose(src, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, Transpose, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_32SC1, CV_64FC1))); ////////////////////////////////////////////////////////////////////// @@ -36,29 +32,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, Transpose, testing::Combine( GPU_PERF_TEST(Flip, cv::gpu::DeviceInfo, cv::Size, perf::MatType, FlipCode) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int flipCode = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::flip(src, dst, flipCode); + cv::flip(src, dst, flipCode); } } INSTANTIATE_TEST_CASE_P(Arithm, Flip, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), testing::Values((int) HORIZONTAL_AXIS, (int) VERTICAL_AXIS, (int) BOTH_AXIS))); @@ -67,29 +59,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, Flip, testing::Combine( GPU_PERF_TEST(LUT, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, type); + cv::Mat src(size, type); cv::Mat lut(1, 256, CV_8UC1); - declare.in(src_host, lut, WARMUP_RNG); + declare.in(src, lut, WARMUP_RNG); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::LUT(src, lut, dst); + cv::LUT(src, lut, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, LUT, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3))); ////////////////////////////////////////////////////////////////////// @@ -97,30 +85,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, LUT, testing::Combine( GPU_PERF_TEST(CartToPolar, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat x(size, CV_32FC1); + cv::Mat y(size, CV_32FC1); - cv::Mat x_host(size, CV_32FC1); - cv::Mat y_host(size, CV_32FC1); + fill(x, -100.0, 100.0); + fill(y, -100.0, 100.0); - fill(x_host, -100.0, 100.0); - fill(y_host, -100.0, 100.0); - - cv::gpu::GpuMat x(x_host); - cv::gpu::GpuMat y(y_host); - cv::gpu::GpuMat magnitude; - cv::gpu::GpuMat angle; + cv::Mat magnitude; + cv::Mat angle; TEST_CYCLE() { - cv::gpu::cartToPolar(x, y, magnitude, angle); + cv::cartToPolar(x, y, magnitude, angle); } } INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); ////////////////////////////////////////////////////////////////////// @@ -128,30 +111,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, testing::Combine( GPU_PERF_TEST(PolarToCart, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat magnitude(size, CV_32FC1); + cv::Mat angle(size, CV_32FC1); - cv::Mat magnitude_host(size, CV_32FC1); - cv::Mat angle_host(size, CV_32FC1); + fill(magnitude, 0.0, 100.0); + fill(angle, 0.0, 360.0); - fill(magnitude_host, 0.0, 100.0); - fill(angle_host, 0.0, 360.0); - - cv::gpu::GpuMat magnitude(magnitude_host); - cv::gpu::GpuMat angle(angle_host); - cv::gpu::GpuMat x; - cv::gpu::GpuMat y; + cv::Mat x; + cv::Mat y; TEST_CYCLE() { - cv::gpu::polarToCart(magnitude, angle, x, y, true); + cv::polarToCart(magnitude, angle, x, y, true); } } INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); ////////////////////////////////////////////////////////////////////// @@ -159,31 +137,26 @@ INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, testing::Combine( GPU_PERF_TEST(AddMat, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, type); + cv::Mat src2(size, type); - cv::Mat src1_host(size, type); - cv::Mat src2_host(size, type); + fill(src1, 0.0, 100.0); + fill(src2, 0.0, 100.0); - fill(src1_host, 0.0, 100.0); - fill(src2_host, 0.0, 100.0); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::add(src1, src2, dst); + cv::add(src1, src2, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, AddMat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -191,29 +164,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, AddMat, testing::Combine( GPU_PERF_TEST(AddScalar, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + fill(src, 0.0, 100.0); - fill(src_host, 0.0, 100.0); - - cv::gpu::GpuMat src(src_host); cv::Scalar s(1,2,3,4); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::add(src, s, dst); + cv::add(src, s, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, AddScalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -221,26 +190,22 @@ INSTANTIATE_TEST_CASE_P(Arithm, AddScalar, testing::Combine( GPU_PERF_TEST(Exp, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_32FC1); - cv::Mat src_host(size, CV_32FC1); + fill(src, 0.0, 10.0); - fill(src_host, 0.0, 10.0); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::exp(src, dst); + cv::exp(src, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, Exp, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); ////////////////////////////////////////////////////////////////////// @@ -248,59 +213,50 @@ INSTANTIATE_TEST_CASE_P(Arithm, Exp, testing::Combine( GPU_PERF_TEST(Pow, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::pow(src, 0.5, dst); + cv::pow(src, 0.5, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, Pow, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1))); + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, + testing::Values(perf::MatType(CV_32FC1)))); ////////////////////////////////////////////////////////////////////// // Compare GPU_PERF_TEST(Compare, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, type); + cv::Mat src2(size, type); - cv::Mat src1_host(size, type); - cv::Mat src2_host(size, type); + declare.in(src1, src2, WARMUP_RNG); - declare.in(src1_host, src2_host, WARMUP_RNG); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::compare(src1, src2, dst, cv::CMP_EQ); + cv::compare(src1, src2, dst, cv::CMP_EQ); } } INSTANTIATE_TEST_CASE_P(Arithm, Compare, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -308,28 +264,24 @@ INSTANTIATE_TEST_CASE_P(Arithm, Compare, testing::Combine( GPU_PERF_TEST(BitwiseNot, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::bitwise_not(src, dst); + cv::bitwise_not(src, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, BitwiseNot, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32SC1))); ////////////////////////////////////////////////////////////////////// @@ -337,57 +289,51 @@ INSTANTIATE_TEST_CASE_P(Arithm, BitwiseNot, testing::Combine( GPU_PERF_TEST(BitwiseAnd, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, type); + cv::Mat src2(size, type); - cv::Mat src1_host(size, type); - cv::Mat src2_host(size, type); + declare.in(src1, src2, WARMUP_RNG); - declare.in(src1_host, src2_host, WARMUP_RNG); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::bitwise_and(src1, src2, dst); + cv::bitwise_and(src1, src2, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, BitwiseAnd, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32SC1))); +////////////////////////////////////////////////////////////////////// +// BitwiseScalarAnd + GPU_PERF_TEST(BitwiseScalarAnd, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; cv::Scalar sc = cv::Scalar(123, 123, 123, 123); TEST_CYCLE() { - cv::gpu::bitwise_and(src, sc, dst); + cv::bitwise_and(src, sc, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, BitwiseScalarAnd, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32SC1, CV_32SC3, CV_32SC4))); ////////////////////////////////////////////////////////////////////// @@ -395,30 +341,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, BitwiseScalarAnd, testing::Combine( GPU_PERF_TEST(Min, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, type); + cv::Mat src2(size, type); - cv::Mat src1_host(size, type); - cv::Mat src2_host(size, type); + declare.in(src1, src2, WARMUP_RNG); - declare.in(src1_host, src2_host, WARMUP_RNG); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst(size, type); + cv::Mat dst(size, type); TEST_CYCLE() { - cv::gpu::min(src1, src2, dst); + cv::min(src1, src2, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, Min, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32SC1))); ////////////////////////////////////////////////////////////////////// @@ -426,28 +367,23 @@ INSTANTIATE_TEST_CASE_P(Arithm, Min, testing::Combine( GPU_PERF_TEST(MeanStdDev, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_8UC1); - cv::Mat src_host(size, CV_8UC1); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); cv::Scalar mean; cv::Scalar stddev; - cv::gpu::GpuMat buf; TEST_CYCLE() { - cv::gpu::meanStdDev(src, mean, stddev, buf); + cv::meanStdDev(src, mean, stddev); } } INSTANTIATE_TEST_CASE_P(Arithm, MeanStdDev, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); ////////////////////////////////////////////////////////////////////// @@ -455,30 +391,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, MeanStdDev, testing::Combine( GPU_PERF_TEST(Norm, cv::gpu::DeviceInfo, cv::Size, perf::MatType, NormType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int normType = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); double dst; - cv::gpu::GpuMat buf; TEST_CYCLE() { - dst = cv::gpu::norm(src, normType, buf); + dst = cv::norm(src, normType); } } INSTANTIATE_TEST_CASE_P(Arithm, Norm, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32SC1), testing::Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2))); @@ -487,30 +418,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, Norm, testing::Combine( GPU_PERF_TEST(NormDiff, cv::gpu::DeviceInfo, cv::Size, NormType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int normType = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, CV_8UC1); + cv::Mat src2(size, CV_8UC1); - cv::Mat src1_host(size, CV_8UC1); - cv::Mat src2_host(size, CV_8UC1); + declare.in(src1, src2, WARMUP_RNG); - declare.in(src1_host, src2_host, WARMUP_RNG); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); double dst; TEST_CYCLE() { - dst = cv::gpu::norm(src1, src2, normType); + dst = cv::norm(src1, src2, normType); } } INSTANTIATE_TEST_CASE_P(Arithm, NormDiff, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2))); ////////////////////////////////////////////////////////////////////// @@ -518,59 +444,24 @@ INSTANTIATE_TEST_CASE_P(Arithm, NormDiff, testing::Combine( GPU_PERF_TEST(Sum, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); cv::Scalar dst; - cv::gpu::GpuMat buf; TEST_CYCLE() { - dst = cv::gpu::sum(src, buf); + dst = cv::sum(src); } } INSTANTIATE_TEST_CASE_P(Arithm, Sum, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); - -////////////////////////////////////////////////////////////////////// -// MinMax - -GPU_PERF_TEST(MinMax, cv::gpu::DeviceInfo, cv::Size, perf::MatType) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, type); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - double minVal, maxVal; - cv::gpu::GpuMat buf; - - TEST_CYCLE() - { - cv::gpu::minMax(src, &minVal, &maxVal, cv::gpu::GpuMat(), buf); - } -} - -INSTANTIATE_TEST_CASE_P(Arithm, MinMax, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -578,30 +469,25 @@ INSTANTIATE_TEST_CASE_P(Arithm, MinMax, testing::Combine( GPU_PERF_TEST(MinMaxLoc, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); double minVal, maxVal; cv::Point minLoc, maxLoc; - cv::gpu::GpuMat valbuf, locbuf; TEST_CYCLE() { - cv::gpu::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), valbuf, locbuf); + cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); } } INSTANTIATE_TEST_CASE_P(Arithm, MinMaxLoc, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -609,29 +495,24 @@ INSTANTIATE_TEST_CASE_P(Arithm, MinMaxLoc, testing::Combine( GPU_PERF_TEST(CountNonZero, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + fill(src, 0.0, 1.0); - fill(src_host, 0.0, 1.0); - - cv::gpu::GpuMat src(src_host); int dst; - cv::gpu::GpuMat buf; TEST_CYCLE() { - dst = cv::gpu::countNonZero(src, buf); + dst = cv::countNonZero(src); } } INSTANTIATE_TEST_CASE_P(Arithm, CountNonZero, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -639,33 +520,26 @@ INSTANTIATE_TEST_CASE_P(Arithm, CountNonZero, testing::Combine( GPU_PERF_TEST(AddWeighted, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, type); + cv::Mat src2(size, type); - cv::Mat src1_host(size, type); - cv::Mat src2_host(size, type); + fill(src1, 0.0, 100.0); + fill(src2, 0.0, 100.0); - fill(src1_host, 0.0, 100.0); - fill(src2_host, 0.0, 100.0); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::addWeighted(src1, 0.5, src2, 0.5, 0.0, dst); + cv::addWeighted(src1, 0.5, src2, 0.5, 0.0, dst); } - - cv::Mat dst_host(dst); } INSTANTIATE_TEST_CASE_P(Arithm, AddWeighted, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -673,32 +547,26 @@ INSTANTIATE_TEST_CASE_P(Arithm, AddWeighted, testing::Combine( GPU_PERF_TEST(Reduce, cv::gpu::DeviceInfo, cv::Size, perf::MatType, FlipCode) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int dim = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + fill(src, 0.0, 10.0); - fill(src_host, 0.0, 10.0); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::reduce(src, dst, dim, CV_REDUCE_MIN); + cv::reduce(src, dst, dim, CV_REDUCE_MIN); } - - cv::Mat dst_host(dst); } INSTANTIATE_TEST_CASE_P(Arithm, Reduce, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_16UC1, CV_32FC1), + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, + testing::Values(CV_8UC1, CV_16UC1, CV_32FC1), testing::Values((int) HORIZONTAL_AXIS, (int) VERTICAL_AXIS))); ////////////////////////////////////////////////////////////////////// @@ -706,34 +574,28 @@ INSTANTIATE_TEST_CASE_P(Arithm, Reduce, testing::Combine( GPU_PERF_TEST(GEMM, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src1(size, CV_32FC1); + cv::Mat src2(size, CV_32FC1); + cv::Mat src3(size, CV_32FC1); - cv::Mat src1_host(size, CV_32FC1); - cv::Mat src2_host(size, CV_32FC1); - cv::Mat src3_host(size, CV_32FC1); + fill(src1, 0.0, 10.0); + fill(src2, 0.0, 10.0); + fill(src3, 0.0, 10.0); - fill(src1_host, 0.0, 10.0); - fill(src2_host, 0.0, 10.0); - fill(src3_host, 0.0, 10.0); + cv::Mat dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat src3(src3_host); - cv::gpu::GpuMat dst; - - declare.time(5.0); + declare.time(15.0); TEST_CYCLE() { - cv::gpu::gemm(src1, src2, 1.0, src3, 1.0, dst); + cv::gemm(src1, src2, 1.0, src3, 1.0, dst); } } INSTANTIATE_TEST_CASE_P(Arithm, GEMM, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, testing::Values(cv::Size(512, 512), cv::Size(1024, 1024), cv::Size(2048, 2048)))); #endif diff --git a/modules/gpu/perf_cpu/perf_calib3d.cpp b/modules/gpu/perf_cpu/perf_calib3d.cpp index 0175527b37..c52a8d4608 100644 --- a/modules/gpu/perf_cpu/perf_calib3d.cpp +++ b/modules/gpu/perf_cpu/perf_calib3d.cpp @@ -1,50 +1,21 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA -////////////////////////////////////////////////////////////////////// -// TransformPoints - -GPU_PERF_TEST_1(TransformPoints, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(1, 10000, CV_32FC3); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::transformPoints(src, cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(1, 3, CV_32FC1), dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // ProjectPoints GPU_PERF_TEST_1(ProjectPoints, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat src(1, 10000, CV_32FC3); - cv::gpu::setDevice(devInfo.deviceID()); + declare.in(src, WARMUP_RNG); - cv::Mat src_host(1, 10000, CV_32FC3); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::projectPoints(src, cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(3, 3, CV_32FC1), cv::Mat(), dst); + cv::projectPoints(src, cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(3, 3, CV_32FC1), cv::Mat(), dst); } } @@ -55,10 +26,6 @@ INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, ALL_DEVICES); GPU_PERF_TEST_1(SolvePnPRansac, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - cv::Mat object(1, 10000, CV_32FC3); cv::Mat image(1, 10000, CV_32FC2); @@ -70,7 +37,7 @@ GPU_PERF_TEST_1(SolvePnPRansac, cv::gpu::DeviceInfo) TEST_CYCLE() { - cv::gpu::solvePnPRansac(object, image, cv::Mat::ones(3, 3, CV_32FC1), cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec); + cv::solvePnPRansac(object, image, cv::Mat::ones(3, 3, CV_32FC1), cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec); } } @@ -81,21 +48,15 @@ INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, ALL_DEVICES); GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat img_l = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); + cv::Mat img_r = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - cv::gpu::setDevice(devInfo.deviceID()); + ASSERT_FALSE(img_l.empty()); + ASSERT_FALSE(img_r.empty()); - cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); + cv::Mat dst; - ASSERT_FALSE(img_l_host.empty()); - ASSERT_FALSE(img_r_host.empty()); - - cv::gpu::GpuMat img_l(img_l_host); - cv::gpu::GpuMat img_r(img_r_host); - cv::gpu::GpuMat dst; - - cv::gpu::StereoBM_GPU bm(0, 256); + cv::StereoBM bm(0, 256); declare.time(5.0); @@ -107,96 +68,5 @@ GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo) INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES); -////////////////////////////////////////////////////////////////////// -// StereoBeliefPropagation - -GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png"); - cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png"); - - ASSERT_FALSE(img_l_host.empty()); - ASSERT_FALSE(img_r_host.empty()); - - cv::gpu::GpuMat img_l(img_l_host); - cv::gpu::GpuMat img_r(img_r_host); - cv::gpu::GpuMat dst; - - cv::gpu::StereoBeliefPropagation bp(64); - - declare.time(10.0); - - TEST_CYCLE() - { - bp(img_l, img_r, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// StereoConstantSpaceBP - -GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); - cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(img_l_host.empty()); - ASSERT_FALSE(img_r_host.empty()); - - cv::gpu::GpuMat img_l(img_l_host); - cv::gpu::GpuMat img_r(img_r_host); - cv::gpu::GpuMat dst; - - cv::gpu::StereoConstantSpaceBP bp(128); - - declare.time(10.0); - - TEST_CYCLE() - { - bp(img_l, img_r, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// DisparityBilateralFilter - -GPU_PERF_TEST_1(DisparityBilateralFilter, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); - cv::Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(img_host.empty()); - ASSERT_FALSE(disp_host.empty()); - - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat disp(disp_host); - cv::gpu::GpuMat dst; - - cv::gpu::DisparityBilateralFilter f(128); - - TEST_CYCLE() - { - f(disp, img, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, DisparityBilateralFilter, ALL_DEVICES); - #endif diff --git a/modules/gpu/perf_cpu/perf_cpu_precomp.cpp b/modules/gpu/perf_cpu/perf_cpu_precomp.cpp new file mode 100644 index 0000000000..d947dd0258 --- /dev/null +++ b/modules/gpu/perf_cpu/perf_cpu_precomp.cpp @@ -0,0 +1 @@ +#include "perf_cpu_precomp.hpp" diff --git a/modules/gpu/perf_cpu/perf_precomp.hpp b/modules/gpu/perf_cpu/perf_cpu_precomp.hpp similarity index 59% rename from modules/gpu/perf_cpu/perf_precomp.hpp rename to modules/gpu/perf_cpu/perf_cpu_precomp.hpp index ef2839be51..5ecd4fba3f 100644 --- a/modules/gpu/perf_cpu/perf_precomp.hpp +++ b/modules/gpu/perf_cpu/perf_cpu_precomp.hpp @@ -1,14 +1,22 @@ -#ifndef __OPENCV_PERF_PRECOMP_HPP__ -#define __OPENCV_PERF_PRECOMP_HPP__ +#ifndef __OPENCV_PERF_CPU_PRECOMP_HPP__ +#define __OPENCV_PERF_CPU_PRECOMP_HPP__ #include #include + #include "cvconfig.h" + #include "opencv2/ts/ts.hpp" #include "opencv2/ts/ts_perf.hpp" + #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/gpu/gpu.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/video/video.hpp" +#include "opencv2/calib3d/calib3d.hpp" +#include "opencv2/nonfree/nonfree.hpp" + #include "perf_utility.hpp" #if GTEST_CREATE_SHARED_LIBRARY diff --git a/modules/gpu/perf_cpu/perf_features2d.cpp b/modules/gpu/perf_cpu/perf_features2d.cpp index 18e1497871..c255fb1221 100644 --- a/modules/gpu/perf_cpu/perf_features2d.cpp +++ b/modules/gpu/perf_cpu/perf_features2d.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA @@ -7,32 +7,26 @@ GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); int desc_size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat query(3000, desc_size, CV_32FC1); + cv::Mat train(3000, desc_size, CV_32FC1); - cv::Mat query_host(3000, desc_size, CV_32FC1); - cv::Mat train_host(3000, desc_size, CV_32FC1); + declare.in(query, train, WARMUP_RNG); - declare.in(query_host, train_host, WARMUP_RNG); + cv::BFMatcher matcher(cv::NORM_L2); + std::vector matches; - cv::gpu::GpuMat query(query_host); - cv::gpu::GpuMat train(train_host); - cv::gpu::GpuMat trainIdx, distance; - - cv::gpu::BFMatcher_GPU matcher(cv::NORM_L2); - - declare.time(3.0); + declare.time(10.0); TEST_CYCLE() { - matcher.matchSingle(query, train, trainIdx, distance); + matcher.match(query, train, matches); } } INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, testing::Values(64, 128, 256))); ////////////////////////////////////////////////////////////////////// @@ -40,33 +34,27 @@ INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine( GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, int, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); int desc_size = GET_PARAM(1); int k = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat query(3000, desc_size, CV_32FC1); + cv::Mat train(3000, desc_size, CV_32FC1); - cv::Mat query_host(3000, desc_size, CV_32FC1); - cv::Mat train_host(3000, desc_size, CV_32FC1); + declare.in(query, train, WARMUP_RNG); - declare.in(query_host, train_host, WARMUP_RNG); + cv::BFMatcher matcher(cv::NORM_L2); + std::vector< std::vector > matches; - cv::gpu::GpuMat query(query_host); - cv::gpu::GpuMat train(train_host); - cv::gpu::GpuMat trainIdx, distance, allDist; - - cv::gpu::BFMatcher_GPU matcher(cv::NORM_L2); - - declare.time(3.0); + declare.time(10.0); TEST_CYCLE() { - matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k); + matcher.knnMatch(query, train, matches, k); } } INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, testing::Values(64, 128, 256), testing::Values(2, 3))); @@ -75,33 +63,27 @@ INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); int desc_size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat query(3000, desc_size, CV_32FC1); + cv::Mat train(3000, desc_size, CV_32FC1); - cv::Mat query_host(3000, desc_size, CV_32FC1); - cv::Mat train_host(3000, desc_size, CV_32FC1); + fill(query, 0, 1); + fill(train, 0, 1); - fill(query_host, 0, 1); - fill(train_host, 0, 1); + cv::BFMatcher matcher(cv::NORM_L2); + std::vector< std::vector > matches; - cv::gpu::GpuMat query(query_host); - cv::gpu::GpuMat train(train_host); - cv::gpu::GpuMat trainIdx, nMatches, distance; - - cv::gpu::BFMatcher_GPU matcher(cv::NORM_L2); - - declare.time(3.0); + declare.time(10.0); TEST_CYCLE() { - matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0); + matcher.radiusMatch(query, train, matches, 2.0); } } INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine( - ALL_DEVICES, + ALL_DEVICES, testing::Values(64, 128, 256))); ////////////////////////////////////////////////////////////////////// @@ -109,24 +91,20 @@ INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Comb GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - cv::gpu::setDevice(devInfo.deviceID()); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); + std::vector keypoints; + cv::Mat descriptors; - ASSERT_FALSE(img_host.empty()); + cv::SURF surf; - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat keypoints, descriptors; - - cv::gpu::SURF_GPU surf; - - declare.time(2.0); + declare.time(10.0); TEST_CYCLE() { - surf(img, cv::gpu::GpuMat(), keypoints, descriptors); + surf(img, cv::noArray(), keypoints, descriptors); } } @@ -137,22 +115,15 @@ INSTANTIATE_TEST_CASE_P(Features2D, SURF, DEVICES(cv::gpu::GLOBAL_ATOMICS)); GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - cv::gpu::setDevice(devInfo.deviceID()); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(img_host.empty()); - - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat keypoints, descriptors; - - cv::gpu::FAST_GPU fastGPU(20); + std::vector keypoints; TEST_CYCLE() { - fastGPU(img, cv::gpu::GpuMat(), keypoints); + cv::FAST(img, keypoints, 20); } } @@ -163,22 +134,18 @@ INSTANTIATE_TEST_CASE_P(Features2D, FAST, DEVICES(cv::gpu::GLOBAL_ATOMICS)); GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - cv::gpu::setDevice(devInfo.deviceID()); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); + std::vector keypoints; + cv::Mat descriptors; - ASSERT_FALSE(img_host.empty()); - - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat keypoints, descriptors; - - cv::gpu::ORB_GPU orbGPU(4000); + cv::ORB orb(4000); TEST_CYCLE() { - orbGPU(img, cv::gpu::GpuMat(), keypoints, descriptors); + orb(img, cv::noArray(), keypoints, descriptors); } } diff --git a/modules/gpu/perf_cpu/perf_filters.cpp b/modules/gpu/perf_cpu/perf_filters.cpp index 9322557283..ebd9dba765 100644 --- a/modules/gpu/perf_cpu/perf_filters.cpp +++ b/modules/gpu/perf_cpu/perf_filters.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA @@ -7,21 +7,17 @@ GPU_PERF_TEST(BoxFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int ksize = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); + cv::Mat dst(src.size(), src.type()); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::Ptr filter = cv::gpu::createBoxFilter_GPU(type, type, cv::Size(ksize, ksize)); + cv::Ptr filter = cv::createBoxFilter(type, type, cv::Size(ksize, ksize)); TEST_CYCLE() { @@ -30,8 +26,8 @@ GPU_PERF_TEST(BoxFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int) } INSTANTIATE_TEST_CASE_P(Filter, BoxFilter, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC4), testing::Values(3, 5))); @@ -40,22 +36,18 @@ INSTANTIATE_TEST_CASE_P(Filter, BoxFilter, testing::Combine( GPU_PERF_TEST(MorphologyFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, MorphOp, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int op = GET_PARAM(3); int ksize = GET_PARAM(4); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); + cv::Mat dst(src.size(), src.type()); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::Ptr filter = cv::gpu::createMorphologyFilter_GPU(op, type, cv::Mat::ones(ksize, ksize, CV_8U)); + cv::Ptr filter = cv::createMorphologyFilter(op, type, cv::Mat::ones(ksize, ksize, CV_8U)); TEST_CYCLE() { @@ -64,8 +56,8 @@ GPU_PERF_TEST(MorphologyFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Mo } INSTANTIATE_TEST_CASE_P(Filter, MorphologyFilter, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC4), testing::Values((int) cv::MORPH_ERODE, (int) cv::MORPH_DILATE), testing::Values(3, 5))); @@ -75,21 +67,17 @@ INSTANTIATE_TEST_CASE_P(Filter, MorphologyFilter, testing::Combine( GPU_PERF_TEST(LinearFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int ksize = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); + cv::Mat dst(src.size(), src.type()); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::Ptr filter = cv::gpu::createLinearFilter_GPU(type, type, cv::Mat::ones(ksize, ksize, CV_8U)); + cv::Ptr filter = cv::createLinearFilter(type, type, cv::Mat::ones(ksize, ksize, CV_8U)); declare.time(1.0); @@ -100,8 +88,8 @@ GPU_PERF_TEST(LinearFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int) } INSTANTIATE_TEST_CASE_P(Filter, LinearFilter, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC4, CV_32FC1), testing::Values(3, 5, 7, 9))); @@ -110,34 +98,30 @@ INSTANTIATE_TEST_CASE_P(Filter, LinearFilter, testing::Combine( GPU_PERF_TEST(SeparableLinearFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int ksize = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst(src.size(), src.type()); cv::Mat kernel = cv::getGaussianKernel(ksize, 0.5, CV_32F); - cv::Ptr filter = cv::gpu::createSeparableLinearFilter_GPU(type, type, kernel, kernel); + cv::Ptr filter = cv::createSeparableLinearFilter(type, type, kernel, kernel); declare.time(1.0); TEST_CYCLE() { - filter->apply(src, dst, cv::Rect(0, 0, src.cols, src.rows)); + filter->apply(src, dst); } } INSTANTIATE_TEST_CASE_P(Filter, SeparableLinearFilter, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC4, CV_32FC1), testing::Values(3, 5, 7, 9, 11, 13, 15))); diff --git a/modules/gpu/perf_cpu/perf_imgproc.cpp b/modules/gpu/perf_cpu/perf_imgproc.cpp index 5472acf85f..b722740af0 100644 --- a/modules/gpu/perf_cpu/perf_imgproc.cpp +++ b/modules/gpu/perf_cpu/perf_imgproc.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA @@ -7,30 +7,24 @@ GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation, BorderMode) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int interpolation = GET_PARAM(3); int borderMode = GET_PARAM(4); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); + cv::Mat xmap(size, CV_32FC1); + cv::Mat ymap(size, CV_32FC1); - cv::Mat src_host(size, type); - cv::Mat xmap_host(size, CV_32FC1); - cv::Mat ymap_host(size, CV_32FC1); + declare.in(src, xmap, ymap, WARMUP_RNG); - declare.in(src_host, xmap_host, ymap_host, WARMUP_RNG); + cv::Mat dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat xmap(xmap_host); - cv::gpu::GpuMat ymap(ymap_host); - cv::gpu::GpuMat dst; - - declare.time(3.0); + declare.time(10.0); TEST_CYCLE() { - cv::gpu::remap(src, dst, xmap, ymap, interpolation, borderMode); + cv::remap(src, dst, xmap, ymap, interpolation, borderMode); } } @@ -46,136 +40,38 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine( GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - cv::Mat img = readImage("gpu/meanshift/cones.png"); ASSERT_FALSE(img.empty()); - cv::Mat rgba; - cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); + cv::Mat dst; - cv::gpu::GpuMat src(rgba); - cv::gpu::GpuMat dst; - - declare.time(5.0); + declare.time(15.0); TEST_CYCLE() { - cv::gpu::meanShiftFiltering(src, dst, 50, 50); + cv::pyrMeanShiftFiltering(img, dst, 50, 50); } } INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES); -////////////////////////////////////////////////////////////////////// -// MeanShiftProc - -GPU_PERF_TEST_1(MeanShiftProc, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img = readImage("gpu/meanshift/cones.png"); - ASSERT_FALSE(img.empty()); - - cv::Mat rgba; - cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - - cv::gpu::GpuMat src(rgba); - cv::gpu::GpuMat dstr; - cv::gpu::GpuMat dstsp; - - declare.time(5.0); - - TEST_CYCLE() - { - cv::gpu::meanShiftProc(src, dstr, dstsp, 50, 50); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftProc, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// MeanShiftSegmentation - -GPU_PERF_TEST_1(MeanShiftSegmentation, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img = readImage("gpu/meanshift/cones.png"); - ASSERT_FALSE(img.empty()); - - cv::Mat rgba; - cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - - cv::gpu::GpuMat src(rgba); - cv::Mat dst; - - declare.time(5.0); - - TEST_CYCLE() - { - meanShiftSegmentation(src, dst, 10, 10, 20); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// DrawColorDisp - -GPU_PERF_TEST(DrawColorDisp, cv::gpu::DeviceInfo, cv::Size, perf::MatType) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, type); - - fill(src_host, 0, 255); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::drawColorDisp(src, dst, 255); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, DrawColorDisp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_16SC1))); - ////////////////////////////////////////////////////////////////////// // ReprojectImageTo3D GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::reprojectImageTo3D(src, dst, cv::Mat::ones(4, 4, CV_32FC1)); + cv::reprojectImageTo3D(src, dst, cv::Mat::ones(4, 4, CV_32FC1)); } } @@ -189,23 +85,19 @@ INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, testing::Combine( GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, perf::MatType, CvtColorInfo) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); CvtColorInfo info = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_MAKETYPE(type, info.scn)); - cv::Mat src_host(size, CV_MAKETYPE(type, info.scn)); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::cvtColor(src, dst, info.code, info.dcn); + cv::cvtColor(src, dst, info.code, info.dcn); } } @@ -215,56 +107,26 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine( testing::Values(CV_8UC1, CV_16UC1, CV_32FC1), testing::Values( CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA), - CvtColorInfo(4, 4, cv::COLOR_BGR2XYZ), CvtColorInfo(4, 4, cv::COLOR_BGR2YCrCb), CvtColorInfo(4, 4, cv::COLOR_YCrCb2BGR), - CvtColorInfo(4, 4, cv::COLOR_BGR2HSV), CvtColorInfo(4, 4, cv::COLOR_HSV2BGR)))); - -////////////////////////////////////////////////////////////////////// -// SwapChannels - -GPU_PERF_TEST(SwapChannels, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, CV_8UC4); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - - const int dstOrder[] = {2, 1, 0, 3}; - - TEST_CYCLE() - { - cv::gpu::swapChannels(src, dstOrder); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, SwapChannels, testing::Combine(ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); + CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ), CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb), CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR), + CvtColorInfo(3, 3, cv::COLOR_BGR2HSV), CvtColorInfo(3, 3, cv::COLOR_HSV2BGR)))); ////////////////////////////////////////////////////////////////////// // Threshold GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst(size, type); + cv::Mat dst(size, type); TEST_CYCLE() { - cv::gpu::threshold(src, dst, 100.0, 255.0, cv::THRESH_BINARY); + cv::threshold(src, dst, 100.0, 255.0, cv::THRESH_BINARY); } } @@ -278,26 +140,22 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine( GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation, double) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int interpolation = GET_PARAM(3); double f = GET_PARAM(4); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; declare.time(1.0); TEST_CYCLE() { - cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation); + cv::resize(src, dst, cv::Size(), f, f, interpolation); } } @@ -313,19 +171,15 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine( GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int interpolation = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; const double aplha = CV_PI / 4; double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, @@ -334,7 +188,7 @@ GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpol TEST_CYCLE() { - cv::gpu::warpAffine(src, dst, M, size, interpolation, cv::BORDER_CONSTANT, cv::Scalar()); + cv::warpAffine(src, dst, M, size, interpolation, cv::BORDER_CONSTANT, cv::Scalar()); } } @@ -349,19 +203,15 @@ INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine( GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int interpolation = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; const double aplha = CV_PI / 4; double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, @@ -371,7 +221,7 @@ GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Int TEST_CYCLE() { - cv::gpu::warpPerspective(src, dst, M, size, interpolation, cv::BORDER_CONSTANT, cv::Scalar()); + cv::warpPerspective(src, dst, M, size, interpolation, cv::BORDER_CONSTANT, cv::Scalar()); } } @@ -381,131 +231,24 @@ INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine( testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4), testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC))); -////////////////////////////////////////////////////////////////////// -// BuildWarpPlaneMaps - -GPU_PERF_TEST(BuildWarpPlaneMaps, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::gpu::GpuMat map_x; - cv::gpu::GpuMat map_y; - - TEST_CYCLE() - { - cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1), - cv::Mat::ones(3, 3, CV_32FC1), cv::Mat::zeros(1, 3, CV_32F), 1.0, map_x, map_y); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpPlaneMaps, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// BuildWarpCylindricalMaps - -GPU_PERF_TEST(BuildWarpCylindricalMaps, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::gpu::GpuMat map_x; - cv::gpu::GpuMat map_y; - - TEST_CYCLE() - { - cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1), - cv::Mat::ones(3, 3, CV_32FC1), 1.0, map_x, map_y); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpCylindricalMaps, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// BuildWarpSphericalMaps - -GPU_PERF_TEST(BuildWarpSphericalMaps, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::gpu::GpuMat map_x; - cv::gpu::GpuMat map_y; - - TEST_CYCLE() - { - cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1), - cv::Mat::ones(3, 3, CV_32FC1), 1.0, map_x, map_y); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpSphericalMaps, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Rotate - -GPU_PERF_TEST(Rotate, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, type); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::rotate(src, dst, size, 30.0, 0, 0, interpolation); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Rotate, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4), - testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC))); - ////////////////////////////////////////////////////////////////////// // CopyMakeBorder GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, perf::MatType, BorderMode) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); int borderType = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); + cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); } } @@ -520,22 +263,17 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine( GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_8UC1); - cv::Mat src_host(size, CV_8UC1); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::integralBuffered(src, dst, buf); + cv::integral(src, dst); } } @@ -543,79 +281,19 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine( ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); -////////////////////////////////////////////////////////////////////// -// IntegralSqr - -GPU_PERF_TEST(IntegralSqr, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, CV_8UC1); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::sqrIntegral(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, IntegralSqr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// ColumnSum - -GPU_PERF_TEST(ColumnSum, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, CV_32FC1); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::columnSum(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // CornerHarris GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); int type = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); - cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - cv::gpu::GpuMat src(img); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat Dx; - cv::gpu::GpuMat Dy; + cv::Mat dst; int blockSize = 3; int ksize = 7; @@ -623,7 +301,7 @@ GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, perf::MatType) TEST_CYCLE() { - cv::gpu::cornerHarris(src, dst, Dx, Dy, blockSize, ksize, k); + cv::cornerHarris(img, dst, blockSize, ksize, k); } } @@ -636,27 +314,21 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine( GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); int type = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); - cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - cv::gpu::GpuMat src(img); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat Dx; - cv::gpu::GpuMat Dy; + cv::Mat dst; int blockSize = 3; int ksize = 7; TEST_CYCLE() { - cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, blockSize, ksize); + cv::cornerMinEigenVal(img, dst, blockSize, ksize); } } @@ -669,23 +341,18 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine( GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat a(size, CV_32FC2); + cv::Mat b(size, CV_32FC2); - cv::Mat a_host(size, CV_32FC2); - cv::Mat b_host(size, CV_32FC2); + declare.in(a, b, WARMUP_RNG); - declare.in(a_host, b_host, WARMUP_RNG); - - cv::gpu::GpuMat a(a_host); - cv::gpu::GpuMat b(b_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::mulSpectrums(a, b, dst, 0); + cv::mulSpectrums(a, b, dst, 0); } } @@ -698,23 +365,19 @@ INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine( GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_32FC2); - cv::Mat src_host(size, CV_32FC2); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; declare.time(2.0); TEST_CYCLE() { - cv::gpu::dft(src, dst, size); + cv::dft(src, dst); } } @@ -727,27 +390,22 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine( GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, int, bool) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int templ_size = GET_PARAM(2); - bool ccorr = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::gpu::GpuMat image = cv::gpu::createContinuous(size, CV_32FC1); - cv::gpu::GpuMat templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); + cv::Mat image(size, CV_32FC1); + cv::Mat templ(templ_size, templ_size, CV_32FC1); image.setTo(cv::Scalar(1.0)); templ.setTo(cv::Scalar(1.0)); - cv::gpu::GpuMat dst; - cv::gpu::ConvolveBuf buf; + cv::Mat dst; declare.time(2.0); TEST_CYCLE() { - cv::gpu::convolve(image, templ, dst, ccorr, buf); + cv::filter2D(image, dst, image.depth(), templ); } } @@ -762,22 +420,18 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine( GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::pyrDown(src, dst); + cv::pyrDown(src, dst); } } @@ -791,22 +445,18 @@ INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine( GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); - cv::Mat src_host(size, type); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::pyrUp(src, dst); + cv::pyrUp(src, dst); } } @@ -815,91 +465,19 @@ INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine( GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1))); -////////////////////////////////////////////////////////////////////// -// BlendLinear - -GPU_PERF_TEST(BlendLinear, cv::gpu::DeviceInfo, cv::Size, perf::MatType) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img1_host(size, type); - cv::Mat img2_host(size, type); - - declare.in(img1_host, img2_host, WARMUP_RNG); - - cv::gpu::GpuMat img1(img1_host); - cv::gpu::GpuMat img2(img2_host); - cv::gpu::GpuMat weights1(size, CV_32FC1, cv::Scalar::all(0.5)); - cv::gpu::GpuMat weights2(size, CV_32FC1, cv::Scalar::all(0.5)); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::blendLinear(img1, img2, weights1, weights2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, BlendLinear, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_32FC1))); - -////////////////////////////////////////////////////////////////////// -// AlphaComp - -GPU_PERF_TEST(AlphaComp, cv::gpu::DeviceInfo, cv::Size, perf::MatType, AlphaOp) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int alpha_op = GET_PARAM(3); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img1_host(size, type); - cv::Mat img2_host(size, type); - - declare.in(img1_host, img2_host, WARMUP_RNG); - - cv::gpu::GpuMat img1(img1_host); - cv::gpu::GpuMat img2(img2_host); - cv::gpu::GpuMat dst; - - TEST_CYCLE() - { - cv::gpu::alphaComp(img1, img2, dst, alpha_op); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, AlphaComp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4), - testing::Values((int)cv::gpu::ALPHA_OVER, (int)cv::gpu::ALPHA_IN, (int)cv::gpu::ALPHA_OUT, (int)cv::gpu::ALPHA_ATOP, (int)cv::gpu::ALPHA_XOR, (int)cv::gpu::ALPHA_PLUS, (int)cv::gpu::ALPHA_OVER_PREMUL, (int)cv::gpu::ALPHA_IN_PREMUL, (int)cv::gpu::ALPHA_OUT_PREMUL, (int)cv::gpu::ALPHA_ATOP_PREMUL, (int)cv::gpu::ALPHA_XOR_PREMUL, (int)cv::gpu::ALPHA_PLUS_PREMUL, (int)cv::gpu::ALPHA_PREMUL))); - ////////////////////////////////////////////////////////////////////// // Canny GPU_PERF_TEST_1(Canny, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat image = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(image.empty()); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat image_host = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image_host.empty()); - - cv::gpu::GpuMat image(image_host); - cv::gpu::GpuMat dst; - cv::gpu::CannyBuf buf; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::Canny(image, buf, dst, 50.0, 100.0); + cv::Canny(image, dst, 50.0, 100.0); } } @@ -910,22 +488,21 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Canny, ALL_DEVICES); GPU_PERF_TEST(CalcHist, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_8UC1); - cv::Mat src_host(size, CV_8UC1); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); + cv::Mat hist; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat hist; - cv::gpu::GpuMat buf; + int histSize = 256; + float range[] = { 0, 256 } ; + const float* histRange = { range }; TEST_CYCLE() { - cv::gpu::calcHist(src, hist, buf); + cv::calcHist(&src, 1, 0, cv::noArray(), hist, 1, &histSize, &histRange); } } @@ -938,23 +515,17 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, testing::Combine( GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, CV_8UC1); - cv::Mat src_host(size, CV_8UC1); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat hist; - cv::gpu::GpuMat buf; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::equalizeHist(src, dst, hist, buf); + cv::equalizeHist(src, dst); } } @@ -962,62 +533,4 @@ INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine( ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); -////////////////////////////////////////////////////////////////////// -// ImagePyramid - -GPU_PERF_TEST(ImagePyramid_build, cv::gpu::DeviceInfo, cv::Size, perf::MatType) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, type); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - - cv::gpu::ImagePyramid pyr; - - TEST_CYCLE() - { - pyr.build(src, 5); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_build, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); - -GPU_PERF_TEST(ImagePyramid_getLayer, cv::gpu::DeviceInfo, cv::Size, perf::MatType) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat src_host(size, type); - - declare.in(src_host, WARMUP_RNG); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::ImagePyramid pyr(src, 3); - - TEST_CYCLE() - { - pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10)); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_getLayer, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); - #endif diff --git a/modules/gpu/perf_cpu/perf_main.cpp b/modules/gpu/perf_cpu/perf_main.cpp index 0cd4002775..6fcf56d0b0 100644 --- a/modules/gpu/perf_cpu/perf_main.cpp +++ b/modules/gpu/perf_cpu/perf_main.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/perf_cpu/perf_matop.cpp b/modules/gpu/perf_cpu/perf_matop.cpp index f56dbf3e5f..0cf225e093 100644 --- a/modules/gpu/perf_cpu/perf_matop.cpp +++ b/modules/gpu/perf_cpu/perf_matop.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA @@ -7,29 +7,26 @@ GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); - const int num_channels = 4; - std::vector src(num_channels); + std::vector src(num_channels); for (int i = 0; i < num_channels; ++i) - src[i] = cv::gpu::GpuMat(size, type, cv::Scalar::all(i)); + src[i] = cv::Mat(size, type, cv::Scalar::all(i)); - cv::gpu::GpuMat dst; + cv::Mat dst; TEST_CYCLE() { - cv::gpu::merge(src, dst); + cv::merge(src, dst); } } INSTANTIATE_TEST_CASE_P(MatOp, Merge, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -37,29 +34,26 @@ INSTANTIATE_TEST_CASE_P(MatOp, Merge, testing::Combine( GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); - const int num_channels = 4; - cv::gpu::GpuMat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4)); + cv::Mat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4)); - std::vector dst(num_channels); + std::vector dst(num_channels); for (int i = 0; i < num_channels; ++i) - dst[i] = cv::gpu::GpuMat(size, type); + dst[i] = cv::Mat(size, type); TEST_CYCLE() { - cv::gpu::split(src, dst); + cv::split(src, dst); } } INSTANTIATE_TEST_CASE_P(MatOp, Split, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); ////////////////////////////////////////////////////////////////////// @@ -67,13 +61,10 @@ INSTANTIATE_TEST_CASE_P(MatOp, Split, testing::Combine( GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::gpu::GpuMat src(size, type); + cv::Mat src(size, type); cv::Scalar val(1, 2, 3, 4); TEST_CYCLE() @@ -83,8 +74,8 @@ GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType) } INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); ////////////////////////////////////////////////////////////////////// @@ -92,22 +83,17 @@ INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine( GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); + cv::Mat mask(size, CV_8UC1); - cv::Mat src_host(size, type); - cv::Mat mask_host(size, CV_8UC1); + declare.in(src, WARMUP_RNG); + fill(mask, 0, 2); - declare.in(src_host, WARMUP_RNG); - fill(mask_host, 0, 2); - - cv::gpu::GpuMat src(src_host); cv::Scalar val(1, 2, 3, 4); - cv::gpu::GpuMat mask(mask_host); - + TEST_CYCLE() { src.setTo(val, mask); @@ -115,8 +101,8 @@ GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType) } INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); ////////////////////////////////////////////////////////////////////// @@ -124,22 +110,17 @@ INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine( GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type = GET_PARAM(2); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type); + cv::Mat mask(size, CV_8UC1); - cv::Mat src_host(size, type); - cv::Mat mask_host(size, CV_8UC1); + declare.in(src, WARMUP_RNG); + fill(mask, 0, 2); - declare.in(src_host, WARMUP_RNG); - fill(mask_host, 0, 2); + cv::Mat dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat mask(mask_host); - cv::gpu::GpuMat dst; - TEST_CYCLE() { src.copyTo(dst, mask); @@ -147,8 +128,8 @@ GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType) } INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); ////////////////////////////////////////////////////////////////////// @@ -156,20 +137,16 @@ INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine( GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType, perf::MatType) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); cv::Size size = GET_PARAM(1); int type1 = GET_PARAM(2); int type2 = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat src(size, type1); - cv::Mat src_host(size, type1); + declare.in(src, WARMUP_RNG); - declare.in(src_host, WARMUP_RNG); + cv::Mat dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - TEST_CYCLE() { src.convertTo(dst, type2, 0.5, 1.0); @@ -177,9 +154,9 @@ GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType, perf::Mat } INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_16UC1, CV_32FC1), + ALL_DEVICES, + GPU_TYPICAL_MAT_SIZES, + testing::Values(CV_8UC1, CV_16UC1, CV_32FC1), testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); #endif diff --git a/modules/gpu/perf_cpu/perf_objdetect.cpp b/modules/gpu/perf_cpu/perf_objdetect.cpp index b6c02aaba7..5b059665b4 100644 --- a/modules/gpu/perf_cpu/perf_objdetect.cpp +++ b/modules/gpu/perf_cpu/perf_objdetect.cpp @@ -1,19 +1,14 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat img = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_host = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE); - - cv::gpu::GpuMat img(img_host); std::vector found_locations; - cv::gpu::HOGDescriptor hog; + cv::HOGDescriptor hog; hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); TEST_CYCLE() diff --git a/modules/gpu/perf_cpu/perf_precomp.cpp b/modules/gpu/perf_cpu/perf_precomp.cpp deleted file mode 100644 index 8552ac3d42..0000000000 --- a/modules/gpu/perf_cpu/perf_precomp.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "perf_precomp.hpp" diff --git a/modules/gpu/perf_cpu/perf_utility.cpp b/modules/gpu/perf_cpu/perf_utility.cpp index c0b2fadade..e5b22adb53 100644 --- a/modules/gpu/perf_cpu/perf_utility.cpp +++ b/modules/gpu/perf_cpu/perf_utility.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" using namespace std; using namespace cv; @@ -12,7 +12,7 @@ void fill(Mat& m, double a, double b) void PrintTo(const CvtColorInfo& info, ostream* os) { - static const char* str[] = + static const char* str[] = { "BGR2BGRA", "BGRA2BGR", @@ -89,7 +89,7 @@ void PrintTo(const CvtColorInfo& info, ostream* os) 0, 0, 0, - + "HLS2BGR", "HLS2RGB", @@ -131,7 +131,7 @@ void PrintTo(const CvtColorInfo& info, ostream* os) 0, 0, 0, - 0 + 0 }; *os << str[info.code]; @@ -179,7 +179,7 @@ const vector& devices() vector devices(FeatureSet feature) { const vector& d = devices(); - + vector devs_filtered; if (TargetArchs::builtWith(feature)) diff --git a/modules/gpu/perf_cpu/perf_video.cpp b/modules/gpu/perf_cpu/perf_video.cpp index ff80aabb63..a2a011a1f8 100644 --- a/modules/gpu/perf_cpu/perf_video.cpp +++ b/modules/gpu/perf_cpu/perf_video.cpp @@ -1,142 +1,23 @@ -#include "perf_precomp.hpp" +#include "perf_cpu_precomp.hpp" #ifdef HAVE_CUDA -////////////////////////////////////////////////////// -// BroxOpticalFlow - -GPU_PERF_TEST_1(BroxOpticalFlow, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(frame0_host.empty()); - ASSERT_FALSE(frame1_host.empty()); - - frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0); - frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0); - - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat u; - cv::gpu::GpuMat v; - - cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, - 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); - - declare.time(10); - - TEST_CYCLE() - { - d_flow(frame0, frame1, u, v); - } -} - -INSTANTIATE_TEST_CASE_P(Video, BroxOpticalFlow, ALL_DEVICES); - -////////////////////////////////////////////////////// -// InterpolateFrames - -GPU_PERF_TEST_1(InterpolateFrames, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(frame0_host.empty()); - ASSERT_FALSE(frame1_host.empty()); - - frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0); - frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0); - - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat fu, fv; - cv::gpu::GpuMat bu, bv; - - cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, - 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); - - d_flow(frame0, frame1, fu, fv); - d_flow(frame1, frame0, bu, bv); - - cv::gpu::GpuMat newFrame; - cv::gpu::GpuMat buf; - - TEST_CYCLE() - { - cv::gpu::interpolateFrames(frame0, frame1, fu, fv, bu, bv, 0.5f, newFrame, buf); - } -} - -INSTANTIATE_TEST_CASE_P(Video, InterpolateFrames, ALL_DEVICES); - -////////////////////////////////////////////////////// -// CreateOpticalFlowNeedleMap - -GPU_PERF_TEST_1(CreateOpticalFlowNeedleMap, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(frame0_host.empty()); - ASSERT_FALSE(frame1_host.empty()); - - frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0); - frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0); - - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat u, v; - - cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, - 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); - - d_flow(frame0, frame1, u, v); - - cv::gpu::GpuMat vertex, colors; - - TEST_CYCLE() - { - cv::gpu::createOpticalFlowNeedleMap(u, v, vertex, colors); - } -} - -INSTANTIATE_TEST_CASE_P(Video, CreateOpticalFlowNeedleMap, ALL_DEVICES); - ////////////////////////////////////////////////////// // GoodFeaturesToTrack GPU_PERF_TEST(GoodFeaturesToTrack, cv::gpu::DeviceInfo, double) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); double minDistance = GET_PARAM(1); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat image_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); + cv::Mat image = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image_host.empty()); + ASSERT_FALSE(image.empty()); - cv::gpu::GoodFeaturesToTrackDetector_GPU detector(8000, 0.01, minDistance); - - cv::gpu::GpuMat image(image_host); - cv::gpu::GpuMat pts; + cv::Mat corners; TEST_CYCLE() { - detector(image, pts); + cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance); } } @@ -147,112 +28,66 @@ INSTANTIATE_TEST_CASE_P(Video, GoodFeaturesToTrack, testing::Combine(ALL_DEVICES GPU_PERF_TEST(PyrLKOpticalFlowSparse, cv::gpu::DeviceInfo, bool, int, int) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); bool useGray = GET_PARAM(1); int points = GET_PARAM(2); int win_size = GET_PARAM(3); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); + cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); + cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame0_host.empty()); - ASSERT_FALSE(frame1_host.empty()); + ASSERT_FALSE(frame0.empty()); + ASSERT_FALSE(frame1.empty()); cv::Mat gray_frame; if (useGray) - gray_frame = frame0_host; + gray_frame = frame0; else - cv::cvtColor(frame0_host, gray_frame, cv::COLOR_BGR2GRAY); + cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY); - cv::gpu::GpuMat pts; + cv::Mat pts; + cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0); - cv::gpu::GoodFeaturesToTrackDetector_GPU detector(points, 0.01, 0.0); - detector(cv::gpu::GpuMat(gray_frame), pts); - - cv::gpu::PyrLKOpticalFlow pyrLK; - pyrLK.winSize = cv::Size(win_size, win_size); - - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat nextPts; - cv::gpu::GpuMat status; + cv::Mat nextPts; + cv::Mat status; TEST_CYCLE() { - pyrLK.sparse(frame0, frame1, pts, nextPts, status); + cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), cv::Size(win_size, win_size)); } } -INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowSparse, testing::Combine - ( - ALL_DEVICES, - testing::Bool(), - testing::Values(1000, 2000, 4000, 8000), - testing::Values(17, 21) - )); - -////////////////////////////////////////////////////// -// PyrLKOpticalFlowDense - -GPU_PERF_TEST_1(PyrLKOpticalFlowDense, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(frame0_host.empty()); - ASSERT_FALSE(frame1_host.empty()); - - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat u; - cv::gpu::GpuMat v; - - cv::gpu::PyrLKOpticalFlow pyrLK; - - declare.time(10); - - TEST_CYCLE() - { - pyrLK.dense(frame0, frame1, u, v); - } -} - -INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowDense, ALL_DEVICES); - +INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowSparse, testing::Combine( + ALL_DEVICES, + testing::Bool(), + testing::Values(1000, 2000, 4000, 8000), + testing::Values(17, 21))); ////////////////////////////////////////////////////// // FarnebackOpticalFlowTest GPU_PERF_TEST_1(FarnebackOpticalFlowTest, cv::gpu::DeviceInfo) { - cv::gpu::DeviceInfo devInfo = GetParam(); + cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); + cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - cv::gpu::setDevice(devInfo.deviceID()); + ASSERT_FALSE(frame0.empty()); + ASSERT_FALSE(frame1.empty()); - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - - ASSERT_FALSE(frame0_host.empty()); - ASSERT_FALSE(frame1_host.empty()); - - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat u; - cv::gpu::GpuMat v; - - cv::gpu::FarnebackOpticalFlow calc; + cv::Mat flow; declare.time(10); + int numLevels = 5; + double pyrScale = 0.5; + int winSize = 13; + int numIters = 10; + int polyN = 5; + double polySigma = 1.1; + int flags = 0; + TEST_CYCLE() { - calc(frame0, frame1, u, v); + cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); } }