From ddca47040b01ae7fff0f6028fbc1acb3f3f1e0d4 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 16 Aug 2012 16:23:27 +0400 Subject: [PATCH 1/9] updated gpu accuracy tests added posibility to specify device on which tests will be executed --- modules/gpu/test/main.cpp | 91 +++++++++++------ modules/gpu/test/precomp.hpp | 1 + modules/gpu/test/utility.cpp | 183 +++++++++++++++++++++++++++-------- modules/gpu/test/utility.hpp | 21 ++-- 4 files changed, 219 insertions(+), 77 deletions(-) diff --git a/modules/gpu/test/main.cpp b/modules/gpu/test/main.cpp index 6a8c67d79..6df7db0a1 100644 --- a/modules/gpu/test/main.cpp +++ b/modules/gpu/test/main.cpp @@ -49,35 +49,39 @@ using namespace cv::gpu; using namespace cvtest; using namespace testing; -void print_info() +void printInfo() { - printf("\n"); #if defined _WIN32 # if defined _WIN64 - puts("OS: Windows 64"); + puts("OS: Windows x64"); # else - puts("OS: Windows 32"); + puts("OS: Windows x32"); # endif #elif defined linux # if defined _LP64 - puts("OS: Linux 64"); + puts("OS: Linux x64"); # else - puts("OS: Linux 32"); + puts("OS: Linux x32"); # endif #elif defined __APPLE__ # if defined _LP64 - puts("OS: Apple 64"); + puts("OS: Apple x64"); # else - puts("OS: Apple 32"); + puts("OS: Apple x32"); # endif #endif - int deviceCount = getCudaEnabledDeviceCount(); int driver; cudaDriverGetVersion(&driver); printf("CUDA Driver version: %d\n", driver); printf("CUDA Runtime version: %d\n", CUDART_VERSION); + + puts("GPU module was compiled for the following GPU archs:"); + printf(" BIN: %s\n", CUDA_ARCH_BIN); + printf(" PTX: %s\n\n", CUDA_ARCH_PTX); + + int deviceCount = getCudaEnabledDeviceCount(); printf("CUDA device count: %d\n\n", deviceCount); for (int i = 0; i < deviceCount; ++i) @@ -87,17 +91,13 @@ void print_info() printf("Device %d:\n", i); printf(" Name: %s\n", info.name().c_str()); printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion()); + printf(" Multi Processor Count: %d\n", info.multiProcessorCount()); printf(" Total memory: %d Mb\n", static_cast(static_cast(info.totalMemory() / 1024.0) / 1024.0)); printf(" Free memory: %d Mb\n", static_cast(static_cast(info.freeMemory() / 1024.0) / 1024.0)); - if (info.isCompatible()) - puts(" This device is compatible with current GPU module build\n"); - else - puts(" This device is NOT compatible with current GPU module build\n"); + if (!info.isCompatible()) + puts(" !!! This device is NOT compatible with current GPU module build\n"); + printf("\n"); } - - puts("GPU module was compiled for the following GPU archs:"); - printf(" BIN: %s\n", CUDA_ARCH_BIN); - printf(" PTX: %s\n\n", CUDA_ARCH_PTX); } enum OutputLevel @@ -111,25 +111,56 @@ extern OutputLevel nvidiaTestOutputLevel; int main(int argc, char** argv) { - TS::ptr()->init("gpu"); - InitGoogleTest(&argc, argv); + try + { + CommandLineParser parser(argc, (const char**)argv, + "{ print_info_only | print_info_only | false | Print information about system and exit }" + "{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }" + "{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"); - const char* keys ="{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"; + printInfo(); - CommandLineParser parser(argc, (const char**)argv, keys); + if (parser.get("print_info_only")) + return 0; - string outputLevel = parser.get("nvtest_output_level", "none"); + int device = parser.get("device"); + if (device < 0) + { + DeviceManager::instance().loadAll(); + std::cout << "Run tests on all supported devices\n" << std::endl; + } + else + { + DeviceManager::instance().load(device); + std::cout << "Run tests on device " << device << '\n' << std::endl; + } - if (outputLevel == "none") - nvidiaTestOutputLevel = OutputLevelNone; - else if (outputLevel == "compact") - nvidiaTestOutputLevel = OutputLevelCompact; - else if (outputLevel == "full") - nvidiaTestOutputLevel = OutputLevelFull; + string outputLevel = parser.get("nvtest_output_level"); - print_info(); + if (outputLevel == "none") + nvidiaTestOutputLevel = OutputLevelNone; + else if (outputLevel == "compact") + nvidiaTestOutputLevel = OutputLevelCompact; + else if (outputLevel == "full") + nvidiaTestOutputLevel = OutputLevelFull; - return RUN_ALL_TESTS(); + TS::ptr()->init("gpu"); + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); + } + catch (const exception& e) + { + cerr << e.what() << endl; + return -1; + } + catch (...) + { + cerr << "Unknown error" << endl; + return -1; + } + + return 0; } #else // HAVE_CUDA diff --git a/modules/gpu/test/precomp.hpp b/modules/gpu/test/precomp.hpp index afc3be855..753367cce 100644 --- a/modules/gpu/test/precomp.hpp +++ b/modules/gpu/test/precomp.hpp @@ -56,6 +56,7 @@ #include #include #include +#include #include "cvconfig.h" #include "opencv2/core/core.hpp" diff --git a/modules/gpu/test/utility.cpp b/modules/gpu/test/utility.cpp index bc73d3003..148c9d202 100644 --- a/modules/gpu/test/utility.cpp +++ b/modules/gpu/test/utility.cpp @@ -46,6 +46,7 @@ using namespace cv; using namespace cv::gpu; using namespace cvtest; using namespace testing; +using namespace testing::internal; ////////////////////////////////////////////////////////////////////// // random generators @@ -108,12 +109,12 @@ GpuMat loadMat(const Mat& m, bool useRoi) ////////////////////////////////////////////////////////////////////// // Image load -Mat readImage(const string& fileName, int flags) +Mat readImage(const std::string& fileName, int flags) { - return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags); + return imread(TS::ptr()->get_data_path() + fileName, flags); } -Mat readImageType(const string& fname, int type) +Mat readImageType(const std::string& fname, int type) { Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR); if (CV_MAT_CN(type) == 4) @@ -134,50 +135,150 @@ bool supportFeature(const DeviceInfo& info, FeatureSet feature) return TargetArchs::builtWith(feature) && info.supports(feature); } -const vector& devices() +DeviceManager& DeviceManager::instance() { - static vector devs; - static bool first = true; - - if (first) - { - int deviceCount = getCudaEnabledDeviceCount(); - - devs.reserve(deviceCount); - - for (int i = 0; i < deviceCount; ++i) - { - DeviceInfo info(i); - if (info.isCompatible()) - devs.push_back(info); - } - - first = false; - } - - return devs; + static DeviceManager obj; + return obj; } -vector devices(FeatureSet feature) +void DeviceManager::load(int i) { - const vector& d = devices(); + devices_.clear(); + devices_.reserve(1); - vector devs_filtered; + ostringstream msg; - if (TargetArchs::builtWith(feature)) + if (i < 0 || i >= getCudaEnabledDeviceCount()) { - devs_filtered.reserve(d.size()); - - for (size_t i = 0, size = d.size(); i < size; ++i) - { - const DeviceInfo& info = d[i]; - - if (info.supports(feature)) - devs_filtered.push_back(info); - } + msg << "Incorrect device number - " << i; + throw runtime_error(msg.str()); } - return devs_filtered; + DeviceInfo info(i); + + if (!info.isCompatible()) + { + msg << "Device " << i << " [" << info.name() << "] is NOT compatible with current GPU module build"; + throw runtime_error(msg.str()); + } + + devices_.push_back(info); +} + +void DeviceManager::loadAll() +{ + int deviceCount = getCudaEnabledDeviceCount(); + + devices_.clear(); + devices_.reserve(deviceCount); + + for (int i = 0; i < deviceCount; ++i) + { + DeviceInfo info(i); + if (info.isCompatible()) + { + devices_.push_back(info); + } + } +} + +class DevicesGenerator : public ParamGeneratorInterface +{ +public: + ~DevicesGenerator(); + + ParamIteratorInterface* Begin() const; + ParamIteratorInterface* End() const; + +private: + class Iterator : public ParamIteratorInterface + { + public: + Iterator(const ParamGeneratorInterface* base, vector::const_iterator iterator); + + virtual ~Iterator(); + + virtual const ParamGeneratorInterface* BaseGenerator() const; + + virtual void Advance(); + + virtual ParamIteratorInterface* Clone() const; + + virtual const DeviceInfo* Current() const; + + virtual bool Equals(const ParamIteratorInterface& other) const; + + private: + Iterator(const Iterator& other); + + const ParamGeneratorInterface* const base_; + vector::const_iterator iterator_; + + mutable DeviceInfo value_; + }; +}; + +DevicesGenerator::~DevicesGenerator() +{ +} + +ParamIteratorInterface* DevicesGenerator::Begin() const +{ + return new Iterator(this, DeviceManager::instance().values().begin()); +} + +ParamIteratorInterface* DevicesGenerator::End() const +{ + return new Iterator(this, DeviceManager::instance().values().end()); +} + +DevicesGenerator::Iterator::Iterator(const ParamGeneratorInterface* base, vector::const_iterator iterator) + : base_(base), iterator_(iterator) +{ +} + +DevicesGenerator::Iterator::~Iterator() +{ +} + +const ParamGeneratorInterface* DevicesGenerator::Iterator::BaseGenerator() const +{ + return base_; +} + +void DevicesGenerator::Iterator::Advance() +{ + ++iterator_; +} + +ParamIteratorInterface* DevicesGenerator::Iterator::Clone() const +{ + return new Iterator(*this); +} + +const DeviceInfo* DevicesGenerator::Iterator::Current() const +{ + value_ = *iterator_; + return &value_; +} + +bool DevicesGenerator::Iterator::Equals(const ParamIteratorInterface& other) const +{ + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << endl; + + return iterator_ == CheckedDowncastToActualType(&other)->iterator_; +} + +DevicesGenerator::Iterator::Iterator(const Iterator& other) : + ParamIteratorInterface(), base_(other.base_), iterator_(other.iterator_) +{ +} + +ParamGenerator DevicesGenerator_() +{ + return ParamGenerator(new DevicesGenerator); } ////////////////////////////////////////////////////////////////////// @@ -250,7 +351,7 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL namespace { - template string printMatValImpl(const Mat& m, Point p) + template std::string printMatValImpl(const Mat& m, Point p) { const int cn = m.channels(); @@ -269,9 +370,9 @@ namespace return ostr.str(); } - string printMatVal(const Mat& m, Point p) + std::string printMatVal(const Mat& m, Point p) { - typedef string (*func_t)(const Mat& m, Point p); + typedef std::string (*func_t)(const Mat& m, Point p); static const func_t funcs[] = { diff --git a/modules/gpu/test/utility.hpp b/modules/gpu/test/utility.hpp index 3ad02decb..b36f177f6 100644 --- a/modules/gpu/test/utility.hpp +++ b/modules/gpu/test/utility.hpp @@ -80,14 +80,23 @@ cv::Mat readImageType(const std::string& fname, int type); //! return true if device supports specified feature and gpu module was built with support the feature. bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature); -//! return all devices compatible with current gpu module build. -const std::vector& devices(); +class DeviceManager +{ +public: + static DeviceManager& instance(); -//! return all devices compatible with current gpu module build which support specified feature. -std::vector devices(cv::gpu::FeatureSet feature); + void load(int i); + void loadAll(); -#define ALL_DEVICES testing::ValuesIn(devices()) -#define DEVICES(feature) testing::ValuesIn(devices(feature)) + const std::vector& values() const { return devices_; } + +private: + std::vector devices_; +}; + +testing::internal::ParamGenerator DevicesGenerator_(); + +#define ALL_DEVICES DevicesGenerator_() ////////////////////////////////////////////////////////////////////// // Additional assertion From 6e4eb722a6e426960f2e515cf35b28482fc4a8bc Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Aug 2012 15:14:14 +0400 Subject: [PATCH 2/9] updated gpu performance tests now it executes only on one device added posibility to specify device on which tests will be executed --- modules/gpu/perf/perf_calib3d.cpp | 268 ++-- modules/gpu/perf/perf_core.cpp | 1830 ++++++++++---------------- modules/gpu/perf/perf_features2d.cpp | 234 ++-- modules/gpu/perf/perf_filters.cpp | 281 ++-- modules/gpu/perf/perf_imgproc.cpp | 1384 +++++++++---------- modules/gpu/perf/perf_labeling.cpp | 18 +- modules/gpu/perf/perf_main.cpp | 87 ++ modules/gpu/perf/perf_matop.cpp | 134 +- modules/gpu/perf/perf_objdetect.cpp | 83 +- modules/gpu/perf/perf_precomp.hpp | 8 + modules/gpu/perf/perf_utility.cpp | 41 +- modules/gpu/perf/perf_utility.hpp | 74 +- modules/gpu/perf/perf_video.cpp | 490 +++---- 13 files changed, 2079 insertions(+), 2853 deletions(-) diff --git a/modules/gpu/perf/perf_calib3d.cpp b/modules/gpu/perf/perf_calib3d.cpp index 7a9c6c395..343a4e9fa 100644 --- a/modules/gpu/perf/perf_calib3d.cpp +++ b/modules/gpu/perf/perf_calib3d.cpp @@ -1,207 +1,180 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { ////////////////////////////////////////////////////////////////////// // StereoBM -GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo) +typedef pair pair_string; +DEF_PARAM_TEST_1(ImagePair, pair_string); + +PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(make_pair("gpu/perf/aloe.jpg", "gpu/perf/aloeR.jpg"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_l_host.empty()); - - cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_r_host.empty()); - - cv::gpu::StereoBM_GPU bm(0, 256); - cv::gpu::GpuMat img_l(img_l_host); - cv::gpu::GpuMat img_r(img_r_host); - cv::gpu::GpuMat dst; - - bm(img_l, img_r, dst); - declare.time(5.0); + cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(imgLeft.empty()); + + cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(imgRight.empty()); + + cv::gpu::StereoBM_GPU d_bm(0, 256); + cv::gpu::GpuMat d_imgLeft(imgLeft); + cv::gpu::GpuMat d_imgRight(imgRight); + cv::gpu::GpuMat d_dst; + + d_bm(d_imgLeft, d_imgRight, d_dst); + TEST_CYCLE() { - bm(img_l, img_r, dst); + d_bm(d_imgLeft, d_imgRight, d_dst); } } -INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // StereoBeliefPropagation -GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo) +PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(make_pair("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png"); - ASSERT_FALSE(img_l_host.empty()); - - cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png"); - ASSERT_FALSE(img_r_host.empty()); - - cv::gpu::StereoBeliefPropagation bp(64); - cv::gpu::GpuMat img_l(img_l_host); - cv::gpu::GpuMat img_r(img_r_host); - cv::gpu::GpuMat dst; - - bp(img_l, img_r, dst); - declare.time(10.0); + cv::Mat imgLeft = readImage(GetParam().first); + ASSERT_FALSE(imgLeft.empty()); + + cv::Mat imgRight = readImage(GetParam().second); + ASSERT_FALSE(imgRight.empty()); + + cv::gpu::StereoBeliefPropagation d_bp(64); + cv::gpu::GpuMat d_imgLeft(imgLeft); + cv::gpu::GpuMat d_imgRight(imgRight); + cv::gpu::GpuMat d_dst; + + d_bp(d_imgLeft, d_imgRight, d_dst); + TEST_CYCLE() { - bp(img_l, img_r, dst); + d_bp(d_imgLeft, d_imgRight, d_dst); } } -INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // StereoConstantSpaceBP -GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo) +PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(make_pair("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_l_host.empty()); - - cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_r_host.empty()); - - cv::gpu::StereoConstantSpaceBP csbp(128); - cv::gpu::GpuMat img_l(img_l_host); - cv::gpu::GpuMat img_r(img_r_host); - cv::gpu::GpuMat dst; - - csbp(img_l, img_r, dst); - declare.time(10.0); + cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(imgLeft.empty()); + + cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(imgRight.empty()); + + cv::gpu::StereoConstantSpaceBP d_csbp(128); + cv::gpu::GpuMat d_imgLeft(imgLeft); + cv::gpu::GpuMat d_imgRight(imgRight); + cv::gpu::GpuMat d_dst; + + d_csbp(d_imgLeft, d_imgRight, d_dst); + TEST_CYCLE() { - csbp(img_l, img_r, dst); + d_csbp(d_imgLeft, d_imgRight, d_dst); } } -INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // DisparityBilateralFilter -GPU_PERF_TEST_1(DisparityBilateralFilter, cv::gpu::DeviceInfo) +PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(make_pair("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); + cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(disp.empty()); - cv::Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(disp_host.empty()); + cv::gpu::DisparityBilateralFilter d_filter(128); + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_disp(disp); + cv::gpu::GpuMat d_dst; - cv::gpu::DisparityBilateralFilter f(128); - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat disp(disp_host); - cv::gpu::GpuMat dst; - - f(disp, img, dst); + d_filter(d_disp, d_img, d_dst); TEST_CYCLE() { - f(disp, img, dst); + d_filter(d_disp, d_img, d_dst); } } -INSTANTIATE_TEST_CASE_P(Calib3D, DisparityBilateralFilter, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // TransformPoints -IMPLEMENT_PARAM_CLASS(Count, int) +DEF_PARAM_TEST_1(Count, int); -GPU_PERF_TEST(TransformPoints, cv::gpu::DeviceInfo, Count) +PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + int count = GetParam(); - int count = GET_PARAM(1); + cv::Mat src(1, count, CV_32FC3); + fillRandom(src, -100, 100); - cv::Mat src_host(1, count, CV_32FC3); - fill(src_host, -100, 100); - - cv::gpu::GpuMat src(src_host); cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::gpu::GpuMat dst; - cv::gpu::transformPoints(src, rvec, tvec, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); TEST_CYCLE() { - cv::gpu::transformPoints(src, rvec, tvec, dst); + cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); } } -INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - ////////////////////////////////////////////////////////////////////// // ProjectPoints -GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count) +PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + int count = GetParam(); - int count = GET_PARAM(1); + cv::Mat src(1, count, CV_32FC3); + fillRandom(src, -100, 100); - cv::Mat src_host(1, count, CV_32FC3); - fill(src_host, -100, 100); - - cv::gpu::GpuMat src(src_host); cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat dst; - cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); TEST_CYCLE() { - cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst); + cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); } } -INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - ////////////////////////////////////////////////////////////////////// // SolvePnPRansac -GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count) +PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(3.0); - int count = GET_PARAM(1); + int count = GetParam(); cv::Mat object(1, count, CV_32FC3); - fill(object, -100, 100); + fillRandom(object, -100, 100); cv::Mat camera_mat(3, 3, CV_32FC1); - fill(camera_mat, 0.5, 1); + fillRandom(camera_mat, 0.5, 1); camera_mat.at(0, 1) = 0.f; camera_mat.at(1, 0) = 0.f; camera_mat.at(2, 0) = 0.f; @@ -211,9 +184,9 @@ GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count) std::vector image_vec; cv::Mat rvec_gold(1, 3, CV_32FC1); - fill(rvec_gold, 0, 1); + fillRandom(rvec_gold, 0, 1); cv::Mat tvec_gold(1, 3, CV_32FC1); - fill(tvec_gold, 0, 1); + fillRandom(tvec_gold, 0, 1); cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec); cv::Mat image(1, count, CV_32FC2, &image_vec[0]); @@ -223,80 +196,57 @@ GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count) cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - declare.time(3.0); - TEST_CYCLE() { cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); } } -INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - ////////////////////////////////////////////////////////////////////// // ReprojectImageTo3D -GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src_host(size, depth); - fill(src_host, 5.0, 30.0); + cv::Mat src(size, depth); + fillRandom(src, 5.0, 30.0); cv::Mat Q(4, 4, CV_32FC1); - fill(Q, 0.1, 1.0); + fillRandom(Q, 0.1, 1.0); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::reprojectImageTo3D(src, dst, Q); + cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); TEST_CYCLE() { - cv::gpu::reprojectImageTo3D(src, dst, Q); + cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); } } -INSTANTIATE_TEST_CASE_P(Calib3D, ReprojectImageTo3D, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S))); - ////////////////////////////////////////////////////////////////////// // DrawColorDisp -GPU_PERF_TEST(DrawColorDisp, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Mat src(size, type); + fillRandom(src, 0, 255); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::drawColorDisp(src, dst, 255); + cv::gpu::drawColorDisp(d_src, d_dst, 255); TEST_CYCLE() { - cv::gpu::drawColorDisp(src, dst, 255); + cv::gpu::drawColorDisp(d_src, d_dst, 255); } } -INSTANTIATE_TEST_CASE_P(Calib3D, DrawColorDisp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16S)))); - -#endif - +} // namespace diff --git a/modules/gpu/perf/perf_core.cpp b/modules/gpu/perf/perf_core.cpp index f41343204..b56713a70 100644 --- a/modules/gpu/perf/perf_core.cpp +++ b/modules/gpu/perf/perf_core.cpp @@ -1,1883 +1,1513 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { + +#define ARITHM_MAT_DEPTH Values(CV_8U, CV_16U, CV_32F, CV_64F) ////////////////////////////////////////////////////////////////////// // Merge -GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - std::vector src(channels); + std::vector d_src(channels); for (int i = 0; i < channels; ++i) - src[i] = cv::gpu::GpuMat(size, depth, cv::Scalar::all(i)); + d_src[i] = cv::gpu::GpuMat(size, depth, cv::Scalar::all(i)); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_dst; - cv::gpu::merge(src, dst); + cv::gpu::merge(d_src, d_dst); TEST_CYCLE() { - cv::gpu::merge(src, dst); + cv::gpu::merge(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Merge, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(2, 3, 4))); - ////////////////////////////////////////////////////////////////////// // Split -GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); + cv::gpu::GpuMat d_src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); - cv::gpu::GpuMat src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); + std::vector d_dst; - std::vector dst; - - cv::gpu::split(src, dst); + cv::gpu::split(d_src, d_dst); TEST_CYCLE() { - cv::gpu::split(src, dst); + cv::gpu::split(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Split, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(2, 3, 4))); - ////////////////////////////////////////////////////////////////////// -// Add_Mat +// AddMat -GPU_PERF_TEST(Add_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0.0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::add(src1, src2, dst); + cv::gpu::add(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::add(src1, src2, dst); + cv::gpu::add(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Add_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Add_Scalar +// AddScalar -GPU_PERF_TEST(Add_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - 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::gpu::add(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::add(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::add(src, s, dst); + cv::gpu::add(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Add_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Subtract_Mat +// SubtractMat -GPU_PERF_TEST(Subtract_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0.0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::subtract(src1, src2, dst); + cv::gpu::subtract(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::subtract(src1, src2, dst); + cv::gpu::subtract(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Subtract_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Subtract_Scalar +// SubtractScalar -GPU_PERF_TEST(Subtract_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - 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::gpu::subtract(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::subtract(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::subtract(src, s, dst); + cv::gpu::subtract(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Subtract_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Multiply_Mat +// MultiplyMat -GPU_PERF_TEST(Multiply_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0.0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::multiply(src1, src2, dst); + cv::gpu::multiply(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::multiply(src1, src2, dst); + cv::gpu::multiply(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Multiply_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Multiply_Scalar +// MultiplyScalar -GPU_PERF_TEST(Multiply_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - 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::gpu::multiply(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::multiply(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::multiply(src, s, dst); + cv::gpu::multiply(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Multiply_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Divide_Mat +// DivideMat -GPU_PERF_TEST(Divide_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0.0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::divide(src1, src2, dst); + cv::gpu::divide(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::divide(src1, src2, dst); + cv::gpu::divide(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Divide_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Divide_Scalar +// DivideScalar -GPU_PERF_TEST(Divide_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - 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::gpu::divide(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::divide(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::divide(src, s, dst); + cv::gpu::divide(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Divide_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// Divide_Scalar_Inv +// DivideScalarInv -GPU_PERF_TEST(Divide_Scalar_Inv, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 100.0); + double s = 100.0; - cv::gpu::GpuMat src(src_host); - double scale = 100.0; - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::divide(scale, src, dst); + cv::gpu::divide(s, d_src, d_dst); TEST_CYCLE() { - cv::gpu::divide(scale, src, dst); + cv::gpu::divide(s, d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Divide_Scalar_Inv, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// AbsDiff_Mat +// AbsDiffMat -GPU_PERF_TEST(AbsDiff_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0.0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::absdiff(src1, src2, dst); + cv::gpu::absdiff(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::absdiff(src1, src2, dst); + cv::gpu::absdiff(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, AbsDiff_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// -// AbsDiff_Scalar +// AbsDiffScalar -GPU_PERF_TEST(AbsDiff_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - 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::gpu::absdiff(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::absdiff(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::absdiff(src, s, dst); + cv::gpu::absdiff(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, AbsDiff_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// // Abs -GPU_PERF_TEST(Abs, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::abs(src, dst); + cv::gpu::abs(d_src, d_dst); TEST_CYCLE() { - cv::gpu::abs(src, dst); + cv::gpu::abs(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Abs, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_16S, CV_32F))); - ////////////////////////////////////////////////////////////////////// // Sqr -GPU_PERF_TEST(Sqr, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::sqr(src, dst); + cv::gpu::sqr(d_src, d_dst); TEST_CYCLE() { - cv::gpu::sqr(src, dst); + cv::gpu::sqr(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Sqr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - ////////////////////////////////////////////////////////////////////// // Sqrt -GPU_PERF_TEST(Sqrt, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::sqrt(src, dst); + cv::gpu::sqrt(d_src, d_dst); TEST_CYCLE() { - cv::gpu::sqrt(src, dst); + cv::gpu::sqrt(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Sqrt, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - ////////////////////////////////////////////////////////////////////// // Log -GPU_PERF_TEST(Log, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src, 1.0, 255.0); - cv::Mat src_host(size, depth); - fill(src_host, 1.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::log(src, dst); + cv::gpu::log(d_src, d_dst); TEST_CYCLE() { - cv::gpu::log(src, dst); + cv::gpu::log(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Log, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - ////////////////////////////////////////////////////////////////////// // Exp -GPU_PERF_TEST(Exp, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src, 1.0, 10.0); - cv::Mat src_host(size, depth); - fill(src_host, 1.0, 10.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::exp(src, dst); + cv::gpu::exp(d_src, d_dst); TEST_CYCLE() { - cv::gpu::exp(src, dst); + cv::gpu::exp(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Exp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - ////////////////////////////////////////////////////////////////////// // Pow -GPU_PERF_TEST(Pow, cv::gpu::DeviceInfo, cv::Size, MatDepth) +DEF_PARAM_TEST(Sz_Depth_Power, cv::Size, MatDepth, double); + +PERF_TEST_P(Sz_Depth_Power, Core_Pow, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F), Values(0.3, 2.0, 2.4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + double power = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src, 1.0, 10.0); - cv::Mat src_host(size, depth); - fill(src_host, 1.0, 10.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::pow(src, 2.3, dst); + cv::gpu::pow(d_src, power, d_dst); TEST_CYCLE() { - cv::gpu::pow(src, 2.3, dst); + cv::gpu::pow(d_src, power, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Pow, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - ////////////////////////////////////////////////////////////////////// -// Compare_Mat +// CompareMat CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE) -#define ALL_CMP_CODES testing::Values(CmpCode(cv::CMP_EQ), CmpCode(cv::CMP_NE), CmpCode(cv::CMP_GT), CmpCode(cv::CMP_GE), CmpCode(cv::CMP_LT), CmpCode(cv::CMP_LE)) +#define ALL_CMP_CODES ValuesIn(CmpCode::all()) -GPU_PERF_TEST(Compare_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode) +DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CmpCode); + +PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int cmp_code = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int cmp_code = GET_PARAM(3); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::compare(src1, src2, dst, cmp_code); + cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); TEST_CYCLE() { - cv::gpu::compare(src1, src2, dst, cmp_code); + cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); } } -INSTANTIATE_TEST_CASE_P(Core, Compare_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - ALL_CMP_CODES)); - ////////////////////////////////////////////////////////////////////// -// Compare_Scalar +// CompareScalar -GPU_PERF_TEST(Compare_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode) +PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int cmp_code = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int cmp_code = GET_PARAM(3); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0, 100.0); + cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat src(src_host); - cv::Scalar s = cv::Scalar::all(50); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::compare(src, s, dst, cmp_code); + cv::gpu::compare(d_src, s, d_dst, cmp_code); TEST_CYCLE() { - cv::gpu::compare(src, s, dst, cmp_code); + cv::gpu::compare(d_src, s, d_dst, cmp_code); } } -INSTANTIATE_TEST_CASE_P(Core, Compare_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - ALL_CMP_CODES)); - ////////////////////////////////////////////////////////////////////// -// Bitwise_Not +// BitwiseNot -GPU_PERF_TEST(Bitwise_Not, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::bitwise_not(src, dst); + cv::gpu::bitwise_not(d_src, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_not(src, dst); + cv::gpu::bitwise_not(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Not, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - ////////////////////////////////////////////////////////////////////// -// Bitwise_And_Mat +// BitwiseAndMat -GPU_PERF_TEST(Bitwise_And_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::bitwise_and(src1, src2, dst); + cv::gpu::bitwise_and(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_and(src1, src2, dst); + cv::gpu::bitwise_and(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_And_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - ////////////////////////////////////////////////////////////////////// -// Bitwise_And_Scalar +// BitwiseAndScalar -GPU_PERF_TEST(Bitwise_And_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 100.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::gpu::GpuMat dst; + cv::Scalar s = cv::Scalar::all(100); - cv::gpu::bitwise_and(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::bitwise_and(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_and(src, s, dst); + cv::gpu::bitwise_and(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_And_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - ////////////////////////////////////////////////////////////////////// -// Bitwise_Or_Mat +// BitwiseOrMat -GPU_PERF_TEST(Bitwise_Or_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::bitwise_or(src1, src2, dst); + cv::gpu::bitwise_or(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_or(src1, src2, dst); + cv::gpu::bitwise_or(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Or_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - ////////////////////////////////////////////////////////////////////// -// Bitwise_Or_Scalar +// BitwiseOrScalar -GPU_PERF_TEST(Bitwise_Or_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 100.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::gpu::GpuMat dst; + cv::Scalar s = cv::Scalar::all(100); - cv::gpu::bitwise_or(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::bitwise_or(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_or(src, s, dst); + cv::gpu::bitwise_or(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Or_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - ////////////////////////////////////////////////////////////////////// -// Bitwise_Xor_Mat +// BitwiseXorMat -GPU_PERF_TEST(Bitwise_Xor_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0, 100.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::bitwise_xor(src1, src2, dst); + cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_xor(src1, src2, dst); + cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Xor_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - ////////////////////////////////////////////////////////////////////// -// Bitwise_Xor_Scalar +// BitwiseXorScalar -GPU_PERF_TEST(Bitwise_Xor_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 100.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::gpu::GpuMat dst; + cv::Scalar s = cv::Scalar::all(100); - cv::gpu::bitwise_xor(src, s, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::bitwise_xor(d_src, s, d_dst); TEST_CYCLE() { - cv::gpu::bitwise_xor(src, s, dst); + cv::gpu::bitwise_xor(d_src, s, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Xor_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - ////////////////////////////////////////////////////////////////////// // RShift -GPU_PERF_TEST(RShift, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); cv::Scalar_ val = cv::Scalar_::all(4); - cv::gpu::GpuMat dst; - cv::gpu::rshift(src, val, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::rshift(d_src, val, d_dst); TEST_CYCLE() { - cv::gpu::rshift(src, val, dst); + cv::gpu::rshift(d_src, val, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, RShift, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - ////////////////////////////////////////////////////////////////////// // LShift -GPU_PERF_TEST(LShift, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) +PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); cv::Scalar_ val = cv::Scalar_::all(4); - cv::gpu::GpuMat dst; - cv::gpu::lshift(src, val, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::lshift(d_src, val, d_dst); TEST_CYCLE() { - cv::gpu::lshift(src, val, dst); + cv::gpu::lshift(d_src, val, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, LShift, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - ////////////////////////////////////////////////////////////////////// -// Min_Mat +// MinMat -GPU_PERF_TEST(Min_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0, 255.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0, 255.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::min(src1, src2, dst); + cv::gpu::min(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::min(src1, src2, dst); + cv::gpu::min(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Min_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - ////////////////////////////////////////////////////////////////////// -// Min_Scalar +// MinScalar -GPU_PERF_TEST(Min_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0, 255.0); - - cv::gpu::GpuMat src(src_host); double val = 50.0; - cv::gpu::GpuMat dst; - cv::gpu::min(src, val, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::min(d_src, val, d_dst); TEST_CYCLE() { - cv::gpu::min(src, val, dst); + cv::gpu::min(d_src, val, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Min_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - ////////////////////////////////////////////////////////////////////// -// Max_Mat +// MaxMat -GPU_PERF_TEST(Max_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src1(size, depth); + fillRandom(src1); - cv::Mat src1_host(size, depth); - fill(src1_host, 0, 255.0); + cv::Mat src2(size, depth); + fillRandom(src2); - cv::Mat src2_host(size, depth); - fill(src2_host, 0, 255.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::max(src1, src2, dst); + cv::gpu::max(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::max(src1, src2, dst); + cv::gpu::max(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Max_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - ////////////////////////////////////////////////////////////////////// -// Max_Scalar +// MaxScalar -GPU_PERF_TEST(Max_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0, 255.0); - - cv::gpu::GpuMat src(src_host); double val = 50.0; - cv::gpu::GpuMat dst; - cv::gpu::max(src, val, dst); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::max(d_src, val, d_dst); TEST_CYCLE() { - cv::gpu::max(src, val, dst); + cv::gpu::max(d_src, val, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Max_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - ////////////////////////////////////////////////////////////////////// // AddWeighted -GPU_PERF_TEST(AddWeighted, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth, MatDepth) +DEF_PARAM_TEST(Sz_3Depth, cv::Size, MatDepth, MatDepth, MatDepth); + +PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F, CV_64F), + Values(CV_8U, CV_16U, CV_32F, CV_64F), + Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth1 = GET_PARAM(1); + int depth2 = GET_PARAM(2); + int dst_depth = GET_PARAM(3); - cv::Size size = GET_PARAM(1); - int depth1 = GET_PARAM(2); - int depth2 = GET_PARAM(3); - int dst_depth = GET_PARAM(4); + cv::Mat src1(size, depth1); + fillRandom(src1); - cv::Mat src1_host(size, depth1); - fill(src1_host, 0, 100.0); + cv::Mat src2(size, depth2); + fillRandom(src2); - cv::Mat src2_host(size, depth2); - fill(src2_host, 0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); + cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); TEST_CYCLE() { - cv::gpu::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); + cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); } } -INSTANTIATE_TEST_CASE_P(Core, AddWeighted, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// // GEMM -#ifdef HAVE_CUBLAS CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T) -#define ALL_GEMM_FLAGS testing::Values(GemmFlags(0), GemmFlags(cv::GEMM_1_T), GemmFlags(cv::GEMM_2_T), GemmFlags(cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T)) +#define ALL_GEMM_FLAGS Values(0, CV_GEMM_A_T, CV_GEMM_B_T, CV_GEMM_C_T, CV_GEMM_A_T | CV_GEMM_B_T, CV_GEMM_A_T | CV_GEMM_C_T, CV_GEMM_A_T | CV_GEMM_B_T | CV_GEMM_C_T) -GPU_PERF_TEST(GEMM, cv::gpu::DeviceInfo, cv::Size, MatType, GemmFlags) +DEF_PARAM_TEST(Sz_Type_Flags, cv::Size, MatType, GemmFlags); + +PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine( + Values(cv::Size(512, 512), cv::Size(1024, 1024)), + Values(CV_32FC1, CV_32FC2, CV_64FC1, CV_64FC2), + ALL_GEMM_FLAGS)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int flags = GET_PARAM(3); - - cv::Mat src1_host(size, type); - fill(src1_host, 0.0, 10.0); - - cv::Mat src2_host(size, type); - fill(src2_host, 0.0, 10.0); - - cv::Mat src3_host(size, type); - fill(src3_host, 0.0, 10.0); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat src3(src3_host); - cv::gpu::GpuMat dst; - - cv::gpu::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); - declare.time(5.0); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int flags = GET_PARAM(2); + + cv::Mat src1(size, type); + fillRandom(src1); + + cv::Mat src2(size, type); + fillRandom(src2); + + cv::Mat src3(size, type); + fillRandom(src3); + + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_src3(src3); + cv::gpu::GpuMat d_dst; + + cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); + TEST_CYCLE() { - cv::gpu::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); + cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); } } -INSTANTIATE_TEST_CASE_P(Core, GEMM, testing::Combine( - ALL_DEVICES, - testing::Values(cv::Size(512, 512), cv::Size(1024, 1024)), - testing::Values(CV_32FC1, CV_32FC2, CV_64FC1, CV_64FC2), - ALL_GEMM_FLAGS)); - -#endif ////////////////////////////////////////////////////////////////////// // Transpose -GPU_PERF_TEST(Transpose, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Type, Core_Transpose, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::transpose(src, dst); + cv::gpu::transpose(d_src, d_dst); TEST_CYCLE() { - cv::gpu::transpose(src, dst); + cv::gpu::transpose(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Transpose, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1))); - ////////////////////////////////////////////////////////////////////// // Flip enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1}; CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y) -#define ALL_FLIP_CODES testing::Values(FlipCode(FLIP_BOTH), FlipCode(FLIP_X), FlipCode(FLIP_Y)) +#define ALL_FLIP_CODES ValuesIn(FlipCode::all()) -GPU_PERF_TEST(Flip, cv::gpu::DeviceInfo, cv::Size, MatType, FlipCode) +DEF_PARAM_TEST(Sz_Depth_Cn_Code, cv::Size, MatDepth, int, FlipCode); + +PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + ALL_FLIP_CODES)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int flipCode = GET_PARAM(3); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 100.0); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::flip(src, dst, flipCode); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::flip(d_src, d_dst, flipCode); TEST_CYCLE() { - cv::gpu::flip(src, dst, flipCode); + cv::gpu::flip(d_src, d_dst, flipCode); } } -INSTANTIATE_TEST_CASE_P(Core, Flip, 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), - ALL_FLIP_CODES)); - ////////////////////////////////////////////////////////////////////// -// LUT_OneChannel +// LutOneChannel -GPU_PERF_TEST(LUT_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Type, Core_LutOneChannel, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8UC1, CV_8UC3))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src_host(size, type); - fill(src_host, 0.0, 100.0); + cv::Mat src(size, type); + fillRandom(src); cv::Mat lut(1, 256, CV_8UC1); - fill(lut, 0.0, 100.0); + fillRandom(lut); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::LUT(src, lut, dst); + cv::gpu::LUT(d_src, lut, d_dst); TEST_CYCLE() { - cv::gpu::LUT(src, lut, dst); + cv::gpu::LUT(d_src, lut, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, LUT_OneChannel, testing::Combine( - ALL_DEVICES, +////////////////////////////////////////////////////////////////////// +// LutMultiChannel + +PERF_TEST_P(Sz_Type, Core_LutMultiChannel, Combine( GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3))); - -////////////////////////////////////////////////////////////////////// -// LUT_MultiChannel - -GPU_PERF_TEST(LUT_MultiChannel, cv::gpu::DeviceInfo, cv::Size, MatType) + Values(CV_8UC3))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 100.0); + cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels())); + fillRandom(lut); - cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src_host.channels())); - fill(lut, 0.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::LUT(src, lut, dst); + cv::gpu::LUT(d_src, lut, d_dst); TEST_CYCLE() { - cv::gpu::LUT(src, lut, dst); + cv::gpu::LUT(d_src, lut, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, LUT_MultiChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC3))); - ////////////////////////////////////////////////////////////////////// -// Magnitude_Complex +// MagnitudeComplex -GPU_PERF_TEST(Magnitude_Complex, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, Core_MagnitudeComplex, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_32FC2); + fillRandom(src, -100.0, 100.0); - cv::Mat src_host(size, CV_32FC2); - fill(src_host, -100.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::magnitude(src, dst); + cv::gpu::magnitude(d_src, d_dst); TEST_CYCLE() { - cv::gpu::magnitude(src, dst); + cv::gpu::magnitude(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Magnitude_Complex, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// -// Magnitude_Sqr_Complex +// MagnitudeSqrComplex -GPU_PERF_TEST(Magnitude_Sqr_Complex, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_32FC2); + fillRandom(src, -100.0, 100.0); - cv::Mat src_host(size, CV_32FC2); - fill(src_host, -100.0, 100.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::magnitudeSqr(src, dst); + cv::gpu::magnitudeSqr(d_src, d_dst); TEST_CYCLE() { - cv::gpu::magnitudeSqr(src, dst); + cv::gpu::magnitudeSqr(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Magnitude_Sqr_Complex, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // Magnitude -GPU_PERF_TEST(Magnitude, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, Core_Magnitude, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src1(size, CV_32FC1); + fillRandom(src1, -100.0, 100.0); - cv::Mat src1_host(size, CV_32FC1); - fill(src1_host, -100.0, 100.0); + cv::Mat src2(size, CV_32FC1); + fillRandom(src2, -100.0, 100.0); - cv::Mat src2_host(size, CV_32FC1); - fill(src2_host, -100.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::magnitude(src1, src2, dst); + cv::gpu::magnitude(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::magnitude(src1, src2, dst); + cv::gpu::magnitude(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Magnitude, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// -// Magnitude_Sqr +// MagnitudeSqr -GPU_PERF_TEST(Magnitude_Sqr, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, Core_MagnitudeSqr, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src1(size, CV_32FC1); + fillRandom(src1, -100.0, 100.0); - cv::Mat src1_host(size, CV_32FC1); - fill(src1_host, -100.0, 100.0); + cv::Mat src2(size, CV_32FC1); + fillRandom(src2, -100.0, 100.0); - cv::Mat src2_host(size, CV_32FC1); - fill(src2_host, -100.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::magnitudeSqr(src1, src2, dst); + cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); TEST_CYCLE() { - cv::gpu::magnitudeSqr(src1, src2, dst); + cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); } } -INSTANTIATE_TEST_CASE_P(Core, Magnitude_Sqr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // Phase -IMPLEMENT_PARAM_CLASS(AngleInDegrees, bool) +DEF_PARAM_TEST(Sz_AngleInDegrees, cv::Size, bool); -GPU_PERF_TEST(Phase, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) +PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + bool angleInDegrees = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); + cv::Mat src1(size, CV_32FC1); + fillRandom(src1, -100.0, 100.0); - cv::Mat src1_host(size, CV_32FC1); - fill(src1_host, -100.0, 100.0); + cv::Mat src2(size, CV_32FC1); + fillRandom(src2, -100.0, 100.0); - cv::Mat src2_host(size, CV_32FC1); - fill(src2_host, -100.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; - - cv::gpu::phase(src1, src2, dst, angleInDegrees); + cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); TEST_CYCLE() { - cv::gpu::phase(src1, src2, dst, angleInDegrees); + cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); } } -INSTANTIATE_TEST_CASE_P(Core, Phase, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - ////////////////////////////////////////////////////////////////////// // CartToPolar -GPU_PERF_TEST(CartToPolar, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) +PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + bool angleInDegrees = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); + cv::Mat src1(size, CV_32FC1); + fillRandom(src1, -100.0, 100.0); - cv::Mat src1_host(size, CV_32FC1); - fill(src1_host, -100.0, 100.0); + cv::Mat src2(size, CV_32FC1); + fillRandom(src2, -100.0, 100.0); - cv::Mat src2_host(size, CV_32FC1); - fill(src2_host, -100.0, 100.0); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_magnitude; + cv::gpu::GpuMat d_angle; - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat magnitude; - cv::gpu::GpuMat angle; - - cv::gpu::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); + cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); TEST_CYCLE() { - cv::gpu::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); + cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); } } -INSTANTIATE_TEST_CASE_P(Core, CartToPolar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - ////////////////////////////////////////////////////////////////////// // PolarToCart -GPU_PERF_TEST(PolarToCart, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) +PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + bool angleInDegrees = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); + cv::Mat magnitude(size, CV_32FC1); + fillRandom(magnitude, 0.0, 100.0); - cv::Mat magnitude_host(size, CV_32FC1); - fill(magnitude_host, 0.0, 100.0); + cv::Mat angle(size, CV_32FC1); + fillRandom(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI); - cv::Mat angle_host(size, CV_32FC1); - fill(angle_host, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI); + cv::gpu::GpuMat d_magnitude(magnitude); + cv::gpu::GpuMat d_angle(angle); + cv::gpu::GpuMat d_x; + cv::gpu::GpuMat d_y; - cv::gpu::GpuMat magnitude(magnitude_host); - cv::gpu::GpuMat angle(angle_host); - cv::gpu::GpuMat x; - cv::gpu::GpuMat y; - - cv::gpu::polarToCart(magnitude, angle, x, y, angleInDegrees); + cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); TEST_CYCLE() { - cv::gpu::polarToCart(magnitude, angle, x, y, angleInDegrees); + cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); } } -INSTANTIATE_TEST_CASE_P(Core, PolarToCart, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - ////////////////////////////////////////////////////////////////////// // MeanStdDev -GPU_PERF_TEST(MeanStdDev, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, Core_MeanStdDev, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_8UC1); + fillRandom(src); - cv::Mat src_host(size, CV_8UC1); - fill(src_host, 0.0, 255.0); - - cv::gpu::GpuMat src(src_host); cv::Scalar mean; cv::Scalar stddev; - cv::gpu::GpuMat buf; - cv::gpu::meanStdDev(src, mean, stddev, buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); TEST_CYCLE() { - cv::gpu::meanStdDev(src, mean, stddev, buf); + cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, MeanStdDev, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // Norm -GPU_PERF_TEST(Norm, cv::gpu::DeviceInfo, cv::Size, MatDepth, NormType) +DEF_PARAM_TEST(Sz_Depth_Norm, cv::Size, MatDepth, NormType); + +PERF_TEST_P(Sz_Depth_Norm, Core_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)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int normType = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int normType = GET_PARAM(3); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 255.0); - - cv::gpu::GpuMat src(src_host); double dst; - cv::gpu::GpuMat buf; - dst = cv::gpu::norm(src, normType, buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + dst = cv::gpu::norm(d_src, normType, d_buf); TEST_CYCLE() { - dst = cv::gpu::norm(src, normType, buf); + dst = cv::gpu::norm(d_src, normType, d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, Norm, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S, CV_32F), - testing::Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))); - ////////////////////////////////////////////////////////////////////// // NormDiff -GPU_PERF_TEST(NormDiff, cv::gpu::DeviceInfo, cv::Size, NormType) +DEF_PARAM_TEST(Sz_Norm, cv::Size, NormType); + +PERF_TEST_P(Sz_Norm, Core_NormDiff, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int normType = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int normType = GET_PARAM(2); + cv::Mat src1(size, CV_8UC1); + fillRandom(src1); - cv::Mat src1_host(size, CV_8UC1); - fill(src1_host, 0.0, 255.0); + cv::Mat src2(size, CV_8UC1); + fillRandom(src2); - cv::Mat src2_host(size, CV_8UC1); - fill(src2_host, 0.0, 255.0); - - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); double dst; - dst = cv::gpu::norm(src1, src2, normType); + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + + dst = cv::gpu::norm(d_src1, d_src2, normType); TEST_CYCLE() { - dst = cv::gpu::norm(src1, src2, normType); + dst = cv::gpu::norm(d_src1, d_src2, normType); } } -INSTANTIATE_TEST_CASE_P(Core, NormDiff, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))); - ////////////////////////////////////////////////////////////////////// // Sum -GPU_PERF_TEST(Sum, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); cv::Scalar dst; - cv::gpu::GpuMat buf; - dst = cv::gpu::sum(src, buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + dst = cv::gpu::sum(d_src, d_buf); TEST_CYCLE() { - dst = cv::gpu::sum(src, buf); + dst = cv::gpu::sum(d_src, d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, Sum, 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))); - ////////////////////////////////////////////////////////////////////// -// Sum_Abs +// SumAbs -GPU_PERF_TEST(Sum_Abs, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); cv::Scalar dst; - cv::gpu::GpuMat buf; - dst = cv::gpu::absSum(src, buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + dst = cv::gpu::absSum(d_src, d_buf); TEST_CYCLE() { - dst = cv::gpu::absSum(src, buf); + dst = cv::gpu::absSum(d_src, d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, Sum_Abs, 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))); - ////////////////////////////////////////////////////////////////////// -// Sum_Sqr +// SumSqr -GPU_PERF_TEST(Sum_Sqr, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); cv::Scalar dst; - cv::gpu::GpuMat buf; - dst = cv::gpu::sqrSum(src, buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + dst = cv::gpu::sqrSum(d_src, d_buf); TEST_CYCLE() { - dst = cv::gpu::sqrSum(src, buf); + dst = cv::gpu::sqrSum(d_src, d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, Sum_Sqr, 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))); - ////////////////////////////////////////////////////////////////////// // MinMax -GPU_PERF_TEST(MinMax, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MinMax, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 255.0); - - cv::gpu::GpuMat src(src_host); double minVal, maxVal; - cv::gpu::GpuMat buf; - cv::gpu::minMax(src, &minVal, &maxVal, cv::gpu::GpuMat(), buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); TEST_CYCLE() { - cv::gpu::minMax(src, &minVal, &maxVal, cv::gpu::GpuMat(), buf); + cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, MinMax, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// // MinMaxLoc -GPU_PERF_TEST(MinMaxLoc, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 255.0); - - cv::gpu::GpuMat src(src_host); double minVal, maxVal; cv::Point minLoc, maxLoc; - cv::gpu::GpuMat valbuf, locbuf; - cv::gpu::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), valbuf, locbuf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_valbuf, d_locbuf; + + cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); TEST_CYCLE() { - cv::gpu::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), valbuf, locbuf); + cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); } } -INSTANTIATE_TEST_CASE_P(Core, MinMaxLoc, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// // CountNonZero -GPU_PERF_TEST(CountNonZero, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, Core_CountNonZero, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0.0, 1.5); - - cv::gpu::GpuMat src(src_host); int dst; - cv::gpu::GpuMat buf; - dst = cv::gpu::countNonZero(src, buf); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + + dst = cv::gpu::countNonZero(d_src, d_buf); TEST_CYCLE() { - dst = cv::gpu::countNonZero(src, buf); + dst = cv::gpu::countNonZero(d_src, d_buf); } } -INSTANTIATE_TEST_CASE_P(Core, CountNonZero, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - ////////////////////////////////////////////////////////////////////// // Reduce CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) -#define ALL_REDUCE_CODES testing::Values(CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) +#define ALL_REDUCE_CODES ValuesIn(ReduceCode::all()) enum {Rows = 0, Cols = 1}; CV_ENUM(ReduceDim, Rows, Cols) +#define ALL_REDUCE_DIMS ValuesIn(ReduceDim::all()) -GPU_PERF_TEST(Reduce, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, ReduceCode, ReduceDim) +DEF_PARAM_TEST(Sz_Depth_Cn_Code_Dim, cv::Size, MatDepth, int, ReduceCode, ReduceDim); + +PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_16S, CV_32F), + Values(1, 2, 3, 4), + ALL_REDUCE_CODES, + ALL_REDUCE_DIMS)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - int reduceOp = GET_PARAM(4); - int dim = GET_PARAM(5); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); + int reduceOp = GET_PARAM(3); + int dim = GET_PARAM(4); int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 10.0); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::reduce(src, dst, dim, reduceOp); + cv::gpu::reduce(d_src, d_dst, dim, reduceOp); TEST_CYCLE() { - cv::gpu::reduce(src, dst, dim, reduceOp); + cv::gpu::reduce(d_src, d_dst, dim, reduceOp); } } -INSTANTIATE_TEST_CASE_P(Core, Reduce, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_16S, CV_32F), - testing::Values(1, 2, 3, 4), - ALL_REDUCE_CODES, - testing::Values(ReduceDim(Rows), ReduceDim(Cols)))); - -#endif +} // namespace diff --git a/modules/gpu/perf/perf_features2d.cpp b/modules/gpu/perf/perf_features2d.cpp index 8a8186017..ef9612b54 100644 --- a/modules/gpu/perf/perf_features2d.cpp +++ b/modules/gpu/perf/perf_features2d.cpp @@ -1,209 +1,179 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { ////////////////////////////////////////////////////////////////////// // SURF -GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo) +DEF_PARAM_TEST_1(Image, string); + +PERF_TEST_P(Image, Features2D_SURF, Values("gpu/perf/aloe.jpg")) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); - - cv::gpu::SURF_GPU surf; - - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat keypoints, descriptors; - - surf(img, cv::gpu::GpuMat(), keypoints, descriptors); - declare.time(2.0); + cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); + + cv::gpu::SURF_GPU d_surf; + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints, d_descriptors; + + d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + TEST_CYCLE() { - surf(img, cv::gpu::GpuMat(), keypoints, descriptors); + d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); } } -INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // FAST -GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo) +PERF_TEST_P(Image, Features2D_FAST, Values("gpu/perf/aloe.jpg")) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); + cv::gpu::FAST_GPU d_fast(20); - cv::gpu::FAST_GPU fast(20); + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints; - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat keypoints; - - fast(img, cv::gpu::GpuMat(), keypoints); + d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); TEST_CYCLE() { - fast(img, cv::gpu::GpuMat(), keypoints); + d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); } } -INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // ORB -GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo) +PERF_TEST_P(Image, Features2D_ORB, Values("gpu/perf/aloe.jpg")) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); + cv::gpu::ORB_GPU d_orb(4000); - cv::gpu::ORB_GPU orb(4000); + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints, d_descriptors; - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat keypoints, descriptors; + d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); TEST_CYCLE() { - orb(img, cv::gpu::GpuMat(), keypoints, descriptors); + d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); } } -INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES); +////////////////////////////////////////////////////////////////////// +// BFMatch + +DEF_PARAM_TEST(DescSize_Norm, int, NormType); + +PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) +{ + declare.time(3.0); + + int desc_size = GET_PARAM(0); + int normType = GET_PARAM(1); + + int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; + + cv::Mat query(3000, desc_size, type); + fillRandom(query); + + cv::Mat train(3000, desc_size, type); + fillRandom(train); + + cv::gpu::BFMatcher_GPU d_matcher(normType); + + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_distance; + + d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + + TEST_CYCLE() + { + d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + } +} ////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_match +// BFKnnMatch -IMPLEMENT_PARAM_CLASS(DescriptorSize, int) +DEF_PARAM_TEST(DescSize_K_Norm, int, int, NormType); -GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType) +PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( + Values(64, 128, 256), + Values(2, 3), + Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(3.0); - int desc_size = GET_PARAM(1); + int desc_size = GET_PARAM(0); + int k = GET_PARAM(1); int normType = GET_PARAM(2); int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - cv::Mat query_host(3000, desc_size, type); - fill(query_host, 0.0, 10.0); + cv::Mat query(3000, desc_size, type); + fillRandom(query); - cv::Mat train_host(3000, desc_size, type); - fill(train_host, 0.0, 10.0); + cv::Mat train(3000, desc_size, type); + fillRandom(train); - cv::gpu::BFMatcher_GPU matcher(normType); + cv::gpu::BFMatcher_GPU d_matcher(normType); - cv::gpu::GpuMat query(query_host); - cv::gpu::GpuMat train(train_host); - cv::gpu::GpuMat trainIdx, distance; + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist; - matcher.matchSingle(query, train, trainIdx, distance); - - declare.time(3.0); + d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); TEST_CYCLE() { - matcher.matchSingle(query, train, trainIdx, distance); + d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); } } -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - ////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_knnMatch +// BFRadiusMatch -IMPLEMENT_PARAM_CLASS(K, int) - -GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType) +PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(3.0); - int desc_size = GET_PARAM(1); - int k = GET_PARAM(2); - int normType = GET_PARAM(3); + int desc_size = GET_PARAM(0); + int normType = GET_PARAM(1); int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - cv::Mat query_host(3000, desc_size, type); - fill(query_host, 0.0, 10.0); + cv::Mat query(3000, desc_size, type); + fillRandom(query, 0.0, 1.0); - cv::Mat train_host(3000, desc_size, type); - fill(train_host, 0.0, 10.0); + cv::Mat train(3000, desc_size, type); + fillRandom(train, 0.0, 1.0); - cv::gpu::BFMatcher_GPU matcher(normType); + cv::gpu::BFMatcher_GPU d_matcher(normType); - cv::gpu::GpuMat query(query_host); - cv::gpu::GpuMat train(train_host); - cv::gpu::GpuMat trainIdx, distance, allDist; + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance; - matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k); - - declare.time(3.0); + d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); TEST_CYCLE() { - matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k); + d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); } } -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(K(2), K(3)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_radiusMatch - -GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - int desc_size = GET_PARAM(1); - int normType = GET_PARAM(2); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query_host(3000, desc_size, type); - fill(query_host, 0.0, 1.0); - - cv::Mat train_host(3000, desc_size, type); - fill(train_host, 0.0, 1.0); - - cv::gpu::BFMatcher_GPU matcher(normType); - - cv::gpu::GpuMat query(query_host); - cv::gpu::GpuMat train(train_host); - cv::gpu::GpuMat trainIdx, nMatches, distance; - - matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0); - - declare.time(3.0); - - TEST_CYCLE() - { - matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -#endif +} // namespace diff --git a/modules/gpu/perf/perf_filters.cpp b/modules/gpu/perf/perf_filters.cpp index 0263e8063..71dcd49e2 100644 --- a/modules/gpu/perf/perf_filters.cpp +++ b/modules/gpu/perf/perf_filters.cpp @@ -1,308 +1,235 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { ////////////////////////////////////////////////////////////////////// // Blur -IMPLEMENT_PARAM_CLASS(KernelSize, int) +DEF_PARAM_TEST(Sz_Type_KernelSz, cv::Size, MatType, int); -GPU_PERF_TEST(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) +PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), Values(3, 5, 7))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int ksize = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::blur(src, dst, cv::Size(ksize, ksize)); + cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); TEST_CYCLE() { - cv::gpu::blur(src, dst, cv::Size(ksize, ksize)); + cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); } } -INSTANTIATE_TEST_CASE_P(Filters, Blur, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7)))); - ////////////////////////////////////////////////////////////////////// // Sobel -GPU_PERF_TEST(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) +PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int ksize = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; - - cv::gpu::Sobel(src, dst, -1, 1, 1, buf, ksize); + cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); TEST_CYCLE() { - cv::gpu::Sobel(src, dst, -1, 1, 1, buf, ksize); + cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); } } -INSTANTIATE_TEST_CASE_P(Filters, Sobel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - ////////////////////////////////////////////////////////////////////// // Scharr -GPU_PERF_TEST(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; - - cv::gpu::Scharr(src, dst, -1, 1, 0, buf); + cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); TEST_CYCLE() { - cv::gpu::Scharr(src, dst, -1, 1, 0, buf); + cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); } } -INSTANTIATE_TEST_CASE_P(Filters, Scharr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)))); - ////////////////////////////////////////////////////////////////////// // GaussianBlur -GPU_PERF_TEST(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) +PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int ksize = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; - - cv::gpu::GaussianBlur(src, dst, cv::Size(ksize, ksize), buf, 0.5); + cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); TEST_CYCLE() { - cv::gpu::GaussianBlur(src, dst, cv::Size(ksize, ksize), buf, 0.5); + cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); } } -INSTANTIATE_TEST_CASE_P(Filters, GaussianBlur, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - ////////////////////////////////////////////////////////////////////// // Laplacian -GPU_PERF_TEST(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) +PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 3))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int ksize = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::Laplacian(src, dst, -1, ksize); + cv::gpu::Laplacian(d_src, d_dst, -1, ksize); TEST_CYCLE() { - cv::gpu::Laplacian(src, dst, -1, ksize); + cv::gpu::Laplacian(d_src, d_dst, -1, ksize); } } -INSTANTIATE_TEST_CASE_P(Filters, Laplacian, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)), - testing::Values(KernelSize(1), KernelSize(3)))); - ////////////////////////////////////////////////////////////////////// // Erode -GPU_PERF_TEST(Erode, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::erode(src, dst, ker, buf); + cv::gpu::erode(d_src, d_dst, ker, d_buf); TEST_CYCLE() { - cv::gpu::erode(src, dst, ker, buf); + cv::gpu::erode(d_src, d_dst, ker, d_buf); } } -INSTANTIATE_TEST_CASE_P(Filters, Erode, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); - ////////////////////////////////////////////////////////////////////// // Dilate -GPU_PERF_TEST(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::dilate(src, dst, ker, buf); + cv::gpu::dilate(d_src, d_dst, ker, d_buf); TEST_CYCLE() { - cv::gpu::dilate(src, dst, ker, buf); + cv::gpu::dilate(d_src, d_dst, ker, d_buf); } } -INSTANTIATE_TEST_CASE_P(Filters, Dilate, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); - ////////////////////////////////////////////////////////////////////// // MorphologyEx CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT) -#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT)) +#define ALL_MORPH_OPS ValuesIn(MorphOp::all()) -GPU_PERF_TEST(MorphologyEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp) +DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, MorphOp); + +PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), ALL_MORPH_OPS)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int morphOp = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int morphOp = GET_PARAM(3); - - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf1; - cv::gpu::GpuMat buf2; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf1; + cv::gpu::GpuMat d_buf2; - cv::gpu::morphologyEx(src, dst, morphOp, ker, buf1, buf2); + cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); TEST_CYCLE() { - cv::gpu::morphologyEx(src, dst, morphOp, ker, buf1, buf2); + cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); } } -INSTANTIATE_TEST_CASE_P(Filters, MorphologyEx, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)), - ALL_MORPH_OPS)); - ////////////////////////////////////////////////////////////////////// // Filter2D -GPU_PERF_TEST(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) +PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(3, 5, 7, 9, 11, 13, 15))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int ksize = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src_host(size, type); - fill(src_host, 0.0, 255.0); + cv::Mat src(size, type); + fillRandom(src); cv::Mat kernel(ksize, ksize, CV_32FC1); - fill(kernel, 0.0, 1.0); + fillRandom(kernel, 0.0, 1.0); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::filter2D(src, dst, -1, kernel); + cv::gpu::filter2D(d_src, d_dst, -1, kernel); TEST_CYCLE() { - cv::gpu::filter2D(src, dst, -1, kernel); + cv::gpu::filter2D(d_src, d_dst, -1, kernel); } } -INSTANTIATE_TEST_CASE_P(Filters, Filter2D, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -#endif +} // namespace diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index 0dbcd34c6..a1614a79f 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -1,188 +1,226 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { ////////////////////////////////////////////////////////////////////// // Remap -GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) +enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH}; +CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH); +#define ALL_REMAP_MODES ValuesIn(RemapMode::all()) + +void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src_host(size, type); - fill(src_host, 0, 255); - - cv::Mat xmap_host(size, CV_32FC1); - fill(xmap_host, 0, size.width); - - cv::Mat ymap_host(size, CV_32FC1); - fill(ymap_host, 0, size.height); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat xmap(xmap_host); - cv::gpu::GpuMat ymap(ymap_host); - cv::gpu::GpuMat dst; - - cv::gpu::remap(src, dst, xmap, ymap, interpolation, borderMode); - - declare.time(3.0); - - TEST_CYCLE() + for (int j = 0; j < map_x.rows; ++j) { - cv::gpu::remap(src, dst, xmap, ymap, interpolation, borderMode); + for (int i = 0; i < map_x.cols; ++i) + { + switch (remapMode) + { + case HALF_SIZE: + if (i > map_x.cols*0.25 && i < map_x.cols*0.75 && j > map_x.rows*0.25 && j < map_x.rows*0.75) + { + map_x.at(j,i) = 2 * (i - map_x.cols * 0.25) + 0.5; + map_y.at(j,i) = 2 * (j - map_x.rows * 0.25) + 0.5; + } + else + { + map_x.at(j,i) = 0; + map_y.at(j,i) = 0; + } + break; + case UPSIDE_DOWN: + map_x.at(j,i) = i; + map_y.at(j,i) = map_x.rows - j; + break; + case REFLECTION_X: + map_x.at(j,i) = map_x.cols - i; + map_y.at(j,i) = j; + break; + case REFLECTION_BOTH: + map_x.at(j,i) = map_x.cols - i; + map_y.at(j,i) = map_x.rows - j; + break; + } // end of switch + } } } -INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); +DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border_Mode, cv::Size, MatDepth, int, Interpolation, BorderMode, RemapMode); +PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), + ALL_BORDER_MODES, + ALL_REMAP_MODES)) +{ + declare.time(3.0); + + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); + int interpolation = GET_PARAM(3); + int borderMode = GET_PARAM(4); + int remapMode = GET_PARAM(5); + + int type = CV_MAKE_TYPE(depth, channels); + + cv::Mat src(size, type); + fillRandom(src); + + cv::Mat xmap(size, CV_32FC1); + cv::Mat ymap(size, CV_32FC1); + + generateMap(xmap, ymap, remapMode); + + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_xmap(xmap); + cv::gpu::GpuMat d_ymap(ymap); + cv::gpu::GpuMat d_dst; + + cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + + TEST_CYCLE() + { + cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + } +} ////////////////////////////////////////////////////////////////////// // Resize -IMPLEMENT_PARAM_CLASS(Scale, double) +DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Scale, cv::Size, MatDepth, int, Interpolation, double); -GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Scale) +PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + ALL_INTERPOLATIONS, + Values(0.5, 0.3, 2.0))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(1.0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int interpolation = GET_PARAM(3); double f = GET_PARAM(4); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - declare.time(1.0); + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); TEST_CYCLE() { - cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation); + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine( - ALL_DEVICES, +////////////////////////////////////////////////////////////////////// +// ResizeArea + +DEF_PARAM_TEST(Sz_Depth_Cn_Scale, cv::Size, MatDepth, int, double); + +PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine( GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), - Interpolation(cv::INTER_CUBIC), Interpolation(cv::INTER_AREA)), - testing::Values(Scale(0.5), Scale(0.3), Scale(2.0)))); - -GPU_PERF_TEST(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, Scale) + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + Values(0.2, 0.1, 0.05))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(1.0); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int interpolation = cv::INTER_AREA; double f = GET_PARAM(3); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - declare.time(1.0); + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); TEST_CYCLE() { - cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation); + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); } } -INSTANTIATE_TEST_CASE_P(ImgProc, ResizeArea, testing::Combine( - ALL_DEVICES, - testing::Values(perf::sz1080p/*, cv::Size(4096, 2048)*/), - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Scale(0.2),Scale(0.1),Scale(0.05)))); - ////////////////////////////////////////////////////////////////////// // WarpAffine -GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); +DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border, cv::Size, MatDepth, int, Interpolation, BorderMode); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); +PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), + ALL_BORDER_MODES)) +{ + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int interpolation = GET_PARAM(3); int borderMode = GET_PARAM(4); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat src(size, type); + fillRandom(src); const double aplha = CV_PI / 4; double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, {std::sin(aplha), std::cos(aplha), 0}}; cv::Mat M(2, 3, CV_64F, (void*) mat); - cv::gpu::warpAffine(src, dst, M, size, interpolation, borderMode); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); TEST_CYCLE() { - cv::gpu::warpAffine(src, dst, M, size, interpolation, borderMode); + cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); } } -INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - ////////////////////////////////////////////////////////////////////// // WarpPerspective -GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) +PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), + ALL_BORDER_MODES)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int interpolation = GET_PARAM(3); int borderMode = GET_PARAM(4); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat src(size, type); + fillRandom(src); const double aplha = CV_PI / 4; double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, @@ -190,1160 +228,958 @@ GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Interpola {0.0, 0.0, 1.0}}; cv::Mat M(3, 3, CV_64F, (void*) mat); - cv::gpu::warpPerspective(src, dst, M, size, interpolation, borderMode); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); TEST_CYCLE() { - cv::gpu::warpPerspective(src, dst, M, size, interpolation, borderMode); + cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); } } -INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - ////////////////////////////////////////////////////////////////////// // CopyMakeBorder -GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, BorderMode) +DEF_PARAM_TEST(Sz_Depth_Cn_Border, cv::Size, MatDepth, int, BorderMode); + +PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + ALL_BORDER_MODES)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); + int borderMode = GET_PARAM(3); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int borderType = GET_PARAM(3); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); + cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); TEST_CYCLE() { - cv::gpu::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); + cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); } } -INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - ////////////////////////////////////////////////////////////////////// // 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)) +#define ALL_THRESH_OPS ValuesIn(ThreshOp::all()) -GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, MatDepth, ThreshOp) +DEF_PARAM_TEST(Sz_Depth_Op, cv::Size, MatDepth, ThreshOp); + +PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F, CV_64F), + ALL_THRESH_OPS)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int threshOp = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int threshOp = GET_PARAM(3); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::threshold(src, dst, 100.0, 255.0, threshOp); + cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); TEST_CYCLE() { - cv::gpu::threshold(src, dst, 100.0, 255.0, threshOp); + cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)), - ALL_THRESH_OPS)); - ////////////////////////////////////////////////////////////////////// // Integral -GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_8UC1); + fillRandom(src); - cv::Mat src_host(size, CV_8UC1); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat buf; - - cv::gpu::integralBuffered(src, dst, buf); + cv::gpu::integralBuffered(d_src, d_dst, d_buf); TEST_CYCLE() { - cv::gpu::integralBuffered(src, dst, buf); + cv::gpu::integralBuffered(d_src, d_dst, d_buf); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// -// Integral_Sqr +// IntegralSqr -GPU_PERF_TEST(Integral_Sqr, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_8UC1); + fillRandom(src); - cv::Mat src_host(size, CV_8UC1); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::sqrIntegral(src, dst); + cv::gpu::sqrIntegral(d_src, d_dst); TEST_CYCLE() { - cv::gpu::sqrIntegral(src, dst); + cv::gpu::sqrIntegral(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Integral_Sqr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// -// HistEven_OneChannel +// HistEvenC1 -GPU_PERF_TEST(HistEven_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, depth); + fillRandom(src); - cv::Mat src_host(size, depth); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat hist; - cv::gpu::GpuMat buf; - - cv::gpu::histEven(src, hist, buf, 30, 0, 180); + cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); TEST_CYCLE() { - cv::gpu::histEven(src, hist, buf, 30, 0, 180); + cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); } } -INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_OneChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S)))); - ////////////////////////////////////////////////////////////////////// -// HistEven_FourChannel +// HistEvenC4 -GPU_PERF_TEST(HistEven_FourChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth) +PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); + cv::Mat src(size, CV_MAKE_TYPE(depth, 4)); + fillRandom(src); - cv::Mat src_host(size, CV_MAKE_TYPE(depth, 4)); - fill(src_host, 0, 255); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat hist[4]; - cv::gpu::GpuMat buf; int histSize[] = {30, 30, 30, 30}; int lowerLevel[] = {0, 0, 0, 0}; int upperLevel[] = {180, 180, 180, 180}; - cv::gpu::histEven(src, hist, buf, histSize, lowerLevel, upperLevel); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist[4]; + cv::gpu::GpuMat d_buf; + + cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); TEST_CYCLE() { - cv::gpu::histEven(src, hist, buf, histSize, lowerLevel, upperLevel); + cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); } } -INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_FourChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S)))); - ////////////////////////////////////////////////////////////////////// // CalcHist -GPU_PERF_TEST(CalcHist, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_8UC1); + fillRandom(src); - cv::Mat src_host(size, CV_8UC1); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat hist; - cv::gpu::GpuMat buf; - - cv::gpu::calcHist(src, hist, buf); + cv::gpu::calcHist(d_src, d_hist, d_buf); TEST_CYCLE() { - cv::gpu::calcHist(src, hist, buf); + cv::gpu::calcHist(d_src, d_hist, d_buf); } } -INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // EqualizeHist -GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_8UC1); + fillRandom(src); - cv::Mat src_host(size, CV_8UC1); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - cv::gpu::GpuMat hist; - cv::gpu::GpuMat buf; - - cv::gpu::equalizeHist(src, dst, hist, buf); + cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); TEST_CYCLE() { - cv::gpu::equalizeHist(src, dst, hist, buf); + cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); } } -INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // ColumnSum -GPU_PERF_TEST(ColumnSum, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); + cv::Mat src(size, CV_32FC1); + fillRandom(src); - cv::Mat src_host(size, CV_32FC1); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::columnSum(src, dst); + cv::gpu::columnSum(d_src, d_dst); TEST_CYCLE() { - cv::gpu::columnSum(src, dst); + cv::gpu::columnSum(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // Canny -IMPLEMENT_PARAM_CLASS(AppertureSize, int) -IMPLEMENT_PARAM_CLASS(L2gradient, bool) +DEF_PARAM_TEST(Image_AppertureSz_L2gradient, string, int, bool); -GPU_PERF_TEST(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient) +PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine( + Values("perf/800x600.jpg", "perf/1280x1024.jpg", "perf/1680x1050.jpg"), + Values(3, 5), + Bool())) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - + string fileName = GET_PARAM(0); int apperture_size = GET_PARAM(1); bool useL2gradient = GET_PARAM(2); - cv::Mat image_host = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image_host.empty()); + cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(image.empty()); - cv::gpu::GpuMat image(image_host); - cv::gpu::GpuMat dst; - cv::gpu::CannyBuf buf; + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_dst; + cv::gpu::CannyBuf d_buf; - cv::gpu::Canny(image, buf, dst, 50.0, 100.0, apperture_size, useL2gradient); + cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); TEST_CYCLE() { - cv::gpu::Canny(image, buf, dst, 50.0, 100.0, apperture_size, useL2gradient); + cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine( - ALL_DEVICES, - testing::Values(AppertureSize(3), AppertureSize(5)), - testing::Values(L2gradient(false), L2gradient(true)))); - ////////////////////////////////////////////////////////////////////// // MeanShiftFiltering -GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo) -{ - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); +DEF_PARAM_TEST_1(Image, string); - cv::Mat img = readImage("gpu/meanshift/cones.png"); +PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values("gpu/meanshift/cones.png")) +{ + declare.time(5.0); + + cv::Mat img = readImage(GetParam()); ASSERT_FALSE(img.empty()); cv::Mat rgba; cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - cv::gpu::GpuMat src(rgba); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(rgba); + cv::gpu::GpuMat d_dst; - cv::gpu::meanShiftFiltering(src, dst, 50, 50); - - declare.time(5.0); + cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); TEST_CYCLE() { - cv::gpu::meanShiftFiltering(src, dst, 50, 50); + cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); } } -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // MeanShiftProc -GPU_PERF_TEST_1(MeanShiftProc, cv::gpu::DeviceInfo) +PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values("gpu/meanshift/cones.png")) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(5.0); - cv::Mat img = readImage("gpu/meanshift/cones.png"); + cv::Mat img = readImage(GetParam()); 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; + cv::gpu::GpuMat d_src(rgba); + cv::gpu::GpuMat d_dstr; + cv::gpu::GpuMat d_dstsp; - cv::gpu::meanShiftProc(src, dstr, dstsp, 50, 50); - - declare.time(5.0); + cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); TEST_CYCLE() { - cv::gpu::meanShiftProc(src, dstr, dstsp, 50, 50); + cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); } } -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftProc, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // MeanShiftSegmentation -GPU_PERF_TEST_1(MeanShiftSegmentation, cv::gpu::DeviceInfo) +PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values("gpu/meanshift/cones.png")) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(5.0); - cv::Mat img = readImage("gpu/meanshift/cones.png"); + cv::Mat img = readImage(GetParam()); ASSERT_FALSE(img.empty()); cv::Mat rgba; cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - cv::gpu::GpuMat src(rgba); cv::Mat dst; - meanShiftSegmentation(src, dst, 10, 10, 20); + cv::gpu::GpuMat d_src(rgba); - declare.time(5.0); + cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); TEST_CYCLE() { - meanShiftSegmentation(src, dst, 10, 10, 20); + cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); } } -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, ALL_DEVICES); - ////////////////////////////////////////////////////////////////////// // BlendLinear -GPU_PERF_TEST(BlendLinear, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_32F), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat img1_host(size, type); - fill(img1_host, 0, 255); + cv::Mat img1(size, type); + fillRandom(img1); - cv::Mat img2_host(size, type); - fill(img2_host, 0, 255); + cv::Mat img2(size, type); + fillRandom(img2); - 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; + cv::gpu::GpuMat d_img1(img1); + cv::gpu::GpuMat d_img2(img2); + cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5)); + cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5)); + cv::gpu::GpuMat d_dst; - cv::gpu::blendLinear(img1, img2, weights1, weights2, dst); + cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); TEST_CYCLE() { - cv::gpu::blendLinear(img1, img2, weights1, weights2, dst); + cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); } } -INSTANTIATE_TEST_CASE_P(ImgProc, BlendLinear, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - ////////////////////////////////////////////////////////////////////// // Convolve -IMPLEMENT_PARAM_CLASS(KSize, int) -IMPLEMENT_PARAM_CLASS(Ccorr, bool) +DEF_PARAM_TEST(Sz_KernelSz_Ccorr, cv::Size, int, bool); -GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr) +PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool())) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int templ_size = GET_PARAM(2); - bool ccorr = GET_PARAM(3); - - cv::gpu::GpuMat image = cv::gpu::createContinuous(size, CV_32FC1); - image.setTo(cv::Scalar(1.0)); - - cv::gpu::GpuMat templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); - templ.setTo(cv::Scalar(1.0)); - - cv::gpu::GpuMat dst; - cv::gpu::ConvolveBuf buf; - - cv::gpu::convolve(image, templ, dst, ccorr, buf); - declare.time(2.0); + cv::Size size = GET_PARAM(0); + int templ_size = GET_PARAM(1); + bool ccorr = GET_PARAM(2); + + cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1); + d_image.setTo(cv::Scalar(1.0)); + + cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); + d_templ.setTo(cv::Scalar(1.0)); + + cv::gpu::GpuMat d_dst; + cv::gpu::ConvolveBuf d_buf; + + cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); + TEST_CYCLE() { - cv::gpu::convolve(image, templ, dst, ccorr, buf); + cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(KSize(3), KSize(9), KSize(17), KSize(27), KSize(32), KSize(64)), - testing::Values(Ccorr(false), Ccorr(true)))); - //////////////////////////////////////////////////////////////////////////////// -// MatchTemplate_8U +// MatchTemplate8U CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED) -#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED)) +#define ALL_TEMPLATE_METHODS ValuesIn(TemplateMethod::all()) -IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size) +DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, int, TemplateMethod); -GPU_PERF_TEST(MatchTemplate_8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod) +PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)), + Values(1, 3, 4), + ALL_TEMPLATE_METHODS)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + cv::Size templ_size = GET_PARAM(1); + int cn = GET_PARAM(2); + int method = GET_PARAM(3); - cv::Size size = GET_PARAM(1); - cv::Size templ_size = GET_PARAM(2); - int cn = GET_PARAM(3); - int method = GET_PARAM(4); + cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn)); + fillRandom(image); - cv::Mat image_host(size, CV_MAKE_TYPE(CV_8U, cn)); - fill(image_host, 0, 255); + cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn)); + fillRandom(templ); - cv::Mat templ_host(templ_size, CV_MAKE_TYPE(CV_8U, cn)); - fill(templ_host, 0, 255); + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_templ(templ); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat image(image_host); - cv::gpu::GpuMat templ(templ_host); - cv::gpu::GpuMat dst; - - cv::gpu::matchTemplate(image, templ, dst, method); + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); TEST_CYCLE() { - cv::gpu::matchTemplate(image, templ, dst, method); + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); } }; -INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_8U, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))), - testing::Values(Channels(1), Channels(3), Channels(4)), - ALL_TEMPLATE_METHODS)); - //////////////////////////////////////////////////////////////////////////////// -// MatchTemplate_32F +// MatchTemplate32F -GPU_PERF_TEST(MatchTemplate_32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod) +PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)), + Values(1, 3, 4), + Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + cv::Size templ_size = GET_PARAM(1); + int cn = GET_PARAM(2); + int method = GET_PARAM(3); - cv::Size size = GET_PARAM(1); - cv::Size templ_size = GET_PARAM(2); - int cn = GET_PARAM(3); - int method = GET_PARAM(4); + cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn)); + fillRandom(image); - cv::Mat image_host(size, CV_MAKE_TYPE(CV_32F, cn)); - fill(image_host, 0, 255); + cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn)); + fillRandom(templ); - cv::Mat templ_host(templ_size, CV_MAKE_TYPE(CV_32F, cn)); - fill(templ_host, 0, 255); + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_templ(templ); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat image(image_host); - cv::gpu::GpuMat templ(templ_host); - cv::gpu::GpuMat dst; - - cv::gpu::matchTemplate(image, templ, dst, method); + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); TEST_CYCLE() { - cv::gpu::matchTemplate(image, templ, dst, method); + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); } }; -INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_32F, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR)))); - ////////////////////////////////////////////////////////////////////// // MulSpectrums CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT) -GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags) +DEF_PARAM_TEST(Sz_Flags, cv::Size, DftFlags); + +PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(0, DftFlags(cv::DFT_ROWS)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int flag = GET_PARAM(1); - cv::Size size = GET_PARAM(1); - int flag = GET_PARAM(2); + cv::Mat a(size, CV_32FC2); + fillRandom(a, 0, 100); - cv::Mat a_host(size, CV_32FC2); - fill(a_host, 0, 100); + cv::Mat b(size, CV_32FC2); + fillRandom(b, 0, 100); - cv::Mat b_host(size, CV_32FC2); - fill(b_host, 0, 100); + cv::gpu::GpuMat d_a(a); + cv::gpu::GpuMat d_b(b); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat a(a_host); - cv::gpu::GpuMat b(b_host); - cv::gpu::GpuMat dst; - - cv::gpu::mulSpectrums(a, b, dst, flag); + cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); TEST_CYCLE() { - cv::gpu::mulSpectrums(a, b, dst, flag); + cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); } } -INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS)))); - ////////////////////////////////////////////////////////////////////// // MulAndScaleSpectrums -GPU_PERF_TEST(MulAndScaleSpectrums, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); + cv::Size size = GetParam(); float scale = 1.f / size.area(); - cv::Mat src1_host(size, CV_32FC2); - fill(src1_host, 0, 100); + cv::Mat src1(size, CV_32FC2); + fillRandom(src1, 0, 100); - cv::Mat src2_host(size, CV_32FC2); - fill(src2_host, 0, 100); + cv::Mat src2(size, CV_32FC2); + fillRandom(src2, 0, 100); - cv::gpu::GpuMat src1(src1_host); - cv::gpu::GpuMat src2(src2_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::mulAndScaleSpectrums(src1, src2, dst, cv::DFT_ROWS, scale, false); + cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); TEST_CYCLE() { - cv::gpu::mulAndScaleSpectrums(src1, src2, dst, cv::DFT_ROWS, scale, false); + cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); } } -INSTANTIATE_TEST_CASE_P(ImgProc, MulAndScaleSpectrums, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // Dft -GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size, DftFlags) +PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); - int flag = GET_PARAM(2); - - cv::Mat src_host(size, CV_32FC2); - fill(src_host, 0, 100); - - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - cv::gpu::dft(src, dst, size, flag); - declare.time(2.0); + cv::Size size = GET_PARAM(0); + int flag = GET_PARAM(1); + + cv::Mat src(size, CV_32FC2); + fillRandom(src, 0, 100); + + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::dft(d_src, d_dst, size, flag); + TEST_CYCLE() { - cv::gpu::dft(src, dst, size, flag); + cv::gpu::dft(d_src, d_dst, size, flag); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))); - ////////////////////////////////////////////////////////////////////// // CornerHarris -IMPLEMENT_PARAM_CLASS(BlockSize, int) -IMPLEMENT_PARAM_CLASS(ApertureSize, int) +DEF_PARAM_TEST(Image_Type_Border_BlockSz_ApertureSz, string, MatType, BorderMode, int, int); -GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize) +PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine( + Values("gpu/stereobm/aloe-L.png"), + Values(CV_8UC1, CV_32FC1), + Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), + Values(3, 5, 7), + Values(0, 3, 5, 7))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + double k = 0.5; + string fileName = GET_PARAM(0); int type = GET_PARAM(1); - int borderType = GET_PARAM(2); + int borderMode = GET_PARAM(2); int blockSize = GET_PARAM(3); int apertureSize = GET_PARAM(4); - cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); + cv::Mat img = readImage(fileName, 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::gpu::GpuMat buf; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_Dx; + cv::gpu::GpuMat d_Dy; + cv::gpu::GpuMat d_buf; - double k = 0.5; - - cv::gpu::cornerHarris(src, dst, Dx, Dy, buf, blockSize, apertureSize, k, borderType); + cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); TEST_CYCLE() { - cv::gpu::cornerHarris(src, dst, Dx, Dy, buf, blockSize, apertureSize, k, borderType); + cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); } } -INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine( - ALL_DEVICES, - testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), - testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)), - testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7)))); - ////////////////////////////////////////////////////////////////////// // CornerMinEigenVal -GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize) +PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Combine( + Values("gpu/stereobm/aloe-L.png"), + Values(CV_8UC1, CV_32FC1), + Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), + Values(3, 5, 7), + Values(0, 3, 5, 7))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - + string fileName = GET_PARAM(0); int type = GET_PARAM(1); - int borderType = GET_PARAM(2); + int borderMode = GET_PARAM(2); int blockSize = GET_PARAM(3); int apertureSize = GET_PARAM(4); - cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); + cv::Mat img = readImage(fileName, 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::gpu::GpuMat buf; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_Dx; + cv::gpu::GpuMat d_Dy; + cv::gpu::GpuMat d_buf; - cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, buf, blockSize, apertureSize, borderType); + cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); TEST_CYCLE() { - cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, buf, blockSize, apertureSize, borderType); + cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); } } -INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine( - ALL_DEVICES, - testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), - testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)), - testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7)))); - ////////////////////////////////////////////////////////////////////// // BuildWarpPlaneMaps -GPU_PERF_TEST(BuildWarpPlaneMaps, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); + cv::Size size = GetParam(); cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); cv::Mat T = cv::Mat::zeros(1, 3, CV_32F); - cv::gpu::GpuMat map_x; - cv::gpu::GpuMat map_y; - cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, map_x, map_y); + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; + + cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); TEST_CYCLE() { - cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, map_x, map_y); + cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_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) +PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); + cv::Size size = GetParam(); cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat map_x; - cv::gpu::GpuMat map_y; - cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y); + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; + + cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); TEST_CYCLE() { - cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y); + cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_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) +PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Size size = GET_PARAM(1); + cv::Size size = GetParam(); cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat map_x; - cv::gpu::GpuMat map_y; - cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y); + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; + + cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); TEST_CYCLE() { - cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y); + cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_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, MatType, Interpolation) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); +DEF_PARAM_TEST(Sz_Depth_Cn_Inter, cv::Size, MatDepth, int, Interpolation); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); +PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4), + Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)))) +{ + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); int interpolation = GET_PARAM(3); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::rotate(src, dst, size, 30.0, 0, 0, interpolation); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); TEST_CYCLE() { - cv::gpu::rotate(src, dst, size, 30.0, 0, 0, interpolation); + cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); } } -INSTANTIATE_TEST_CASE_P(ImgProc, Rotate, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)))); - ////////////////////////////////////////////////////////////////////// // PyrDown -GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::pyrDown(src, dst); + cv::gpu::pyrDown(d_src, d_dst); TEST_CYCLE() { - cv::gpu::pyrDown(src, dst); + cv::gpu::pyrDown(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - ////////////////////////////////////////////////////////////////////// // PyrUp -GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::pyrUp(src, dst); + cv::gpu::pyrUp(d_src, d_dst); TEST_CYCLE() { - cv::gpu::pyrUp(src, dst); + cv::gpu::pyrUp(d_src, d_dst); } } -INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - ////////////////////////////////////////////////////////////////////// // CvtColor -GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, MatDepth, CvtColorInfo) +DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CvtColorInfo); + +PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine( + GPU_TYPICAL_MAT_SIZES, + Values(CV_8U, CV_16U, CV_32F), + Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), + CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), + CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA), + CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ), + CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR), + CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb), + CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR), + CvtColorInfo(3, 3, cv::COLOR_BGR2YUV), + CvtColorInfo(3, 3, cv::COLOR_YUV2BGR), + CvtColorInfo(3, 3, cv::COLOR_BGR2HSV), + CvtColorInfo(3, 3, cv::COLOR_HSV2BGR), + CvtColorInfo(3, 3, cv::COLOR_BGR2HLS), + CvtColorInfo(3, 3, cv::COLOR_HLS2BGR), + CvtColorInfo(3, 3, cv::COLOR_BGR2Lab), + CvtColorInfo(3, 3, cv::COLOR_RGB2Lab), + CvtColorInfo(3, 3, cv::COLOR_BGR2Luv), + CvtColorInfo(3, 3, cv::COLOR_RGB2Luv), + CvtColorInfo(3, 3, cv::COLOR_Lab2BGR), + CvtColorInfo(3, 3, cv::COLOR_Lab2RGB), + CvtColorInfo(3, 3, cv::COLOR_Luv2BGR), + CvtColorInfo(3, 3, cv::COLOR_Luv2RGB), + CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR), + CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR), + CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR), + CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR), + CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA)))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + CvtColorInfo info = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - CvtColorInfo info = GET_PARAM(3); + cv::Mat src(size, CV_MAKETYPE(depth, info.scn)); + fillRandom(src); - cv::Mat src_host(size, CV_MAKETYPE(depth, info.scn)); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - if (info.code >= cv::COLOR_BayerBG2BGR && info.code <= cv::COLOR_BayerGR2BGR) - info.dcn = 4; - - cv::gpu::cvtColor(src, dst, info.code, info.dcn); + cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); TEST_CYCLE() { - cv::gpu::cvtColor(src, dst, info.code, info.dcn); + cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); } } -INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)), - testing::Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), - CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), - CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA), - CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ), - CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb), - CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2YUV), - CvtColorInfo(3, 3, cv::COLOR_YUV2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2HSV), - CvtColorInfo(3, 3, cv::COLOR_HSV2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2HLS), - CvtColorInfo(3, 3, cv::COLOR_HLS2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2Lab), - CvtColorInfo(3, 3, cv::COLOR_RGB2Lab), - CvtColorInfo(3, 3, cv::COLOR_BGR2Luv), - CvtColorInfo(3, 3, cv::COLOR_RGB2Luv), - CvtColorInfo(3, 3, cv::COLOR_Lab2BGR), - CvtColorInfo(3, 3, cv::COLOR_Lab2RGB), - CvtColorInfo(3, 3, cv::COLOR_Luv2BGR), - CvtColorInfo(3, 3, cv::COLOR_Luv2RGB), - CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR), - CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA)))); - ////////////////////////////////////////////////////////////////////// // SwapChannels -GPU_PERF_TEST(SwapChannels, cv::gpu::DeviceInfo, cv::Size) +PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GetParam(); - cv::Size size = GET_PARAM(1); - - cv::Mat src_host(size, CV_8UC4); - fill(src_host, 0, 255); - - cv::gpu::GpuMat src(src_host); + cv::Mat src(size, CV_8UC4); + fillRandom(src); const int dstOrder[] = {2, 1, 0, 3}; - cv::gpu::swapChannels(src, dstOrder); + cv::gpu::GpuMat d_src(src); + + cv::gpu::swapChannels(d_src, dstOrder); TEST_CYCLE() { - cv::gpu::swapChannels(src, dstOrder); + cv::gpu::swapChannels(d_src, dstOrder); } } -INSTANTIATE_TEST_CASE_P(ImgProc, SwapChannels, testing::Combine(ALL_DEVICES, GPU_TYPICAL_MAT_SIZES)); - ////////////////////////////////////////////////////////////////////// // AlphaComp CV_ENUM(AlphaOp, cv::gpu::ALPHA_OVER, cv::gpu::ALPHA_IN, cv::gpu::ALPHA_OUT, cv::gpu::ALPHA_ATOP, cv::gpu::ALPHA_XOR, cv::gpu::ALPHA_PLUS, cv::gpu::ALPHA_OVER_PREMUL, cv::gpu::ALPHA_IN_PREMUL, cv::gpu::ALPHA_OUT_PREMUL, cv::gpu::ALPHA_ATOP_PREMUL, cv::gpu::ALPHA_XOR_PREMUL, cv::gpu::ALPHA_PLUS_PREMUL, cv::gpu::ALPHA_PREMUL) +#define ALL_ALPHA_OPS ValuesIn(AlphaOp::all()) -GPU_PERF_TEST(AlphaComp, cv::gpu::DeviceInfo, cv::Size, MatType, AlphaOp) +DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp); + +PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4), ALL_ALPHA_OPS)) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int type = GET_PARAM(1); + int alpha_op = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int alpha_op = GET_PARAM(3); + cv::Mat img1(size, type); + fillRandom(img1); - cv::Mat img1_host(size, type); - fill(img1_host, 0, 255); + cv::Mat img2(size, type); + fillRandom(img2); - cv::Mat img2_host(size, type); - fill(img2_host, 0, 255); + cv::gpu::GpuMat d_img1(img1); + cv::gpu::GpuMat d_img2(img2); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat img1(img1_host); - cv::gpu::GpuMat img2(img2_host); - cv::gpu::GpuMat dst; - - cv::gpu::alphaComp(img1, img2, dst, alpha_op); + cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); TEST_CYCLE() { - cv::gpu::alphaComp(img1, img2, dst, alpha_op); + cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); } } -INSTANTIATE_TEST_CASE_P(ImgProc, AlphaComp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC4), MatType(CV_16UC4), MatType(CV_32SC4), MatType(CV_32FC4)), - testing::Values(AlphaOp(cv::gpu::ALPHA_OVER), - AlphaOp(cv::gpu::ALPHA_IN), - AlphaOp(cv::gpu::ALPHA_OUT), - AlphaOp(cv::gpu::ALPHA_ATOP), - AlphaOp(cv::gpu::ALPHA_XOR), - AlphaOp(cv::gpu::ALPHA_PLUS), - AlphaOp(cv::gpu::ALPHA_OVER_PREMUL), - AlphaOp(cv::gpu::ALPHA_IN_PREMUL), - AlphaOp(cv::gpu::ALPHA_OUT_PREMUL), - AlphaOp(cv::gpu::ALPHA_ATOP_PREMUL), - AlphaOp(cv::gpu::ALPHA_XOR_PREMUL), - AlphaOp(cv::gpu::ALPHA_PLUS_PREMUL), - AlphaOp(cv::gpu::ALPHA_PREMUL)))); - ////////////////////////////////////////////////////////////////////// -// ImagePyramid +// ImagePyramidBuild -GPU_PERF_TEST(ImagePyramid_build, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); + cv::gpu::GpuMat d_src(src); - cv::gpu::ImagePyramid pyr; + cv::gpu::ImagePyramid d_pyr; - pyr.build(src, 5); + d_pyr.build(d_src, 5); TEST_CYCLE() { - pyr.build(src, 5); + d_pyr.build(d_src, 5); } } -INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_build, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); +////////////////////////////////////////////////////////////////////// +// ImagePyramidGetLayer -GPU_PERF_TEST(ImagePyramid_getLayer, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; + cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10); - cv::gpu::ImagePyramid pyr(src, 3); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10)); + cv::gpu::ImagePyramid d_pyr(d_src, 3); + + d_pyr.getLayer(d_dst, dstSize); TEST_CYCLE() { - pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10)); + d_pyr.getLayer(d_dst, dstSize); } } -INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_getLayer, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - ////////////////////////////////////////////////////////////////////// // HoughLines -IMPLEMENT_PARAM_CLASS(DoSort, bool) +DEF_PARAM_TEST(Sz_DoSort, cv::Size, bool); -GPU_PERF_TEST(HoughLines, cv::gpu::DeviceInfo, cv::Size, DoSort) +PERF_TEST_P(Sz_DoSort, ImgProc_HoughLines, Combine(GPU_TYPICAL_MAT_SIZES, Bool())) { declare.time(30.0); - const cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - const cv::Size size = GET_PARAM(1); - const bool doSort = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const bool doSort = GET_PARAM(1); const float rho = 1.0f; const float theta = CV_PI / 180.0f; @@ -1365,6 +1201,7 @@ GPU_PERF_TEST(HoughLines, cv::gpu::DeviceInfo, cv::Size, DoSort) cv::gpu::GpuMat d_lines; cv::gpu::GpuMat d_accum; cv::gpu::GpuMat d_buf; + cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); TEST_CYCLE() @@ -1373,9 +1210,4 @@ GPU_PERF_TEST(HoughLines, cv::gpu::DeviceInfo, cv::Size, DoSort) } } -INSTANTIATE_TEST_CASE_P(ImgProc, HoughLines, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DoSort(false), DoSort(true)))); - -#endif +} // namespace diff --git a/modules/gpu/perf/perf_labeling.cpp b/modules/gpu/perf/perf_labeling.cpp index 2c537ebbe..86d67ff93 100644 --- a/modules/gpu/perf/perf_labeling.cpp +++ b/modules/gpu/perf/perf_labeling.cpp @@ -41,14 +41,16 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; -GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size) +namespace { + +DEF_PARAM_TEST_1(Image, string); + +PERF_TEST_P(Image, Labeling_ConnectedComponents, Values("gpu/labeling/aloe-disp.png")) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE); + cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE); // cv::threshold(image, image, 150, 255, CV_THRESH_BINARY); @@ -70,6 +72,4 @@ GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size) } } -INSTANTIATE_TEST_CASE_P(Labeling, ConnectedComponents, testing::Combine(ALL_DEVICES, testing::Values(cv::Size(261, 262)))); - -#endif \ No newline at end of file +} // namespace diff --git a/modules/gpu/perf/perf_main.cpp b/modules/gpu/perf/perf_main.cpp index 0cd400277..988c95ae0 100644 --- a/modules/gpu/perf/perf_main.cpp +++ b/modules/gpu/perf/perf_main.cpp @@ -2,11 +2,98 @@ #ifdef HAVE_CUDA +using namespace std; +using namespace cv; +using namespace cv::gpu; +using namespace cvtest; +using namespace testing; + +void printInfo() +{ +#if defined _WIN32 +# if defined _WIN64 + puts("OS: Windows x64"); +# else + puts("OS: Windows x32"); +# endif +#elif defined linux +# if defined _LP64 + puts("OS: Linux x64"); +# else + puts("OS: Linux x32"); +# endif +#elif defined __APPLE__ +# if defined _LP64 + puts("OS: Apple x64"); +# else + puts("OS: Apple x32"); +# endif +#endif + + int driver; + cudaDriverGetVersion(&driver); + + printf("CUDA Driver version: %d\n", driver); + printf("CUDA Runtime version: %d\n", CUDART_VERSION); + + puts("GPU module was compiled for the following GPU archs:"); + printf(" BIN: %s\n", CUDA_ARCH_BIN); + printf(" PTX: %s\n\n", CUDA_ARCH_PTX); + + int deviceCount = getCudaEnabledDeviceCount(); + printf("CUDA device count: %d\n\n", deviceCount); + + for (int i = 0; i < deviceCount; ++i) + { + DeviceInfo info(i); + + printf("Device %d:\n", i); + printf(" Name: %s\n", info.name().c_str()); + printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion()); + printf(" Multi Processor Count: %d\n", info.multiProcessorCount()); + printf(" Total memory: %d Mb\n", static_cast(static_cast(info.totalMemory() / 1024.0) / 1024.0)); + printf(" Free memory: %d Mb\n", static_cast(static_cast(info.freeMemory() / 1024.0) / 1024.0)); + if (!info.isCompatible()) + puts(" !!! This device is NOT compatible with current GPU module build\n"); + printf("\n"); + } +} + int main(int argc, char **argv) { + CommandLineParser parser(argc, (const char**)argv, + "{ print_info_only | print_info_only | false | Print information about system and exit }" + "{ device | device | 0 | Device on which tests will be executed }"); + + printInfo(); + + if (parser.get("print_info_only")) + return 0; + + int device = parser.get("device"); + + if (device < 0 || device >= getCudaEnabledDeviceCount()) + { + cerr << "Incorrect device number - " << device << endl; + return -1; + } + + DeviceInfo info(device); + if (!info.isCompatible()) + { + cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl; + return -1; + } + + std::cout << "Run tests on device " << device << '\n' << std::endl; + + setDevice(device); + testing::InitGoogleTest(&argc, argv); perf::TestBase::Init(argc, argv); return RUN_ALL_TESTS(); + + return 0; } #else diff --git a/modules/gpu/perf/perf_matop.cpp b/modules/gpu/perf/perf_matop.cpp index 5cc24402c..c014b19da 100644 --- a/modules/gpu/perf/perf_matop.cpp +++ b/modules/gpu/perf/perf_matop.cpp @@ -1,141 +1,115 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { ////////////////////////////////////////////////////////////////////// // SetTo -GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::gpu::GpuMat src(size, type); cv::Scalar val(1, 2, 3, 4); - src.setTo(val); + cv::gpu::GpuMat d_src(size, type); + + d_src.setTo(val); TEST_CYCLE() { - src.setTo(val); + d_src.setTo(val); } } -INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - ////////////////////////////////////////////////////////////////////// // SetToMasked -GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat mask_host(size, CV_8UC1); - fill(mask_host, 0, 2); + cv::Mat mask(size, CV_8UC1); + fillRandom(mask, 0, 2); - cv::gpu::GpuMat src(src_host); cv::Scalar val(1, 2, 3, 4); - cv::gpu::GpuMat mask(mask_host); - src.setTo(val, mask); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_mask(mask); + + d_src.setTo(val, d_mask); TEST_CYCLE() { - src.setTo(val, mask); + d_src.setTo(val, d_mask); } } -INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - ////////////////////////////////////////////////////////////////////// // CopyToMasked -GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType) +PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth = GET_PARAM(1); + int channels = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); + int type = CV_MAKE_TYPE(depth, channels); - cv::Mat src_host(size, type); - fill(src_host, 0, 255); + cv::Mat src(size, type); + fillRandom(src); - cv::Mat mask_host(size, CV_8UC1); - fill(mask_host, 0, 2); + cv::Mat mask(size, CV_8UC1); + fillRandom(mask, 0, 2); - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat mask(mask_host); - cv::gpu::GpuMat dst; + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_mask(mask); + cv::gpu::GpuMat d_dst; - src.copyTo(dst, mask); + d_src.copyTo(d_dst, d_mask); TEST_CYCLE() { - src.copyTo(dst, mask); + d_src.copyTo(d_dst, d_mask); } } -INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - ////////////////////////////////////////////////////////////////////// // ConvertTo -GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth) +DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth); + +PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Size size = GET_PARAM(0); + int depth1 = GET_PARAM(1); + int depth2 = GET_PARAM(2); - cv::Size size = GET_PARAM(1); - int depth1 = GET_PARAM(2); - int depth2 = GET_PARAM(3); + cv::Mat src(size, depth1); + fillRandom(src); - cv::Mat src_host(size, depth1); - fill(src_host, 0, 255); + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat src(src_host); - cv::gpu::GpuMat dst; - - src.convertTo(dst, depth2, 0.5, 1.0); + d_src.convertTo(d_dst, depth2, 0.5, 1.0); TEST_CYCLE() { - src.convertTo(dst, depth2, 0.5, 1.0); + d_src.convertTo(d_dst, depth2, 0.5, 1.0); } } -INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)), - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)))); - -#endif +} // namespace diff --git a/modules/gpu/perf/perf_objdetect.cpp b/modules/gpu/perf/perf_objdetect.cpp index c376586c9..9c1f7919f 100644 --- a/modules/gpu/perf/perf_objdetect.cpp +++ b/modules/gpu/perf/perf_objdetect.cpp @@ -1,85 +1,84 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { /////////////////////////////////////////////////////////////// // HOG -GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo) +DEF_PARAM_TEST_1(Image, string); + +PERF_TEST_P(Image, ObjDetect_HOG, Values("gpu/hog/road.png")) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); - - cv::gpu::GpuMat img(img_host); std::vector found_locations; - cv::gpu::HOGDescriptor hog; - hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); + cv::gpu::GpuMat d_img(img); - hog.detectMultiScale(img, found_locations); + cv::gpu::HOGDescriptor d_hog; + d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); + + d_hog.detectMultiScale(d_img, found_locations); TEST_CYCLE() { - hog.detectMultiScale(img, found_locations); + d_hog.detectMultiScale(d_img, found_locations); } } -INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES); - /////////////////////////////////////////////////////////////// // HaarClassifier -GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo) +typedef pair pair_string; +DEF_PARAM_TEST_1(ImageAndCascade, pair_string); + +PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier, + Values(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/perf/haarcascade_frontalface_alt.xml"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); + cv::gpu::CascadeClassifier_GPU d_cascade; - cv::gpu::CascadeClassifier_GPU cascade; + ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); - ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml"))); + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_objects_buffer; - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat objects_buffer; - - cascade.detectMultiScale(img, objects_buffer); + d_cascade.detectMultiScale(d_img, d_objects_buffer); TEST_CYCLE() { - cascade.detectMultiScale(img, objects_buffer); + d_cascade.detectMultiScale(d_img, d_objects_buffer); } } -INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES); +/////////////////////////////////////////////////////////////// +// LBP cascade -//===================== LBP cascade ==========================// -GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo) +PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier, + Values(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(img.empty()); - cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_host.empty()); + cv::gpu::CascadeClassifier_GPU d_cascade; + ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_gpu_rects; - cv::gpu::GpuMat img(img_host); - cv::gpu::GpuMat gpu_rects; - cv::gpu::CascadeClassifier_GPU cascade; - ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); + d_cascade.detectMultiScale(d_img, d_gpu_rects); - cascade.detectMultiScale(img, gpu_rects); TEST_CYCLE() { - cascade.detectMultiScale(img, gpu_rects); + d_cascade.detectMultiScale(d_img, d_gpu_rects); } } -INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES); - -#endif +} // namespace diff --git a/modules/gpu/perf/perf_precomp.hpp b/modules/gpu/perf/perf_precomp.hpp index 19608bde1..be3f234a3 100644 --- a/modules/gpu/perf/perf_precomp.hpp +++ b/modules/gpu/perf/perf_precomp.hpp @@ -11,6 +11,10 @@ #include "cvconfig.h" +#ifdef HAVE_CUDA +#include +#endif + #include "opencv2/ts/ts.hpp" #include "opencv2/ts/ts_perf.hpp" @@ -18,6 +22,10 @@ #include "opencv2/highgui/highgui.hpp" #include "opencv2/gpu/gpu.hpp" #include "opencv2/calib3d/calib3d.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/video/video.hpp" +#include "opencv2/nonfree/nonfree.hpp" +#include "opencv2/legacy/legacy.hpp" #include "perf_utility.hpp" diff --git a/modules/gpu/perf/perf_utility.cpp b/modules/gpu/perf/perf_utility.cpp index bf6bdfe73..42862f49d 100644 --- a/modules/gpu/perf/perf_utility.cpp +++ b/modules/gpu/perf/perf_utility.cpp @@ -4,12 +4,17 @@ using namespace std; using namespace cv; using namespace cv::gpu; -void fill(Mat& m, double a, double b) +void fillRandom(Mat& m, double a, double b) { RNG rng(123456789); rng.fill(m, RNG::UNIFORM, Scalar::all(a), Scalar::all(b)); } +Mat readImage(const string& fileName, int flags) +{ + return imread(perf::TestBase::getDataPath(fileName), flags); +} + void PrintTo(const CvtColorInfo& info, ostream* os) { static const char* str[] = @@ -184,37 +189,3 @@ void PrintTo(const CvtColorInfo& info, ostream* os) *os << str[info.code]; } - -void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os) -{ - *os << info.name(); -} - -Mat readImage(const string& fileName, int flags) -{ - return imread(perf::TestBase::getDataPath(fileName), flags); -} - -const vector& devices() -{ - static vector devs; - static bool first = true; - - if (first) - { - int deviceCount = getCudaEnabledDeviceCount(); - - devs.reserve(deviceCount); - - for (int i = 0; i < deviceCount; ++i) - { - DeviceInfo info(i); - if (info.isCompatible()) - devs.push_back(info); - } - - first = false; - } - - return devs; -} diff --git a/modules/gpu/perf/perf_utility.hpp b/modules/gpu/perf/perf_utility.hpp index 8693cfc3c..b717030ff 100644 --- a/modules/gpu/perf/perf_utility.hpp +++ b/modules/gpu/perf/perf_utility.hpp @@ -1,13 +1,21 @@ #ifndef __OPENCV_PERF_GPU_UTILITY_HPP__ #define __OPENCV_PERF_GPU_UTILITY_HPP__ -void fill(cv::Mat& m, double a, double b); +#include "opencv2/core/core.hpp" +#include "opencv2/core/gpumat.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/ts/ts_perf.hpp" + +void fillRandom(cv::Mat& m, double a = 0.0, double b = 255.0); +cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); using perf::MatType; using perf::MatDepth; CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP) - CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA) +#define ALL_BORDER_MODES testing::ValuesIn(BorderMode::all()) +CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA) +#define ALL_INTERPOLATIONS testing::ValuesIn(Interpolation::all()) CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING) struct CvtColorInfo @@ -18,60 +26,18 @@ struct CvtColorInfo explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {} }; - void PrintTo(const CvtColorInfo& info, std::ostream* os); -#define IMPLEMENT_PARAM_CLASS(name, type) \ - class name \ - { \ - public: \ - name ( type arg = type ()) : val_(arg) {} \ - operator type () const {return val_;} \ - private: \ - type val_; \ - }; \ - inline void PrintTo( name param, std::ostream* os) \ - { \ - *os << #name << " = " << testing::PrintToString(static_cast< type >(param)); \ - } - -IMPLEMENT_PARAM_CLASS(Channels, int) - -namespace cv { namespace gpu -{ - void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os); -}} - -#define GPU_PERF_TEST(name, ...) \ - struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \ - { \ - public: \ - name() {} \ - protected: \ - void PerfTestBody(); \ - }; \ - TEST_P(name, perf){ RunPerfTestBody(); } \ - void name :: PerfTestBody() - -#define GPU_PERF_TEST_1(name, param_type) \ - struct name : perf::TestBaseWithParam< param_type > \ - { \ - public: \ - name() {} \ - protected: \ - void PerfTestBody(); \ - }; \ - TEST_P(name, perf){ RunPerfTestBody(); } \ - void name :: PerfTestBody() - -#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500)) - -cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); - -const std::vector& devices(); - -#define ALL_DEVICES testing::ValuesIn(devices()) - #define GET_PARAM(k) std::tr1::get< k >(GetParam()) +#define DEF_PARAM_TEST(name, ...) typedef ::perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > name +#define DEF_PARAM_TEST_1(name, param_type) typedef ::perf::TestBaseWithParam< param_type > name + +DEF_PARAM_TEST_1(Sz, cv::Size); +typedef perf::Size_MatType Sz_Type; +DEF_PARAM_TEST(Sz_Depth, cv::Size, MatDepth); +DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, int); + +#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz720p, perf::sz1080p) + #endif // __OPENCV_PERF_GPU_UTILITY_HPP__ diff --git a/modules/gpu/perf/perf_video.cpp b/modules/gpu/perf/perf_video.cpp index 6e577a4a4..a5a1e4da5 100644 --- a/modules/gpu/perf/perf_video.cpp +++ b/modules/gpu/perf/perf_video.cpp @@ -1,305 +1,277 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA +using namespace std; +using namespace testing; + +namespace { ////////////////////////////////////////////////////// // BroxOpticalFlow -GPU_PERF_TEST_1(BroxOpticalFlow, cv::gpu::DeviceInfo) +typedef pair pair_string; + +DEF_PARAM_TEST_1(ImagePair, pair_string); + +PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + declare.time(10); - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0_host.empty()); + cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame0.empty()); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame1_host.empty()); + cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame1.empty()); - frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0); - frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0); + frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); + frame1.convertTo(frame1, 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::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_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); - - declare.time(10); + d_flow(d_frame0, d_frame1, d_u, d_v); TEST_CYCLE() { - d_flow(frame0, frame1, u, v); + d_flow(d_frame0, d_frame1, d_u, d_v); } } -INSTANTIATE_TEST_CASE_P(Video, BroxOpticalFlow, ALL_DEVICES); - ////////////////////////////////////////////////////// // InterpolateFrames -GPU_PERF_TEST_1(InterpolateFrames, cv::gpu::DeviceInfo) +PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame0.empty()); - cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0_host.empty()); + cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame1.empty()); - cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame1_host.empty()); + frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); + frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - 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::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_fu, d_fv; + cv::gpu::GpuMat d_bu, d_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); + d_flow(d_frame0, d_frame1, d_fu, d_fv); + d_flow(d_frame1, d_frame0, d_bu, d_bv); - cv::gpu::GpuMat newFrame; - cv::gpu::GpuMat buf; + cv::gpu::GpuMat d_newFrame; + cv::gpu::GpuMat d_buf; - cv::gpu::interpolateFrames(frame0, frame1, fu, fv, bu, bv, 0.5f, newFrame, buf); + cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); TEST_CYCLE() { - cv::gpu::interpolateFrames(frame0, frame1, fu, fv, bu, bv, 0.5f, newFrame, buf); + cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); } } -INSTANTIATE_TEST_CASE_P(Video, InterpolateFrames, ALL_DEVICES); - ////////////////////////////////////////////////////// // CreateOpticalFlowNeedleMap -GPU_PERF_TEST_1(CreateOpticalFlowNeedleMap, cv::gpu::DeviceInfo) +PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); + cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame0.empty()); - cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0_host.empty()); + cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame1.empty()); - cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame1_host.empty()); + frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); + frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - 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::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_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); + d_flow(d_frame0, d_frame1, d_u, d_v); - cv::gpu::GpuMat vertex, colors; + cv::gpu::GpuMat d_vertex, d_colors; - cv::gpu::createOpticalFlowNeedleMap(u, v, vertex, colors); + cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); TEST_CYCLE() { - cv::gpu::createOpticalFlowNeedleMap(u, v, vertex, colors); + cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); } } -INSTANTIATE_TEST_CASE_P(Video, CreateOpticalFlowNeedleMap, ALL_DEVICES); - ////////////////////////////////////////////////////// // GoodFeaturesToTrack -IMPLEMENT_PARAM_CLASS(MinDistance, double) +DEF_PARAM_TEST(Image_MinDistance, string, double); -GPU_PERF_TEST(GoodFeaturesToTrack, cv::gpu::DeviceInfo, MinDistance) +PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values("gpu/perf/aloe.jpg"), Values(0.0, 3.0))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - + string fileName = GET_PARAM(0); double minDistance = GET_PARAM(1); - cv::Mat image_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image_host.empty()); + cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(image.empty()); - cv::gpu::GoodFeaturesToTrackDetector_GPU detector(8000, 0.01, minDistance); + cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance); - cv::gpu::GpuMat image(image_host); - cv::gpu::GpuMat pts; + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_pts; - detector(image, pts); + d_detector(d_image, d_pts); TEST_CYCLE() { - detector(image, pts); + d_detector(d_image, d_pts); } } -INSTANTIATE_TEST_CASE_P(Video, GoodFeaturesToTrack, testing::Combine( - ALL_DEVICES, - testing::Values(MinDistance(0.0), MinDistance(3.0)))); - ////////////////////////////////////////////////////// // PyrLKOpticalFlowSparse -IMPLEMENT_PARAM_CLASS(GraySource, bool) -IMPLEMENT_PARAM_CLASS(Points, int) -IMPLEMENT_PARAM_CLASS(WinSize, int) -IMPLEMENT_PARAM_CLASS(Levels, int) -IMPLEMENT_PARAM_CLASS(Iters, int) +DEF_PARAM_TEST(ImagePair_Gray_NPts_WinSz_Levels_Iters, pair_string, bool, int, int, int, int); -GPU_PERF_TEST(PyrLKOpticalFlowSparse, cv::gpu::DeviceInfo, GraySource, Points, WinSize, Levels, Iters) +PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse, Combine( + Values(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")), + Bool(), + Values(1000, 2000, 4000, 8000), + Values(9, 13, 17, 21), + Values(1, 2, 3), + Values(1, 10, 30))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - + pair_string imagePair = GET_PARAM(0); bool useGray = GET_PARAM(1); int points = GET_PARAM(2); int winSize = GET_PARAM(3); int levels = GET_PARAM(4); int iters = GET_PARAM(5); - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame0_host.empty()); + cv::Mat frame0 = readImage(imagePair.first, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); + ASSERT_FALSE(frame0.empty()); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame1_host.empty()); + cv::Mat frame1 = readImage(imagePair.second, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); + 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::gpu::GpuMat d_pts; - cv::gpu::GoodFeaturesToTrackDetector_GPU detector(points, 0.01, 0.0); - detector(cv::gpu::GpuMat(gray_frame), pts); + cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(points, 0.01, 0.0); + d_detector(cv::gpu::GpuMat(gray_frame), d_pts); - cv::gpu::PyrLKOpticalFlow pyrLK; - pyrLK.winSize = cv::Size(winSize, winSize); - pyrLK.maxLevel = levels - 1; - pyrLK.iters = iters; + cv::gpu::PyrLKOpticalFlow d_pyrLK; + d_pyrLK.winSize = cv::Size(winSize, winSize); + d_pyrLK.maxLevel = levels - 1; + d_pyrLK.iters = iters; - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat nextPts; - cv::gpu::GpuMat status; + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_nextPts; + cv::gpu::GpuMat d_status; - pyrLK.sparse(frame0, frame1, pts, nextPts, status); + d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); TEST_CYCLE() { - pyrLK.sparse(frame0, frame1, pts, nextPts, status); + d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); } } -INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowSparse, testing::Combine( - ALL_DEVICES, - testing::Values(GraySource(true), GraySource(false)), - testing::Values(Points(1000), Points(2000), Points(4000), Points(8000)), - testing::Values(WinSize(9), WinSize(13), WinSize(17), WinSize(21)), - testing::Values(Levels(1), Levels(2), Levels(3)), - testing::Values(Iters(1), Iters(10), Iters(30)))); - ////////////////////////////////////////////////////// // PyrLKOpticalFlowDense -GPU_PERF_TEST(PyrLKOpticalFlowDense, cv::gpu::DeviceInfo, WinSize, Levels, Iters) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); +DEF_PARAM_TEST(ImagePair_WinSz_Levels_Iters, pair_string, int, int, int); +PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine( + Values(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")), + Values(3, 5, 7, 9, 13, 17, 21), + Values(1, 2, 3), + Values(1, 10))) +{ + declare.time(30); + + pair_string imagePair = GET_PARAM(0); int winSize = GET_PARAM(1); int levels = GET_PARAM(2); int iters = GET_PARAM(3); - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0_host.empty()); + cv::Mat frame0 = readImage(imagePair.first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame0.empty()); - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame1_host.empty()); + cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame1.empty()); - cv::gpu::GpuMat frame0(frame0_host); - cv::gpu::GpuMat frame1(frame1_host); - cv::gpu::GpuMat u; - cv::gpu::GpuMat v; + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; - cv::gpu::PyrLKOpticalFlow pyrLK; + cv::gpu::PyrLKOpticalFlow d_pyrLK; + d_pyrLK.winSize = cv::Size(winSize, winSize); + d_pyrLK.maxLevel = levels - 1; + d_pyrLK.iters = iters; - pyrLK.winSize = cv::Size(winSize, winSize); - pyrLK.maxLevel = levels - 1; - pyrLK.iters = iters; - - pyrLK.dense(frame0, frame1, u, v); - - declare.time(30); + d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); TEST_CYCLE() { - pyrLK.dense(frame0, frame1, u, v); + d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); } } -INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowDense, testing::Combine( - ALL_DEVICES, - testing::Values(WinSize(3), WinSize(5), WinSize(7), WinSize(9), WinSize(13), WinSize(17), WinSize(21)), - testing::Values(Levels(1), Levels(2), Levels(3)), - testing::Values(Iters(1), Iters(10)))); - ////////////////////////////////////////////////////// -// FarnebackOpticalFlowTest +// FarnebackOpticalFlow -GPU_PERF_TEST_1(FarnebackOpticalFlowTest, cv::gpu::DeviceInfo) +PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png"))) { - cv::gpu::DeviceInfo devInfo = GetParam(); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat frame0_host = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0_host.empty()); - - cv::Mat frame1_host = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - 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 farneback; - - farneback(frame0, frame1, u, v); - declare.time(10); + cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame0.empty()); + + cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + ASSERT_FALSE(frame1.empty()); + + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; + + cv::gpu::FarnebackOpticalFlow d_farneback; + + d_farneback(d_frame0, d_frame1, d_u, d_v); + TEST_CYCLE() { - farneback(frame0, frame1, u, v); + d_farneback(d_frame0, d_frame1, d_u, d_v); } } -INSTANTIATE_TEST_CASE_P(Video, FarnebackOpticalFlowTest, ALL_DEVICES); - ////////////////////////////////////////////////////// // FGDStatModel -GPU_PERF_TEST(FGDStatModel, cv::gpu::DeviceInfo, std::string) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); +DEF_PARAM_TEST_1(Video, string); - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); +PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) +{ + declare.time(10); + + string inputFile = perf::TestBase::getDataPath(GetParam()); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); @@ -312,8 +284,6 @@ GPU_PERF_TEST(FGDStatModel, cv::gpu::DeviceInfo, std::string) cv::gpu::FGDStatModel d_model(4); d_model.create(d_frame); - declare.time(10); - for (int i = 0; i < 10; ++i) { cap >> frame; @@ -327,23 +297,16 @@ GPU_PERF_TEST(FGDStatModel, cv::gpu::DeviceInfo, std::string) } } -INSTANTIATE_TEST_CASE_P(Video, FGDStatModel, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - ////////////////////////////////////////////////////// // MOG -IMPLEMENT_PARAM_CLASS(LearningRate, double) +DEF_PARAM_TEST(Video_Cn_LearningRate, string, int, double); -GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate) +PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4), Values(0.0, 0.01))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - double learningRate = GET_PARAM(3); + string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); + int cn = GET_PARAM(1); + double learningRate = GET_PARAM(2); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); @@ -351,8 +314,8 @@ GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate) cv::Mat frame; cv::gpu::GpuMat d_frame; - cv::gpu::MOG_GPU mog; - cv::gpu::GpuMat foreground; + cv::gpu::MOG_GPU d_mog; + cv::gpu::GpuMat d_foreground; cap >> frame; ASSERT_FALSE(frame.empty()); @@ -369,7 +332,7 @@ GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate) d_frame.upload(frame); - mog(d_frame, foreground, learningRate); + d_mog(d_frame, d_foreground, learningRate); for (int i = 0; i < 10; ++i) { @@ -389,27 +352,20 @@ GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate) d_frame.upload(frame); startTimer(); next(); - mog(d_frame, foreground, learningRate); + d_mog(d_frame, d_foreground, learningRate); stopTimer(); } } -INSTANTIATE_TEST_CASE_P(Video, MOG, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(LearningRate(0.0), LearningRate(0.01)))); - ////////////////////////////////////////////////////// // MOG2 -GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); +DEF_PARAM_TEST(Video_Cn, string, int); - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); +PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4))) +{ + string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); + int cn = GET_PARAM(1); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); @@ -417,8 +373,8 @@ GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels) cv::Mat frame; cv::gpu::GpuMat d_frame; - cv::gpu::MOG2_GPU mog2; - cv::gpu::GpuMat foreground; + cv::gpu::MOG2_GPU d_mog2; + cv::gpu::GpuMat d_foreground; cap >> frame; ASSERT_FALSE(frame.empty()); @@ -435,7 +391,7 @@ GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels) d_frame.upload(frame); - mog2(d_frame, foreground); + d_mog2(d_frame, d_foreground); for (int i = 0; i < 10; ++i) { @@ -455,23 +411,18 @@ GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels) d_frame.upload(frame); startTimer(); next(); - mog2(d_frame, foreground); + d_mog2(d_frame, d_foreground); stopTimer(); } } -INSTANTIATE_TEST_CASE_P(Video, MOG2_update, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)))); +////////////////////////////////////////////////////// +// MOG2GetBackgroundImage -GPU_PERF_TEST(MOG2_getBackgroundImage, cv::gpu::DeviceInfo, std::string, Channels) +PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); + string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); + int cn = GET_PARAM(1); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); @@ -479,8 +430,8 @@ GPU_PERF_TEST(MOG2_getBackgroundImage, cv::gpu::DeviceInfo, std::string, Channel cv::Mat frame; cv::gpu::GpuMat d_frame; - cv::gpu::MOG2_GPU mog2; - cv::gpu::GpuMat foreground; + cv::gpu::MOG2_GPU d_mog2; + cv::gpu::GpuMat d_foreground; for (int i = 0; i < 10; ++i) { @@ -499,33 +450,25 @@ GPU_PERF_TEST(MOG2_getBackgroundImage, cv::gpu::DeviceInfo, std::string, Channel d_frame.upload(frame); - mog2(d_frame, foreground); + d_mog2(d_frame, d_foreground); } - cv::gpu::GpuMat background; - mog2.getBackgroundImage(background); + cv::gpu::GpuMat d_background; + d_mog2.getBackgroundImage(d_background); TEST_CYCLE() { - mog2.getBackgroundImage(background); + d_mog2.getBackgroundImage(d_background); } } -INSTANTIATE_TEST_CASE_P(Video, MOG2_getBackgroundImage, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)))); - ////////////////////////////////////////////////////// // VIBE -GPU_PERF_TEST(VIBE, cv::gpu::DeviceInfo, std::string, Channels) +PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); + string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); + int cn = GET_PARAM(1); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); @@ -545,10 +488,10 @@ GPU_PERF_TEST(VIBE, cv::gpu::DeviceInfo, std::string, Channels) } cv::gpu::GpuMat d_frame(frame); - cv::gpu::VIBE_GPU vibe; - cv::gpu::GpuMat foreground; + cv::gpu::VIBE_GPU d_vibe; + cv::gpu::GpuMat d_foreground; - vibe(d_frame, foreground); + d_vibe(d_frame, d_foreground); for (int i = 0; i < 10; ++i) { @@ -568,28 +511,21 @@ GPU_PERF_TEST(VIBE, cv::gpu::DeviceInfo, std::string, Channels) d_frame.upload(frame); startTimer(); next(); - vibe(d_frame, foreground); + d_vibe(d_frame, d_foreground); stopTimer(); } } -INSTANTIATE_TEST_CASE_P(Video, VIBE, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)))); - ////////////////////////////////////////////////////// // GMG -IMPLEMENT_PARAM_CLASS(MaxFeatures, int) +DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, int, int); -GPU_PERF_TEST(GMG, cv::gpu::DeviceInfo, std::string, Channels, MaxFeatures) +PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1, 3, 4), Values(20, 40, 60))) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - int maxFeatures = GET_PARAM(3); + std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); + int cn = GET_PARAM(1); + int maxFeatures = GET_PARAM(2); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); @@ -611,10 +547,10 @@ GPU_PERF_TEST(GMG, cv::gpu::DeviceInfo, std::string, Channels, MaxFeatures) cv::gpu::GpuMat d_frame(frame); cv::gpu::GpuMat d_fgmask; - cv::gpu::GMG_GPU gmg; - gmg.maxFeatures = maxFeatures; + cv::gpu::GMG_GPU d_gmg; + d_gmg.maxFeatures = maxFeatures; - gmg(d_frame, d_fgmask); + d_gmg(d_frame, d_fgmask); for (int i = 0; i < 150; ++i) { @@ -638,32 +574,21 @@ GPU_PERF_TEST(GMG, cv::gpu::DeviceInfo, std::string, Channels, MaxFeatures) d_frame.upload(frame); startTimer(); next(); - gmg(d_frame, d_fgmask); + d_gmg(d_frame, d_fgmask); stopTimer(); } } -INSTANTIATE_TEST_CASE_P(Video, GMG, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(MaxFeatures(20), MaxFeatures(40), MaxFeatures(60)))); - ////////////////////////////////////////////////////// // VideoWriter -#ifdef WIN32 - -GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string) +PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) { + string inputFile = perf::TestBase::getDataPath(GetParam()); + string outputFile = cv::tempfile(".avi"); + const double FPS = 25.0; - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - std::string outputFile = cv::tempfile(".avi"); - cv::VideoCapture reader(inputFile); ASSERT_TRUE( reader.isOpened() ); @@ -690,39 +615,26 @@ GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string) } } -INSTANTIATE_TEST_CASE_P(Video, VideoWriter, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -#endif // WIN32 - ////////////////////////////////////////////////////// // VideoReader -GPU_PERF_TEST(VideoReader, cv::gpu::DeviceInfo, std::string) +PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) { - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - - cv::gpu::VideoReader_GPU reader(inputFile); - ASSERT_TRUE( reader.isOpened() ); - - cv::gpu::GpuMat frame; - - reader.read(frame); - declare.time(20); + string inputFile = perf::TestBase::getDataPath(GetParam()); + + cv::gpu::VideoReader_GPU d_reader(inputFile); + ASSERT_TRUE( d_reader.isOpened() ); + + cv::gpu::GpuMat d_frame; + + d_reader.read(d_frame); + TEST_CYCLE_N(10) { - reader.read(frame); + d_reader.read(d_frame); } } -INSTANTIATE_TEST_CASE_P(Video, VideoReader, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -#endif +} // namespace From 362df96cb9670c1757f1aae77541010da6bbe0a4 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Aug 2012 15:16:45 +0400 Subject: [PATCH 3/9] renamed perf_main.cpp to main.cpp --- modules/gpu/perf/{perf_main.cpp => main.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/gpu/perf/{perf_main.cpp => main.cpp} (100%) diff --git a/modules/gpu/perf/perf_main.cpp b/modules/gpu/perf/main.cpp similarity index 100% rename from modules/gpu/perf/perf_main.cpp rename to modules/gpu/perf/main.cpp From 2634dc6cce264af42379961c64c0ac84a9ba0074 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Aug 2012 15:22:29 +0400 Subject: [PATCH 4/9] removed license comments --- modules/gpu/perf/perf_labeling.cpp | 41 ------------------------------ 1 file changed, 41 deletions(-) diff --git a/modules/gpu/perf/perf_labeling.cpp b/modules/gpu/perf/perf_labeling.cpp index 86d67ff93..bd1bcf144 100644 --- a/modules/gpu/perf/perf_labeling.cpp +++ b/modules/gpu/perf/perf_labeling.cpp @@ -1,44 +1,3 @@ -/*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) 2008-2011, 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: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions 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 "perf_precomp.hpp" using namespace std; From 00546f24e006c0454dd138f8faec81891543dabe Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Aug 2012 15:50:35 +0400 Subject: [PATCH 5/9] updated mark_nvidia.py script --- modules/gpu/misc/mark_nvidia.py | 357 +++++++++++++++----------------- 1 file changed, 168 insertions(+), 189 deletions(-) diff --git a/modules/gpu/misc/mark_nvidia.py b/modules/gpu/misc/mark_nvidia.py index fd543e9f5..88070117d 100644 --- a/modules/gpu/misc/mark_nvidia.py +++ b/modules/gpu/misc/mark_nvidia.py @@ -1,255 +1,234 @@ import sys, re spaces = '[\s]*' -symbols = '[\s\w\d,.=:|]*' +symbols = '[\s\w\d,.:|]*' def pattern1(prefix, test): - return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + '\)' + spaces) + return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + '\)' + spaces) -def pattern2(prefix, test, cvtype): - return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + cvtype + symbols + '\)' + spaces) +def pattern2(prefix, test, param1): + return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + '\)' + spaces) -def pattern3(prefix, test, cvtype, param1): - return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + cvtype + symbols + param1 + symbols + '\)' + spaces) +def pattern3(prefix, test, param1, param2): + return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + param2 + symbols + '\)' + spaces) -def pattern4(prefix, test, cvtype, param1, param2): - return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + cvtype + symbols + param1 + symbols + param2 + symbols + '\)' + spaces) +def pattern4(prefix, test, param1, param2, param3): + return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + param2 + symbols + param3 + symbols + '\)' + spaces) + +def pattern5(prefix, test, param1, param2, param3, param5): + return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + param2 + symbols + param3 + symbols + param4 + symbols + '\)' + spaces) npp_patterns = [ ############################################################## # Core - - # Core/Add_Mat (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Add_Mat', '8U'), - pattern2('Core', 'Add_Mat', '16U'), - pattern2('Core', 'Add_Mat', '32F'), - - # Core/Add_Scalar (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Add_Scalar', '8U'), - pattern2('Core', 'Add_Scalar', '16U'), - pattern2('Core', 'Add_Scalar', '32F'), - - # Core/Subtract_Mat (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Subtract_Mat', '8U'), - pattern2('Core', 'Subtract_Mat', '16U'), - pattern2('Core', 'Subtract_Mat', '32F'), - - # Core/Subtract_Scalar (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Subtract_Scalar', '8U'), - pattern2('Core', 'Subtract_Scalar', '16U'), - pattern2('Core', 'Subtract_Scalar', '32F'), - - # Core/Multiply_Mat (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Multiply_Mat', '8U'), - pattern2('Core', 'Multiply_Mat', '16U'), - pattern2('Core', 'Multiply_Mat', '32F'), - - # Core/Multiply_Scalar (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Multiply_Scalar', '8U'), - pattern2('Core', 'Multiply_Scalar', '16U'), - pattern2('Core', 'Multiply_Scalar', '32F'), - - # Core/Divide_Mat (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Divide_Mat', '8U'), - pattern2('Core', 'Divide_Mat', '16U'), - pattern2('Core', 'Divide_Mat', '32F'), - - # Core/Divide_Scalar (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'Divide_Scalar', '8U'), - pattern2('Core', 'Divide_Scalar', '16U'), - pattern2('Core', 'Divide_Scalar', '32F'), - - # Core/AbsDiff_Mat (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'AbsDiff_Mat', '8U'), - pattern2('Core', 'AbsDiff_Mat', '16U'), - pattern2('Core', 'AbsDiff_Mat', '32F'), - - # Core/AbsDiff_Scalar (CV_8U | CV_16U | CV_32F) - pattern2('Core', 'AbsDiff_Scalar', '8U'), - pattern2('Core', 'AbsDiff_Scalar', '16U'), - pattern2('Core', 'AbsDiff_Scalar', '32F'), - # Core/Abs + # Core_AddMat (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'AddMat', '8U'), + pattern2('Core', 'AddMat', '16U'), + pattern2('Core', 'AddMat', '32F'), + + # Core_AddScalar (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'AddScalar', '8U'), + pattern2('Core', 'AddScalar', '16U'), + pattern2('Core', 'AddScalar', '32F'), + + # Core_SubtractMat (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'SubtractMat', '8U'), + pattern2('Core', 'SubtractMat', '16U'), + pattern2('Core', 'SubtractMat', '32F'), + + # Core_SubtractScalar (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'SubtractScalar', '8U'), + pattern2('Core', 'SubtractScalar', '16U'), + pattern2('Core', 'SubtractScalar', '32F'), + + # Core_MultiplyMat (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'MultiplyMat', '8U'), + pattern2('Core', 'MultiplyMat', '16U'), + pattern2('Core', 'MultiplyMat', '32F'), + + # Core_MultiplyScalar (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'MultiplyScalar', '8U'), + pattern2('Core', 'MultiplyScalar', '16U'), + pattern2('Core', 'MultiplyScalar', '32F'), + + # Core_DivideMat (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'DivideMat', '8U'), + pattern2('Core', 'DivideMat', '16U'), + pattern2('Core', 'DivideMat', '32F'), + + # Core_Divide_Scalar (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'DivideScalar', '8U'), + pattern2('Core', 'DivideScalar', '16U'), + pattern2('Core', 'DivideScalar', '32F'), + + # Core_AbsDiff_Mat (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'AbsDiffMat', '8U'), + pattern2('Core', 'AbsDiffMat', '16U'), + pattern2('Core', 'AbsDiffMat', '32F'), + + # Core_AbsDiffScalar (CV_8U | CV_16U | CV_32F) + pattern2('Core', 'AbsDiffScalar', '8U'), + pattern2('Core', 'AbsDiffScalar', '16U'), + pattern2('Core', 'AbsDiffScalar', '32F'), + + # Core_Abs pattern1('Core', 'Abs'), - # Core/Sqr + # Core_Sqr pattern1('Core', 'Sqr'), - # Core/Sqrt + # Core_Sqrt pattern1('Core', 'Sqrt'), - # Core/Log + # Core_Log pattern1('Core', 'Log'), - # Core/Exp + # Core_Exp pattern1('Core', 'Exp'), - # Core/Bitwise_And_Scalar - pattern1('Core', 'Bitwise_And_Scalar'), + # Core_BitwiseAndScalar + pattern1('Core', 'BitwiseAndScalar'), - # Core/Bitwise_Or_Scalar - pattern1('Core', 'Bitwise_Or_Scalar'), + # Core_BitwiseOrScalar + pattern1('Core', 'BitwiseOrScalar'), - # Core/Bitwise_Xor_Scalar - pattern1('Core', 'Bitwise_Xor_Scalar'), + # Core_BitwiseXorScalar + pattern1('Core', 'BitwiseXorScalar'), - # Core/RShift + # Core_RShift pattern1('Core', 'RShift'), - # Core/LShift + # Core_LShift pattern1('Core', 'LShift'), - # Core/Transpose + # Core_Transpose pattern1('Core', 'Transpose'), - # Core/Flip + # Core_Flip pattern1('Core', 'Flip'), - # Core/LUT_OneChannel - pattern1('Core', 'LUT_OneChannel'), + # Core_LutOneChannel + pattern1('Core', 'LutOneChannel'), - # Core/LUT_MultiChannel - pattern1('Core', 'LUT_MultiChannel'), + # Core_LutMultiChannel + pattern1('Core', 'LutMultiChannel'), - # Core/Magnitude_Complex - pattern1('Core', 'Magnitude_Complex'), + # Core_MagnitudeComplex + pattern1('Core', 'MagnitudeComplex'), - # Core/Magnitude_Sqr_Complex - pattern1('Core', 'Magnitude_Sqr_Complex'), + # Core_MagnitudeSqrComplex + pattern1('Core', 'MagnitudeSqrComplex'), - # Core/MeanStdDev + # Core_MeanStdDev pattern1('Core', 'MeanStdDev'), - # Core/NormDiff + # Core_NormDiff pattern1('Core', 'NormDiff'), - + ############################################################## # Filters - # Filters/Blur + # Filters_Blur pattern1('Filters', 'Blur'), - - # Filters/Erode + + # Filters_Erode pattern1('Filters', 'Erode'), - - # Filters/Dilate + + # Filters_Dilate pattern1('Filters', 'Dilate'), - - # Filters/MorphologyEx + + # Filters_MorphologyEx pattern1('Filters', 'MorphologyEx'), - + ############################################################## # ImgProc - - # ImgProc/Resize (8UC1 | 8UC4, INTER_NEAREST | INTER_LINEAR) - pattern3('ImgProc', 'Resize', '8UC1', 'INTER_NEAREST'), - pattern3('ImgProc', 'Resize', '8UC4', 'INTER_NEAREST'), - pattern3('ImgProc', 'Resize', '8UC1', 'INTER_LINEAR'), - pattern3('ImgProc', 'Resize', '8UC4', 'INTER_LINEAR'), - - # ImgProc/Resize (8UC4, INTER_CUBIC) - pattern3('ImgProc', 'Resize', '8UC4', 'INTER_CUBIC'), - - # ImgProc/WarpAffine (8UC1 | 8UC3 | 8UC4 | 32FC1 | 32FC3 | 32FC4, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT) - pattern4('ImgProc', 'WarpAffine', '8UC1', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC1', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC1', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC3', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC3', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC3', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC4', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC4', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '8UC4', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC1', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC1', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC1', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC3', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC3', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC3', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC4', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC4', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpAffine', '32FC4', 'INTER_CUBIC', 'BORDER_CONSTANT'), - - # ImgProc/WarpPerspective (8UC1 | 8UC3 | 8UC4 | 32FC1 | 32FC3 | 32FC4, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT) - pattern4('ImgProc', 'WarpPerspective', '8UC1', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC1', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC1', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC3', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC3', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC3', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC4', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC4', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '8UC4', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC1', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC1', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC1', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC3', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC3', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC3', 'INTER_CUBIC', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC4', 'INTER_NEAREST', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC4', 'INTER_LINEAR', 'BORDER_CONSTANT'), - pattern4('ImgProc', 'WarpPerspective', '32FC4', 'INTER_CUBIC', 'BORDER_CONSTANT'), - - # ImgProc/CopyMakeBorder (8UC1 | 8UC4 | 32SC1 | 32FC1, BORDER_CONSTANT) - pattern3('ImgProc', 'CopyMakeBorder', '8UC1', 'BORDER_CONSTANT'), - pattern3('ImgProc', 'CopyMakeBorder', '8UC4', 'BORDER_CONSTANT'), - pattern3('ImgProc', 'CopyMakeBorder', '32SC1', 'BORDER_CONSTANT'), - pattern3('ImgProc', 'CopyMakeBorder', '32FC1', 'BORDER_CONSTANT'), - - # ImgProc/Threshold (32F, THRESH_TRUNC) + + # ImgProc_Resize (8U, 1 | 4, INTER_NEAREST | INTER_LINEAR) + pattern4('ImgProc', 'Resize', '8U', '1', 'INTER_NEAREST'), + pattern4('ImgProc', 'Resize', '8U', '4', 'INTER_NEAREST'), + pattern4('ImgProc', 'Resize', '8U', '1', 'INTER_LINEAR'), + pattern4('ImgProc', 'Resize', '8U', '4', 'INTER_LINEAR'), + + # ImgProc_Resize (8U, 4, INTER_CUBIC) + pattern4('ImgProc', 'Resize', '8U', '4', 'INTER_CUBIC'), + + # ImgProc_WarpAffine (8U | 32F, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT) + pattern4('ImgProc', 'WarpAffine', '8U' , 'INTER_NEAREST', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpAffine', '8U' , 'INTER_LINEAR', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpAffine', '8U' , 'INTER_CUBIC', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpAffine', '32F', 'INTER_NEAREST', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpAffine', '32F', 'INTER_LINEAR', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpAffine', '32F', 'INTER_CUBIC', 'BORDER_CONSTANT'), + + # ImgProc_WarpPerspective (8U | 32F, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT) + pattern4('ImgProc', 'WarpPerspective', '8U' , 'INTER_NEAREST', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpPerspective', '8U' , 'INTER_LINEAR', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpPerspective', '8U' , 'INTER_CUBIC', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpPerspective', '32F', 'INTER_NEAREST', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpPerspective', '32F', 'INTER_LINEAR', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'WarpPerspective', '32F', 'INTER_CUBIC', 'BORDER_CONSTANT'), + + # ImgProc_CopyMakeBorder (8UC1 | 8UC4 | 32SC1 | 32FC1, BORDER_CONSTANT) + pattern4('ImgProc', 'CopyMakeBorder', '8U' , '1', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'CopyMakeBorder', '8U' , '4', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'CopyMakeBorder', '32S', '1', 'BORDER_CONSTANT'), + pattern4('ImgProc', 'CopyMakeBorder', '32F', '1', 'BORDER_CONSTANT'), + + # ImgProc_Threshold (32F, THRESH_TRUNC) pattern3('ImgProc', 'Threshold', '32F', 'THRESH_TRUNC'), - # ImgProc/Integral_Sqr - pattern1('ImgProc', 'Integral_Sqr'), + # ImgProc_IntegralSqr + pattern1('ImgProc', 'IntegralSqr'), - # ImgProc/HistEven_OneChannel - pattern1('ImgProc', 'HistEven_OneChannel'), + # ImgProc_HistEven_OneChannel + pattern1('ImgProc', 'HistEvenOneChannel'), - # ImgProc/HistEven_FourChannel - pattern1('ImgProc', 'HistEven_FourChannel'), + # ImgProc_HistEven_FourChannel + pattern1('ImgProc', 'HistEvenFourChannel'), - # ImgProc/Rotate + # ImgProc_Rotate pattern1('ImgProc', 'Rotate'), - # ImgProc/SwapChannels + # ImgProc_SwapChannels pattern1('ImgProc', 'SwapChannels'), - # ImgProc/AlphaComp + # ImgProc_AlphaComp pattern1('ImgProc', 'AlphaComp'), - # ImgProc/ImagePyramid_build - pattern1('ImgProc', 'ImagePyramid_build'), + # ImgProc_ImagePyramidBuild + pattern1('ImgProc', 'ImagePyramidBuild'), + + # ImgProc_ImagePyramid_getLayer + pattern1('ImgProc', 'ImagePyramidGetLayer'), - # ImgProc/ImagePyramid_getLayer - pattern1('ImgProc', 'ImagePyramid_getLayer'), - ############################################################## # MatOp - - # MatOp/SetTo (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4) - pattern2('MatOp', 'SetTo', '8UC4'), - pattern2('MatOp', 'SetTo', '16UC1'), - pattern2('MatOp', 'SetTo', '16UC4'), - pattern2('MatOp', 'SetTo', '32FC1'), - pattern2('MatOp', 'SetTo', '32FC4'), - - # MatOp/SetToMasked (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4) - pattern2('MatOp', 'SetToMasked', '8UC4'), - pattern2('MatOp', 'SetToMasked', '16UC1'), - pattern2('MatOp', 'SetToMasked', '16UC4'), - pattern2('MatOp', 'SetToMasked', '32FC1'), - pattern2('MatOp', 'SetToMasked', '32FC4'), - - # MatOp/CopyToMasked (8UC1 | 8UC3 |8UC4 | 16UC1 | 16UC3 | 16UC4 | 32FC1 | 32FC3 | 32FC4) - pattern2('MatOp', 'CopyToMasked', '8UC1'), - pattern2('MatOp', 'CopyToMasked', '8UC3'), - pattern2('MatOp', 'CopyToMasked', '8UC4'), - pattern2('MatOp', 'CopyToMasked', '16UC1'), - pattern2('MatOp', 'CopyToMasked', '16UC3'), - pattern2('MatOp', 'CopyToMasked', '16UC4'), - pattern2('MatOp', 'CopyToMasked', '32FC1'), - pattern2('MatOp', 'CopyToMasked', '32FC3'), - pattern2('MatOp', 'CopyToMasked', '32FC4'), + + # MatOp_SetTo (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4) + pattern3('MatOp', 'SetTo', '8U' , '4'), + pattern3('MatOp', 'SetTo', '16U', '1'), + pattern3('MatOp', 'SetTo', '16U', '4'), + pattern3('MatOp', 'SetTo', '32F', '1'), + pattern3('MatOp', 'SetTo', '32F', '4'), + + # MatOp_SetToMasked (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4) + pattern3('MatOp', 'SetToMasked', '8U' , '4'), + pattern3('MatOp', 'SetToMasked', '16U', '1'), + pattern3('MatOp', 'SetToMasked', '16U', '4'), + pattern3('MatOp', 'SetToMasked', '32F', '1'), + pattern3('MatOp', 'SetToMasked', '32F', '4'), + + # MatOp_CopyToMasked (8UC1 | 8UC3 |8UC4 | 16UC1 | 16UC3 | 16UC4 | 32FC1 | 32FC3 | 32FC4) + pattern3('MatOp', 'CopyToMasked', '8U' , '1'), + pattern3('MatOp', 'CopyToMasked', '8U' , '3'), + pattern3('MatOp', 'CopyToMasked', '8U' , '4'), + pattern3('MatOp', 'CopyToMasked', '16U', '1'), + pattern3('MatOp', 'CopyToMasked', '16U', '3'), + pattern3('MatOp', 'CopyToMasked', '16U', '4'), + pattern3('MatOp', 'CopyToMasked', '32F', '1'), + pattern3('MatOp', 'CopyToMasked', '32F', '3'), + pattern3('MatOp', 'CopyToMasked', '32F', '4'), ] cublasPattern = pattern1('Core', 'GEMM') @@ -260,7 +239,7 @@ if __name__ == "__main__": inputFile = open(sys.argv[1], 'r') lines = inputFile.readlines() inputFile.close() - + for i in range(len(lines)): if cublasPattern.match(lines[i]): From 93172bab87c2c9bab596b964a16256a2f479b303 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Aug 2012 16:12:32 +0400 Subject: [PATCH 6/9] added --cpu flag (run tests on CPU) --- modules/gpu/perf/main.cpp | 124 +++++++++++++++++------------- modules/gpu/perf/perf_utility.cpp | 2 + modules/gpu/perf/perf_utility.hpp | 2 + 3 files changed, 75 insertions(+), 53 deletions(-) diff --git a/modules/gpu/perf/main.cpp b/modules/gpu/perf/main.cpp index 988c95ae0..865362f88 100644 --- a/modules/gpu/perf/main.cpp +++ b/modules/gpu/perf/main.cpp @@ -1,107 +1,125 @@ #include "perf_precomp.hpp" -#ifdef HAVE_CUDA - using namespace std; using namespace cv; using namespace cv::gpu; using namespace cvtest; using namespace testing; -void printInfo() +void printOsInfo() { #if defined _WIN32 # if defined _WIN64 - puts("OS: Windows x64"); + cout << "OS: Windows x64 \n" << endl; # else - puts("OS: Windows x32"); + cout << "OS: Windows x32 \n" << endl; # endif #elif defined linux # if defined _LP64 - puts("OS: Linux x64"); + cout << "OS: Linux x64 \n" << endl; # else - puts("OS: Linux x32"); + cout << "OS: Linux x32 \n" << endl; # endif #elif defined __APPLE__ # if defined _LP64 - puts("OS: Apple x64"); + cout << "OS: Apple x64 \n" << endl; # else - puts("OS: Apple x32"); + cout << "OS: Apple x32 \n" << endl; # endif #endif +} +void printCudaInfo() +{ +#ifndef HAVE_CUDA + cout << "OpenCV was built without CUDA support \n" << endl; +#else int driver; cudaDriverGetVersion(&driver); - printf("CUDA Driver version: %d\n", driver); - printf("CUDA Runtime version: %d\n", CUDART_VERSION); + cout << "CUDA Driver version: " << driver << '\n'; + cout << "CUDA Runtime version: " << CUDART_VERSION << '\n'; - puts("GPU module was compiled for the following GPU archs:"); - printf(" BIN: %s\n", CUDA_ARCH_BIN); - printf(" PTX: %s\n\n", CUDA_ARCH_PTX); + cout << endl; + + cout << "GPU module was compiled for the following GPU archs:" << endl; + cout << " BIN: " << CUDA_ARCH_BIN << '\n'; + cout << " PTX: " << CUDA_ARCH_PTX << '\n'; + + cout << endl; int deviceCount = getCudaEnabledDeviceCount(); - printf("CUDA device count: %d\n\n", deviceCount); + cout << "CUDA device count: " << deviceCount << '\n'; + + cout << endl; for (int i = 0; i < deviceCount; ++i) { DeviceInfo info(i); - printf("Device %d:\n", i); - printf(" Name: %s\n", info.name().c_str()); - printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion()); - printf(" Multi Processor Count: %d\n", info.multiProcessorCount()); - printf(" Total memory: %d Mb\n", static_cast(static_cast(info.totalMemory() / 1024.0) / 1024.0)); - printf(" Free memory: %d Mb\n", static_cast(static_cast(info.freeMemory() / 1024.0) / 1024.0)); + cout << "Device [" << i << "] \n"; + cout << "\t Name: " << info.name() << '\n'; + cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n'; + cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n'; + cout << "\t Total memory: " << static_cast(static_cast(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n"; + cout << "\t Free memory: " << static_cast(static_cast(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n"; if (!info.isCompatible()) - puts(" !!! This device is NOT compatible with current GPU module build\n"); - printf("\n"); + cout << "\t !!! This device is NOT compatible with current GPU module build \n"; + + cout << endl; } +#endif } int main(int argc, char **argv) { - CommandLineParser parser(argc, (const char**)argv, - "{ print_info_only | print_info_only | false | Print information about system and exit }" - "{ device | device | 0 | Device on which tests will be executed }"); + CommandLineParser cmd(argc, argv, + "{ print_info_only | print_info_only | false | Print information about system and exit }" + "{ device | device | 0 | Device on which tests will be executed }" + "{ cpu | cpu | false | Run tests on cpu }" + ); - printInfo(); + printOsInfo(); + printCudaInfo(); - if (parser.get("print_info_only")) + if (cmd.get("print_info_only")) return 0; - int device = parser.get("device"); + int device = cmd.get("device"); + bool cpu = cmd.get("cpu"); +#ifndef HAVE_CUDA + cpu = true; +#endif - if (device < 0 || device >= getCudaEnabledDeviceCount()) + if (cpu) { - cerr << "Incorrect device number - " << device << endl; - return -1; - } + runOnGpu = false; - DeviceInfo info(device); - if (!info.isCompatible()) + cout << "Run tests on CPU \n" << endl; + } + else { - cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl; - return -1; + runOnGpu = true; + + if (device < 0 || device >= getCudaEnabledDeviceCount()) + { + cerr << "Incorrect device index - " << device << endl; + return -1; + } + + DeviceInfo info(device); + if (!info.isCompatible()) + { + cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl; + return -1; + } + + setDevice(device); + + cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; } - std::cout << "Run tests on device " << device << '\n' << std::endl; - - setDevice(device); - testing::InitGoogleTest(&argc, argv); perf::TestBase::Init(argc, argv); return RUN_ALL_TESTS(); - - return 0; } - -#else - -int main() -{ - printf("OpenCV was built without CUDA support\n"); - return 0; -} - -#endif diff --git a/modules/gpu/perf/perf_utility.cpp b/modules/gpu/perf/perf_utility.cpp index 42862f49d..3be162b93 100644 --- a/modules/gpu/perf/perf_utility.cpp +++ b/modules/gpu/perf/perf_utility.cpp @@ -4,6 +4,8 @@ using namespace std; using namespace cv; using namespace cv::gpu; +bool runOnGpu = true; + void fillRandom(Mat& m, double a, double b) { RNG rng(123456789); diff --git a/modules/gpu/perf/perf_utility.hpp b/modules/gpu/perf/perf_utility.hpp index b717030ff..2d21fffb5 100644 --- a/modules/gpu/perf/perf_utility.hpp +++ b/modules/gpu/perf/perf_utility.hpp @@ -6,6 +6,8 @@ #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/ts/ts_perf.hpp" +extern bool runOnGpu; + void fillRandom(cv::Mat& m, double a = 0.0, double b = 255.0); cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); From a507d564a4aaa33cb1fa8bac144a3dacbddbf103 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Aug 2012 17:34:58 +0400 Subject: [PATCH 7/9] merged gpu_perf_cpu into gpu_perf --- modules/gpu/perf/perf_calib3d.cpp | 258 +++- modules/gpu/perf/perf_core.cpp | 1652 +++++++++++++++------ modules/gpu/perf/perf_features2d.cpp | 209 ++- modules/gpu/perf/perf_filters.cpp | 266 +++- modules/gpu/perf/perf_imgproc.cpp | 994 +++++++++---- modules/gpu/perf/perf_labeling.cpp | 134 +- modules/gpu/perf/perf_matop.cpp | 102 +- modules/gpu/perf/perf_objdetect.cpp | 103 +- modules/gpu/perf/perf_video.cpp | 792 ++++++---- modules/gpu/perf_cpu/perf_calib3d.cpp | 136 -- modules/gpu/perf_cpu/perf_core.cpp | 1388 ----------------- modules/gpu/perf_cpu/perf_cpu_precomp.cpp | 1 - modules/gpu/perf_cpu/perf_cpu_precomp.hpp | 32 - modules/gpu/perf_cpu/perf_features2d.cpp | 187 --- modules/gpu/perf_cpu/perf_filters.cpp | 283 ---- modules/gpu/perf_cpu/perf_imgproc.cpp | 771 ---------- modules/gpu/perf_cpu/perf_labeling.cpp | 158 -- modules/gpu/perf_cpu/perf_main.cpp | 20 - modules/gpu/perf_cpu/perf_matop.cpp | 124 -- modules/gpu/perf_cpu/perf_objdetect.cpp | 74 - modules/gpu/perf_cpu/perf_utility.cpp | 220 --- modules/gpu/perf_cpu/perf_utility.hpp | 77 - modules/gpu/perf_cpu/perf_video.cpp | 466 ------ 23 files changed, 3270 insertions(+), 5177 deletions(-) delete mode 100644 modules/gpu/perf_cpu/perf_calib3d.cpp delete mode 100644 modules/gpu/perf_cpu/perf_core.cpp delete mode 100644 modules/gpu/perf_cpu/perf_cpu_precomp.cpp delete mode 100644 modules/gpu/perf_cpu/perf_cpu_precomp.hpp delete mode 100644 modules/gpu/perf_cpu/perf_features2d.cpp delete mode 100644 modules/gpu/perf_cpu/perf_filters.cpp delete mode 100644 modules/gpu/perf_cpu/perf_imgproc.cpp delete mode 100644 modules/gpu/perf_cpu/perf_labeling.cpp delete mode 100644 modules/gpu/perf_cpu/perf_main.cpp delete mode 100644 modules/gpu/perf_cpu/perf_matop.cpp delete mode 100644 modules/gpu/perf_cpu/perf_objdetect.cpp delete mode 100644 modules/gpu/perf_cpu/perf_utility.cpp delete mode 100644 modules/gpu/perf_cpu/perf_utility.hpp delete mode 100644 modules/gpu/perf_cpu/perf_video.cpp diff --git a/modules/gpu/perf/perf_calib3d.cpp b/modules/gpu/perf/perf_calib3d.cpp index 343a4e9fa..f62185e00 100644 --- a/modules/gpu/perf/perf_calib3d.cpp +++ b/modules/gpu/perf/perf_calib3d.cpp @@ -15,22 +15,42 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(make_pair("gpu/p { declare.time(5.0); - cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + const cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(imgLeft.empty()); - cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + const cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(imgRight.empty()); - cv::gpu::StereoBM_GPU d_bm(0, 256); - cv::gpu::GpuMat d_imgLeft(imgLeft); - cv::gpu::GpuMat d_imgRight(imgRight); - cv::gpu::GpuMat d_dst; + const int preset = 0; + const int ndisp = 256; - d_bm(d_imgLeft, d_imgRight, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::StereoBM_GPU d_bm(preset, ndisp); + + cv::gpu::GpuMat d_imgLeft(imgLeft); + cv::gpu::GpuMat d_imgRight(imgRight); + cv::gpu::GpuMat d_dst; + d_bm(d_imgLeft, d_imgRight, d_dst); + + TEST_CYCLE() + { + d_bm(d_imgLeft, d_imgRight, d_dst); + } + } + else + { + cv::StereoBM bm(preset, ndisp); + + cv::Mat dst; + + bm(imgLeft, imgRight, dst); + + TEST_CYCLE() + { + bm(imgLeft, imgRight, dst); + } } } @@ -41,22 +61,32 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(make_pair("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png"))) { - cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + const cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(disp.empty()); - cv::gpu::DisparityBilateralFilter d_filter(128); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_disp(disp); - cv::gpu::GpuMat d_dst; + const int ndisp = 128; - d_filter(d_disp, d_img, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::DisparityBilateralFilter d_filter(ndisp); + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_disp(disp); + cv::gpu::GpuMat d_dst; + d_filter(d_disp, d_img, d_dst); + + TEST_CYCLE() + { + d_filter(d_disp, d_img, d_dst); + } + } + else + { + FAIL(); } } @@ -117,22 +167,29 @@ DEF_PARAM_TEST_1(Count, int); PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000)) { - int count = GetParam(); + const int count = GetParam(); cv::Mat src(1, count, CV_32FC3); fillRandom(src, -100, 100); - cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); + + TEST_CYCLE() + { + cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); + } + } + else + { + FAIL(); } } @@ -141,23 +198,37 @@ PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000)) PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000)) { - int count = GetParam(); + const int count = GetParam(); cv::Mat src(1, count, CV_32FC3); fillRandom(src, -100, 100); - cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); + const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); + + TEST_CYCLE() + { + cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); + } + } + else + { + cv::Mat dst; + + cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); + + TEST_CYCLE() + { + cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); + } } } @@ -166,9 +237,9 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000)) PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) { - declare.time(3.0); + declare.time(10.0); - int count = GetParam(); + const int count = GetParam(); cv::Mat object(1, count, CV_32FC3); fillRandom(object, -100, 100); @@ -180,7 +251,7 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) camera_mat.at(2, 0) = 0.f; camera_mat.at(2, 1) = 0.f; - cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); + const cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); std::vector image_vec; cv::Mat rvec_gold(1, 3, CV_32FC1); @@ -194,11 +265,23 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) cv::Mat rvec; cv::Mat tvec; - cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - - TEST_CYCLE() + if (runOnGpu) { cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + + TEST_CYCLE() + { + cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + } + } + else + { + cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + + TEST_CYCLE() + { + cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + } } } @@ -207,8 +290,8 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src, 5.0, 30.0); @@ -216,14 +299,28 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat Q(4, 4, CV_32FC1); fillRandom(Q, 0.1, 1.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); + + TEST_CYCLE() + { + cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); + } + } + else + { + cv::Mat dst; + + cv::reprojectImageTo3D(src, dst, Q); + + TEST_CYCLE() + { + cv::reprojectImageTo3D(src, dst, Q); + } } } @@ -232,20 +329,27 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S))) { - cv::Size size = GET_PARAM(0); - int type = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int type = GET_PARAM(1); cv::Mat src(size, type); fillRandom(src, 0, 255); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::drawColorDisp(d_src, d_dst, 255); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::drawColorDisp(d_src, d_dst, 255); + + TEST_CYCLE() + { + cv::gpu::drawColorDisp(d_src, d_dst, 255); + } + } + else + { + FAIL(); } } diff --git a/modules/gpu/perf/perf_core.cpp b/modules/gpu/perf/perf_core.cpp index b56713a70..90d0d831c 100644 --- a/modules/gpu/perf/perf_core.cpp +++ b/modules/gpu/perf/perf_core.cpp @@ -12,21 +12,39 @@ namespace { PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - std::vector d_src(channels); + std::vector src(channels); for (int i = 0; i < channels; ++i) - d_src[i] = cv::gpu::GpuMat(size, depth, cv::Scalar::all(i)); + src[i] = cv::Mat(size, depth, cv::Scalar::all(i)); - cv::gpu::GpuMat d_dst; - - cv::gpu::merge(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + std::vector d_src(channels); + for (int i = 0; i < channels; ++i) + d_src[i].upload(src[i]); + + cv::gpu::GpuMat d_dst; + cv::gpu::merge(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::merge(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::merge(src, dst); + + TEST_CYCLE() + { + cv::merge(src, dst); + } } } @@ -35,19 +53,35 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - cv::gpu::GpuMat d_src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); + cv::Mat src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); - std::vector d_dst; - - cv::gpu::split(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + + std::vector d_dst; + cv::gpu::split(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::split(d_src, d_dst); + } + } + else + { + std::vector dst; + + cv::split(src, dst); + + TEST_CYCLE() + { + cv::split(src, dst); + } } } @@ -56,8 +90,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -65,15 +99,29 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEP cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::add(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::add(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::add(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::add(src1, src2, dst); + + TEST_CYCLE() + { + cv::add(src1, src2, dst); + } } } @@ -82,22 +130,36 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEP PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::add(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::add(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::add(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::add(src, s, dst); + + TEST_CYCLE() + { + cv::add(src, s, dst); + } } } @@ -106,8 +168,8 @@ PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -115,15 +177,29 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::subtract(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::subtract(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::subtract(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::subtract(src1, src2, dst); + + TEST_CYCLE() + { + cv::subtract(src1, src2, dst); + } } } @@ -132,22 +208,36 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::subtract(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::subtract(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::subtract(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::subtract(src, s, dst); + + TEST_CYCLE() + { + cv::subtract(src, s, dst); + } } } @@ -156,8 +246,8 @@ PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -165,15 +255,29 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::multiply(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::multiply(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::multiply(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::multiply(src1, src2, dst); + + TEST_CYCLE() + { + cv::multiply(src1, src2, dst); + } } } @@ -182,22 +286,36 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::multiply(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::multiply(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::multiply(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::multiply(src, s, dst); + + TEST_CYCLE() + { + cv::multiply(src, s, dst); + } } } @@ -206,8 +324,8 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -215,15 +333,29 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_ cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::divide(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::divide(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::divide(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::divide(src1, src2, dst); + + TEST_CYCLE() + { + cv::divide(src1, src2, dst); + } } } @@ -232,22 +364,36 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_ PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::divide(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::divide(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::divide(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::divide(src, s, dst); + + TEST_CYCLE() + { + cv::divide(src, s, dst); + } } } @@ -256,22 +402,36 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_M PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); double s = 100.0; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::divide(s, d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::divide(s, d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::divide(s, d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::divide(s, src, dst); + + TEST_CYCLE() + { + cv::divide(s, src, dst); + } } } @@ -280,8 +440,8 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITH PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -289,15 +449,29 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::absdiff(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::absdiff(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::absdiff(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::absdiff(src1, src2, dst); + + TEST_CYCLE() + { + cv::absdiff(src1, src2, dst); + } } } @@ -306,22 +480,36 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::absdiff(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::absdiff(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::absdiff(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::absdiff(src, s, dst); + + TEST_CYCLE() + { + cv::absdiff(src, s, dst); + } } } @@ -330,20 +518,27 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_ PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::abs(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::abs(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::abs(d_src, d_dst); + } + } + else + { + FAIL(); } } @@ -352,20 +547,27 @@ PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::sqr(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::sqr(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::sqr(d_src, d_dst); + } + } + else + { + FAIL(); } } @@ -374,20 +576,34 @@ PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_ PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::sqrt(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::sqrt(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::sqrt(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::sqrt(src, dst); + + TEST_CYCLE() + { + cv::sqrt(src, dst); + } } } @@ -396,20 +612,34 @@ PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src, 1.0, 255.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::log(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::log(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::log(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::log(src, dst); + + TEST_CYCLE() + { + cv::log(src, dst); + } } } @@ -418,20 +648,34 @@ PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_ PERF_TEST_P(Sz_Depth, Core_Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src, 1.0, 10.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::exp(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::exp(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::exp(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::exp(src, dst); + + TEST_CYCLE() + { + cv::exp(src, dst); + } } } @@ -442,21 +686,35 @@ DEF_PARAM_TEST(Sz_Depth_Power, cv::Size, MatDepth, double); PERF_TEST_P(Sz_Depth_Power, Core_Pow, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F), Values(0.3, 2.0, 2.4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - double power = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const double power = GET_PARAM(2); cv::Mat src(size, depth); fillRandom(src, 1.0, 10.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::pow(d_src, power, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::pow(d_src, power, d_dst); + + TEST_CYCLE() + { + cv::gpu::pow(d_src, power, d_dst); + } + } + else + { + cv::Mat dst; + + cv::pow(src, power, dst); + + TEST_CYCLE() + { + cv::pow(src, power, dst); + } } } @@ -470,9 +728,9 @@ DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CmpCode); PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int cmp_code = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int cmp_code = GET_PARAM(2); cv::Mat src1(size, depth); fillRandom(src1); @@ -480,15 +738,29 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITH cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); + + TEST_CYCLE() + { + cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); + } + } + else + { + cv::Mat dst; + + cv::compare(src1, src2, dst, cmp_code); + + TEST_CYCLE() + { + cv::compare(src1, src2, dst, cmp_code); + } } } @@ -497,23 +769,37 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITH PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int cmp_code = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int cmp_code = GET_PARAM(2); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::compare(d_src, s, d_dst, cmp_code); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::compare(d_src, s, d_dst, cmp_code); + + TEST_CYCLE() + { + cv::gpu::compare(d_src, s, d_dst, cmp_code); + } + } + else + { + cv::Mat dst; + + cv::compare(src, s, dst, cmp_code); + + TEST_CYCLE() + { + cv::compare(src, s, dst, cmp_code); + } } } @@ -522,20 +808,34 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, AR PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_not(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_not(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_not(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_not(src, dst); + + TEST_CYCLE() + { + cv::bitwise_not(src, dst); + } } } @@ -544,8 +844,8 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -553,15 +853,29 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_and(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_and(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_and(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_and(src1, src2, dst); + + TEST_CYCLE() + { + cv::bitwise_and(src1, src2, dst); + } } } @@ -570,25 +884,39 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_and(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_and(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_and(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_and(src, s, dst); + + TEST_CYCLE() + { + cv::bitwise_and(src, s, dst); + } } } @@ -597,8 +925,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, V PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -606,15 +934,29 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(C cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_or(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_or(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_or(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_or(src1, src2, dst); + + TEST_CYCLE() + { + cv::bitwise_or(src1, src2, dst); + } } } @@ -623,25 +965,39 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(C PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_or(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_or(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_or(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_or(src, s, dst); + + TEST_CYCLE() + { + cv::bitwise_or(src, s, dst); + } } } @@ -650,8 +1006,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Va PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -659,15 +1015,29 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_xor(src1, src2, dst); + + TEST_CYCLE() + { + cv::bitwise_xor(src1, src2, dst); + } } } @@ -676,25 +1046,39 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::bitwise_xor(d_src, s, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::bitwise_xor(d_src, s, d_dst); + + TEST_CYCLE() + { + cv::gpu::bitwise_xor(d_src, s, d_dst); + } + } + else + { + cv::Mat dst; + + cv::bitwise_xor(src, s, dst); + + TEST_CYCLE() + { + cv::bitwise_xor(src, s, dst); + } } } @@ -703,25 +1087,32 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, V PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); - cv::Scalar_ val = cv::Scalar_::all(4); + const cv::Scalar_ val = cv::Scalar_::all(4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::rshift(d_src, val, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::rshift(d_src, val, d_dst); + + TEST_CYCLE() + { + cv::gpu::rshift(d_src, val, d_dst); + } + } + else + { + FAIL(); } } @@ -730,25 +1121,32 @@ PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); - cv::Scalar_ val = cv::Scalar_::all(4); + const cv::Scalar_ val = cv::Scalar_::all(4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::lshift(d_src, val, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::lshift(d_src, val, d_dst); + + TEST_CYCLE() + { + cv::gpu::lshift(d_src, val, d_dst); + } + } + else + { + FAIL(); } } @@ -757,8 +1155,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -766,15 +1164,29 @@ PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::min(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::min(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::min(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::min(src1, src2, dst); + + TEST_CYCLE() + { + cv::min(src1, src2, dst); + } } } @@ -783,22 +1195,36 @@ PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - double val = 50.0; + const double val = 50.0; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::min(d_src, val, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::min(d_src, val, d_dst); + + TEST_CYCLE() + { + cv::gpu::min(d_src, val, d_dst); + } + } + else + { + cv::Mat dst; + + cv::min(src, val, dst); + + TEST_CYCLE() + { + cv::min(src, val, dst); + } } } @@ -807,8 +1233,8 @@ PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -816,15 +1242,29 @@ PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::max(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::max(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::max(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::max(src1, src2, dst); + + TEST_CYCLE() + { + cv::max(src1, src2, dst); + } } } @@ -833,22 +1273,36 @@ PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, PERF_TEST_P(Sz_Depth, Core_MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - double val = 50.0; + const double val = 50.0; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::max(d_src, val, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::max(d_src, val, d_dst); + + TEST_CYCLE() + { + cv::gpu::max(d_src, val, d_dst); + } + } + else + { + cv::Mat dst; + + cv::max(src, val, dst); + + TEST_CYCLE() + { + cv::max(src, val, dst); + } } } @@ -863,10 +1317,10 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine( Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::Size size = GET_PARAM(0); - int depth1 = GET_PARAM(1); - int depth2 = GET_PARAM(2); - int dst_depth = GET_PARAM(3); + const cv::Size size = GET_PARAM(0); + const int depth1 = GET_PARAM(1); + const int depth2 = GET_PARAM(2); + const int dst_depth = GET_PARAM(3); cv::Mat src1(size, depth1); fillRandom(src1); @@ -874,15 +1328,29 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine( cv::Mat src2(size, depth2); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); + + TEST_CYCLE() + { + cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); + } + } + else + { + cv::Mat dst; + + cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); + + TEST_CYCLE() + { + cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); + } } } @@ -901,9 +1369,9 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine( { declare.time(5.0); - cv::Size size = GET_PARAM(0); - int type = GET_PARAM(1); - int flags = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int type = GET_PARAM(1); + const int flags = GET_PARAM(2); cv::Mat src1(size, type); fillRandom(src1); @@ -914,16 +1382,32 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine( cv::Mat src3(size, type); fillRandom(src3); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_src3(src3); - cv::gpu::GpuMat d_dst; - - cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_src3(src3); + cv::gpu::GpuMat d_dst; + cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); + + TEST_CYCLE() + { + cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); + } + } + else + { + cv::Mat dst; + + cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); + + declare.time(50.0); + + TEST_CYCLE() + { + cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); + } } } @@ -940,14 +1424,28 @@ PERF_TEST_P(Sz_Type, Core_Transpose, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::transpose(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::transpose(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::transpose(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::transpose(src, dst); + + TEST_CYCLE() + { + cv::transpose(src, dst); + } } } @@ -976,14 +1474,28 @@ PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::flip(d_src, d_dst, flipCode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::flip(d_src, d_dst, flipCode); + + TEST_CYCLE() + { + cv::gpu::flip(d_src, d_dst, flipCode); + } + } + else + { + cv::Mat dst; + + cv::flip(src, dst, flipCode); + + TEST_CYCLE() + { + cv::flip(src, dst, flipCode); + } } } @@ -1003,14 +1515,28 @@ PERF_TEST_P(Sz_Type, Core_LutOneChannel, Combine( cv::Mat lut(1, 256, CV_8UC1); fillRandom(lut); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::LUT(d_src, lut, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::LUT(d_src, lut, d_dst); + + TEST_CYCLE() + { + cv::gpu::LUT(d_src, lut, d_dst); + } + } + else + { + cv::Mat dst; + + cv::LUT(src, lut, dst); + + TEST_CYCLE() + { + cv::LUT(src, lut, dst); + } } } @@ -1030,14 +1556,28 @@ PERF_TEST_P(Sz_Type, Core_LutMultiChannel, Combine( cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels())); fillRandom(lut); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::LUT(d_src, lut, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::LUT(d_src, lut, d_dst); + + TEST_CYCLE() + { + cv::gpu::LUT(d_src, lut, d_dst); + } + } + else + { + cv::Mat dst; + + cv::LUT(src, lut, dst); + + TEST_CYCLE() + { + cv::LUT(src, lut, dst); + } } } @@ -1051,14 +1591,31 @@ PERF_TEST_P(Sz, Core_MagnitudeComplex, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_32FC2); fillRandom(src, -100.0, 100.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::magnitude(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::magnitude(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::magnitude(d_src, d_dst); + } + } + else + { + cv::Mat xy[2]; + cv::split(src, xy); + + cv::Mat dst; + + cv::magnitude(xy[0], xy[1], dst); + + TEST_CYCLE() + { + cv::magnitude(xy[0], xy[1], dst); + } } } @@ -1072,14 +1629,21 @@ PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_32FC2); fillRandom(src, -100.0, 100.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::magnitudeSqr(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::magnitudeSqr(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::magnitudeSqr(d_src, d_dst); + } + } + else + { + FAIL(); } } @@ -1096,15 +1660,29 @@ PERF_TEST_P(Sz, Core_Magnitude, GPU_TYPICAL_MAT_SIZES) cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::magnitude(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::magnitude(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::magnitude(d_src1, d_src2, d_dst); + } + } + else + { + cv::Mat dst; + + cv::magnitude(src1, src2, dst); + + TEST_CYCLE() + { + cv::magnitude(src1, src2, dst); + } } } @@ -1121,15 +1699,22 @@ PERF_TEST_P(Sz, Core_MagnitudeSqr, GPU_TYPICAL_MAT_SIZES) cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); + + TEST_CYCLE() + { + cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); + } + } + else + { + FAIL(); } } @@ -1149,15 +1734,29 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool() cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); + + TEST_CYCLE() + { + cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); + } + } + else + { + cv::Mat dst; + + cv::phase(src1, src2, dst, angleInDegrees); + + TEST_CYCLE() + { + cv::phase(src1, src2, dst, angleInDegrees); + } } } @@ -1175,16 +1774,31 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_magnitude; - cv::gpu::GpuMat d_angle; - - cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_magnitude; + cv::gpu::GpuMat d_angle; + cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); + + TEST_CYCLE() + { + cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); + } + } + else + { + cv::Mat magnitude; + cv::Mat angle; + + cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); + + TEST_CYCLE() + { + cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); + } } } @@ -1202,16 +1816,31 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat angle(size, CV_32FC1); fillRandom(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI); - cv::gpu::GpuMat d_magnitude(magnitude); - cv::gpu::GpuMat d_angle(angle); - cv::gpu::GpuMat d_x; - cv::gpu::GpuMat d_y; - - cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_magnitude(magnitude); + cv::gpu::GpuMat d_angle(angle); + cv::gpu::GpuMat d_x; + cv::gpu::GpuMat d_y; + cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); + + TEST_CYCLE() + { + cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); + } + } + else + { + cv::Mat x; + cv::Mat y; + + cv::polarToCart(magnitude, angle, x, y, angleInDegrees); + + TEST_CYCLE() + { + cv::polarToCart(magnitude, angle, x, y, angleInDegrees); + } } } @@ -1228,14 +1857,26 @@ PERF_TEST_P(Sz, Core_MeanStdDev, GPU_TYPICAL_MAT_SIZES) cv::Scalar mean; cv::Scalar stddev; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); + + TEST_CYCLE() + { + cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); + } + } + else + { + cv::meanStdDev(src, mean, stddev); + + TEST_CYCLE() + { + cv::meanStdDev(src, mean, stddev); + } } } @@ -1258,14 +1899,26 @@ PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine( double dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - dst = cv::gpu::norm(d_src, normType, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + dst = cv::gpu::norm(d_src, normType, d_buf); + + TEST_CYCLE() + { + dst = cv::gpu::norm(d_src, normType, d_buf); + } + } + else + { + dst = cv::norm(src, normType); + + TEST_CYCLE() + { + dst = cv::norm(src, normType); + } } } @@ -1289,14 +1942,26 @@ PERF_TEST_P(Sz_Norm, Core_NormDiff, Combine( double dst; - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - - dst = cv::gpu::norm(d_src1, d_src2, normType); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + dst = cv::gpu::norm(d_src1, d_src2, normType); + + TEST_CYCLE() + { + dst = cv::gpu::norm(d_src1, d_src2, normType); + } + } + else + { + dst = cv::norm(src1, src2, normType); + + TEST_CYCLE() + { + dst = cv::norm(src1, src2, normType); + } } } @@ -1319,14 +1984,26 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine( cv::Scalar dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - dst = cv::gpu::sum(d_src, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + dst = cv::gpu::sum(d_src, d_buf); + + TEST_CYCLE() + { + dst = cv::gpu::sum(d_src, d_buf); + } + } + else + { + dst = cv::sum(src); + + TEST_CYCLE() + { + dst = cv::sum(src); + } } } @@ -1349,14 +2026,21 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine( cv::Scalar dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - dst = cv::gpu::absSum(d_src, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + dst = cv::gpu::absSum(d_src, d_buf); + + TEST_CYCLE() + { + dst = cv::gpu::absSum(d_src, d_buf); + } + } + else + { + FAIL(); } } @@ -1379,14 +2063,21 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine( cv::Scalar dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - dst = cv::gpu::sqrSum(d_src, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + dst = cv::gpu::sqrSum(d_src, d_buf); + + TEST_CYCLE() + { + dst = cv::gpu::sqrSum(d_src, d_buf); + } + } + else + { + FAIL(); } } @@ -1405,14 +2096,21 @@ PERF_TEST_P(Sz_Depth, Core_MinMax, Combine( double minVal, maxVal; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); + + TEST_CYCLE() + { + cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); + } + } + else + { + FAIL(); } } @@ -1432,14 +2130,26 @@ PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, Combine( double minVal, maxVal; cv::Point minLoc, maxLoc; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_valbuf, d_locbuf; - - cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_valbuf, d_locbuf; + cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); + + TEST_CYCLE() + { + cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); + } + } + else + { + cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); + + TEST_CYCLE() + { + cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); + } } } @@ -1458,14 +2168,26 @@ PERF_TEST_P(Sz_Depth, Core_CountNonZero, Combine( int dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; - - dst = cv::gpu::countNonZero(d_src, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; + dst = cv::gpu::countNonZero(d_src, d_buf); + + TEST_CYCLE() + { + dst = cv::gpu::countNonZero(d_src, d_buf); + } + } + else + { + dst = cv::countNonZero(src); + + TEST_CYCLE() + { + dst = cv::countNonZero(src); + } } } @@ -1499,14 +2221,28 @@ PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::reduce(d_src, d_dst, dim, reduceOp); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::reduce(d_src, d_dst, dim, reduceOp); + + TEST_CYCLE() + { + cv::gpu::reduce(d_src, d_dst, dim, reduceOp); + } + } + else + { + cv::Mat dst; + + cv::reduce(src, dst, dim, reduceOp); + + TEST_CYCLE() + { + cv::reduce(src, dst, dim, reduceOp); + } } } diff --git a/modules/gpu/perf/perf_features2d.cpp b/modules/gpu/perf/perf_features2d.cpp index ef9612b54..53b98d462 100644 --- a/modules/gpu/perf/perf_features2d.cpp +++ b/modules/gpu/perf/perf_features2d.cpp @@ -12,21 +12,39 @@ DEF_PARAM_TEST_1(Image, string); PERF_TEST_P(Image, Features2D_SURF, Values("gpu/perf/aloe.jpg")) { - declare.time(2.0); + declare.time(50.0); cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::SURF_GPU d_surf; - - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_keypoints, d_descriptors; - - d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::SURF_GPU d_surf; + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints, d_descriptors; + d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + + TEST_CYCLE() + { + d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + } + } + else + { + cv::SURF surf; + + std::vector keypoints; + cv::Mat descriptors; + + surf(img, cv::noArray(), keypoints, descriptors); + + TEST_CYCLE() + { + keypoints.clear(); + surf(img, cv::noArray(), keypoints, descriptors); + } } } @@ -38,16 +56,31 @@ PERF_TEST_P(Image, Features2D_FAST, Values("gpu/perf/aloe.jpg")) cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::FAST_GPU d_fast(20); - - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_keypoints; - - d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::FAST_GPU d_fast(20); + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints; + d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); + + TEST_CYCLE() + { + d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); + } + } + else + { + std::vector keypoints; + + cv::FAST(img, keypoints, 20); + + TEST_CYCLE() + { + keypoints.clear(); + cv::FAST(img, keypoints, 20); + } } } @@ -59,16 +92,34 @@ PERF_TEST_P(Image, Features2D_ORB, Values("gpu/perf/aloe.jpg")) cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::ORB_GPU d_orb(4000); - - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_keypoints, d_descriptors; - - d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::ORB_GPU d_orb(4000); + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints, d_descriptors; + d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + + TEST_CYCLE() + { + d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + } + } + else + { + cv::ORB orb(4000); + + std::vector keypoints; + cv::Mat descriptors; + + orb(img, cv::noArray(), keypoints, descriptors); + + TEST_CYCLE() + { + keypoints.clear(); + orb(img, cv::noArray(), keypoints, descriptors); + } } } @@ -79,7 +130,7 @@ DEF_PARAM_TEST(DescSize_Norm, int, NormType); PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - declare.time(3.0); + declare.time(20.0); int desc_size = GET_PARAM(0); int normType = GET_PARAM(1); @@ -92,17 +143,33 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Val cv::Mat train(3000, desc_size, type); fillRandom(train); - cv::gpu::BFMatcher_GPU d_matcher(normType); - - cv::gpu::GpuMat d_query(query); - cv::gpu::GpuMat d_train(train); - cv::gpu::GpuMat d_trainIdx, d_distance; - - d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::BFMatcher_GPU d_matcher(normType); + + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_distance; + d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + + TEST_CYCLE() + { + d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + } + } + else + { + cv::BFMatcher matcher(normType); + + std::vector matches; + + matcher.match(query, train, matches); + + TEST_CYCLE() + { + matcher.match(query, train, matches); + } } } @@ -116,7 +183,7 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( Values(2, 3), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - declare.time(3.0); + declare.time(30.0); int desc_size = GET_PARAM(0); int k = GET_PARAM(1); @@ -130,17 +197,33 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( cv::Mat train(3000, desc_size, type); fillRandom(train); - cv::gpu::BFMatcher_GPU d_matcher(normType); - - cv::gpu::GpuMat d_query(query); - cv::gpu::GpuMat d_train(train); - cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist; - - d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::BFMatcher_GPU d_matcher(normType); + + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist; + d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); + + TEST_CYCLE() + { + d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); + } + } + else + { + cv::BFMatcher matcher(normType); + + std::vector< std::vector > matches; + + matcher.knnMatch(query, train, matches, k); + + TEST_CYCLE() + { + matcher.knnMatch(query, train, matches, k); + } } } @@ -149,7 +232,7 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - declare.time(3.0); + declare.time(30.0); int desc_size = GET_PARAM(0); int normType = GET_PARAM(1); @@ -162,17 +245,33 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256 cv::Mat train(3000, desc_size, type); fillRandom(train, 0.0, 1.0); - cv::gpu::BFMatcher_GPU d_matcher(normType); - - cv::gpu::GpuMat d_query(query); - cv::gpu::GpuMat d_train(train); - cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance; - - d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::BFMatcher_GPU d_matcher(normType); + + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance; + d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); + + TEST_CYCLE() + { + d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); + } + } + else + { + cv::BFMatcher matcher(normType); + + std::vector< std::vector > matches; + + matcher.radiusMatch(query, train, matches, 2.0); + + TEST_CYCLE() + { + matcher.radiusMatch(query, train, matches, 2.0); + } } } diff --git a/modules/gpu/perf/perf_filters.cpp b/modules/gpu/perf/perf_filters.cpp index 71dcd49e2..64ab829f8 100644 --- a/modules/gpu/perf/perf_filters.cpp +++ b/modules/gpu/perf/perf_filters.cpp @@ -12,6 +12,8 @@ DEF_PARAM_TEST(Sz_Type_KernelSz, cv::Size, MatType, int); PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), Values(3, 5, 7))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -19,14 +21,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); + + TEST_CYCLE() + { + cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); + } + } + else + { + cv::Mat dst; + + cv::blur(src, dst, cv::Size(ksize, ksize)); + + TEST_CYCLE() + { + cv::blur(src, dst, cv::Size(ksize, ksize)); + } } } @@ -35,6 +51,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -42,15 +60,29 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; - - cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; + cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); + + TEST_CYCLE() + { + cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); + } + } + else + { + cv::Mat dst; + + cv::Sobel(src, dst, -1, 1, 1, ksize); + + TEST_CYCLE() + { + cv::Sobel(src, dst, -1, 1, 1, ksize); + } } } @@ -59,21 +91,37 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; - - cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; + cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); + + TEST_CYCLE() + { + cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); + } + } + else + { + cv::Mat dst; + + cv::Scharr(src, dst, -1, 1, 0); + + TEST_CYCLE() + { + cv::Scharr(src, dst, -1, 1, 0); + } } } @@ -82,6 +130,8 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -89,15 +139,29 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; - - cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; + cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); + + TEST_CYCLE() + { + cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); + } + } + else + { + cv::Mat dst; + + cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); + + TEST_CYCLE() + { + cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); + } } } @@ -106,6 +170,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 3))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -113,14 +179,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::Laplacian(d_src, d_dst, -1, ksize); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::Laplacian(d_src, d_dst, -1, ksize); + + TEST_CYCLE() + { + cv::gpu::Laplacian(d_src, d_dst, -1, ksize); + } + } + else + { + cv::Mat dst; + + cv::Laplacian(src, dst, -1, ksize); + + TEST_CYCLE() + { + cv::Laplacian(src, dst, -1, ksize); + } } } @@ -129,6 +209,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); @@ -137,15 +219,29 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; - - cv::gpu::erode(d_src, d_dst, ker, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; + cv::gpu::erode(d_src, d_dst, ker, d_buf); + + TEST_CYCLE() + { + cv::gpu::erode(d_src, d_dst, ker, d_buf); + } + } + else + { + cv::Mat dst; + + cv::erode(src, dst, ker); + + TEST_CYCLE() + { + cv::erode(src, dst, ker); + } } } @@ -154,6 +250,8 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); @@ -162,15 +260,29 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; - - cv::gpu::dilate(d_src, d_dst, ker, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; + cv::gpu::dilate(d_src, d_dst, ker, d_buf); + + TEST_CYCLE() + { + cv::gpu::dilate(d_src, d_dst, ker, d_buf); + } + } + else + { + cv::Mat dst; + + cv::dilate(src, dst, ker); + + TEST_CYCLE() + { + cv::dilate(src, dst, ker); + } } } @@ -184,6 +296,8 @@ DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, MorphOp); PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), ALL_MORPH_OPS)) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int morphOp = GET_PARAM(2); @@ -193,16 +307,30 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf1; - cv::gpu::GpuMat d_buf2; - - cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf1; + cv::gpu::GpuMat d_buf2; + cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); + + TEST_CYCLE() + { + cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); + } + } + else + { + cv::Mat dst; + + cv::morphologyEx(src, dst, morphOp, ker); + + TEST_CYCLE() + { + cv::morphologyEx(src, dst, morphOp, ker); + } } } @@ -211,6 +339,8 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(3, 5, 7, 9, 11, 13, 15))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -221,14 +351,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V cv::Mat kernel(ksize, ksize, CV_32FC1); fillRandom(kernel, 0.0, 1.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::filter2D(d_src, d_dst, -1, kernel); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::filter2D(d_src, d_dst, -1, kernel); + + TEST_CYCLE() + { + cv::gpu::filter2D(d_src, d_dst, -1, kernel); + } + } + else + { + cv::Mat dst; + + cv::filter2D(src, dst, -1, kernel); + + TEST_CYCLE() + { + cv::filter2D(src, dst, -1, kernel); + } } } diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index a1614a79f..9104892db 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -59,7 +59,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine( ALL_BORDER_MODES, ALL_REMAP_MODES)) { - declare.time(3.0); + declare.time(20.0); cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); @@ -78,16 +78,30 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine( generateMap(xmap, ymap, remapMode); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_xmap(xmap); - cv::gpu::GpuMat d_ymap(ymap); - cv::gpu::GpuMat d_dst; - - cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_xmap(xmap); + cv::gpu::GpuMat d_ymap(ymap); + cv::gpu::GpuMat d_dst; + cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + + TEST_CYCLE() + { + cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + } + } + else + { + cv::Mat dst; + + cv::remap(src, dst, xmap, ymap, interpolation, borderMode); + + TEST_CYCLE() + { + cv::remap(src, dst, xmap, ymap, interpolation, borderMode); + } } } @@ -103,7 +117,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine( ALL_INTERPOLATIONS, Values(0.5, 0.3, 2.0))) { - declare.time(1.0); + declare.time(20.0); cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); @@ -116,14 +130,28 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + + TEST_CYCLE() + { + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + } + } + else + { + cv::Mat dst; + + cv::resize(src, dst, cv::Size(), f, f, interpolation); + + TEST_CYCLE() + { + cv::resize(src, dst, cv::Size(), f, f, interpolation); + } } } @@ -151,14 +179,28 @@ PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + + TEST_CYCLE() + { + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + } + } + else + { + cv::Mat dst; + + cv::resize(src, dst, cv::Size(), f, f, interpolation); + + TEST_CYCLE() + { + cv::resize(src, dst, cv::Size(), f, f, interpolation); + } } } @@ -174,6 +216,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine( Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), ALL_BORDER_MODES)) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); int channels = GET_PARAM(2); @@ -190,14 +234,28 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine( {std::sin(aplha), std::cos(aplha), 0}}; cv::Mat M(2, 3, CV_64F, (void*) mat); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); + + TEST_CYCLE() + { + cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); + } + } + else + { + cv::Mat dst; + + cv::warpAffine(src, dst, M, size, interpolation, borderMode); + + TEST_CYCLE() + { + cv::warpAffine(src, dst, M, size, interpolation, borderMode); + } } } @@ -211,6 +269,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine( Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), ALL_BORDER_MODES)) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); int channels = GET_PARAM(2); @@ -228,14 +288,28 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine( {0.0, 0.0, 1.0}}; cv::Mat M(3, 3, CV_64F, (void*) mat); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); + + TEST_CYCLE() + { + cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); + } + } + else + { + cv::Mat dst; + + cv::warpPerspective(src, dst, M, size, interpolation, borderMode); + + TEST_CYCLE() + { + cv::warpPerspective(src, dst, M, size, interpolation, borderMode); + } } } @@ -260,14 +334,28 @@ PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); + + TEST_CYCLE() + { + cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); + } + } + else + { + cv::Mat dst; + + cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode); + + TEST_CYCLE() + { + cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode); + } } } @@ -291,14 +379,28 @@ PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine( cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); + + TEST_CYCLE() + { + cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); + } + } + else + { + cv::Mat dst; + + cv::threshold(src, dst, 100.0, 255.0, threshOp); + + TEST_CYCLE() + { + cv::threshold(src, dst, 100.0, 255.0, threshOp); + } } } @@ -312,15 +414,29 @@ PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; - - cv::gpu::integralBuffered(d_src, d_dst, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; + cv::gpu::integralBuffered(d_src, d_dst, d_buf); + + TEST_CYCLE() + { + cv::gpu::integralBuffered(d_src, d_dst, d_buf); + } + } + else + { + cv::Mat dst; + + cv::integral(src, dst); + + TEST_CYCLE() + { + cv::integral(src, dst); + } } } @@ -334,14 +450,21 @@ PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::sqrIntegral(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::sqrIntegral(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::sqrIntegral(d_src, d_dst); + } + } + else + { + FAIL(); } } @@ -356,15 +479,35 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values( cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_hist; - cv::gpu::GpuMat d_buf; - - cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; + cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); + + TEST_CYCLE() + { + cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); + } + } + else + { + int hbins = 30; + float hranges[] = {0.0f, 180.0f}; + int histSize[] = {hbins}; + const float* ranges[] = {hranges}; + int channels[] = {0}; + + cv::Mat hist; + + cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); + + TEST_CYCLE() + { + cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); + } } } @@ -383,15 +526,22 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values( int lowerLevel[] = {0, 0, 0, 0}; int upperLevel[] = {180, 180, 180, 180}; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_hist[4]; - cv::gpu::GpuMat d_buf; - - cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist[4]; + cv::gpu::GpuMat d_buf; + cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); + + TEST_CYCLE() + { + cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); + } + } + else + { + FAIL(); } } @@ -405,15 +555,22 @@ PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_hist; - cv::gpu::GpuMat d_buf; - - cv::gpu::calcHist(d_src, d_hist, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; + cv::gpu::calcHist(d_src, d_hist, d_buf); + + TEST_CYCLE() + { + cv::gpu::calcHist(d_src, d_hist, d_buf); + } + } + else + { + FAIL(); } } @@ -427,16 +584,30 @@ PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_hist; - cv::gpu::GpuMat d_buf; - - cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; + cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); + + TEST_CYCLE() + { + cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); + } + } + else + { + cv::Mat dst; + + cv::equalizeHist(src, dst); + + TEST_CYCLE() + { + cv::equalizeHist(src, dst); + } } } @@ -450,14 +621,21 @@ PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_32FC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::columnSum(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::columnSum(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::columnSum(d_src, d_dst); + } + } + else + { + FAIL(); } } @@ -478,15 +656,29 @@ PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine( cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_dst; - cv::gpu::CannyBuf d_buf; - - cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_dst; + cv::gpu::CannyBuf d_buf; + cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); + + TEST_CYCLE() + { + cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); + } + } + else + { + cv::Mat dst; + + cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); + + TEST_CYCLE() + { + cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); + } } } @@ -497,7 +689,7 @@ DEF_PARAM_TEST_1(Image, string); PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values("gpu/meanshift/cones.png")) { - declare.time(5.0); + declare.time(15.0); cv::Mat img = readImage(GetParam()); ASSERT_FALSE(img.empty()); @@ -505,14 +697,28 @@ PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values("gpu/meanshift/con cv::Mat rgba; cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - cv::gpu::GpuMat d_src(rgba); - cv::gpu::GpuMat d_dst; - - cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(rgba); + cv::gpu::GpuMat d_dst; + cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); + + TEST_CYCLE() + { + cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); + } + } + else + { + cv::Mat dst; + + cv::pyrMeanShiftFiltering(img, dst, 50, 50); + + TEST_CYCLE() + { + cv::pyrMeanShiftFiltering(img, dst, 50, 50); + } } } @@ -529,15 +735,22 @@ PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values("gpu/meanshift/cones.pn cv::Mat rgba; cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - cv::gpu::GpuMat d_src(rgba); - cv::gpu::GpuMat d_dstr; - cv::gpu::GpuMat d_dstsp; - - cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(rgba); + cv::gpu::GpuMat d_dstr; + cv::gpu::GpuMat d_dstsp; + cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); + + TEST_CYCLE() + { + cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); + } + } + else + { + FAIL(); } } @@ -556,13 +769,20 @@ PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values("gpu/meanshift/ cv::Mat dst; - cv::gpu::GpuMat d_src(rgba); - - cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(rgba); + cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); + + TEST_CYCLE() + { + cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); + } + } + else + { + FAIL(); } } @@ -583,17 +803,24 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Val cv::Mat img2(size, type); fillRandom(img2); - cv::gpu::GpuMat d_img1(img1); - cv::gpu::GpuMat d_img2(img2); - cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5)); - cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5)); - cv::gpu::GpuMat d_dst; - - cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_img1(img1); + cv::gpu::GpuMat d_img2(img2); + cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5)); + cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5)); + cv::gpu::GpuMat d_dst; + cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); + + TEST_CYCLE() + { + cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); + } + } + else + { + FAIL(); } } @@ -604,26 +831,48 @@ DEF_PARAM_TEST(Sz_KernelSz_Ccorr, cv::Size, int, bool); PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool())) { - declare.time(2.0); + declare.time(10.0); cv::Size size = GET_PARAM(0); int templ_size = GET_PARAM(1); bool ccorr = GET_PARAM(2); - cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1); - d_image.setTo(cv::Scalar(1.0)); + cv::Mat image(size, CV_32FC1); + image.setTo(1.0); - cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); - d_templ.setTo(cv::Scalar(1.0)); + cv::Mat templ(templ_size, templ_size, CV_32FC1); + templ.setTo(1.0); - cv::gpu::GpuMat d_dst; - cv::gpu::ConvolveBuf d_buf; - - cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1); + d_image.upload(image); + + cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); + d_templ.upload(templ); + + cv::gpu::GpuMat d_dst; + cv::gpu::ConvolveBuf d_buf; + cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); + + TEST_CYCLE() + { + cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); + } + } + else + { + ASSERT_FALSE(ccorr); + + cv::Mat dst; + + cv::filter2D(image, dst, image.depth(), templ); + + TEST_CYCLE() + { + cv::filter2D(image, dst, image.depth(), templ); + } } } @@ -652,15 +901,29 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine( cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn)); fillRandom(templ); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_templ(templ); - cv::gpu::GpuMat d_dst; - - cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_templ(templ); + cv::gpu::GpuMat d_dst; + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + + TEST_CYCLE() + { + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + } + } + else + { + cv::Mat dst; + + cv::matchTemplate(image, templ, dst, method); + + TEST_CYCLE() + { + cv::matchTemplate(image, templ, dst, method); + } } }; @@ -684,15 +947,29 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine( cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn)); fillRandom(templ); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_templ(templ); - cv::gpu::GpuMat d_dst; - - cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_templ(templ); + cv::gpu::GpuMat d_dst; + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + + TEST_CYCLE() + { + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + } + } + else + { + cv::Mat dst; + + cv::matchTemplate(image, templ, dst, method); + + TEST_CYCLE() + { + cv::matchTemplate(image, templ, dst, method); + } } }; @@ -716,15 +993,29 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine( cv::Mat b(size, CV_32FC2); fillRandom(b, 0, 100); - cv::gpu::GpuMat d_a(a); - cv::gpu::GpuMat d_b(b); - cv::gpu::GpuMat d_dst; - - cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_a(a); + cv::gpu::GpuMat d_b(b); + cv::gpu::GpuMat d_dst; + cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); + + TEST_CYCLE() + { + cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); + } + } + else + { + cv::Mat dst; + + cv::mulSpectrums(a, b, dst, flag); + + TEST_CYCLE() + { + cv::mulSpectrums(a, b, dst, flag); + } } } @@ -743,15 +1034,22 @@ PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES) cv::Mat src2(size, CV_32FC2); fillRandom(src2, 0, 100); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; - - cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; + cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); + + TEST_CYCLE() + { + cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); + } + } + else + { + FAIL(); } } @@ -762,7 +1060,7 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine( GPU_TYPICAL_MAT_SIZES, Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))) { - declare.time(2.0); + declare.time(10.0); cv::Size size = GET_PARAM(0); int flag = GET_PARAM(1); @@ -770,14 +1068,28 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine( cv::Mat src(size, CV_32FC2); fillRandom(src, 0, 100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::dft(d_src, d_dst, size, flag); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::dft(d_src, d_dst, size, flag); + + TEST_CYCLE() + { + cv::gpu::dft(d_src, d_dst, size, flag); + } + } + else + { + cv::Mat dst; + + cv::dft(src, dst, flag); + + TEST_CYCLE() + { + cv::dft(src, dst, flag); + } } } @@ -793,8 +1105,6 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine( Values(3, 5, 7), Values(0, 3, 5, 7))) { - double k = 0.5; - string fileName = GET_PARAM(0); int type = GET_PARAM(1); int borderMode = GET_PARAM(2); @@ -803,20 +1113,35 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine( cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_Dx; - cv::gpu::GpuMat d_Dy; - cv::gpu::GpuMat d_buf; + double k = 0.5; - cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_Dx; + cv::gpu::GpuMat d_Dy; + cv::gpu::GpuMat d_buf; + cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); + + TEST_CYCLE() + { + cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); + } + } + else + { + cv::Mat dst; + + cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode); + + TEST_CYCLE() + { + cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode); + } } } @@ -841,17 +1166,31 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_Dx; - cv::gpu::GpuMat d_Dy; - cv::gpu::GpuMat d_buf; - - cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_Dx; + cv::gpu::GpuMat d_Dy; + cv::gpu::GpuMat d_buf; + cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); + + TEST_CYCLE() + { + cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); + } + } + else + { + cv::Mat dst; + + cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode); + + TEST_CYCLE() + { + cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode); + } } } @@ -866,14 +1205,21 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES) cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); cv::Mat T = cv::Mat::zeros(1, 3, CV_32F); - cv::gpu::GpuMat d_map_x; - cv::gpu::GpuMat d_map_y; - - cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; + cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); + + TEST_CYCLE() + { + cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); + } + } + else + { + FAIL(); } } @@ -887,14 +1233,21 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES) cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat d_map_x; - cv::gpu::GpuMat d_map_y; - - cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; + cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + + TEST_CYCLE() + { + cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + } + } + else + { + FAIL(); } } @@ -908,14 +1261,21 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES) cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat d_map_x; - cv::gpu::GpuMat d_map_y; - - cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; + cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + + TEST_CYCLE() + { + cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + } + } + else + { + FAIL(); } } @@ -940,14 +1300,21 @@ PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); + + TEST_CYCLE() + { + cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); + } + } + else + { + FAIL(); } } @@ -968,14 +1335,28 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::pyrDown(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::pyrDown(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::pyrDown(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::pyrDown(src, dst); + + TEST_CYCLE() + { + cv::pyrDown(src, dst); + } } } @@ -996,14 +1377,28 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::pyrUp(d_src, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::pyrUp(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::pyrUp(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::pyrUp(src, dst); + + TEST_CYCLE() + { + cv::pyrUp(src, dst); + } } } @@ -1049,14 +1444,28 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine( cv::Mat src(size, CV_MAKETYPE(depth, info.scn)); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); + + TEST_CYCLE() + { + cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); + } + } + else + { + cv::Mat dst; + + cv::cvtColor(src, dst, info.code, info.dcn); + + TEST_CYCLE() + { + cv::cvtColor(src, dst, info.code, info.dcn); + } } } @@ -1072,13 +1481,20 @@ PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES) const int dstOrder[] = {2, 1, 0, 3}; - cv::gpu::GpuMat d_src(src); - - cv::gpu::swapChannels(d_src, dstOrder); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::swapChannels(d_src, dstOrder); + + TEST_CYCLE() + { + cv::gpu::swapChannels(d_src, dstOrder); + } + } + else + { + FAIL(); } } @@ -1102,15 +1518,22 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values cv::Mat img2(size, type); fillRandom(img2); - cv::gpu::GpuMat d_img1(img1); - cv::gpu::GpuMat d_img2(img2); - cv::gpu::GpuMat d_dst; - - cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_img1(img1); + cv::gpu::GpuMat d_img2(img2); + cv::gpu::GpuMat d_dst; + cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); + + TEST_CYCLE() + { + cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); + } + } + else + { + FAIL(); } } @@ -1128,15 +1551,22 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZE cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - - cv::gpu::ImagePyramid d_pyr; - - d_pyr.build(d_src, 5); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + + cv::gpu::ImagePyramid d_pyr; + d_pyr.build(d_src, 5); + + TEST_CYCLE() + { + d_pyr.build(d_src, 5); + } + } + else + { + FAIL(); } } @@ -1156,16 +1586,23 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_S cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - cv::gpu::ImagePyramid d_pyr(d_src, 3); - - d_pyr.getLayer(d_dst, dstSize); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + + cv::gpu::ImagePyramid d_pyr(d_src, 3); + d_pyr.getLayer(d_dst, dstSize); + + TEST_CYCLE() + { + d_pyr.getLayer(d_dst, dstSize); + } + } + else + { + FAIL(); } } @@ -1197,16 +1634,29 @@ PERF_TEST_P(Sz_DoSort, ImgProc_HoughLines, Combine(GPU_TYPICAL_MAT_SIZES, Bool() cv::line(src, p1, p2, cv::Scalar::all(255), 2); } - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_lines; - cv::gpu::GpuMat d_accum; - cv::gpu::GpuMat d_buf; - - cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_lines; + cv::gpu::GpuMat d_accum; + cv::gpu::GpuMat d_buf; + cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); + + TEST_CYCLE() + { + cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); + } + } + else + { + std::vector lines; + cv::HoughLines(src, lines, rho, theta, threshold); + + TEST_CYCLE() + { + cv::HoughLines(src, lines, rho, theta, threshold); + } } } diff --git a/modules/gpu/perf/perf_labeling.cpp b/modules/gpu/perf/perf_labeling.cpp index bd1bcf144..f17dd7d0a 100644 --- a/modules/gpu/perf/perf_labeling.cpp +++ b/modules/gpu/perf/perf_labeling.cpp @@ -7,27 +7,129 @@ namespace { DEF_PARAM_TEST_1(Image, string); +struct GreedyLabeling +{ + struct dot + { + int x; + int y; + + static dot make(int i, int j) + { + dot d; d.x = i; d.y = j; + return d; + } + }; + + struct InInterval + { + InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {}; + const int lo, hi; + + bool operator() (const unsigned char a, const unsigned char b) const + { + int d = a - b; + return lo <= d && d <= hi; + } + }; + + GreedyLabeling(cv::Mat img) + : image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];} + + ~GreedyLabeling(){delete[] stack;} + + void operator() (cv::Mat labels) const + { + labels.setTo(cv::Scalar::all(-1)); + InInterval inInt(0, 2); + int cc = -1; + + int* dist_labels = (int*)labels.data; + int pitch = labels.step1(); + + unsigned char* source = (unsigned char*)image.data; + int width = image.cols; + int height = image.rows; + + for (int j = 0; j < image.rows; ++j) + for (int i = 0; i < image.cols; ++i) + { + if (dist_labels[j * pitch + i] != -1) continue; + + dot* top = stack; + dot p = dot::make(i, j); + cc++; + + dist_labels[j * pitch + i] = cc; + + while (top >= stack) + { + int* dl = &dist_labels[p.y * pitch + p.x]; + unsigned char* sp = &source[p.y * image.step1() + p.x]; + + dl[0] = cc; + + //right + if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1])) + *top++ = dot::make(p.x + 1, p.y); + + //left + if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1])) + *top++ = dot::make(p.x - 1, p.y); + + //bottom + if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()])) + *top++ = dot::make(p.x, p.y + 1); + + //top + if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()])) + *top++ = dot::make(p.x, p.y - 1); + + p = *--top; + } + } + } + + cv::Mat image; + cv::Mat _labels; + dot* stack; +}; + PERF_TEST_P(Image, Labeling_ConnectedComponents, Values("gpu/labeling/aloe-disp.png")) { - cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE); - - // cv::threshold(image, image, 150, 255, CV_THRESH_BINARY); - - cv::gpu::GpuMat mask; - mask.create(image.rows, image.cols, CV_8UC1); - - cv::gpu::GpuMat components; - components.create(image.rows, image.cols, CV_32SC1); - - cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2)); - - ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components)); - declare.time(1.0); - TEST_CYCLE() + cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + + if (runOnGpu) { - cv::gpu::labelComponents(mask, components); + cv::gpu::GpuMat mask; + mask.create(image.rows, image.cols, CV_8UC1); + + cv::gpu::GpuMat components; + components.create(image.rows, image.cols, CV_32SC1); + + cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2)); + + ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components)); + + TEST_CYCLE() + { + cv::gpu::labelComponents(mask, components); + } + } + else + { + GreedyLabeling host(image); + + host(host._labels); + + declare.time(1.0); + + TEST_CYCLE() + { + host(host._labels); + } } } diff --git a/modules/gpu/perf/perf_matop.cpp b/modules/gpu/perf/perf_matop.cpp index c014b19da..cdae962f2 100644 --- a/modules/gpu/perf/perf_matop.cpp +++ b/modules/gpu/perf/perf_matop.cpp @@ -18,13 +18,27 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 cv::Scalar val(1, 2, 3, 4); - cv::gpu::GpuMat d_src(size, type); - - d_src.setTo(val); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(size, type); + d_src.setTo(val); + + TEST_CYCLE() + { + d_src.setTo(val); + } + } + else + { + cv::Mat src(size, type); + + src.setTo(val); + + TEST_CYCLE() + { + src.setTo(val); + } } } @@ -47,14 +61,26 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Value cv::Scalar val(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_mask(mask); - - d_src.setTo(val, d_mask); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_mask(mask); + d_src.setTo(val, d_mask); + + TEST_CYCLE() + { + d_src.setTo(val, d_mask); + } + } + else + { + src.setTo(val, mask); + + TEST_CYCLE() + { + src.setTo(val, mask); + } } } @@ -75,15 +101,29 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu cv::Mat mask(size, CV_8UC1); fillRandom(mask, 0, 2); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_mask(mask); - cv::gpu::GpuMat d_dst; - - d_src.copyTo(d_dst, d_mask); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_mask(mask); + cv::gpu::GpuMat d_dst; + d_src.copyTo(d_dst, d_mask); + + TEST_CYCLE() + { + d_src.copyTo(d_dst, d_mask); + } + } + else + { + cv::Mat dst; + + src.copyTo(dst, mask); + + TEST_CYCLE() + { + src.copyTo(dst, mask); + } } } @@ -101,14 +141,28 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV cv::Mat src(size, depth1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - - d_src.convertTo(d_dst, depth2, 0.5, 1.0); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + d_src.convertTo(d_dst, depth2, 0.5, 1.0); + + TEST_CYCLE() + { + d_src.convertTo(d_dst, depth2, 0.5, 1.0); + } + } + else + { + cv::Mat dst; + + src.convertTo(dst, depth2, 0.5, 1.0); + + TEST_CYCLE() + { + src.convertTo(dst, depth2, 0.5, 1.0); + } } } diff --git a/modules/gpu/perf/perf_objdetect.cpp b/modules/gpu/perf/perf_objdetect.cpp index 9c1f7919f..0c4cd5e4c 100644 --- a/modules/gpu/perf/perf_objdetect.cpp +++ b/modules/gpu/perf/perf_objdetect.cpp @@ -17,16 +17,31 @@ PERF_TEST_P(Image, ObjDetect_HOG, Values("gpu/hog/road.png")) std::vector found_locations; - cv::gpu::GpuMat d_img(img); - - cv::gpu::HOGDescriptor d_hog; - d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); - - d_hog.detectMultiScale(d_img, found_locations); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_img(img); + + cv::gpu::HOGDescriptor d_hog; + d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); + d_hog.detectMultiScale(d_img, found_locations); + + TEST_CYCLE() + { + d_hog.detectMultiScale(d_img, found_locations); + } + } + else + { + cv::HOGDescriptor hog; + hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); + + hog.detectMultiScale(img, found_locations); + + TEST_CYCLE() + { + hog.detectMultiScale(img, found_locations); + } } } @@ -42,18 +57,34 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier, cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::CascadeClassifier_GPU d_cascade; - - ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); - - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_objects_buffer; - - d_cascade.detectMultiScale(d_img, d_objects_buffer); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::CascadeClassifier_GPU d_cascade; + ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_objects_buffer; + d_cascade.detectMultiScale(d_img, d_objects_buffer); + + TEST_CYCLE() + { + d_cascade.detectMultiScale(d_img, d_objects_buffer); + } + } + else + { + cv::CascadeClassifier cascade; + ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml"))); + + std::vector rects; + + cascade.detectMultiScale(img, rects); + + TEST_CYCLE() + { + cascade.detectMultiScale(img, rects); + } } } @@ -66,18 +97,34 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier, cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::CascadeClassifier_GPU d_cascade; - - ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); - - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_gpu_rects; - - d_cascade.detectMultiScale(d_img, d_gpu_rects); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::CascadeClassifier_GPU d_cascade; + ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_gpu_rects; + d_cascade.detectMultiScale(d_img, d_gpu_rects); + + TEST_CYCLE() + { + d_cascade.detectMultiScale(d_img, d_gpu_rects); + } + } + else + { + cv::CascadeClassifier cascade; + ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); + + std::vector rects; + + cascade.detectMultiScale(img, rects); + + TEST_CYCLE() + { + cascade.detectMultiScale(img, rects); + } } } diff --git a/modules/gpu/perf/perf_video.cpp b/modules/gpu/perf/perf_video.cpp index a5a1e4da5..7faea0b88 100644 --- a/modules/gpu/perf/perf_video.cpp +++ b/modules/gpu/perf/perf_video.cpp @@ -3,6 +3,14 @@ using namespace std; using namespace testing; +namespace cv +{ + template<> void Ptr::delete_obj() + { + cvReleaseBGStatModel(&obj); + } +} + namespace { ////////////////////////////////////////////////////// @@ -25,19 +33,26 @@ PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values(make_pair("gpu frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_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(d_frame0, d_frame1, d_u, d_v); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_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(d_frame0, d_frame1, d_u, d_v); + + TEST_CYCLE() + { + d_flow(d_frame0, d_frame1, d_u, d_v); + } + } + else + { + FAIL(); } } @@ -55,25 +70,32 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values(make_pair("g frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_fu, d_fv; - cv::gpu::GpuMat d_bu, d_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(d_frame0, d_frame1, d_fu, d_fv); - d_flow(d_frame1, d_frame0, d_bu, d_bv); - - cv::gpu::GpuMat d_newFrame; - cv::gpu::GpuMat d_buf; - - cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_fu, d_fv; + cv::gpu::GpuMat d_bu, d_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(d_frame0, d_frame1, d_fu, d_fv); + d_flow(d_frame1, d_frame0, d_bu, d_bv); + + cv::gpu::GpuMat d_newFrame; + cv::gpu::GpuMat d_buf; + cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); + + TEST_CYCLE() + { + cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); + } + } + else + { + FAIL(); } } @@ -91,23 +113,30 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values(mak frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_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(d_frame0, d_frame1, d_u, d_v); - - cv::gpu::GpuMat d_vertex, d_colors; - - cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_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(d_frame0, d_frame1, d_u, d_v); + + cv::gpu::GpuMat d_vertex, d_colors; + cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); + + TEST_CYCLE() + { + cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); + } + } + else + { + FAIL(); } } @@ -124,16 +153,30 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); - cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance); - - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_pts; - - d_detector(d_image, d_pts); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance); + + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_pts; + d_detector(d_image, d_pts); + + TEST_CYCLE() + { + d_detector(d_image, d_pts); + } + } + else + { + cv::Mat pts; + + cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance); + + TEST_CYCLE() + { + cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance); + } } } @@ -150,6 +193,8 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse Values(1, 2, 3), Values(1, 10, 30))) { + declare.time(20.0); + pair_string imagePair = GET_PARAM(0); bool useGray = GET_PARAM(1); int points = GET_PARAM(2); @@ -169,26 +214,45 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse else cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY); - cv::gpu::GpuMat d_pts; + cv::Mat pts; + cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0); - cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(points, 0.01, 0.0); - d_detector(cv::gpu::GpuMat(gray_frame), d_pts); - - cv::gpu::PyrLKOpticalFlow d_pyrLK; - d_pyrLK.winSize = cv::Size(winSize, winSize); - d_pyrLK.maxLevel = levels - 1; - d_pyrLK.iters = iters; - - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_nextPts; - cv::gpu::GpuMat d_status; - - d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_pts(pts); + + cv::gpu::PyrLKOpticalFlow d_pyrLK; + d_pyrLK.winSize = cv::Size(winSize, winSize); + d_pyrLK.maxLevel = levels - 1; + d_pyrLK.iters = iters; + + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_nextPts; + cv::gpu::GpuMat d_status; + d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); + + TEST_CYCLE() + { + d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); + } + } + else + { + cv::Mat nextPts; + cv::Mat status; + + cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), + cv::Size(winSize, winSize), levels - 1, + cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); + + TEST_CYCLE() + { + cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), + cv::Size(winSize, winSize), levels - 1, + cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); + } } } @@ -216,21 +280,28 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine( cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(frame1.empty()); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_v; - - cv::gpu::PyrLKOpticalFlow d_pyrLK; - d_pyrLK.winSize = cv::Size(winSize, winSize); - d_pyrLK.maxLevel = levels - 1; - d_pyrLK.iters = iters; - - d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; + + cv::gpu::PyrLKOpticalFlow d_pyrLK; + d_pyrLK.winSize = cv::Size(winSize, winSize); + d_pyrLK.maxLevel = levels - 1; + d_pyrLK.iters = iters; + d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); + + TEST_CYCLE() + { + d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); + } + } + else + { + FAIL(); } } @@ -247,18 +318,47 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values(make_pair cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(frame1.empty()); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_v; + int numLevels = 5; + double pyrScale = 0.5; + int winSize = 13; + int numIters = 10; + int polyN = 5; + double polySigma = 1.1; + int flags = 0; - cv::gpu::FarnebackOpticalFlow d_farneback; - - d_farneback(d_frame0, d_frame1, d_u, d_v); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; + + cv::gpu::FarnebackOpticalFlow d_farneback; + d_farneback.numLevels = numLevels; + d_farneback.pyrScale = pyrScale; + d_farneback.winSize = winSize; + d_farneback.numIters = numIters; + d_farneback.polyN = polyN; + d_farneback.polySigma = polySigma; + d_farneback.flags = flags; + d_farneback(d_frame0, d_frame1, d_u, d_v); + + TEST_CYCLE() + { + d_farneback(d_frame0, d_frame1, d_u, d_v); + } + } + else + { + cv::Mat flow; + + cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); + + TEST_CYCLE() + { + cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); + } } } @@ -269,7 +369,7 @@ DEF_PARAM_TEST_1(Video, string); PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) { - declare.time(10); + declare.time(60); string inputFile = perf::TestBase::getDataPath(GetParam()); @@ -280,20 +380,41 @@ PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/vide cap >> frame; ASSERT_FALSE(frame.empty()); - cv::gpu::GpuMat d_frame(frame); - cv::gpu::FGDStatModel d_model(4); - d_model.create(d_frame); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); - d_frame.upload(frame); + cv::gpu::FGDStatModel d_model(4); + d_model.create(d_frame); - startTimer(); next(); - d_model.update(d_frame); - stopTimer(); + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + d_frame.upload(frame); + + startTimer(); next(); + d_model.update(d_frame); + stopTimer(); + } + } + else + { + IplImage ipl_frame = frame; + cv::Ptr model(cvCreateFGDStatModel(&ipl_frame)); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + ipl_frame = frame; + + startTimer(); next(); + cvUpdateBGStatModel(&ipl_frame, model); + stopTimer(); + } } } @@ -313,10 +434,6 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576. cv::Mat frame; - cv::gpu::GpuMat d_frame; - cv::gpu::MOG_GPU d_mog; - cv::gpu::GpuMat d_foreground; - cap >> frame; ASSERT_FALSE(frame.empty()); @@ -330,30 +447,62 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576. cv::swap(temp, frame); } - d_frame.upload(frame); - - d_mog(d_frame, d_foreground, learningRate); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); + cv::gpu::MOG_GPU d_mog; + cv::gpu::GpuMat d_foreground; - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - d_frame.upload(frame); - - startTimer(); next(); d_mog(d_frame, d_foreground, learningRate); - stopTimer(); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_mog(d_frame, d_foreground, learningRate); + stopTimer(); + } + } + else + { + cv::BackgroundSubtractorMOG mog; + cv::Mat foreground; + + mog(frame, foreground, learningRate); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + startTimer(); next(); + mog(frame, foreground, learningRate); + stopTimer(); + } } } @@ -372,10 +521,6 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v cv::Mat frame; - cv::gpu::GpuMat d_frame; - cv::gpu::MOG2_GPU d_mog2; - cv::gpu::GpuMat d_foreground; - cap >> frame; ASSERT_FALSE(frame.empty()); @@ -389,30 +534,62 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v cv::swap(temp, frame); } - d_frame.upload(frame); - - d_mog2(d_frame, d_foreground); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); + cv::gpu::MOG2_GPU d_mog2; + cv::gpu::GpuMat d_foreground; - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - d_frame.upload(frame); - - startTimer(); next(); d_mog2(d_frame, d_foreground); - stopTimer(); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_mog2(d_frame, d_foreground); + stopTimer(); + } + } + else + { + cv::BackgroundSubtractorMOG2 mog2; + cv::Mat foreground; + + mog2(frame, foreground); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + startTimer(); next(); + mog2(frame, foreground); + stopTimer(); + } } } @@ -429,36 +606,70 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/76 cv::Mat frame; - cv::gpu::GpuMat d_frame; - cv::gpu::MOG2_GPU d_mog2; - cv::gpu::GpuMat d_foreground; - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame; + cv::gpu::MOG2_GPU d_mog2; + cv::gpu::GpuMat d_foreground; - if (cn != 3) + for (int i = 0; i < 10; ++i) { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + d_mog2(d_frame, d_foreground); } - d_frame.upload(frame); - - d_mog2(d_frame, d_foreground); - } - - cv::gpu::GpuMat d_background; - d_mog2.getBackgroundImage(d_background); - - TEST_CYCLE() - { + cv::gpu::GpuMat d_background; d_mog2.getBackgroundImage(d_background); + + TEST_CYCLE() + { + d_mog2.getBackgroundImage(d_background); + } + } + else + { + cv::BackgroundSubtractorMOG2 mog2; + cv::Mat foreground; + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + mog2(frame, foreground); + } + + cv::Mat background; + mog2.getBackgroundImage(background); + + TEST_CYCLE() + { + mog2.getBackgroundImage(background); + } } } @@ -487,32 +698,39 @@ PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/v cv::swap(temp, frame); } - cv::gpu::GpuMat d_frame(frame); - cv::gpu::VIBE_GPU d_vibe; - cv::gpu::GpuMat d_foreground; - - d_vibe(d_frame, d_foreground); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); + cv::gpu::VIBE_GPU d_vibe; + cv::gpu::GpuMat d_foreground; - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - d_frame.upload(frame); - - startTimer(); next(); d_vibe(d_frame, d_foreground); - stopTimer(); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_vibe(d_frame, d_foreground); + stopTimer(); + } + } + else + { + FAIL(); } } @@ -544,38 +762,76 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a cv::swap(temp, frame); } - cv::gpu::GpuMat d_frame(frame); - cv::gpu::GpuMat d_fgmask; - - cv::gpu::GMG_GPU d_gmg; - d_gmg.maxFeatures = maxFeatures; - - d_gmg(d_frame, d_fgmask); - - for (int i = 0; i < 150; ++i) + if (runOnGpu) { - cap >> frame; - if (frame.empty()) - { - cap.open(inputFile); - cap >> frame; - } + cv::gpu::GpuMat d_frame(frame); + cv::gpu::GpuMat d_fgmask; - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } + cv::gpu::GMG_GPU d_gmg; + d_gmg.maxFeatures = maxFeatures; - d_frame.upload(frame); - - startTimer(); next(); d_gmg(d_frame, d_fgmask); - stopTimer(); + + for (int i = 0; i < 150; ++i) + { + cap >> frame; + if (frame.empty()) + { + cap.open(inputFile); + cap >> frame; + } + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_gmg(d_frame, d_fgmask); + stopTimer(); + } + } + else + { + cv::Mat fgmask; + cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0)); + + cv::BackgroundSubtractorGMG gmg; + gmg.set("maxFeatures", maxFeatures); + gmg.initialize(frame.size(), 0.0, 255.0); + + gmg(frame, fgmask); + + for (int i = 0; i < 150; ++i) + { + cap >> frame; + if (frame.empty()) + { + cap.open(inputFile); + cap >> frame; + } + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + startTimer(); next(); + gmg(frame, fgmask); + stopTimer(); + } } } @@ -584,6 +840,8 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) { + declare.time(30); + string inputFile = perf::TestBase::getDataPath(GetParam()); string outputFile = cv::tempfile(".avi"); @@ -592,26 +850,45 @@ PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video cv::VideoCapture reader(inputFile); ASSERT_TRUE( reader.isOpened() ); - cv::gpu::VideoWriter_GPU d_writer; - cv::Mat frame; - cv::gpu::GpuMat d_frame; - declare.time(10); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - reader >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::VideoWriter_GPU d_writer; - d_frame.upload(frame); + cv::gpu::GpuMat d_frame; - if (!d_writer.isOpened()) - d_writer.open(outputFile, frame.size(), FPS); + for (int i = 0; i < 10; ++i) + { + reader >> frame; + ASSERT_FALSE(frame.empty()); - startTimer(); next(); - d_writer.write(d_frame); - stopTimer(); + d_frame.upload(frame); + + if (!d_writer.isOpened()) + d_writer.open(outputFile, frame.size(), FPS); + + startTimer(); next(); + d_writer.write(d_frame); + stopTimer(); + } + } + else + { + cv::VideoWriter writer; + + for (int i = 0; i < 10; ++i) + { + reader >> frame; + ASSERT_FALSE(frame.empty()); + + if (!writer.isOpened()) + writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size()); + + startTimer(); next(); + writer.write(frame); + stopTimer(); + } } } @@ -624,16 +901,33 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video string inputFile = perf::TestBase::getDataPath(GetParam()); - cv::gpu::VideoReader_GPU d_reader(inputFile); - ASSERT_TRUE( d_reader.isOpened() ); - - cv::gpu::GpuMat d_frame; - - d_reader.read(d_frame); - - TEST_CYCLE_N(10) + if (runOnGpu) { + cv::gpu::VideoReader_GPU d_reader(inputFile); + ASSERT_TRUE( d_reader.isOpened() ); + + cv::gpu::GpuMat d_frame; + d_reader.read(d_frame); + + TEST_CYCLE_N(10) + { + d_reader.read(d_frame); + } + } + else + { + cv::VideoCapture reader(inputFile); + ASSERT_TRUE( reader.isOpened() ); + + cv::Mat frame; + + reader >> frame; + + TEST_CYCLE_N(10) + { + reader >> frame; + } } } diff --git a/modules/gpu/perf_cpu/perf_calib3d.cpp b/modules/gpu/perf_cpu/perf_calib3d.cpp deleted file mode 100644 index 8124b808a..000000000 --- a/modules/gpu/perf_cpu/perf_calib3d.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// StereoBM - -GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo) -{ - cv::Mat img_l = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_l.empty()); - - cv::Mat img_r = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_r.empty()); - - cv::StereoBM bm(0, 256); - - cv::Mat dst; - - bm(img_l, img_r, dst); - - declare.time(5.0); - - TEST_CYCLE() - { - bm(img_l, img_r, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// ProjectPoints - -IMPLEMENT_PARAM_CLASS(Count, int) - -GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count) -{ - int count = GET_PARAM(1); - - cv::Mat src(1, count, CV_32FC3); - fill(src, -100, 100); - - cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); - cv::Mat dst; - - cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); - - TEST_CYCLE() - { - cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - -////////////////////////////////////////////////////////////////////// -// SolvePnPRansac - -GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count) -{ - int count = GET_PARAM(1); - - cv::Mat object(1, count, CV_32FC3); - fill(object, -100, 100); - - cv::Mat camera_mat(3, 3, CV_32FC1); - fill(camera_mat, 0.5, 1); - camera_mat.at(0, 1) = 0.f; - camera_mat.at(1, 0) = 0.f; - camera_mat.at(2, 0) = 0.f; - camera_mat.at(2, 1) = 0.f; - - cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); - - std::vector image_vec; - cv::Mat rvec_gold(1, 3, CV_32FC1); - fill(rvec_gold, 0, 1); - cv::Mat tvec_gold(1, 3, CV_32FC1); - fill(tvec_gold, 0, 1); - cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec); - - cv::Mat image(1, count, CV_32FC2, &image_vec[0]); - - cv::Mat rvec; - cv::Mat tvec; - - cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - - declare.time(10.0); - - TEST_CYCLE() - { - cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - -////////////////////////////////////////////////////////////////////// -// ReprojectImageTo3D - -GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 5.0, 30.0); - - cv::Mat Q(4, 4, CV_32FC1); - fill(Q, 0.1, 1.0); - - cv::Mat dst; - - cv::reprojectImageTo3D(src, dst, Q); - - TEST_CYCLE() - { - cv::reprojectImageTo3D(src, dst, Q); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, ReprojectImageTo3D, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S))); - -#endif - diff --git a/modules/gpu/perf_cpu/perf_core.cpp b/modules/gpu/perf_cpu/perf_core.cpp deleted file mode 100644 index fb8700958..000000000 --- a/modules/gpu/perf_cpu/perf_core.cpp +++ /dev/null @@ -1,1388 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// Merge - -GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - std::vector src(channels); - for (int i = 0; i < channels; ++i) - src[i] = cv::Mat(size, depth, cv::Scalar::all(i)); - - cv::Mat dst; - - cv::merge(src, dst); - - TEST_CYCLE() - { - cv::merge(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Merge, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(2, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Split - -GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - cv::Mat src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); - - std::vector dst; - - cv::split(src, dst); - - TEST_CYCLE() - { - cv::split(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Split, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(2, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Add_Mat - -GPU_PERF_TEST(Add_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::add(src1, src2, dst); - - TEST_CYCLE() - { - cv::add(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Add_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Add_Scalar - -GPU_PERF_TEST(Add_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::add(src, s, dst); - - TEST_CYCLE() - { - cv::add(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Add_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Subtract_Mat - -GPU_PERF_TEST(Subtract_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::subtract(src1, src2, dst); - - TEST_CYCLE() - { - cv::subtract(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Subtract_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Subtract_Scalar - -GPU_PERF_TEST(Subtract_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::subtract(src, s, dst); - - TEST_CYCLE() - { - cv::subtract(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Subtract_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Multiply_Mat - -GPU_PERF_TEST(Multiply_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::multiply(src1, src2, dst); - - TEST_CYCLE() - { - cv::multiply(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Multiply_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Multiply_Scalar - -GPU_PERF_TEST(Multiply_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::multiply(src, s, dst); - - TEST_CYCLE() - { - cv::multiply(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Multiply_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Divide_Mat - -GPU_PERF_TEST(Divide_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::divide(src1, src2, dst); - - TEST_CYCLE() - { - cv::divide(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Divide_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Divide_Scalar - -GPU_PERF_TEST(Divide_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::divide(src, s, dst); - - TEST_CYCLE() - { - cv::divide(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Divide_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Divide_Scalar_Inv - -GPU_PERF_TEST(Divide_Scalar_Inv, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - double scale = 100.0; - cv::Mat dst; - - cv::divide(scale, src, dst); - - TEST_CYCLE() - { - cv::divide(scale, src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Divide_Scalar_Inv, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// AbsDiff_Mat - -GPU_PERF_TEST(AbsDiff_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::absdiff(src1, src2, dst); - - TEST_CYCLE() - { - cv::absdiff(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, AbsDiff_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// AbsDiff_Scalar - -GPU_PERF_TEST(AbsDiff_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::absdiff(src, s, dst); - - TEST_CYCLE() - { - cv::absdiff(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, AbsDiff_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Sqrt - -GPU_PERF_TEST(Sqrt, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Mat dst; - - cv::sqrt(src, dst); - - TEST_CYCLE() - { - cv::sqrt(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Sqrt, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Log - -GPU_PERF_TEST(Log, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 1.0, 100.0); - - cv::Mat dst; - - cv::log(src, dst); - - TEST_CYCLE() - { - cv::log(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Log, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Exp - -GPU_PERF_TEST(Exp, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 1.0, 10.0); - - cv::Mat dst; - - cv::exp(src, dst); - - TEST_CYCLE() - { - cv::exp(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Exp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Pow - -GPU_PERF_TEST(Pow, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 1.0, 10.0); - - cv::Mat dst; - - cv::pow(src, 2.3, dst); - - TEST_CYCLE() - { - cv::pow(src, 2.3, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Pow, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Compare_Mat - -CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE) -#define ALL_CMP_CODES testing::Values(CmpCode(cv::CMP_EQ), CmpCode(cv::CMP_NE), CmpCode(cv::CMP_GT), CmpCode(cv::CMP_GE), CmpCode(cv::CMP_LT), CmpCode(cv::CMP_LE)) - -GPU_PERF_TEST(Compare_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int cmp_code = GET_PARAM(3); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::compare(src1, src2, dst, cmp_code); - - TEST_CYCLE() - { - cv::compare(src1, src2, dst, cmp_code); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Compare_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - ALL_CMP_CODES)); - -////////////////////////////////////////////////////////////////////// -// Compare_Scalar - -GPU_PERF_TEST(Compare_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int cmp_code = GET_PARAM(3); - - cv::Mat src(size, depth); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar::all(50); - cv::Mat dst; - - cv::compare(src, s, dst, cmp_code); - - TEST_CYCLE() - { - cv::compare(src, s, dst, cmp_code); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Compare_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - ALL_CMP_CODES)); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Not - -GPU_PERF_TEST(Bitwise_Not, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_not(src, dst); - - TEST_CYCLE() - { - cv::bitwise_not(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Not, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_And_Mat - -GPU_PERF_TEST(Bitwise_And_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_and(src1, src2, dst); - - TEST_CYCLE() - { - cv::bitwise_and(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_And_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_And_Scalar - -GPU_PERF_TEST(Bitwise_And_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::Mat dst; - - cv::bitwise_and(src, s, dst); - - TEST_CYCLE() - { - cv::bitwise_and(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_And_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Or_Mat - -GPU_PERF_TEST(Bitwise_Or_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_or(src1, src2, dst); - - TEST_CYCLE() - { - cv::bitwise_or(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Or_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Or_Scalar - -GPU_PERF_TEST(Bitwise_Or_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::Mat dst; - - cv::bitwise_or(src, s, dst); - - TEST_CYCLE() - { - cv::bitwise_or(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Or_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Xor_Mat - -GPU_PERF_TEST(Bitwise_Xor_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_xor(src1, src2, dst); - - TEST_CYCLE() - { - cv::bitwise_xor(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Xor_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Xor_Scalar - -GPU_PERF_TEST(Bitwise_Xor_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::Mat dst; - - cv::bitwise_xor(src, s, dst); - - TEST_CYCLE() - { - cv::bitwise_xor(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Xor_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Min_Mat - -GPU_PERF_TEST(Min_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 255.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 255.0); - - cv::Mat dst; - - cv::min(src1, src2, dst); - - TEST_CYCLE() - { - cv::min(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Min_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Min_Scalar - -GPU_PERF_TEST(Min_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 255.0); - - double val = 50.0; - cv::Mat dst; - - cv::min(src, val, dst); - - TEST_CYCLE() - { - cv::min(src, val, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Min_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Max_Mat - -GPU_PERF_TEST(Max_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 255.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 255.0); - - cv::Mat dst; - - cv::max(src1, src2, dst); - - TEST_CYCLE() - { - cv::max(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Max_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Max_Scalar - -GPU_PERF_TEST(Max_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 255.0); - - double val = 50.0; - cv::Mat dst; - - cv::max(src, val, dst); - - TEST_CYCLE() - { - cv::max(src, val, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Max_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// AddWeighted - -GPU_PERF_TEST(AddWeighted, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth1 = GET_PARAM(2); - int depth2 = GET_PARAM(3); - int dst_depth = GET_PARAM(4); - - cv::Mat src1(size, depth1); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth2); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); - - TEST_CYCLE() - { - cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); - } -} - -INSTANTIATE_TEST_CASE_P(Core, AddWeighted, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// GEMM - -CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T) -#define ALL_GEMM_FLAGS testing::Values(GemmFlags(0), GemmFlags(cv::GEMM_1_T), GemmFlags(cv::GEMM_2_T), GemmFlags(cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T)) - -GPU_PERF_TEST(GEMM, cv::gpu::DeviceInfo, cv::Size, MatType, GemmFlags) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int flags = GET_PARAM(3); - - cv::Mat src1(size, type); - fill(src1, 0.0, 10.0); - - cv::Mat src2(size, type); - fill(src2, 0.0, 10.0); - - cv::Mat src3(size, type); - fill(src3, 0.0, 10.0); - - cv::Mat dst; - - cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); - - declare.time(50.0); - - TEST_CYCLE() - { - cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); - } -} - -INSTANTIATE_TEST_CASE_P(Core, GEMM, testing::Combine( - ALL_DEVICES, - testing::Values(cv::Size(512, 512), cv::Size(1024, 1024)), - testing::Values(CV_32FC1, CV_32FC2, CV_64FC1, CV_64FC2), - ALL_GEMM_FLAGS)); - -////////////////////////////////////////////////////////////////////// -// Transpose - -GPU_PERF_TEST(Transpose, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat dst; - - cv::transpose(src, dst); - - TEST_CYCLE() - { - cv::transpose(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Transpose, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1))); - -////////////////////////////////////////////////////////////////////// -// Flip - -enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1}; -CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y) -#define ALL_FLIP_CODES testing::Values(FlipCode(FLIP_BOTH), FlipCode(FLIP_X), FlipCode(FLIP_Y)) - -GPU_PERF_TEST(Flip, cv::gpu::DeviceInfo, cv::Size, MatType, FlipCode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int flipCode = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat dst; - - cv::flip(src, dst, flipCode); - - TEST_CYCLE() - { - cv::flip(src, dst, flipCode); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Flip, 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), - ALL_FLIP_CODES)); - -////////////////////////////////////////////////////////////////////// -// LUT_OneChannel - -GPU_PERF_TEST(LUT_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat lut(1, 256, CV_8UC1); - fill(lut, 0.0, 100.0); - - cv::Mat dst; - - cv::LUT(src, lut, dst); - - TEST_CYCLE() - { - cv::LUT(src, lut, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, LUT_OneChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3))); - -////////////////////////////////////////////////////////////////////// -// LUT_MultiChannel - -GPU_PERF_TEST(LUT_MultiChannel, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels())); - fill(lut, 0.0, 100.0); - - cv::Mat dst; - - cv::LUT(src, lut, dst); - - TEST_CYCLE() - { - cv::LUT(src, lut, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, LUT_MultiChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC3))); - -////////////////////////////////////////////////////////////////////// -// Magnitude_Complex - -GPU_PERF_TEST(Magnitude_Complex, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_32FC2); - fill(src, -100.0, 100.0); - - cv::Mat srcs[2]; - cv::split(src, srcs); - - cv::Mat dst; - - cv::magnitude(srcs[0], srcs[1], dst); - - TEST_CYCLE() - { - cv::magnitude(srcs[0], srcs[1], dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Magnitude_Complex, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Magnitude - -GPU_PERF_TEST(Magnitude, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src1(size, CV_32FC1); - fill(src1, -100.0, 100.0); - - cv::Mat src2(size, CV_32FC1); - fill(src2, -100.0, 100.0); - - cv::Mat dst; - - cv::magnitude(src1, src2, dst); - - TEST_CYCLE() - { - cv::magnitude(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Magnitude, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Phase - -IMPLEMENT_PARAM_CLASS(AngleInDegrees, bool) - -GPU_PERF_TEST(Phase, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) -{ - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); - - cv::Mat src1(size, CV_32FC1); - fill(src1, -100.0, 100.0); - - cv::Mat src2(size, CV_32FC1); - fill(src2, -100.0, 100.0); - - cv::Mat dst; - - cv::phase(src1, src2, dst, angleInDegrees); - - TEST_CYCLE() - { - cv::phase(src1, src2, dst, angleInDegrees); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Phase, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - -////////////////////////////////////////////////////////////////////// -// CartToPolar - -GPU_PERF_TEST(CartToPolar, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) -{ - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); - - cv::Mat src1(size, CV_32FC1); - fill(src1, -100.0, 100.0); - - cv::Mat src2(size, CV_32FC1); - fill(src2, -100.0, 100.0); - - cv::Mat magnitude; - cv::Mat angle; - - cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); - - TEST_CYCLE() - { - cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); - } -} - -INSTANTIATE_TEST_CASE_P(Core, CartToPolar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - -////////////////////////////////////////////////////////////////////// -// PolarToCart - -GPU_PERF_TEST(PolarToCart, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) -{ - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); - - cv::Mat magnitude(size, CV_32FC1); - fill(magnitude, 0.0, 100.0); - - cv::Mat angle(size, CV_32FC1); - fill(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI); - - cv::Mat x; - cv::Mat y; - - cv::polarToCart(magnitude, angle, x, y, angleInDegrees); - - TEST_CYCLE() - { - cv::polarToCart(magnitude, angle, x, y, angleInDegrees); - } -} - -INSTANTIATE_TEST_CASE_P(Core, PolarToCart, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - -////////////////////////////////////////////////////////////////////// -// MeanStdDev - -GPU_PERF_TEST(MeanStdDev, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_8UC1); - fill(src, 0.0, 255.0); - - cv::Scalar mean; - cv::Scalar stddev; - - cv::meanStdDev(src, mean, stddev); - - TEST_CYCLE() - { - cv::meanStdDev(src, mean, stddev); - } -} - -INSTANTIATE_TEST_CASE_P(Core, MeanStdDev, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Norm - -GPU_PERF_TEST(Norm, cv::gpu::DeviceInfo, cv::Size, MatDepth, NormType) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int normType = GET_PARAM(3); - - cv::Mat src(size, depth); - fill(src, 0.0, 255.0); - - double dst; - cv::Mat buf; - - dst = cv::norm(src, normType); - - TEST_CYCLE() - { - dst = cv::norm(src, normType); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Norm, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S, CV_32F), - testing::Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))); - -////////////////////////////////////////////////////////////////////// -// NormDiff - -GPU_PERF_TEST(NormDiff, cv::gpu::DeviceInfo, cv::Size, NormType) -{ - cv::Size size = GET_PARAM(1); - int normType = GET_PARAM(2); - - cv::Mat src1(size, CV_8UC1); - fill(src1, 0.0, 255.0); - - cv::Mat src2(size, CV_8UC1); - fill(src2, 0.0, 255.0); - - double dst; - - dst = cv::norm(src1, src2, normType); - - TEST_CYCLE() - { - dst = cv::norm(src1, src2, normType); - } -} - -INSTANTIATE_TEST_CASE_P(Core, NormDiff, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))); - -////////////////////////////////////////////////////////////////////// -// Sum - -GPU_PERF_TEST(Sum, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Scalar dst; - - dst = cv::sum(src); - - TEST_CYCLE() - { - dst = cv::sum(src); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Sum, 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))); - -////////////////////////////////////////////////////////////////////// -// MinMaxLoc - -GPU_PERF_TEST(MinMaxLoc, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 255.0); - - double minVal, maxVal; - cv::Point minLoc, maxLoc; - - cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); - - TEST_CYCLE() - { - cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); - } -} - -INSTANTIATE_TEST_CASE_P(Core, MinMaxLoc, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// CountNonZero - -GPU_PERF_TEST(CountNonZero, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 1.5); - - int dst; - - dst = cv::countNonZero(src); - - TEST_CYCLE() - { - dst = cv::countNonZero(src); - } -} - -INSTANTIATE_TEST_CASE_P(Core, CountNonZero, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Reduce - -CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) -#define ALL_REDUCE_CODES testing::Values(CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) - -enum {Rows = 0, Cols = 1}; -CV_ENUM(ReduceDim, Rows, Cols) - -GPU_PERF_TEST(Reduce, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, ReduceCode, ReduceDim) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - int reduceOp = GET_PARAM(4); - int dim = GET_PARAM(5); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0.0, 10.0); - - cv::Mat dst; - - cv::reduce(src, dst, dim, reduceOp); - - TEST_CYCLE() - { - cv::reduce(src, dst, dim, reduceOp); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Reduce, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_16S, CV_32F), - testing::Values(1, 2, 3, 4), - ALL_REDUCE_CODES, - testing::Values(ReduceDim(Rows), ReduceDim(Cols)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_cpu_precomp.cpp b/modules/gpu/perf_cpu/perf_cpu_precomp.cpp deleted file mode 100644 index d947dd025..000000000 --- a/modules/gpu/perf_cpu/perf_cpu_precomp.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "perf_cpu_precomp.hpp" diff --git a/modules/gpu/perf_cpu/perf_cpu_precomp.hpp b/modules/gpu/perf_cpu/perf_cpu_precomp.hpp deleted file mode 100644 index 12680c7a0..000000000 --- a/modules/gpu/perf_cpu/perf_cpu_precomp.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX -#endif - -#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 "opencv2/legacy/legacy.hpp" - -#include "perf_utility.hpp" - -#ifdef GTEST_CREATE_SHARED_LIBRARY -#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined -#endif - -#endif diff --git a/modules/gpu/perf_cpu/perf_features2d.cpp b/modules/gpu/perf_cpu/perf_features2d.cpp deleted file mode 100644 index 74579a64a..000000000 --- a/modules/gpu/perf_cpu/perf_features2d.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// SURF - -GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::SURF surf; - - std::vector keypoints; - cv::Mat descriptors; - - surf(img, cv::noArray(), keypoints, descriptors); - - declare.time(50.0); - - TEST_CYCLE() - { - keypoints.clear(); - surf(img, cv::noArray(), keypoints, descriptors); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// FAST - -GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - std::vector keypoints; - - cv::FAST(img, keypoints, 20); - - TEST_CYCLE() - { - keypoints.clear(); - cv::FAST(img, keypoints, 20); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// ORB - -GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::ORB orb(4000); - - std::vector keypoints; - cv::Mat descriptors; - - orb(img, cv::noArray(), keypoints, descriptors); - - TEST_CYCLE() - { - keypoints.clear(); - orb(img, cv::noArray(), keypoints, descriptors); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_match - -IMPLEMENT_PARAM_CLASS(DescriptorSize, int) - -GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType) -{ - int desc_size = GET_PARAM(1); - int normType = GET_PARAM(2); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query(3000, desc_size, type); - fill(query, 0.0, 10.0); - - cv::Mat train(3000, desc_size, type); - fill(train, 0.0, 10.0); - - cv::BFMatcher matcher(normType); - - std::vector matches; - - matcher.match(query, train, matches); - - declare.time(20.0); - - TEST_CYCLE() - { - matcher.match(query, train, matches); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_knnMatch - -IMPLEMENT_PARAM_CLASS(K, int) - -GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType) -{ - int desc_size = GET_PARAM(1); - int k = GET_PARAM(2); - int normType = GET_PARAM(3); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query(3000, desc_size, type); - fill(query, 0.0, 10.0); - - cv::Mat train(3000, desc_size, type); - fill(train, 0.0, 10.0); - - cv::BFMatcher matcher(normType); - - std::vector< std::vector > matches; - - matcher.knnMatch(query, train, matches, k); - - declare.time(30.0); - - TEST_CYCLE() - { - matcher.knnMatch(query, train, matches, k); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(K(2), K(3)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_radiusMatch - -GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType) -{ - int desc_size = GET_PARAM(1); - int normType = GET_PARAM(2); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query(3000, desc_size, type); - fill(query, 0.0, 1.0); - - cv::Mat train(3000, desc_size, type); - fill(train, 0.0, 1.0); - - cv::BFMatcher matcher(normType); - - std::vector< std::vector > matches; - - matcher.radiusMatch(query, train, matches, 2.0); - - declare.time(30.0); - - TEST_CYCLE() - { - matcher.radiusMatch(query, train, matches, 2.0); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_filters.cpp b/modules/gpu/perf_cpu/perf_filters.cpp deleted file mode 100644 index ab0be3bad..000000000 --- a/modules/gpu/perf_cpu/perf_filters.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -IMPLEMENT_PARAM_CLASS(KernelSize, int) - -////////////////////////////////////////////////////////////////////// -// Blur - -GPU_PERF_TEST(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::blur(src, dst, cv::Size(ksize, ksize)); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::blur(src, dst, cv::Size(ksize, ksize)); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Blur, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7)))); - -////////////////////////////////////////////////////////////////////// -// Sobel - -GPU_PERF_TEST(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Sobel(src, dst, -1, 1, 1, ksize); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::Sobel(src, dst, -1, 1, 1, ksize); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Sobel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -////////////////////////////////////////////////////////////////////// -// Scharr - -GPU_PERF_TEST(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Scharr(src, dst, -1, 1, 0); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::Scharr(src, dst, -1, 1, 0); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Scharr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)))); - -////////////////////////////////////////////////////////////////////// -// GaussianBlur - -GPU_PERF_TEST(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, GaussianBlur, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -////////////////////////////////////////////////////////////////////// -// Laplacian - -GPU_PERF_TEST(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Laplacian(src, dst, -1, ksize); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::Laplacian(src, dst, -1, ksize); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Laplacian, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)), - testing::Values(KernelSize(1), KernelSize(3)))); - -////////////////////////////////////////////////////////////////////// -// Erode - -GPU_PERF_TEST(Erode, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - - cv::Mat dst; - - cv::erode(src, dst, ker); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::erode(src, dst, ker); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Erode, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); - -////////////////////////////////////////////////////////////////////// -// Dilate - -GPU_PERF_TEST(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - - cv::Mat dst; - - cv::dilate(src, dst, ker); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::dilate(src, dst, ker); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Dilate, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); - -////////////////////////////////////////////////////////////////////// -// MorphologyEx - -CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT) -#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT)) - -GPU_PERF_TEST(MorphologyEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int morphOp = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - - cv::morphologyEx(src, dst, morphOp, ker); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::morphologyEx(src, dst, morphOp, ker); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, MorphologyEx, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)), - ALL_MORPH_OPS)); - -////////////////////////////////////////////////////////////////////// -// Filter2D - -GPU_PERF_TEST(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat kernel(ksize, ksize, CV_32FC1); - fill(kernel, 0.0, 1.0); - - cv::Mat dst; - - cv::filter2D(src, dst, -1, kernel); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::filter2D(src, dst, -1, kernel); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Filter2D, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_imgproc.cpp b/modules/gpu/perf_cpu/perf_imgproc.cpp deleted file mode 100644 index 1b3c0951c..000000000 --- a/modules/gpu/perf_cpu/perf_imgproc.cpp +++ /dev/null @@ -1,771 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// Remap - -GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat xmap(size, CV_32FC1); - fill(xmap, 0, size.width); - - cv::Mat ymap(size, CV_32FC1); - fill(ymap, 0, size.height); - - cv::Mat dst; - - cv::remap(src, dst, xmap, ymap, interpolation, borderMode); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::remap(src, dst, xmap, ymap, interpolation, borderMode); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - - -////////////////////////////////////////////////////////////////////// -// Resize - -IMPLEMENT_PARAM_CLASS(Scale, double) - -GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Scale) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - double f = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::resize(src, dst, cv::Size(), f, f, interpolation); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::resize(src, dst, cv::Size(), f, f, interpolation); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), - Interpolation(cv::INTER_CUBIC), Interpolation(cv::INTER_AREA)), - testing::Values(Scale(0.5), Scale(0.3), Scale(2.0)))); - -GPU_PERF_TEST(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, Scale) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = cv::INTER_AREA; - double f = GET_PARAM(3); - - cv::Mat src_host(size, type); - fill(src_host, 0, 255); - - cv::Mat src(src_host); - cv::Mat dst; - - cv::resize(src, dst, cv::Size(), f, f, interpolation); - - declare.time(1.0); - - TEST_CYCLE() - { - cv::resize(src, dst, cv::Size(), f, f, interpolation); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, ResizeArea, testing::Combine( - ALL_DEVICES, - testing::Values(perf::sz1080p, cv::Size(4096, 2048)), - testing::Values(MatType(CV_8UC1)/*, MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)*/), - testing::Values(Scale(0.2),Scale(0.1),Scale(0.05)))); - -////////////////////////////////////////////////////////////////////// -// WarpAffine - -GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - const double aplha = CV_PI / 4; - double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, - {std::sin(aplha), std::cos(aplha), 0}}; - cv::Mat M(2, 3, CV_64F, (void*) mat); - - cv::warpAffine(src, dst, M, size, interpolation, borderMode); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::warpAffine(src, dst, M, size, interpolation, borderMode); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - -////////////////////////////////////////////////////////////////////// -// WarpPerspective - -GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - const double aplha = CV_PI / 4; - double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, - {std::sin(aplha), std::cos(aplha), 0}, - {0.0, 0.0, 1.0}}; - cv::Mat M(3, 3, CV_64F, (void*) mat); - - cv::warpPerspective(src, dst, M, size, interpolation, borderMode); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::warpPerspective(src, dst, M, size, interpolation, borderMode); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - -////////////////////////////////////////////////////////////////////// -// CopyMakeBorder - -GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int borderType = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); - - TEST_CYCLE() - { - cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - -////////////////////////////////////////////////////////////////////// -// 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)) - -GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, MatDepth, ThreshOp) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int threshOp = GET_PARAM(3); - - cv::Mat src(size, depth); - fill(src, 0, 255); - - cv::Mat dst; - - cv::threshold(src, dst, 100.0, 255.0, threshOp); - - TEST_CYCLE() - { - cv::threshold(src, dst, 100.0, 255.0, threshOp); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)), - ALL_THRESH_OPS)); - -////////////////////////////////////////////////////////////////////// -// Integral - -GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_8UC1); - fill(src, 0, 255); - - cv::Mat dst; - - cv::integral(src, dst); - - TEST_CYCLE() - { - cv::integral(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// HistEven_OneChannel - -GPU_PERF_TEST(HistEven_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 255); - - int hbins = 30; - float hranges[] = {0.0f, 180.0f}; - cv::Mat hist; - int histSize[] = {hbins}; - const float* ranges[] = {hranges}; - int channels[] = {0}; - - cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); - - TEST_CYCLE() - { - cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_OneChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S)))); - -////////////////////////////////////////////////////////////////////// -// EqualizeHist - -GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_8UC1); - fill(src, 0, 255); - - cv::Mat dst; - - cv::equalizeHist(src, dst); - - TEST_CYCLE() - { - cv::equalizeHist(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Canny - -IMPLEMENT_PARAM_CLASS(AppertureSize, int) -IMPLEMENT_PARAM_CLASS(L2gradient, bool) - -GPU_PERF_TEST(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient) -{ - int apperture_size = GET_PARAM(1); - bool useL2gradient = GET_PARAM(2); - - cv::Mat image = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image.empty()); - - cv::Mat dst; - - cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); - - TEST_CYCLE() - { - cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine( - ALL_DEVICES, - testing::Values(AppertureSize(3), AppertureSize(5)), - testing::Values(L2gradient(false), L2gradient(true)))); - -////////////////////////////////////////////////////////////////////// -// MeanShiftFiltering - -GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/meanshift/cones.png"); - ASSERT_FALSE(img.empty()); - - cv::Mat dst; - - cv::pyrMeanShiftFiltering(img, dst, 50, 50); - - declare.time(15.0); - - TEST_CYCLE() - { - cv::pyrMeanShiftFiltering(img, dst, 50, 50); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// Convolve - -IMPLEMENT_PARAM_CLASS(KSize, int) -IMPLEMENT_PARAM_CLASS(Ccorr, bool) - -GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr) -{ - cv::Size size = GET_PARAM(1); - int templ_size = GET_PARAM(2); - bool ccorr = GET_PARAM(3); - - ASSERT_FALSE(ccorr); - - cv::Mat image(size, CV_32FC1); - image.setTo(1.0); - - cv::Mat templ(templ_size, templ_size, CV_32FC1); - templ.setTo(1.0); - - cv::Mat dst; - - cv::filter2D(image, dst, image.depth(), templ); - - declare.time(10.0); - - TEST_CYCLE() - { - cv::filter2D(image, dst, image.depth(), templ); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(KSize(3), KSize(9), KSize(17), KSize(27), KSize(32), KSize(64)), - testing::Values(Ccorr(false), Ccorr(true)))); - -//////////////////////////////////////////////////////////////////////////////// -// MatchTemplate_8U - -CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED) -#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED)) - -IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size) - -GPU_PERF_TEST(MatchTemplate_8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod) -{ - cv::Size size = GET_PARAM(1); - cv::Size templ_size = GET_PARAM(2); - int cn = GET_PARAM(3); - int method = GET_PARAM(4); - - cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn)); - fill(image, 0, 255); - - cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn)); - fill(templ, 0, 255); - - cv::Mat dst; - - cv::matchTemplate(image, templ, dst, method); - - TEST_CYCLE() - { - cv::matchTemplate(image, templ, dst, method); - } -}; - -INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_8U, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))), - testing::Values(Channels(1), Channels(3), Channels(4)), - ALL_TEMPLATE_METHODS)); - -//////////////////////////////////////////////////////////////////////////////// -// MatchTemplate_32F - -GPU_PERF_TEST(MatchTemplate_32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod) -{ - cv::Size size = GET_PARAM(1); - cv::Size templ_size = GET_PARAM(2); - int cn = GET_PARAM(3); - int method = GET_PARAM(4); - - cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn)); - fill(image, 0, 255); - - cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn)); - fill(templ, 0, 255); - - cv::Mat dst; - - cv::matchTemplate(image, templ, dst, method); - - TEST_CYCLE() - { - cv::matchTemplate(image, templ, dst, method); - } -}; - -INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_32F, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR)))); - -////////////////////////////////////////////////////////////////////// -// MulSpectrums - -CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT) - -GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags) -{ - cv::Size size = GET_PARAM(1); - int flag = GET_PARAM(2); - - cv::Mat a(size, CV_32FC2); - fill(a, 0, 100); - - cv::Mat b(size, CV_32FC2); - fill(b, 0, 100); - - cv::Mat dst; - - cv::mulSpectrums(a, b, dst, flag); - - TEST_CYCLE() - { - cv::mulSpectrums(a, b, dst, flag); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS)))); - -////////////////////////////////////////////////////////////////////// -// Dft - -GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size, DftFlags) -{ - cv::Size size = GET_PARAM(1); - int flag = GET_PARAM(2); - - cv::Mat src(size, CV_32FC2); - fill(src, 0, 100); - - cv::Mat dst; - - cv::dft(src, dst, flag); - - declare.time(10.0); - - TEST_CYCLE() - { - cv::dft(src, dst, flag); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))); - -////////////////////////////////////////////////////////////////////// -// CornerHarris - -IMPLEMENT_PARAM_CLASS(BlockSize, int) -IMPLEMENT_PARAM_CLASS(ApertureSize, int) - -GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize) -{ - int type = GET_PARAM(1); - int borderType = GET_PARAM(2); - int blockSize = GET_PARAM(3); - int apertureSize = GET_PARAM(4); - - 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::Mat dst; - - double k = 0.5; - - cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderType); - - TEST_CYCLE() - { - cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderType); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine( - ALL_DEVICES, - testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), - testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)), - testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7)))); - -////////////////////////////////////////////////////////////////////// -// CornerMinEigenVal - -GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize) -{ - int type = GET_PARAM(1); - int borderType = GET_PARAM(2); - int blockSize = GET_PARAM(3); - int apertureSize = GET_PARAM(4); - - 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::Mat dst; - - cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderType); - - TEST_CYCLE() - { - cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderType); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine( - ALL_DEVICES, - testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), - testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)), - testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7)))); - -////////////////////////////////////////////////////////////////////// -// PyrDown - -GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::pyrDown(src, dst); - - TEST_CYCLE() - { - cv::pyrDown(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - -////////////////////////////////////////////////////////////////////// -// PyrUp - -GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::pyrUp(src, dst); - - TEST_CYCLE() - { - cv::pyrUp(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - -////////////////////////////////////////////////////////////////////// -// CvtColor - -GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, MatDepth, CvtColorInfo) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - CvtColorInfo info = GET_PARAM(3); - - cv::Mat src(size, CV_MAKETYPE(depth, info.scn)); - fill(src, 0, 255); - - cv::Mat dst; - - cv::cvtColor(src, dst, info.code, info.dcn); - - TEST_CYCLE() - { - cv::cvtColor(src, dst, info.code, info.dcn); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)), - testing::Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), - CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), - CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA), - CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ), - CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb), - CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2YUV), - CvtColorInfo(3, 3, cv::COLOR_YUV2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2HSV), - CvtColorInfo(3, 3, cv::COLOR_HSV2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2HLS), - CvtColorInfo(3, 3, cv::COLOR_HLS2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2Lab), - CvtColorInfo(3, 3, cv::COLOR_RGB2Lab), - CvtColorInfo(3, 3, cv::COLOR_BGR2Luv), - CvtColorInfo(3, 3, cv::COLOR_RGB2Luv), - CvtColorInfo(3, 3, cv::COLOR_Lab2BGR), - CvtColorInfo(3, 3, cv::COLOR_Lab2RGB), - CvtColorInfo(3, 3, cv::COLOR_Luv2BGR), - CvtColorInfo(3, 3, cv::COLOR_Luv2RGB), - CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR), - CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA)))); - -////////////////////////////////////////////////////////////////////// -// HoughLines - -IMPLEMENT_PARAM_CLASS(DoSort, bool) - -GPU_PERF_TEST(HoughLines, cv::gpu::DeviceInfo, cv::Size, DoSort) -{ - declare.time(30.0); - - const cv::Size size = GET_PARAM(1); - - const float rho = 1.0f; - const float theta = CV_PI / 180.0f; - const int threshold = 300; - - cv::RNG rng(123456789); - - cv::Mat src(size, CV_8UC1, cv::Scalar::all(0)); - - const int numLines = rng.uniform(500, 2000); - for (int i = 0; i < numLines; ++i) - { - cv::Point p1(rng.uniform(0, src.cols), rng.uniform(0, src.rows)); - cv::Point p2(rng.uniform(0, src.cols), rng.uniform(0, src.rows)); - cv::line(src, p1, p2, cv::Scalar::all(255), 2); - } - - std::vector lines; - cv::HoughLines(src, lines, rho, theta, threshold); - - TEST_CYCLE() - { - cv::HoughLines(src, lines, rho, theta, threshold); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, HoughLines, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DoSort(false), DoSort(true)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_labeling.cpp b/modules/gpu/perf_cpu/perf_labeling.cpp deleted file mode 100644 index ddf9c3d9b..000000000 --- a/modules/gpu/perf_cpu/perf_labeling.cpp +++ /dev/null @@ -1,158 +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) 2008-2011, 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: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions 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 "perf_precomp.hpp" - -#ifdef HAVE_CUDA - -namespace { - - struct GreedyLabeling - { - struct dot - { - int x; - int y; - - static dot make(int i, int j) - { - dot d; d.x = i; d.y = j; - return d; - } - }; - - struct InInterval - { - InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {}; - const int lo, hi; - - bool operator() (const unsigned char a, const unsigned char b) const - { - int d = a - b; - return lo <= d && d <= hi; - } - }; - - GreedyLabeling(cv::Mat img) - : image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];} - - ~GreedyLabeling(){delete[] stack;} - - void operator() (cv::Mat labels) const - { - labels.setTo(cv::Scalar::all(-1)); - InInterval inInt(0, 2); - int cc = -1; - - int* dist_labels = (int*)labels.data; - int pitch = labels.step1(); - - unsigned char* source = (unsigned char*)image.data; - int width = image.cols; - int height = image.rows; - - for (int j = 0; j < image.rows; ++j) - for (int i = 0; i < image.cols; ++i) - { - if (dist_labels[j * pitch + i] != -1) continue; - - dot* top = stack; - dot p = dot::make(i, j); - cc++; - - dist_labels[j * pitch + i] = cc; - - while (top >= stack) - { - int* dl = &dist_labels[p.y * pitch + p.x]; - unsigned char* sp = &source[p.y * image.step1() + p.x]; - - dl[0] = cc; - - //right - if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1])) - *top++ = dot::make(p.x + 1, p.y); - - //left - if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1])) - *top++ = dot::make(p.x - 1, p.y); - - //bottom - if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()])) - *top++ = dot::make(p.x, p.y + 1); - - //top - if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()])) - *top++ = dot::make(p.x, p.y - 1); - - p = *--top; - } - } - } - - cv::Mat image; - cv::Mat _labels; - dot* stack; - }; -} - -GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE); - - GreedyLabeling host(image); - - host(host._labels); - - declare.time(1.0); - - TEST_CYCLE() - { - host(host._labels); - } -} - -INSTANTIATE_TEST_CASE_P(Labeling, ConnectedComponents, testing::Combine(ALL_DEVICES, testing::Values(cv::Size(261, 262)))); - -#endif \ No newline at end of file diff --git a/modules/gpu/perf_cpu/perf_main.cpp b/modules/gpu/perf_cpu/perf_main.cpp deleted file mode 100644 index 6fcf56d0b..000000000 --- a/modules/gpu/perf_cpu/perf_main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - perf::TestBase::Init(argc, argv); - return RUN_ALL_TESTS(); -} - -#else - -int main() -{ - printf("OpenCV was built without CUDA support\n"); - return 0; -} - -#endif diff --git a/modules/gpu/perf_cpu/perf_matop.cpp b/modules/gpu/perf_cpu/perf_matop.cpp deleted file mode 100644 index 7c46eee80..000000000 --- a/modules/gpu/perf_cpu/perf_matop.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// SetTo - -GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - cv::Scalar val(1, 2, 3, 4); - - src.setTo(val); - - TEST_CYCLE() - { - src.setTo(val); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - -////////////////////////////////////////////////////////////////////// -// SetToMasked - -GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat mask(size, CV_8UC1); - fill(mask, 0, 2); - - cv::Scalar val(1, 2, 3, 4); - - src.setTo(val, mask); - - TEST_CYCLE() - { - src.setTo(val, mask); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - -////////////////////////////////////////////////////////////////////// -// CopyToMasked - -GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat mask(size, CV_8UC1); - fill(mask, 0, 2); - - cv::Mat dst; - - src.copyTo(dst, mask); - - TEST_CYCLE() - { - src.copyTo(dst, mask); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - -////////////////////////////////////////////////////////////////////// -// ConvertTo - -GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth1 = GET_PARAM(2); - int depth2 = GET_PARAM(3); - - cv::Mat src(size, depth1); - fill(src, 0, 255); - - cv::Mat dst; - - src.convertTo(dst, depth2, 0.5, 1.0); - - TEST_CYCLE() - { - src.convertTo(dst, depth2, 0.5, 1.0); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)), - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_objdetect.cpp b/modules/gpu/perf_cpu/perf_objdetect.cpp deleted file mode 100644 index d9ae2b7c8..000000000 --- a/modules/gpu/perf_cpu/perf_objdetect.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -/////////////////////////////////////////////////////////////// -// HOG - -GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - std::vector found_locations; - - cv::HOGDescriptor hog; - hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); - - hog.detectMultiScale(img, found_locations); - - TEST_CYCLE() - { - hog.detectMultiScale(img, found_locations); - } -} - -INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES); - -/////////////////////////////////////////////////////////////// -// HaarClassifier - -GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::CascadeClassifier cascade; - - ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml"))); - - std::vector rects; - - cascade.detectMultiScale(img, rects); - - TEST_CYCLE() - { - cascade.detectMultiScale(img, rects); - } -} - -INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES); - -//===================== LBP cascade ==========================// -GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::CascadeClassifier cascade; - - ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); - - std::vector rects; - - cascade.detectMultiScale(img, rects); - - TEST_CYCLE() - { - cascade.detectMultiScale(img, rects); - } -} - -INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES); - -#endif diff --git a/modules/gpu/perf_cpu/perf_utility.cpp b/modules/gpu/perf_cpu/perf_utility.cpp deleted file mode 100644 index 541e6fdc7..000000000 --- a/modules/gpu/perf_cpu/perf_utility.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -using namespace std; -using namespace cv; -using namespace cv::gpu; - -void fill(Mat& m, double a, double b) -{ - RNG rng(123456789); - rng.fill(m, RNG::UNIFORM, a, b); -} - -void PrintTo(const CvtColorInfo& info, ostream* os) -{ - static const char* str[] = - { - "BGR2BGRA", - "BGRA2BGR", - "BGR2RGBA", - "RGBA2BGR", - "BGR2RGB", - "BGRA2RGBA", - - "BGR2GRAY", - "RGB2GRAY", - "GRAY2BGR", - "GRAY2BGRA", - "BGRA2GRAY", - "RGBA2GRAY", - - "BGR2BGR565", - "RGB2BGR565", - "BGR5652BGR", - "BGR5652RGB", - "BGRA2BGR565", - "RGBA2BGR565", - "BGR5652BGRA", - "BGR5652RGBA", - - "GRAY2BGR565", - "BGR5652GRAY", - - "BGR2BGR555", - "RGB2BGR555", - "BGR5552BGR", - "BGR5552RGB", - "BGRA2BGR555", - "RGBA2BGR555", - "BGR5552BGRA", - "BGR5552RGBA", - - "GRAY2BGR555", - "BGR5552GRAY", - - "BGR2XYZ", - "RGB2XYZ", - "XYZ2BGR", - "XYZ2RGB", - - "BGR2YCrCb", - "RGB2YCrCb", - "YCrCb2BGR", - "YCrCb2RGB", - - "BGR2HSV", - "RGB2HSV", - - "", - "", - - "BGR2Lab", - "RGB2Lab", - - "BayerBG2BGR", - "BayerGB2BGR", - "BayerRG2BGR", - "BayerGR2BGR", - - "BGR2Luv", - "RGB2Luv", - - "BGR2HLS", - "RGB2HLS", - - "HSV2BGR", - "HSV2RGB", - - "Lab2BGR", - "Lab2RGB", - "Luv2BGR", - "Luv2RGB", - - "HLS2BGR", - "HLS2RGB", - - "BayerBG2BGR_VNG", - "BayerGB2BGR_VNG", - "BayerRG2BGR_VNG", - "BayerGR2BGR_VNG", - - "BGR2HSV_FULL", - "RGB2HSV_FULL", - "BGR2HLS_FULL", - "RGB2HLS_FULL", - - "HSV2BGR_FULL", - "HSV2RGB_FULL", - "HLS2BGR_FULL", - "HLS2RGB_FULL", - - "LBGR2Lab", - "LRGB2Lab", - "LBGR2Luv", - "LRGB2Luv", - - "Lab2LBGR", - "Lab2LRGB", - "Luv2LBGR", - "Luv2LRGB", - - "BGR2YUV", - "RGB2YUV", - "YUV2BGR", - "YUV2RGB", - - "BayerBG2GRAY", - "BayerGB2GRAY", - "BayerRG2GRAY", - "BayerGR2GRAY", - - //YUV 4:2:0 formats family - "YUV2RGB_NV12", - "YUV2BGR_NV12", - "YUV2RGB_NV21", - "YUV2BGR_NV21", - - "YUV2RGBA_NV12", - "YUV2BGRA_NV12", - "YUV2RGBA_NV21", - "YUV2BGRA_NV21", - - "YUV2RGB_YV12", - "YUV2BGR_YV12", - "YUV2RGB_IYUV", - "YUV2BGR_IYUV", - - "YUV2RGBA_YV12", - "YUV2BGRA_YV12", - "YUV2RGBA_IYUV", - "YUV2BGRA_IYUV", - - "YUV2GRAY_420", - - //YUV 4:2:2 formats family - "YUV2RGB_UYVY", - "YUV2BGR_UYVY", - "YUV2RGB_VYUY", - "YUV2BGR_VYUY", - - "YUV2RGBA_UYVY", - "YUV2BGRA_UYVY", - "YUV2RGBA_VYUY", - "YUV2BGRA_VYUY", - - "YUV2RGB_YUY2", - "YUV2BGR_YUY2", - "YUV2RGB_YVYU", - "YUV2BGR_YVYU", - - "YUV2RGBA_YUY2", - "YUV2BGRA_YUY2", - "YUV2RGBA_YVYU", - "YUV2BGRA_YVYU", - - "YUV2GRAY_UYVY", - "YUV2GRAY_YUY2", - - // alpha premultiplication - "RGBA2mRGBA", - "mRGBA2RGBA", - - "COLORCVT_MAX" - }; - - *os << str[info.code]; -} - -void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os) -{ - *os << info.name(); -} - -Mat readImage(const string& fileName, int flags) -{ - return imread(perf::TestBase::getDataPath(fileName), flags); -} - -const vector& devices() -{ - static vector devs; - static bool first = true; - - if (first) - { - int deviceCount = getCudaEnabledDeviceCount(); - - devs.reserve(deviceCount); - - for (int i = 0; i < deviceCount; ++i) - { - DeviceInfo info(i); - if (info.isCompatible()) - devs.push_back(info); - } - - first = false; - } - - return devs; -} diff --git a/modules/gpu/perf_cpu/perf_utility.hpp b/modules/gpu/perf_cpu/perf_utility.hpp deleted file mode 100644 index 8693cfc3c..000000000 --- a/modules/gpu/perf_cpu/perf_utility.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__ -#define __OPENCV_PERF_GPU_UTILITY_HPP__ - -void fill(cv::Mat& m, double a, double b); - -using perf::MatType; -using perf::MatDepth; - -CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP) - CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA) -CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING) - -struct CvtColorInfo -{ - int scn; - int dcn; - int code; - - explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {} -}; - -void PrintTo(const CvtColorInfo& info, std::ostream* os); - -#define IMPLEMENT_PARAM_CLASS(name, type) \ - class name \ - { \ - public: \ - name ( type arg = type ()) : val_(arg) {} \ - operator type () const {return val_;} \ - private: \ - type val_; \ - }; \ - inline void PrintTo( name param, std::ostream* os) \ - { \ - *os << #name << " = " << testing::PrintToString(static_cast< type >(param)); \ - } - -IMPLEMENT_PARAM_CLASS(Channels, int) - -namespace cv { namespace gpu -{ - void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os); -}} - -#define GPU_PERF_TEST(name, ...) \ - struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \ - { \ - public: \ - name() {} \ - protected: \ - void PerfTestBody(); \ - }; \ - TEST_P(name, perf){ RunPerfTestBody(); } \ - void name :: PerfTestBody() - -#define GPU_PERF_TEST_1(name, param_type) \ - struct name : perf::TestBaseWithParam< param_type > \ - { \ - public: \ - name() {} \ - protected: \ - void PerfTestBody(); \ - }; \ - TEST_P(name, perf){ RunPerfTestBody(); } \ - void name :: PerfTestBody() - -#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500)) - -cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); - -const std::vector& devices(); - -#define ALL_DEVICES testing::ValuesIn(devices()) - -#define GET_PARAM(k) std::tr1::get< k >(GetParam()) - -#endif // __OPENCV_PERF_GPU_UTILITY_HPP__ diff --git a/modules/gpu/perf_cpu/perf_video.cpp b/modules/gpu/perf_cpu/perf_video.cpp deleted file mode 100644 index 2c3aeb31c..000000000 --- a/modules/gpu/perf_cpu/perf_video.cpp +++ /dev/null @@ -1,466 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////// -// GoodFeaturesToTrack - -IMPLEMENT_PARAM_CLASS(MinDistance, double) - -GPU_PERF_TEST(GoodFeaturesToTrack, cv::gpu::DeviceInfo, MinDistance) -{ - double minDistance = GET_PARAM(1); - - cv::Mat image = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image.empty()); - - cv::Mat corners; - - cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance); - - TEST_CYCLE() - { - cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance); - } -} - -INSTANTIATE_TEST_CASE_P(Video, GoodFeaturesToTrack, testing::Combine( - ALL_DEVICES, - testing::Values(MinDistance(0.0), MinDistance(3.0)))); - -////////////////////////////////////////////////////// -// PyrLKOpticalFlowSparse - -IMPLEMENT_PARAM_CLASS(GraySource, bool) -IMPLEMENT_PARAM_CLASS(Points, int) -IMPLEMENT_PARAM_CLASS(WinSize, int) -IMPLEMENT_PARAM_CLASS(Levels, int) -IMPLEMENT_PARAM_CLASS(Iters, int) - -GPU_PERF_TEST(PyrLKOpticalFlowSparse, cv::gpu::DeviceInfo, GraySource, Points, WinSize, Levels, Iters) -{ - bool useGray = GET_PARAM(1); - int points = GET_PARAM(2); - int win_size = GET_PARAM(3); - int levels = GET_PARAM(4); - int iters = GET_PARAM(5); - - cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame0.empty()); - - cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame1.empty()); - - cv::Mat gray_frame; - if (useGray) - gray_frame = frame0; - else - cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY); - - cv::Mat pts; - cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0); - - cv::Mat nextPts; - cv::Mat status; - - cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), - cv::Size(win_size, win_size), levels - 1, - cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), - cv::Size(win_size, win_size), levels - 1, - cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); - } -} - -INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowSparse, testing::Combine( - ALL_DEVICES, - testing::Values(GraySource(true), GraySource(false)), - testing::Values(Points(1000), Points(2000), Points(4000), Points(8000)), - testing::Values(WinSize(9), WinSize(13), WinSize(17), WinSize(21)), - testing::Values(Levels(1), Levels(2), Levels(3)), - testing::Values(Iters(1), Iters(10), Iters(30)))); - -////////////////////////////////////////////////////// -// FarnebackOpticalFlowTest - -GPU_PERF_TEST_1(FarnebackOpticalFlowTest, cv::gpu::DeviceInfo) -{ - cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0.empty()); - - cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame1.empty()); - - cv::Mat flow; - - int numLevels = 5; - double pyrScale = 0.5; - int winSize = 13; - int numIters = 10; - int polyN = 5; - double polySigma = 1.1; - int flags = 0; - - cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); - - declare.time(10); - - TEST_CYCLE() - { - cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); - } -} - -INSTANTIATE_TEST_CASE_P(Video, FarnebackOpticalFlowTest, ALL_DEVICES); - -////////////////////////////////////////////////////// -// FGDStatModel - -namespace cv -{ - template<> void Ptr::delete_obj() - { - cvReleaseBGStatModel(&obj); - } -} - -GPU_PERF_TEST(FGDStatModel, cv::gpu::DeviceInfo, std::string) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - cap >> frame; - ASSERT_FALSE(frame.empty()); - - IplImage ipl_frame = frame; - cv::Ptr model(cvCreateFGDStatModel(&ipl_frame)); - - declare.time(60); - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - ipl_frame = frame; - - startTimer(); - next(); - - cvUpdateBGStatModel(&ipl_frame, model); - - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, FGDStatModel, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -////////////////////////////////////////////////////// -// MOG - -IMPLEMENT_PARAM_CLASS(LearningRate, double) - -GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - double learningRate = GET_PARAM(3); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - - cv::BackgroundSubtractorMOG mog; - cv::Mat foreground; - - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - mog(frame, foreground, learningRate); - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - startTimer(); next(); - mog(frame, foreground, learningRate); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, MOG, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3)/*, Channels(4)*/), - testing::Values(LearningRate(0.0), LearningRate(0.01)))); - -////////////////////////////////////////////////////// -// MOG2 - -GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - - cv::BackgroundSubtractorMOG2 mog2; - cv::Mat foreground; - - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - mog2(frame, foreground); - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - startTimer(); next(); - mog2(frame, foreground); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, MOG2_update, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3)/*, Channels(4)*/))); - -GPU_PERF_TEST(MOG2_getBackgroundImage, cv::gpu::DeviceInfo, std::string, Channels) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - - cv::BackgroundSubtractorMOG2 mog2; - cv::Mat foreground; - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - mog2(frame, foreground); - } - - cv::Mat background; - mog2.getBackgroundImage(background); - - TEST_CYCLE() - { - mog2.getBackgroundImage(background); - } -} - -INSTANTIATE_TEST_CASE_P(Video, MOG2_getBackgroundImage, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(/*Channels(1),*/ Channels(3)/*, Channels(4)*/))); - -////////////////////////////////////////////////////// -// GMG - -IMPLEMENT_PARAM_CLASS(MaxFeatures, int) - -GPU_PERF_TEST(GMG, cv::gpu::DeviceInfo, std::string, Channels, MaxFeatures) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - int maxFeatures = GET_PARAM(3); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - cv::Mat fgmask; - cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0)); - - cv::BackgroundSubtractorGMG gmg; - gmg.set("maxFeatures", maxFeatures); - gmg.initialize(frame.size(), 0.0, 255.0); - - gmg(frame, fgmask); - - for (int i = 0; i < 150; ++i) - { - cap >> frame; - if (frame.empty()) - { - cap.open(inputFile); - cap >> frame; - } - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - startTimer(); next(); - gmg(frame, fgmask); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, GMG, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(MaxFeatures(20), MaxFeatures(40), MaxFeatures(60)))); - -////////////////////////////////////////////////////// -// VideoWriter - -#ifdef WIN32 - -GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string) -{ - const double FPS = 25.0; - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - std::string outputFile = cv::tempfile(".avi"); - - cv::VideoCapture reader(inputFile); - ASSERT_TRUE( reader.isOpened() ); - - cv::VideoWriter writer; - - cv::Mat frame; - - declare.time(30); - - for (int i = 0; i < 10; ++i) - { - reader >> frame; - ASSERT_FALSE(frame.empty()); - - if (!writer.isOpened()) - writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size()); - - startTimer(); next(); - writer.write(frame); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, VideoWriter, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -#endif // WIN32 - -////////////////////////////////////////////////////// -// VideoReader - -GPU_PERF_TEST(VideoReader, cv::gpu::DeviceInfo, std::string) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - - cv::VideoCapture reader(inputFile); - ASSERT_TRUE( reader.isOpened() ); - - cv::Mat frame; - - reader >> frame; - - declare.time(20); - - TEST_CYCLE_N(10) - { - reader >> frame; - } -} - -INSTANTIATE_TEST_CASE_P(Video, VideoReader, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -#endif From a0aef244d675afc515397e2df3bd7a5d04312b78 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 20 Aug 2012 09:58:37 +0400 Subject: [PATCH 8/9] removed perf_gpu_cpu from CMake scripts --- cmake/OpenCVModule.cmake | 2 - modules/gpu/CMakeLists.txt | 40 ------------------- modules/gpu/perf/perf_precomp.hpp | 2 +- .../perf/{perf_utility.cpp => utility.cpp} | 0 .../perf/{perf_utility.hpp => utility.hpp} | 0 .../test/{precomp.cpp => test_precomp.cpp} | 0 .../test/{precomp.hpp => test_precomp.hpp} | 0 7 files changed, 1 insertion(+), 43 deletions(-) rename modules/gpu/perf/{perf_utility.cpp => utility.cpp} (100%) rename modules/gpu/perf/{perf_utility.hpp => utility.hpp} (100%) rename modules/gpu/test/{precomp.cpp => test_precomp.cpp} (100%) rename modules/gpu/test/{precomp.hpp => test_precomp.hpp} (100%) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 543f9970b..018a46730 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -509,8 +509,6 @@ endmacro() 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_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 e24b73a77..5d2c440fe 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -111,43 +111,3 @@ ocv_add_accuracy_tests(FILES "Include" ${test_hdrs} FILES "Src" ${test_srcs} ${nvidia}) 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 opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_nonfree) - ocv_check_dependencies(${perf_deps}) - - if(OCV_DEPENDENCIES_FOUND) - set(the_target "opencv_perf_gpu_cpu") - - ocv_module_include_directories(${perf_deps} "${perf_cpu_path}") - - if(NOT OPENCV_PERF_${the_module}_CPU_SOURCES) - file(GLOB perf_srcs "${perf_cpu_path}/*.cpp") - file(GLOB perf_hdrs "${perf_cpu_path}/*.hpp" "${perf_cpu_path}/*.h") - source_group("Src" FILES ${perf_srcs}) - source_group("Include" FILES ${perf_hdrs}) - set(OPENCV_PERF_${the_module}_CPU_SOURCES ${perf_srcs} ${perf_hdrs}) - endif() - - add_executable(${the_target} ${OPENCV_PERF_${the_module}_CPU_SOURCES}) - target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS}) - - # Additional target properties - set_target_properties(${the_target} PROPERTIES - DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}" - ) - - if(ENABLE_SOLUTION_FOLDERS) - set_target_properties(${the_target} PROPERTIES FOLDER "tests performance") - endif() - - ocv_add_precompiled_headers(${the_target}) - else(OCV_DEPENDENCIES_FOUND) - #TODO: warn about unsatisfied dependencies - endif(OCV_DEPENDENCIES_FOUND) - endif() diff --git a/modules/gpu/perf/perf_precomp.hpp b/modules/gpu/perf/perf_precomp.hpp index be3f234a3..837859947 100644 --- a/modules/gpu/perf/perf_precomp.hpp +++ b/modules/gpu/perf/perf_precomp.hpp @@ -27,7 +27,7 @@ #include "opencv2/nonfree/nonfree.hpp" #include "opencv2/legacy/legacy.hpp" -#include "perf_utility.hpp" +#include "utility.hpp" #ifdef GTEST_CREATE_SHARED_LIBRARY #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined diff --git a/modules/gpu/perf/perf_utility.cpp b/modules/gpu/perf/utility.cpp similarity index 100% rename from modules/gpu/perf/perf_utility.cpp rename to modules/gpu/perf/utility.cpp diff --git a/modules/gpu/perf/perf_utility.hpp b/modules/gpu/perf/utility.hpp similarity index 100% rename from modules/gpu/perf/perf_utility.hpp rename to modules/gpu/perf/utility.hpp diff --git a/modules/gpu/test/precomp.cpp b/modules/gpu/test/test_precomp.cpp similarity index 100% rename from modules/gpu/test/precomp.cpp rename to modules/gpu/test/test_precomp.cpp diff --git a/modules/gpu/test/precomp.hpp b/modules/gpu/test/test_precomp.hpp similarity index 100% rename from modules/gpu/test/precomp.hpp rename to modules/gpu/test/test_precomp.hpp From ec7f9566e0df2d535d7ac5123026720cb7e80d2d Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 20 Aug 2012 10:15:36 +0400 Subject: [PATCH 9/9] minor gpu tests fix --- modules/gpu/perf/main.cpp | 6 +- modules/gpu/test/main.cpp | 92 ++++++++++--------- modules/gpu/test/main_test_nvidia.h | 4 +- modules/gpu/test/test_calib3d.cpp | 8 +- modules/gpu/test/test_color.cpp | 2 +- modules/gpu/test/test_copy_make_border.cpp | 6 +- modules/gpu/test/test_core.cpp | 6 +- modules/gpu/test/test_features2d.cpp | 6 +- modules/gpu/test/test_filters.cpp | 6 +- modules/gpu/test/test_global_motion.cpp | 8 +- modules/gpu/test/test_gpumat.cpp | 6 +- modules/gpu/test/test_imgproc.cpp | 6 +- modules/gpu/test/test_labeling.cpp | 6 +- modules/gpu/test/test_nvidia.cpp | 14 +-- modules/gpu/test/test_objdetect.cpp | 25 ++--- modules/gpu/test/test_precomp.cpp | 2 +- modules/gpu/test/test_precomp.hpp | 2 + modules/gpu/test/test_pyramids.cpp | 2 +- modules/gpu/test/test_remap.cpp | 2 +- modules/gpu/test/test_resize.cpp | 3 +- modules/gpu/test/test_threshold.cpp | 2 +- modules/gpu/test/test_video.cpp | 6 +- modules/gpu/test/test_warp_affine.cpp | 2 +- modules/gpu/test/test_warp_perspective.cpp | 2 +- modules/gpu/test/utility.cpp | 101 +-------------------- modules/gpu/test/utility.hpp | 4 +- 26 files changed, 134 insertions(+), 195 deletions(-) diff --git a/modules/gpu/perf/main.cpp b/modules/gpu/perf/main.cpp index 865362f88..aadeee955 100644 --- a/modules/gpu/perf/main.cpp +++ b/modules/gpu/perf/main.cpp @@ -71,9 +71,9 @@ void printCudaInfo() #endif } -int main(int argc, char **argv) +int main(int argc, char** argv) { - CommandLineParser cmd(argc, argv, + CommandLineParser cmd(argc, (const char**) argv, "{ print_info_only | print_info_only | false | Print information about system and exit }" "{ device | device | 0 | Device on which tests will be executed }" "{ cpu | cpu | false | Run tests on cpu }" @@ -119,7 +119,7 @@ int main(int argc, char **argv) cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; } - testing::InitGoogleTest(&argc, argv); + InitGoogleTest(&argc, argv); perf::TestBase::Init(argc, argv); return RUN_ALL_TESTS(); } diff --git a/modules/gpu/test/main.cpp b/modules/gpu/test/main.cpp index 6df7db0a1..8f216c9fe 100644 --- a/modules/gpu/test/main.cpp +++ b/modules/gpu/test/main.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA @@ -49,93 +49,103 @@ using namespace cv::gpu; using namespace cvtest; using namespace testing; -void printInfo() +void printOsInfo() { #if defined _WIN32 # if defined _WIN64 - puts("OS: Windows x64"); + cout << "OS: Windows x64 \n" << endl; # else - puts("OS: Windows x32"); + cout << "OS: Windows x32 \n" << endl; # endif #elif defined linux # if defined _LP64 - puts("OS: Linux x64"); + cout << "OS: Linux x64 \n" << endl; # else - puts("OS: Linux x32"); + cout << "OS: Linux x32 \n" << endl; # endif #elif defined __APPLE__ # if defined _LP64 - puts("OS: Apple x64"); + cout << "OS: Apple x64 \n" << endl; # else - puts("OS: Apple x32"); + cout << "OS: Apple x32 \n" << endl; # endif #endif +} +void printCudaInfo() +{ +#ifndef HAVE_CUDA + cout << "OpenCV was built without CUDA support \n" << endl; +#else int driver; cudaDriverGetVersion(&driver); - printf("CUDA Driver version: %d\n", driver); - printf("CUDA Runtime version: %d\n", CUDART_VERSION); + cout << "CUDA Driver version: " << driver << '\n'; + cout << "CUDA Runtime version: " << CUDART_VERSION << '\n'; - puts("GPU module was compiled for the following GPU archs:"); - printf(" BIN: %s\n", CUDA_ARCH_BIN); - printf(" PTX: %s\n\n", CUDA_ARCH_PTX); + cout << endl; + + cout << "GPU module was compiled for the following GPU archs:" << endl; + cout << " BIN: " << CUDA_ARCH_BIN << '\n'; + cout << " PTX: " << CUDA_ARCH_PTX << '\n'; + + cout << endl; int deviceCount = getCudaEnabledDeviceCount(); - printf("CUDA device count: %d\n\n", deviceCount); + cout << "CUDA device count: " << deviceCount << '\n'; + + cout << endl; for (int i = 0; i < deviceCount; ++i) { DeviceInfo info(i); - printf("Device %d:\n", i); - printf(" Name: %s\n", info.name().c_str()); - printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion()); - printf(" Multi Processor Count: %d\n", info.multiProcessorCount()); - printf(" Total memory: %d Mb\n", static_cast(static_cast(info.totalMemory() / 1024.0) / 1024.0)); - printf(" Free memory: %d Mb\n", static_cast(static_cast(info.freeMemory() / 1024.0) / 1024.0)); + cout << "Device [" << i << "] \n"; + cout << "\t Name: " << info.name() << '\n'; + cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n'; + cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n'; + cout << "\t Total memory: " << static_cast(static_cast(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n"; + cout << "\t Free memory: " << static_cast(static_cast(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n"; if (!info.isCompatible()) - puts(" !!! This device is NOT compatible with current GPU module build\n"); - printf("\n"); + cout << "\t !!! This device is NOT compatible with current GPU module build \n"; + + cout << endl; } +#endif } -enum OutputLevel -{ - OutputLevelNone, - OutputLevelCompact, - OutputLevelFull -}; - -extern OutputLevel nvidiaTestOutputLevel; - int main(int argc, char** argv) { try { - CommandLineParser parser(argc, (const char**)argv, - "{ print_info_only | print_info_only | false | Print information about system and exit }" - "{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }" - "{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"); + CommandLineParser cmd(argc, (const char**)argv, + "{ print_info_only | print_info_only | false | Print information about system and exit }" + "{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }" + "{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }" + ); - printInfo(); + printOsInfo(); + printCudaInfo(); - if (parser.get("print_info_only")) + if (cmd.get("print_info_only")) return 0; - int device = parser.get("device"); + int device = cmd.get("device"); if (device < 0) { DeviceManager::instance().loadAll(); - std::cout << "Run tests on all supported devices\n" << std::endl; + + cout << "Run tests on all supported devices \n" << endl; } else { DeviceManager::instance().load(device); - std::cout << "Run tests on device " << device << '\n' << std::endl; + + DeviceInfo info(device); + cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; } - string outputLevel = parser.get("nvtest_output_level"); + string outputLevel = cmd.get("nvtest_output_level"); if (outputLevel == "none") nvidiaTestOutputLevel = OutputLevelNone; diff --git a/modules/gpu/test/main_test_nvidia.h b/modules/gpu/test/main_test_nvidia.h index d1c362012..15016ca64 100644 --- a/modules/gpu/test/main_test_nvidia.h +++ b/modules/gpu/test/main_test_nvidia.h @@ -1,7 +1,7 @@ #ifndef __main_test_nvidia_h__ #define __main_test_nvidia_h__ -#include +#include enum OutputLevel { @@ -10,6 +10,8 @@ enum OutputLevel OutputLevelFull }; +extern OutputLevel nvidiaTestOutputLevel; + bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel); bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel); bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outputLevel); diff --git a/modules/gpu/test/test_calib3d.cpp b/modules/gpu/test/test_calib3d.cpp index bdc043fc5..5fa1ebb41 100644 --- a/modules/gpu/test/test_calib3d.cpp +++ b/modules/gpu/test/test_calib3d.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -329,7 +331,7 @@ TEST_P(ReprojectImageTo3D, Accuracy) cv::gpu::GpuMat dst; cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), dst, Q, 3); - + cv::Mat dst_gold; cv::reprojectImageTo3D(disp, dst_gold, Q, false); @@ -343,3 +345,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ReprojectImageTo3D, testing::Combine( WHOLE_SUBMAT)); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_color.cpp b/modules/gpu/test/test_color.cpp index 645967ef2..c2929fbe7 100644 --- a/modules/gpu/test/test_color.cpp +++ b/modules/gpu/test/test_color.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_copy_make_border.cpp b/modules/gpu/test/test_copy_make_border.cpp index 45b73d302..8bd5a66f9 100644 --- a/modules/gpu/test/test_copy_make_border.cpp +++ b/modules/gpu/test/test_copy_make_border.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -98,3 +100,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine( WHOLE_SUBMAT)); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_core.cpp b/modules/gpu/test/test_core.cpp index 6502c4a05..09c6be1ac 100644 --- a/modules/gpu/test/test_core.cpp +++ b/modules/gpu/test/test_core.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -3396,3 +3398,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Reduce, testing::Combine( WHOLE_SUBMAT)); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_features2d.cpp b/modules/gpu/test/test_features2d.cpp index d8ed864eb..b461d4b44 100644 --- a/modules/gpu/test/test_features2d.cpp +++ b/modules/gpu/test/test_features2d.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -984,3 +986,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, BruteForceMatcher, testing::Combine( testing::Values(UseMask(false), UseMask(true)))); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_filters.cpp b/modules/gpu/test/test_filters.cpp index 9df6ee27c..0781970e4 100644 --- a/modules/gpu/test/test_filters.cpp +++ b/modules/gpu/test/test_filters.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -552,3 +554,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Filter2D, testing::Combine( WHOLE_SUBMAT)); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_global_motion.cpp b/modules/gpu/test/test_global_motion.cpp index eb8b2f7c1..b37d08068 100644 --- a/modules/gpu/test/test_global_motion.cpp +++ b/modules/gpu/test/test_global_motion.cpp @@ -39,11 +39,11 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA -#include using namespace std; - using namespace cv; struct CompactPoints : testing::TestWithParam @@ -85,3 +85,5 @@ TEST_P(CompactPoints, CanCompactizeSmallInput) } INSTANTIATE_TEST_CASE_P(GPU_GlobalMotion, CompactPoints, ALL_DEVICES); + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_gpumat.cpp b/modules/gpu/test/test_gpumat.cpp index 4dd419a18..862795759 100644 --- a/modules/gpu/test/test_gpumat.cpp +++ b/modules/gpu/test/test_gpumat.cpp @@ -40,7 +40,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -323,3 +325,5 @@ INSTANTIATE_TEST_CASE_P(GPU_GpuMat, ConvertTo, testing::Combine( WHOLE_SUBMAT)); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_imgproc.cpp b/modules/gpu/test/test_imgproc.cpp index 4d67de59d..7a616a2e4 100644 --- a/modules/gpu/test/test_imgproc.cpp +++ b/modules/gpu/test/test_imgproc.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -1186,3 +1188,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughLines, testing::Combine( std::string("../cv/shared/pic6.png")))); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_labeling.cpp b/modules/gpu/test/test_labeling.cpp index c88109af1..46f6f4eeb 100644 --- a/modules/gpu/test/test_labeling.cpp +++ b/modules/gpu/test/test_labeling.cpp @@ -39,9 +39,7 @@ // the use of this software, even if advised of the possibility of such damage. //M*/ -#include "precomp.hpp" -#include -#include +#include "test_precomp.hpp" #ifdef HAVE_CUDA @@ -199,4 +197,4 @@ TEST_P(Labeling, ConnectedComponents) INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES); -#endif \ No newline at end of file +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_nvidia.cpp b/modules/gpu/test/test_nvidia.cpp index 386a66cfd..3de355744 100644 --- a/modules/gpu/test/test_nvidia.cpp +++ b/modules/gpu/test/test_nvidia.cpp @@ -39,21 +39,15 @@ // //M*/ -#include -#include "precomp.hpp" +#include "test_precomp.hpp" + +OutputLevel nvidiaTestOutputLevel = OutputLevelCompact; #ifdef HAVE_CUDA using namespace cvtest; using namespace testing; -//enum OutputLevel -//{ -// OutputLevelNone, -// OutputLevelCompact, -// OutputLevelFull -//}; - struct NVidiaTest : TestWithParam { cv::gpu::DeviceInfo devInfo; @@ -73,8 +67,6 @@ struct NVidiaTest : TestWithParam struct NPPST : NVidiaTest {}; struct NCV : NVidiaTest {}; -OutputLevel nvidiaTestOutputLevel = OutputLevelCompact; - //TEST_P(NPPST, Integral) //{ // bool res = nvidia_NPPST_Integral_Image(path, nvidiaTestOutputLevel); diff --git a/modules/gpu/test/test_objdetect.cpp b/modules/gpu/test/test_objdetect.cpp index 927762b2b..957ee1165 100644 --- a/modules/gpu/test/test_objdetect.cpp +++ b/modules/gpu/test/test_objdetect.cpp @@ -39,8 +39,9 @@ // //M*/ -#include "precomp.hpp" -#include +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA namespace { @@ -302,13 +303,13 @@ PARAM_TEST_CASE(LBP_Read_classifier, cv::gpu::DeviceInfo, int) TEST_P(LBP_Read_classifier, Accuracy) { - cv::gpu::CascadeClassifier_GPU classifier; + cv::gpu::CascadeClassifier_GPU classifier; std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml"; ASSERT_TRUE(classifier.load(classifierXmlPath)); } -INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier, - testing::Combine(ALL_DEVICES, testing::Values(0))); +INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier, + testing::Combine(ALL_DEVICES, testing::Values(0))); PARAM_TEST_CASE(LBP_classify, cv::gpu::DeviceInfo, int) @@ -344,7 +345,7 @@ TEST_P(LBP_classify, Accuracy) for (; it != rects.end(); ++it) cv::rectangle(markedImage, *it, CV_RGB(0, 0, 255)); - cv::gpu::CascadeClassifier_GPU gpuClassifier; + cv::gpu::CascadeClassifier_GPU gpuClassifier; ASSERT_TRUE(gpuClassifier.load(classifierXmlPath)); cv::gpu::GpuMat gpu_rects; @@ -352,23 +353,25 @@ TEST_P(LBP_classify, Accuracy) int count = gpuClassifier.detectMultiScale(tested, gpu_rects); cv::Mat downloaded(gpu_rects); - const cv::Rect* faces = downloaded.ptr(); + const cv::Rect* faces = downloaded.ptr(); for (int i = 0; i < count; i++) { cv::Rect r = faces[i]; #if defined (LOG_CASCADE_STATISTIC) - std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl; + std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl; cv::rectangle(markedImage, r , CV_RGB(255, 0, 0)); -#endif +#endif } #if defined (LOG_CASCADE_STATISTIC) - cv::imshow("Res", markedImage); cv::waitKey(); + cv::imshow("Res", markedImage); cv::waitKey(); #endif } INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify, - testing::Combine(ALL_DEVICES, testing::Values(0))); + testing::Combine(ALL_DEVICES, testing::Values(0))); } // namespace + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_precomp.cpp b/modules/gpu/test/test_precomp.cpp index dfa724612..34acf2ae9 100644 --- a/modules/gpu/test/test_precomp.cpp +++ b/modules/gpu/test/test_precomp.cpp @@ -39,4 +39,4 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" diff --git a/modules/gpu/test/test_precomp.hpp b/modules/gpu/test/test_precomp.hpp index 753367cce..f6933d51c 100644 --- a/modules/gpu/test/test_precomp.hpp +++ b/modules/gpu/test/test_precomp.hpp @@ -59,6 +59,7 @@ #include #include "cvconfig.h" + #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/calib3d/calib3d.hpp" @@ -72,6 +73,7 @@ #include "utility.hpp" #include "interpolation.hpp" +#include "main_test_nvidia.h" #ifdef HAVE_CUDA #include diff --git a/modules/gpu/test/test_pyramids.cpp b/modules/gpu/test/test_pyramids.cpp index d0bf37b37..1abd7841e 100644 --- a/modules/gpu/test/test_pyramids.cpp +++ b/modules/gpu/test/test_pyramids.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_remap.cpp b/modules/gpu/test/test_remap.cpp index c61a89914..b83e5db07 100644 --- a/modules/gpu/test/test_remap.cpp +++ b/modules/gpu/test/test_remap.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_resize.cpp b/modules/gpu/test/test_resize.cpp index 7a7aacab1..73b8d9fab 100644 --- a/modules/gpu/test/test_resize.cpp +++ b/modules/gpu/test/test_resize.cpp @@ -39,8 +39,7 @@ // //M*/ -#include "precomp.hpp" -#include +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_threshold.cpp b/modules/gpu/test/test_threshold.cpp index cb31c643b..e878e6dfa 100644 --- a/modules/gpu/test/test_threshold.cpp +++ b/modules/gpu/test/test_threshold.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_video.cpp b/modules/gpu/test/test_video.cpp index 0ee66ba52..ca9442d69 100644 --- a/modules/gpu/test/test_video.cpp +++ b/modules/gpu/test/test_video.cpp @@ -39,7 +39,9 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" + +#ifdef HAVE_CUDA //#define DUMP @@ -865,3 +867,5 @@ TEST_P(VideoReader, Regression) INSTANTIATE_TEST_CASE_P(GPU_Video, VideoReader, testing::Combine( ALL_DEVICES, testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); + +#endif // HAVE_CUDA diff --git a/modules/gpu/test/test_warp_affine.cpp b/modules/gpu/test/test_warp_affine.cpp index 262937fbe..c81fef354 100644 --- a/modules/gpu/test/test_warp_affine.cpp +++ b/modules/gpu/test/test_warp_affine.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_warp_perspective.cpp b/modules/gpu/test/test_warp_perspective.cpp index f14317015..83c170f2e 100644 --- a/modules/gpu/test/test_warp_perspective.cpp +++ b/modules/gpu/test/test_warp_perspective.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" #ifdef HAVE_CUDA diff --git a/modules/gpu/test/utility.cpp b/modules/gpu/test/utility.cpp index 148c9d202..cf3b0fc8c 100644 --- a/modules/gpu/test/utility.cpp +++ b/modules/gpu/test/utility.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "test_precomp.hpp" using namespace std; using namespace cv; @@ -182,105 +182,6 @@ void DeviceManager::loadAll() } } -class DevicesGenerator : public ParamGeneratorInterface -{ -public: - ~DevicesGenerator(); - - ParamIteratorInterface* Begin() const; - ParamIteratorInterface* End() const; - -private: - class Iterator : public ParamIteratorInterface - { - public: - Iterator(const ParamGeneratorInterface* base, vector::const_iterator iterator); - - virtual ~Iterator(); - - virtual const ParamGeneratorInterface* BaseGenerator() const; - - virtual void Advance(); - - virtual ParamIteratorInterface* Clone() const; - - virtual const DeviceInfo* Current() const; - - virtual bool Equals(const ParamIteratorInterface& other) const; - - private: - Iterator(const Iterator& other); - - const ParamGeneratorInterface* const base_; - vector::const_iterator iterator_; - - mutable DeviceInfo value_; - }; -}; - -DevicesGenerator::~DevicesGenerator() -{ -} - -ParamIteratorInterface* DevicesGenerator::Begin() const -{ - return new Iterator(this, DeviceManager::instance().values().begin()); -} - -ParamIteratorInterface* DevicesGenerator::End() const -{ - return new Iterator(this, DeviceManager::instance().values().end()); -} - -DevicesGenerator::Iterator::Iterator(const ParamGeneratorInterface* base, vector::const_iterator iterator) - : base_(base), iterator_(iterator) -{ -} - -DevicesGenerator::Iterator::~Iterator() -{ -} - -const ParamGeneratorInterface* DevicesGenerator::Iterator::BaseGenerator() const -{ - return base_; -} - -void DevicesGenerator::Iterator::Advance() -{ - ++iterator_; -} - -ParamIteratorInterface* DevicesGenerator::Iterator::Clone() const -{ - return new Iterator(*this); -} - -const DeviceInfo* DevicesGenerator::Iterator::Current() const -{ - value_ = *iterator_; - return &value_; -} - -bool DevicesGenerator::Iterator::Equals(const ParamIteratorInterface& other) const -{ - GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) - << "The program attempted to compare iterators " - << "from different generators." << endl; - - return iterator_ == CheckedDowncastToActualType(&other)->iterator_; -} - -DevicesGenerator::Iterator::Iterator(const Iterator& other) : - ParamIteratorInterface(), base_(other.base_), iterator_(other.iterator_) -{ -} - -ParamGenerator DevicesGenerator_() -{ - return ParamGenerator(new DevicesGenerator); -} - ////////////////////////////////////////////////////////////////////// // Additional assertion diff --git a/modules/gpu/test/utility.hpp b/modules/gpu/test/utility.hpp index b36f177f6..f509b786a 100644 --- a/modules/gpu/test/utility.hpp +++ b/modules/gpu/test/utility.hpp @@ -94,9 +94,7 @@ private: std::vector devices_; }; -testing::internal::ParamGenerator DevicesGenerator_(); - -#define ALL_DEVICES DevicesGenerator_() +#define ALL_DEVICES testing::ValuesIn(DeviceManager::instance().values()) ////////////////////////////////////////////////////////////////////// // Additional assertion