#include "perf_precomp.hpp"\r
\r
-#ifdef HAVE_CUDA\r
+using namespace std;\r
+using namespace testing;\r
+\r
+namespace {\r
\r
//////////////////////////////////////////////////////////////////////\r
// Remap\r
\r
-GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode)\r
+enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};\r
+CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH);\r
+#define ALL_REMAP_MODES ValuesIn(RemapMode::all())\r
+\r
+void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ for (int j = 0; j < map_x.rows; ++j)\r
+ {\r
+ for (int i = 0; i < map_x.cols; ++i)\r
+ {\r
+ switch (remapMode)\r
+ {\r
+ case HALF_SIZE:\r
+ 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)\r
+ {\r
+ map_x.at<float>(j,i) = 2.f * (i - map_x.cols * 0.25f) + 0.5f;\r
+ map_y.at<float>(j,i) = 2.f * (j - map_x.rows * 0.25f) + 0.5f;\r
+ }\r
+ else\r
+ {\r
+ map_x.at<float>(j,i) = 0.f;\r
+ map_y.at<float>(j,i) = 0.f;\r
+ }\r
+ break;\r
+ case UPSIDE_DOWN:\r
+ map_x.at<float>(j,i) = static_cast<float>(i);\r
+ map_y.at<float>(j,i) = static_cast<float>(map_x.rows - j);\r
+ break;\r
+ case REFLECTION_X:\r
+ map_x.at<float>(j,i) = static_cast<float>(map_x.cols - i);\r
+ map_y.at<float>(j,i) = static_cast<float>(j);\r
+ break;\r
+ case REFLECTION_BOTH:\r
+ map_x.at<float>(j,i) = static_cast<float>(map_x.cols - i);\r
+ map_y.at<float>(j,i) = static_cast<float>(map_x.rows - j);\r
+ break;\r
+ } // end of switch\r
+ }\r
+ }\r
+}\r
+\r
+DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border_Mode, cv::Size, MatDepth, int, Interpolation, BorderMode, RemapMode);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ ALL_BORDER_MODES,\r
+ ALL_REMAP_MODES))\r
+{\r
+ declare.time(20.0);\r
+\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
int interpolation = GET_PARAM(3);\r
int borderMode = GET_PARAM(4);\r
+ int remapMode = GET_PARAM(5);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::Mat xmap_host(size, CV_32FC1);\r
- fill(xmap_host, 0, size.width);\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::Mat ymap_host(size, CV_32FC1);\r
- fill(ymap_host, 0, size.height);\r
+ cv::Mat xmap(size, CV_32FC1);\r
+ cv::Mat ymap(size, CV_32FC1);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat xmap(xmap_host);\r
- cv::gpu::GpuMat ymap(ymap_host);\r
- cv::gpu::GpuMat dst;\r
+ generateMap(xmap, ymap, remapMode);\r
\r
- cv::gpu::remap(src, dst, xmap, ymap, interpolation, borderMode);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_xmap(xmap);\r
+ cv::gpu::GpuMat d_ymap(ymap);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- declare.time(3.0);\r
+ cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);\r
\r
- TEST_CYCLE()\r
- {\r
- cv::gpu::remap(src, dst, xmap, ymap, interpolation, borderMode);\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);\r
+ }\r
}\r
-}\r
+ else\r
+ {\r
+ cv::Mat dst;\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
- testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));\r
+ cv::remap(src, dst, xmap, ymap, interpolation, borderMode);\r
\r
+ TEST_CYCLE()\r
+ {\r
+ cv::remap(src, dst, xmap, ymap, interpolation, borderMode);\r
+ }\r
+ }\r
+}\r
\r
//////////////////////////////////////////////////////////////////////\r
// Resize\r
\r
-IMPLEMENT_PARAM_CLASS(Scale, double)\r
+DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Scale, cv::Size, MatDepth, int, Interpolation, double);\r
\r
-GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Scale)\r
+PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ ALL_INTERPOLATIONS,\r
+ Values(0.5, 0.3, 2.0)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(20.0);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
int interpolation = GET_PARAM(3);\r
double f = GET_PARAM(4);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- declare.time(1.0);\r
+ cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation);\r
+ cv::Mat dst;\r
+\r
+ cv::resize(src, dst, cv::Size(), f, f, interpolation);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::resize(src, dst, cv::Size(), f, f, interpolation);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine(\r
- ALL_DEVICES,\r
+//////////////////////////////////////////////////////////////////////\r
+// ResizeArea\r
+\r
+DEF_PARAM_TEST(Sz_Depth_Cn_Scale, cv::Size, MatDepth, int, double);\r
+\r
+PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(\r
GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR),\r
- Interpolation(cv::INTER_CUBIC), Interpolation(cv::INTER_AREA)),\r
- testing::Values(Scale(0.5), Scale(0.3), Scale(2.0))));\r
-\r
-GPU_PERF_TEST(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, Scale)\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ Values(0.2, 0.1, 0.05)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(1.0);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
int interpolation = cv::INTER_AREA;\r
double f = GET_PARAM(3);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- declare.time(1.0);\r
+ cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation);\r
+ cv::Mat dst;\r
+\r
+ cv::resize(src, dst, cv::Size(), f, f, interpolation);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::resize(src, dst, cv::Size(), f, f, interpolation);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, ResizeArea, testing::Combine(\r
- ALL_DEVICES,\r
- testing::Values(perf::sz1080p/*, cv::Size(4096, 2048)*/),\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(Scale(0.2),Scale(0.1),Scale(0.05))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// WarpAffine\r
\r
-GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode)\r
+DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border, cv::Size, MatDepth, int, Interpolation, BorderMode);\r
+\r
+PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ ALL_BORDER_MODES))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(20.0);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
int interpolation = GET_PARAM(3);\r
int borderMode = GET_PARAM(4);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
const double aplha = CV_PI / 4;\r
double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},\r
{std::sin(aplha), std::cos(aplha), 0}};\r
cv::Mat M(2, 3, CV_64F, (void*) mat);\r
\r
- cv::gpu::warpAffine(src, dst, M, size, interpolation, borderMode);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
+\r
+ cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::warpAffine(src, dst, M, size, interpolation, borderMode);\r
+ cv::Mat dst;\r
+\r
+ cv::warpAffine(src, dst, M, size, interpolation, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::warpAffine(src, dst, M, size, interpolation, borderMode);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
- testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// WarpPerspective\r
\r
-GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode)\r
+PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ ALL_BORDER_MODES))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(20.0);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
int interpolation = GET_PARAM(3);\r
int borderMode = GET_PARAM(4);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
const double aplha = CV_PI / 4;\r
double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},\r
{0.0, 0.0, 1.0}};\r
cv::Mat M(3, 3, CV_64F, (void*) mat);\r
\r
- cv::gpu::warpPerspective(src, dst, M, size, interpolation, borderMode);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
+\r
+ cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::warpPerspective(src, dst, M, size, interpolation, borderMode);\r
+ cv::Mat dst;\r
+\r
+ cv::warpPerspective(src, dst, M, size, interpolation, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::warpPerspective(src, dst, M, size, interpolation, borderMode);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
- testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// CopyMakeBorder\r
\r
-GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, BorderMode)\r
+DEF_PARAM_TEST(Sz_Depth_Cn_Border, cv::Size, MatDepth, int, BorderMode);\r
+\r
+PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ ALL_BORDER_MODES))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
+ int borderMode = GET_PARAM(3);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
- int borderType = GET_PARAM(3);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType);\r
+ cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType);\r
+ cv::Mat dst;\r
+\r
+ cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// Threshold\r
\r
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)\r
-#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))\r
+#define ALL_THRESH_OPS ValuesIn(ThreshOp::all())\r
\r
-GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, MatDepth, ThreshOp)\r
-{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+DEF_PARAM_TEST(Sz_Depth_Op, cv::Size, MatDepth, ThreshOp);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int depth = GET_PARAM(2);\r
- int threshOp = GET_PARAM(3);\r
+PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F, CV_64F),\r
+ ALL_THRESH_OPS))\r
+{\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int threshOp = GET_PARAM(2);\r
\r
- cv::Mat src_host(size, depth);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, depth);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::threshold(src, dst, 100.0, 255.0, threshOp);\r
+ cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::threshold(src, dst, 100.0, 255.0, threshOp);\r
+ cv::Mat dst;\r
+\r
+ cv::threshold(src, dst, 100.0, 255.0, threshOp);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::threshold(src, dst, 100.0, 255.0, threshOp);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)),\r
- ALL_THRESH_OPS));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// Integral\r
\r
-GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
- cv::Mat src_host(size, CV_8UC1);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_8UC1);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::GpuMat buf;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
+ cv::gpu::GpuMat d_buf;\r
\r
- cv::gpu::integralBuffered(src, dst, buf);\r
+ cv::gpu::integralBuffered(d_src, d_dst, d_buf);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::integralBuffered(d_src, d_dst, d_buf);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::integralBuffered(src, dst, buf);\r
+ cv::Mat dst;\r
+\r
+ cv::integral(src, dst);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::integral(src, dst);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
-// Integral_Sqr\r
+// IntegralSqr\r
\r
-GPU_PERF_TEST(Integral_Sqr, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GetParam();\r
\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Mat src(size, CV_8UC1);\r
+ fillRandom(src);\r
\r
- cv::Mat src_host(size, CV_8UC1);\r
- fill(src_host, 0, 255);\r
-\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::sqrIntegral(src, dst);\r
+ cv::gpu::sqrIntegral(d_src, d_dst);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::sqrIntegral(d_src, d_dst);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::sqrIntegral(src, dst);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Integral_Sqr, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
-// HistEven_OneChannel\r
+// HistEvenC1\r
\r
-GPU_PERF_TEST(HistEven_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth)\r
+PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
- int depth = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
\r
- cv::Mat src_host(size, depth);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, depth);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat hist;\r
- cv::gpu::GpuMat buf;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_hist;\r
+ cv::gpu::GpuMat d_buf;\r
\r
- cv::gpu::histEven(src, hist, buf, 30, 0, 180);\r
+ cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::histEven(src, hist, buf, 30, 0, 180);\r
+ int hbins = 30;\r
+ float hranges[] = {0.0f, 180.0f};\r
+ int histSize[] = {hbins};\r
+ const float* ranges[] = {hranges};\r
+ int channels[] = {0};\r
+\r
+ cv::Mat hist;\r
+\r
+ cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_OneChannel, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
-// HistEven_FourChannel\r
+// HistEvenC4\r
\r
-GPU_PERF_TEST(HistEven_FourChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth)\r
+PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
- int depth = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
\r
- cv::Mat src_host(size, CV_MAKE_TYPE(depth, 4));\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_MAKE_TYPE(depth, 4));\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat hist[4];\r
- cv::gpu::GpuMat buf;\r
int histSize[] = {30, 30, 30, 30};\r
int lowerLevel[] = {0, 0, 0, 0};\r
int upperLevel[] = {180, 180, 180, 180};\r
\r
- cv::gpu::histEven(src, hist, buf, histSize, lowerLevel, upperLevel);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_hist[4];\r
+ cv::gpu::GpuMat d_buf;\r
+\r
+ cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::histEven(src, hist, buf, histSize, lowerLevel, upperLevel);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_FourChannel, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// CalcHist\r
\r
-GPU_PERF_TEST(CalcHist, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
- cv::Mat src_host(size, CV_8UC1);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_8UC1);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat hist;\r
- cv::gpu::GpuMat buf;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_hist;\r
+ cv::gpu::GpuMat d_buf;\r
\r
- cv::gpu::calcHist(src, hist, buf);\r
+ cv::gpu::calcHist(d_src, d_hist, d_buf);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::calcHist(d_src, d_hist, d_buf);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::calcHist(src, hist, buf);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// EqualizeHist\r
\r
-GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
- cv::Mat src_host(size, CV_8UC1);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_8UC1);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::GpuMat hist;\r
- cv::gpu::GpuMat buf;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
+ cv::gpu::GpuMat d_hist;\r
+ cv::gpu::GpuMat d_buf;\r
\r
- cv::gpu::equalizeHist(src, dst, hist, buf);\r
+ cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::equalizeHist(src, dst, hist, buf);\r
+ cv::Mat dst;\r
+\r
+ cv::equalizeHist(src, dst);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::equalizeHist(src, dst);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// ColumnSum\r
\r
-GPU_PERF_TEST(ColumnSum, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
- cv::Mat src_host(size, CV_32FC1);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_32FC1);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::columnSum(src, dst);\r
+ cv::gpu::columnSum(d_src, d_dst);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::columnSum(d_src, d_dst);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::columnSum(src, dst);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// Canny\r
\r
-IMPLEMENT_PARAM_CLASS(AppertureSize, int)\r
-IMPLEMENT_PARAM_CLASS(L2gradient, bool)\r
+DEF_PARAM_TEST(Image_AppertureSz_L2gradient, string, int, bool);\r
\r
-GPU_PERF_TEST(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient)\r
+PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine(\r
+ Values("perf/800x600.jpg", "perf/1280x1024.jpg", "perf/1680x1050.jpg"),\r
+ Values(3, 5),\r
+ Bool()))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
+ string fileName = GET_PARAM(0);\r
int apperture_size = GET_PARAM(1);\r
bool useL2gradient = GET_PARAM(2);\r
\r
- cv::Mat image_host = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE);\r
- ASSERT_FALSE(image_host.empty());\r
+ cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);\r
+ ASSERT_FALSE(image.empty());\r
\r
- cv::gpu::GpuMat image(image_host);\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::CannyBuf buf;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_image(image);\r
+ cv::gpu::GpuMat d_dst;\r
+ cv::gpu::CannyBuf d_buf;\r
\r
- cv::gpu::Canny(image, buf, dst, 50.0, 100.0, apperture_size, useL2gradient);\r
+ cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::Canny(image, buf, dst, 50.0, 100.0, apperture_size, useL2gradient);\r
+ cv::Mat dst;\r
+\r
+ cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(\r
- ALL_DEVICES,\r
- testing::Values(AppertureSize(3), AppertureSize(5)),\r
- testing::Values(L2gradient(false), L2gradient(true))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// MeanShiftFiltering\r
\r
-GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo)\r
+DEF_PARAM_TEST_1(Image, string);\r
+\r
+PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values<string>("gpu/meanshift/cones.png"))\r
{\r
- cv::gpu::DeviceInfo devInfo = GetParam();\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(15.0);\r
\r
- cv::Mat img = readImage("gpu/meanshift/cones.png");\r
+ cv::Mat img = readImage(GetParam());\r
ASSERT_FALSE(img.empty());\r
\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
- cv::gpu::GpuMat src(rgba);\r
- cv::gpu::GpuMat dst;\r
-\r
- cv::gpu::meanShiftFiltering(src, dst, 50, 50);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(rgba);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- declare.time(5.0);\r
+ cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::meanShiftFiltering(src, dst, 50, 50);\r
+ cv::Mat dst;\r
+\r
+ cv::pyrMeanShiftFiltering(img, dst, 50, 50);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::pyrMeanShiftFiltering(img, dst, 50, 50);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES);\r
-\r
//////////////////////////////////////////////////////////////////////\r
// MeanShiftProc\r
\r
-GPU_PERF_TEST_1(MeanShiftProc, cv::gpu::DeviceInfo)\r
+PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values<string>("gpu/meanshift/cones.png"))\r
{\r
- cv::gpu::DeviceInfo devInfo = GetParam();\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(5.0);\r
\r
- cv::Mat img = readImage("gpu/meanshift/cones.png");\r
+ cv::Mat img = readImage(GetParam());\r
ASSERT_FALSE(img.empty());\r
\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
- cv::gpu::GpuMat src(rgba);\r
- cv::gpu::GpuMat dstr;\r
- cv::gpu::GpuMat dstsp;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(rgba);\r
+ cv::gpu::GpuMat d_dstr;\r
+ cv::gpu::GpuMat d_dstsp;\r
\r
- cv::gpu::meanShiftProc(src, dstr, dstsp, 50, 50);\r
+ cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);\r
\r
- declare.time(5.0);\r
-\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::meanShiftProc(src, dstr, dstsp, 50, 50);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftProc, ALL_DEVICES);\r
-\r
//////////////////////////////////////////////////////////////////////\r
// MeanShiftSegmentation\r
\r
-GPU_PERF_TEST_1(MeanShiftSegmentation, cv::gpu::DeviceInfo)\r
+PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values<string>("gpu/meanshift/cones.png"))\r
{\r
- cv::gpu::DeviceInfo devInfo = GetParam();\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(5.0);\r
\r
- cv::Mat img = readImage("gpu/meanshift/cones.png");\r
+ cv::Mat img = readImage(GetParam());\r
ASSERT_FALSE(img.empty());\r
\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
- cv::gpu::GpuMat src(rgba);\r
cv::Mat dst;\r
\r
- meanShiftSegmentation(src, dst, 10, 10, 20);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(rgba);\r
\r
- declare.time(5.0);\r
+ cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);\r
+ }\r
+ }\r
+ else\r
{\r
- meanShiftSegmentation(src, dst, 10, 10, 20);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, ALL_DEVICES);\r
-\r
//////////////////////////////////////////////////////////////////////\r
// BlendLinear\r
\r
-GPU_PERF_TEST(BlendLinear, cv::gpu::DeviceInfo, cv::Size, MatType)\r
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_32F), GPU_CHANNELS_1_3_4))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::Mat img1_host(size, type);\r
- fill(img1_host, 0, 255);\r
+ cv::Mat img1(size, type);\r
+ fillRandom(img1);\r
\r
- cv::Mat img2_host(size, type);\r
- fill(img2_host, 0, 255);\r
+ cv::Mat img2(size, type);\r
+ fillRandom(img2);\r
\r
- cv::gpu::GpuMat img1(img1_host);\r
- cv::gpu::GpuMat img2(img2_host);\r
- cv::gpu::GpuMat weights1(size, CV_32FC1, cv::Scalar::all(0.5));\r
- cv::gpu::GpuMat weights2(size, CV_32FC1, cv::Scalar::all(0.5));\r
- cv::gpu::GpuMat dst;\r
-\r
- cv::gpu::blendLinear(img1, img2, weights1, weights2, dst);\r
-\r
- TEST_CYCLE()\r
+ if (runOnGpu)\r
{\r
- cv::gpu::blendLinear(img1, img2, weights1, weights2, dst);\r
+ cv::gpu::GpuMat d_img1(img1);\r
+ cv::gpu::GpuMat d_img2(img2);\r
+ cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5));\r
+ cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5));\r
+ cv::gpu::GpuMat d_dst;\r
+\r
+ cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, BlendLinear, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// Convolve\r
\r
-IMPLEMENT_PARAM_CLASS(KSize, int)\r
-IMPLEMENT_PARAM_CLASS(Ccorr, bool)\r
+DEF_PARAM_TEST(Sz_KernelSz_Ccorr, cv::Size, int, bool);\r
\r
-GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr)\r
+PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool()))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(10.0);\r
+\r
+ cv::Size size = GET_PARAM(0);\r
+ int templ_size = GET_PARAM(1);\r
+ bool ccorr = GET_PARAM(2);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int templ_size = GET_PARAM(2);\r
- bool ccorr = GET_PARAM(3);\r
+ cv::Mat image(size, CV_32FC1);\r
+ image.setTo(1.0);\r
\r
- cv::gpu::GpuMat image = cv::gpu::createContinuous(size, CV_32FC1);\r
- image.setTo(cv::Scalar(1.0));\r
+ cv::Mat templ(templ_size, templ_size, CV_32FC1);\r
+ templ.setTo(1.0);\r
\r
- cv::gpu::GpuMat templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1);\r
- templ.setTo(cv::Scalar(1.0));\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1);\r
+ d_image.upload(image);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::ConvolveBuf buf;\r
+ cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1);\r
+ d_templ.upload(templ);\r
\r
- cv::gpu::convolve(image, templ, dst, ccorr, buf);\r
+ cv::gpu::GpuMat d_dst;\r
+ cv::gpu::ConvolveBuf d_buf;\r
\r
- declare.time(2.0);\r
+ cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::convolve(image, templ, dst, ccorr, buf);\r
+ ASSERT_FALSE(ccorr);\r
+\r
+ cv::Mat dst;\r
+\r
+ cv::filter2D(image, dst, image.depth(), templ);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::filter2D(image, dst, image.depth(), templ);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(KSize(3), KSize(9), KSize(17), KSize(27), KSize(32), KSize(64)),\r
- testing::Values(Ccorr(false), Ccorr(true))));\r
-\r
////////////////////////////////////////////////////////////////////////////////\r
-// MatchTemplate_8U\r
+// MatchTemplate8U\r
\r
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)\r
-#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))\r
+#define ALL_TEMPLATE_METHODS ValuesIn(TemplateMethod::all())\r
\r
-IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size)\r
+DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, int, TemplateMethod);\r
\r
-GPU_PERF_TEST(MatchTemplate_8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod)\r
+PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),\r
+ GPU_CHANNELS_1_3_4,\r
+ ALL_TEMPLATE_METHODS))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ cv::Size templ_size = GET_PARAM(1);\r
+ int cn = GET_PARAM(2);\r
+ int method = GET_PARAM(3);\r
\r
- cv::Size size = GET_PARAM(1);\r
- cv::Size templ_size = GET_PARAM(2);\r
- int cn = GET_PARAM(3);\r
- int method = GET_PARAM(4);\r
+ cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn));\r
+ fillRandom(image);\r
\r
- cv::Mat image_host(size, CV_MAKE_TYPE(CV_8U, cn));\r
- fill(image_host, 0, 255);\r
+ cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));\r
+ fillRandom(templ);\r
\r
- cv::Mat templ_host(templ_size, CV_MAKE_TYPE(CV_8U, cn));\r
- fill(templ_host, 0, 255);\r
-\r
- cv::gpu::GpuMat image(image_host);\r
- cv::gpu::GpuMat templ(templ_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_image(image);\r
+ cv::gpu::GpuMat d_templ(templ);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::matchTemplate(image, templ, dst, method);\r
+ cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::matchTemplate(image, templ, dst, method);\r
+ cv::Mat dst;\r
+\r
+ cv::matchTemplate(image, templ, dst, method);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::matchTemplate(image, templ, dst, method);\r
+ }\r
}\r
};\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_8U, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),\r
- testing::Values(Channels(1), Channels(3), Channels(4)),\r
- ALL_TEMPLATE_METHODS));\r
-\r
////////////////////////////////////////////////////////////////////////////////\r
-// MatchTemplate_32F\r
+// MatchTemplate32F\r
\r
-GPU_PERF_TEST(MatchTemplate_32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod)\r
+PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),\r
+ GPU_CHANNELS_1_3_4,\r
+ Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ cv::Size templ_size = GET_PARAM(1);\r
+ int cn = GET_PARAM(2);\r
+ int method = GET_PARAM(3);\r
\r
- cv::Size size = GET_PARAM(1);\r
- cv::Size templ_size = GET_PARAM(2);\r
- int cn = GET_PARAM(3);\r
- int method = GET_PARAM(4);\r
+ cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn));\r
+ fillRandom(image);\r
\r
- cv::Mat image_host(size, CV_MAKE_TYPE(CV_32F, cn));\r
- fill(image_host, 0, 255);\r
+ cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));\r
+ fillRandom(templ);\r
\r
- cv::Mat templ_host(templ_size, CV_MAKE_TYPE(CV_32F, cn));\r
- fill(templ_host, 0, 255);\r
-\r
- cv::gpu::GpuMat image(image_host);\r
- cv::gpu::GpuMat templ(templ_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_image(image);\r
+ cv::gpu::GpuMat d_templ(templ);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::matchTemplate(image, templ, dst, method);\r
+ cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::matchTemplate(image, templ, dst, method);\r
+ cv::Mat dst;\r
+\r
+ cv::matchTemplate(image, templ, dst, method);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::matchTemplate(image, templ, dst, method);\r
+ }\r
}\r
};\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_32F, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),\r
- testing::Values(Channels(1), Channels(3), Channels(4)),\r
- testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// MulSpectrums\r
\r
CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)\r
\r
-GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags)\r
-{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+DEF_PARAM_TEST(Sz_Flags, cv::Size, DftFlags);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int flag = GET_PARAM(2);\r
+PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(0, DftFlags(cv::DFT_ROWS))))\r
+{\r
+ cv::Size size = GET_PARAM(0);\r
+ int flag = GET_PARAM(1);\r
\r
- cv::Mat a_host(size, CV_32FC2);\r
- fill(a_host, 0, 100);\r
+ cv::Mat a(size, CV_32FC2);\r
+ fillRandom(a, 0, 100);\r
\r
- cv::Mat b_host(size, CV_32FC2);\r
- fill(b_host, 0, 100);\r
+ cv::Mat b(size, CV_32FC2);\r
+ fillRandom(b, 0, 100);\r
\r
- cv::gpu::GpuMat a(a_host);\r
- cv::gpu::GpuMat b(b_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_a(a);\r
+ cv::gpu::GpuMat d_b(b);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::mulSpectrums(a, b, dst, flag);\r
+ cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::mulSpectrums(a, b, dst, flag);\r
+ cv::Mat dst;\r
+\r
+ cv::mulSpectrums(a, b, dst, flag);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::mulSpectrums(a, b, dst, flag);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// MulAndScaleSpectrums\r
\r
-GPU_PERF_TEST(MulAndScaleSpectrums, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
float scale = 1.f / size.area();\r
\r
- cv::Mat src1_host(size, CV_32FC2);\r
- fill(src1_host, 0, 100);\r
+ cv::Mat src1(size, CV_32FC2);\r
+ fillRandom(src1, 0, 100);\r
\r
- cv::Mat src2_host(size, CV_32FC2);\r
- fill(src2_host, 0, 100);\r
+ cv::Mat src2(size, CV_32FC2);\r
+ fillRandom(src2, 0, 100);\r
\r
- cv::gpu::GpuMat src1(src1_host);\r
- cv::gpu::GpuMat src2(src2_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src1(src1);\r
+ cv::gpu::GpuMat d_src2(src2);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::mulAndScaleSpectrums(src1, src2, dst, cv::DFT_ROWS, scale, false);\r
+ cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::mulAndScaleSpectrums(src1, src2, dst, cv::DFT_ROWS, scale, false);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MulAndScaleSpectrums, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// Dft\r
\r
-GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size, DftFlags)\r
+PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(10.0);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int flag = GET_PARAM(2);\r
+ cv::Size size = GET_PARAM(0);\r
+ int flag = GET_PARAM(1);\r
\r
- cv::Mat src_host(size, CV_32FC2);\r
- fill(src_host, 0, 100);\r
+ cv::Mat src(size, CV_32FC2);\r
+ fillRandom(src, 0, 100);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
-\r
- cv::gpu::dft(src, dst, size, flag);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- declare.time(2.0);\r
+ cv::gpu::dft(d_src, d_dst, size, flag);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::dft(d_src, d_dst, size, flag);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::dft(src, dst, size, flag);\r
+ cv::Mat dst;\r
+\r
+ cv::dft(src, dst, flag);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::dft(src, dst, flag);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// CornerHarris\r
\r
-IMPLEMENT_PARAM_CLASS(BlockSize, int)\r
-IMPLEMENT_PARAM_CLASS(ApertureSize, int)\r
+DEF_PARAM_TEST(Image_Type_Border_BlockSz_ApertureSz, string, MatType, BorderMode, int, int);\r
\r
-GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize)\r
+PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(\r
+ Values<string>("gpu/stereobm/aloe-L.png"),\r
+ Values(CV_8UC1, CV_32FC1),\r
+ Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),\r
+ Values(3, 5, 7),\r
+ Values(0, 3, 5, 7)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
+ string fileName = GET_PARAM(0);\r
int type = GET_PARAM(1);\r
- int borderType = GET_PARAM(2);\r
+ int borderMode = GET_PARAM(2);\r
int blockSize = GET_PARAM(3);\r
int apertureSize = GET_PARAM(4);\r
\r
- cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);\r
+ cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);\r
ASSERT_FALSE(img.empty());\r
-\r
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
\r
- cv::gpu::GpuMat src(img);\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::GpuMat Dx;\r
- cv::gpu::GpuMat Dy;\r
- cv::gpu::GpuMat buf;\r
-\r
double k = 0.5;\r
\r
- cv::gpu::cornerHarris(src, dst, Dx, Dy, buf, blockSize, apertureSize, k, borderType);\r
-\r
- TEST_CYCLE()\r
+ if (runOnGpu)\r
{\r
- cv::gpu::cornerHarris(src, dst, Dx, Dy, buf, blockSize, apertureSize, k, borderType);\r
+ cv::gpu::GpuMat d_img(img);\r
+ cv::gpu::GpuMat d_dst;\r
+ cv::gpu::GpuMat d_Dx;\r
+ cv::gpu::GpuMat d_Dy;\r
+ cv::gpu::GpuMat d_buf;\r
+\r
+ cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode);\r
+ }\r
}\r
-}\r
+ else\r
+ {\r
+ cv::Mat dst;\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine(\r
- ALL_DEVICES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)),\r
- testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),\r
- testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),\r
- testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));\r
+ cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);\r
+ }\r
+ }\r
+}\r
\r
//////////////////////////////////////////////////////////////////////\r
// CornerMinEigenVal\r
\r
-GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize)\r
+PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Combine(\r
+ Values<string>("gpu/stereobm/aloe-L.png"),\r
+ Values(CV_8UC1, CV_32FC1),\r
+ Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),\r
+ Values(3, 5, 7),\r
+ Values(0, 3, 5, 7)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
+ string fileName = GET_PARAM(0);\r
int type = GET_PARAM(1);\r
- int borderType = GET_PARAM(2);\r
+ int borderMode = GET_PARAM(2);\r
int blockSize = GET_PARAM(3);\r
int apertureSize = GET_PARAM(4);\r
\r
- cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);\r
+ cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);\r
ASSERT_FALSE(img.empty());\r
\r
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
\r
- cv::gpu::GpuMat src(img);\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::GpuMat Dx;\r
- cv::gpu::GpuMat Dy;\r
- cv::gpu::GpuMat buf;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_img(img);\r
+ cv::gpu::GpuMat d_dst;\r
+ cv::gpu::GpuMat d_Dx;\r
+ cv::gpu::GpuMat d_Dy;\r
+ cv::gpu::GpuMat d_buf;\r
+\r
+ cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ cv::Mat dst;\r
\r
- cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, buf, blockSize, apertureSize, borderType);\r
+ cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);\r
\r
- TEST_CYCLE()\r
- {\r
- cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, buf, blockSize, apertureSize, borderType);\r
+ TEST_CYCLE()\r
+ {\r
+ cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine(\r
- ALL_DEVICES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)),\r
- testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),\r
- testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),\r
- testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// BuildWarpPlaneMaps\r
\r
-GPU_PERF_TEST(BuildWarpPlaneMaps, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);\r
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);\r
cv::Mat T = cv::Mat::zeros(1, 3, CV_32F);\r
- cv::gpu::GpuMat map_x;\r
- cv::gpu::GpuMat map_y;\r
\r
- cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, map_x, map_y);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_map_x;\r
+ cv::gpu::GpuMat d_map_y;\r
+\r
+ cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, map_x, map_y);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpPlaneMaps, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// BuildWarpCylindricalMaps\r
\r
-GPU_PERF_TEST(BuildWarpCylindricalMaps, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);\r
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);\r
- cv::gpu::GpuMat map_x;\r
- cv::gpu::GpuMat map_y;\r
\r
- cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_map_x;\r
+ cv::gpu::GpuMat d_map_y;\r
+\r
+ cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpCylindricalMaps, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// BuildWarpSphericalMaps\r
\r
-GPU_PERF_TEST(BuildWarpSphericalMaps, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);\r
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);\r
- cv::gpu::GpuMat map_x;\r
- cv::gpu::GpuMat map_y;\r
\r
- cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_map_x;\r
+ cv::gpu::GpuMat d_map_y;\r
+\r
+ cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpSphericalMaps, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// Rotate\r
\r
-GPU_PERF_TEST(Rotate, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation)\r
-{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+DEF_PARAM_TEST(Sz_Depth_Cn_Inter, cv::Size, MatDepth, int, Interpolation);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4,\r
+ Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))))\r
+{\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
int interpolation = GET_PARAM(3);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::gpu::rotate(src, dst, size, 30.0, 0, 0, interpolation);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- TEST_CYCLE()\r
+ cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::rotate(src, dst, size, 30.0, 0, 0, interpolation);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Rotate, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
- testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// PyrDown\r
\r
-GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType)\r
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::pyrDown(src, dst);\r
+ cv::gpu::pyrDown(d_src, d_dst);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::pyrDown(d_src, d_dst);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::pyrDown(src, dst);\r
+ cv::Mat dst;\r
+\r
+ cv::pyrDown(src, dst);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::pyrDown(src, dst);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// PyrUp\r
\r
-GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType)\r
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ GPU_CHANNELS_1_3_4))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::pyrUp(src, dst);\r
+ cv::gpu::pyrUp(d_src, d_dst);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::pyrUp(d_src, d_dst);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::pyrUp(src, dst);\r
+ cv::Mat dst;\r
+\r
+ cv::pyrUp(src, dst);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::pyrUp(src, dst);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// CvtColor\r
\r
-GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, MatDepth, CvtColorInfo)\r
+DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CvtColorInfo);\r
+\r
+PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ Values(CV_8U, CV_16U, CV_32F),\r
+ Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),\r
+ CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),\r
+ CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),\r
+ CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),\r
+ CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),\r
+ CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),\r
+ CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),\r
+ CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),\r
+ CvtColorInfo(3, 3, cv::COLOR_RGB2Lab),\r
+ CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),\r
+ CvtColorInfo(3, 3, cv::COLOR_RGB2Luv),\r
+ CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_Lab2RGB),\r
+ CvtColorInfo(3, 3, cv::COLOR_Luv2BGR),\r
+ CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),\r
+ CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR),\r
+ CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR),\r
+ CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR),\r
+ CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR),\r
+ CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA))))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ CvtColorInfo info = GET_PARAM(2);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int depth = GET_PARAM(2);\r
- CvtColorInfo info = GET_PARAM(3);\r
+ cv::Mat src(size, CV_MAKETYPE(depth, info.scn));\r
+ fillRandom(src);\r
\r
- cv::Mat src_host(size, CV_MAKETYPE(depth, info.scn));\r
- fill(src_host, 0, 255);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);\r
\r
- if (info.code >= cv::COLOR_BayerBG2BGR && info.code <= cv::COLOR_BayerGR2BGR)\r
- info.dcn = 4;\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ cv::Mat dst;\r
\r
- cv::gpu::cvtColor(src, dst, info.code, info.dcn);\r
+ cv::cvtColor(src, dst, info.code, info.dcn);\r
\r
- TEST_CYCLE()\r
- {\r
- cv::gpu::cvtColor(src, dst, info.code, info.dcn);\r
+ TEST_CYCLE()\r
+ {\r
+ cv::cvtColor(src, dst, info.code, info.dcn);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)),\r
- testing::Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),\r
- CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),\r
- CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),\r
- CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),\r
- CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),\r
- CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),\r
- CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),\r
- CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),\r
- CvtColorInfo(3, 3, cv::COLOR_RGB2Lab),\r
- CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),\r
- CvtColorInfo(3, 3, cv::COLOR_RGB2Luv),\r
- CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_Lab2RGB),\r
- CvtColorInfo(3, 3, cv::COLOR_Luv2BGR),\r
- CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),\r
- CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR),\r
- CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR),\r
- CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR),\r
- CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR),\r
- CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA))));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// SwapChannels\r
\r
-GPU_PERF_TEST(SwapChannels, cv::gpu::DeviceInfo, cv::Size)\r
+PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::Size size = GET_PARAM(1);\r
+ cv::Size size = GetParam();\r
\r
- cv::Mat src_host(size, CV_8UC4);\r
- fill(src_host, 0, 255);\r
-\r
- cv::gpu::GpuMat src(src_host);\r
+ cv::Mat src(size, CV_8UC4);\r
+ fillRandom(src);\r
\r
const int dstOrder[] = {2, 1, 0, 3};\r
\r
- cv::gpu::swapChannels(src, dstOrder);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+\r
+ cv::gpu::swapChannels(d_src, dstOrder);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::swapChannels(d_src, dstOrder);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::swapChannels(src, dstOrder);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, SwapChannels, testing::Combine(ALL_DEVICES, GPU_TYPICAL_MAT_SIZES));\r
-\r
//////////////////////////////////////////////////////////////////////\r
// AlphaComp\r
\r
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)\r
+#define ALL_ALPHA_OPS ValuesIn(AlphaOp::all())\r
\r
-GPU_PERF_TEST(AlphaComp, cv::gpu::DeviceInfo, cv::Size, MatType, AlphaOp)\r
+DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp);\r
+\r
+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))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ cv::Size size = GET_PARAM(0);\r
+ int type = GET_PARAM(1);\r
+ int alpha_op = GET_PARAM(2);\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
- int alpha_op = GET_PARAM(3);\r
+ cv::Mat img1(size, type);\r
+ fillRandom(img1);\r
\r
- cv::Mat img1_host(size, type);\r
- fill(img1_host, 0, 255);\r
+ cv::Mat img2(size, type);\r
+ fillRandom(img2);\r
\r
- cv::Mat img2_host(size, type);\r
- fill(img2_host, 0, 255);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_img1(img1);\r
+ cv::gpu::GpuMat d_img2(img2);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::GpuMat img1(img1_host);\r
- cv::gpu::GpuMat img2(img2_host);\r
- cv::gpu::GpuMat dst;\r
+ cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);\r
\r
- cv::gpu::alphaComp(img1, img2, dst, alpha_op);\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ FAIL();\r
+ }\r
+}\r
+\r
+//////////////////////////////////////////////////////////////////////\r
+// ImagePyramidBuild\r
+\r
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4))\r
+{\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
\r
- TEST_CYCLE()\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
+\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
+\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+\r
+ cv::gpu::ImagePyramid d_pyr;\r
+\r
+ d_pyr.build(d_src, 5);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ d_pyr.build(d_src, 5);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::alphaComp(img1, img2, dst, alpha_op);\r
+ FAIL();\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, AlphaComp, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC4), MatType(CV_16UC4), MatType(CV_32SC4), MatType(CV_32FC4)),\r
- testing::Values(AlphaOp(cv::gpu::ALPHA_OVER),\r
- AlphaOp(cv::gpu::ALPHA_IN),\r
- AlphaOp(cv::gpu::ALPHA_OUT),\r
- AlphaOp(cv::gpu::ALPHA_ATOP),\r
- AlphaOp(cv::gpu::ALPHA_XOR),\r
- AlphaOp(cv::gpu::ALPHA_PLUS),\r
- AlphaOp(cv::gpu::ALPHA_OVER_PREMUL),\r
- AlphaOp(cv::gpu::ALPHA_IN_PREMUL),\r
- AlphaOp(cv::gpu::ALPHA_OUT_PREMUL),\r
- AlphaOp(cv::gpu::ALPHA_ATOP_PREMUL),\r
- AlphaOp(cv::gpu::ALPHA_XOR_PREMUL),\r
- AlphaOp(cv::gpu::ALPHA_PLUS_PREMUL),\r
- AlphaOp(cv::gpu::ALPHA_PREMUL))));\r
+//////////////////////////////////////////////////////////////////////\r
+// ImagePyramidGetLayer\r
+\r
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4))\r
+{\r
+ cv::Size size = GET_PARAM(0);\r
+ int depth = GET_PARAM(1);\r
+ int channels = GET_PARAM(2);\r
+\r
+ int type = CV_MAKE_TYPE(depth, channels);\r
+\r
+ cv::Mat src(size, type);\r
+ fillRandom(src);\r
+\r
+ cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);\r
+\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
+\r
+ cv::gpu::ImagePyramid d_pyr(d_src, 3);\r
+\r
+ d_pyr.getLayer(d_dst, dstSize);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ d_pyr.getLayer(d_dst, dstSize);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ FAIL();\r
+ }\r
+}\r
\r
//////////////////////////////////////////////////////////////////////\r
-// ImagePyramid\r
+// HoughLines\r
\r
-GPU_PERF_TEST(ImagePyramid_build, cv::gpu::DeviceInfo, cv::Size, MatType)\r
+PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(30.0);\r
+\r
+ const cv::Size size = GetParam();\r
+\r
+ const float rho = 1.0f;\r
+ const float theta = static_cast<float>(CV_PI / 180.0);\r
+ const int threshold = 300;\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ cv::RNG rng(123456789);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));\r
\r
- cv::gpu::GpuMat src(src_host);\r
+ const int numLines = rng.uniform(100, 300);\r
+ for (int i = 0; i < numLines; ++i)\r
+ {\r
+ cv::Point p1(rng.uniform(0, src.cols), rng.uniform(0, src.rows));\r
+ cv::Point p2(rng.uniform(0, src.cols), rng.uniform(0, src.rows));\r
+ cv::line(src, p1, p2, cv::Scalar::all(255), 2);\r
+ }\r
\r
- cv::gpu::ImagePyramid pyr;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_lines;\r
+ cv::gpu::HoughLinesBuf d_buf;\r
\r
- pyr.build(src, 5);\r
+ cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);\r
+ }\r
+ }\r
+ else\r
{\r
- pyr.build(src, 5);\r
+ std::vector<cv::Vec2f> lines;\r
+ cv::HoughLines(src, lines, rho, theta, threshold);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::HoughLines(src, lines, rho, theta, threshold);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_build, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));\r
+//////////////////////////////////////////////////////////////////////\r
+// HoughCircles\r
+\r
+DEF_PARAM_TEST(Sz_Dp_MinDist, cv::Size, float, float);\r
\r
-GPU_PERF_TEST(ImagePyramid_getLayer, cv::gpu::DeviceInfo, cv::Size, MatType)\r
+PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES, Values(1.0f, 2.0f, 4.0f), Values(1.0f, 10.0f)))\r
{\r
- cv::gpu::DeviceInfo devInfo = GET_PARAM(0);\r
- cv::gpu::setDevice(devInfo.deviceID());\r
+ declare.time(30.0);\r
+\r
+ const cv::Size size = GET_PARAM(0);\r
+ const float dp = GET_PARAM(1);\r
+ const float minDist = GET_PARAM(2);\r
+\r
+ const int minRadius = 10;\r
+ const int maxRadius = 30;\r
+ const int cannyThreshold = 100;\r
+ const int votesThreshold = 15;\r
\r
- cv::Size size = GET_PARAM(1);\r
- int type = GET_PARAM(2);\r
+ cv::RNG rng(123456789);\r
\r
- cv::Mat src_host(size, type);\r
- fill(src_host, 0, 255);\r
+ cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));\r
\r
- cv::gpu::GpuMat src(src_host);\r
- cv::gpu::GpuMat dst;\r
+ const int numCircles = rng.uniform(50, 100);\r
+ for (int i = 0; i < numCircles; ++i)\r
+ {\r
+ cv::Point center(rng.uniform(0, src.cols), rng.uniform(0, src.rows));\r
+ const int radius = rng.uniform(minRadius, maxRadius + 1);\r
\r
- cv::gpu::ImagePyramid pyr(src, 3);\r
+ cv::circle(src, center, radius, cv::Scalar::all(255), -1);\r
+ }\r
\r
- pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10));\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_circles;\r
+ cv::gpu::HoughCirclesBuf d_buf;\r
\r
- TEST_CYCLE()\r
+ cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);\r
+ }\r
+ }\r
+ else\r
{\r
- pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10));\r
+ std::vector<cv::Vec3f> circles;\r
+\r
+ cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);\r
+ }\r
}\r
}\r
\r
-INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_getLayer, testing::Combine(\r
- ALL_DEVICES,\r
- GPU_TYPICAL_MAT_SIZES,\r
- testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),\r
- MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),\r
- MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));\r
+//////////////////////////////////////////////////////////////////////\r
+// GeneralizedHough\r
+\r
+CV_FLAGS(GHMethod, cv::GHT_POSITION, cv::GHT_SCALE, cv::GHT_ROTATION);\r
+\r
+DEF_PARAM_TEST(Method_Sz, GHMethod, cv::Size);\r
+\r
+PERF_TEST_P(Method_Sz, GeneralizedHough, Combine(\r
+ Values(GHMethod(cv::GHT_POSITION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE), GHMethod(cv::GHT_POSITION | cv::GHT_ROTATION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE | cv::GHT_ROTATION)),\r
+ GPU_TYPICAL_MAT_SIZES))\r
+{\r
+ declare.time(10);\r
+\r
+ const int method = GET_PARAM(0);\r
+ const cv::Size imageSize = GET_PARAM(1);\r
+\r
+ const cv::Mat templ = readImage("cv/shared/templ.png", cv::IMREAD_GRAYSCALE);\r
+ ASSERT_FALSE(templ.empty());\r
+\r
+ cv::Mat image(imageSize, CV_8UC1, cv::Scalar::all(0));\r
+\r
+ cv::RNG rng(123456789);\r
+ const int objCount = rng.uniform(5, 15);\r
+ for (int i = 0; i < objCount; ++i)\r
+ {\r
+ double scale = rng.uniform(0.7, 1.3);\r
+ bool rotate = rng.uniform(0, 2);\r
+\r
+ cv::Mat obj;\r
+ cv::resize(templ, obj, cv::Size(), scale, scale);\r
+ if (rotate)\r
+ obj = obj.t();\r
+\r
+ cv::Point pos;\r
+\r
+ pos.x = rng.uniform(0, image.cols - obj.cols);\r
+ pos.y = rng.uniform(0, image.rows - obj.rows);\r
+\r
+ cv::Mat roi = image(cv::Rect(pos, obj.size()));\r
+ cv::add(roi, obj, roi);\r
+ }\r
+\r
+ cv::Mat edges;\r
+ cv::Canny(image, edges, 50, 100);\r
+\r
+ cv::Mat dx, dy;\r
+ cv::Sobel(image, dx, CV_32F, 1, 0);\r
+ cv::Sobel(image, dy, CV_32F, 0, 1);\r
+\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_edges(edges);\r
+ cv::gpu::GpuMat d_dx(dx);\r
+ cv::gpu::GpuMat d_dy(dy);\r
+ cv::gpu::GpuMat d_position;\r
+\r
+ cv::Ptr<cv::gpu::GeneralizedHough_GPU> d_hough = cv::gpu::GeneralizedHough_GPU::create(method);\r
+ if (method & cv::GHT_ROTATION)\r
+ {\r
+ d_hough->set("maxAngle", 90.0);\r
+ d_hough->set("angleStep", 2.0);\r
+ }\r
+\r
+ d_hough->setTemplate(cv::gpu::GpuMat(templ));\r
+\r
+ d_hough->detect(d_edges, d_dx, d_dy, d_position);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ d_hough->detect(d_edges, d_dx, d_dy, d_position);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ cv::Mat positions;\r
+\r
+ cv::Ptr<cv::GeneralizedHough> hough = cv::GeneralizedHough::create(method);\r
+ if (method & cv::GHT_ROTATION)\r
+ {\r
+ hough->set("maxAngle", 90.0);\r
+ hough->set("angleStep", 2.0);\r
+ }\r
+\r
+ hough->setTemplate(templ);\r
+\r
+ hough->detect(edges, dx, dy, positions);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ hough->detect(edges, dx, dy, positions);\r
+ }\r
+ }\r
+}\r
\r
-#endif\r
+} // namespace\r