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 * (i - map_x.cols * 0.25) + 0.5;\r
- map_y.at<float>(j,i) = 2 * (j - map_x.rows * 0.25) + 0.5;\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;\r
- map_y.at<float>(j,i) = 0;\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) = i;\r
- map_y.at<float>(j,i) = map_x.rows - j;\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) = map_x.cols - i;\r
- map_y.at<float>(j,i) = j;\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) = map_x.cols - i;\r
- map_y.at<float>(j,i) = map_x.rows - j;\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
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
- Values(1, 3, 4),\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(3.0);\r
+ declare.time(20.0);\r
\r
cv::Size size = GET_PARAM(0);\r
int depth = GET_PARAM(1);\r
\r
generateMap(xmap, ymap, remapMode);\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
+ 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
- cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);\r
+ cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);\r
+ cv::Mat dst;\r
+\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
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
- Values(1, 3, 4),\r
+ GPU_CHANNELS_1_3_4,\r
ALL_INTERPOLATIONS,\r
Values(0.5, 0.3, 2.0)))\r
{\r
- declare.time(1.0);\r
+ declare.time(20.0);\r
\r
cv::Size size = GET_PARAM(0);\r
int depth = GET_PARAM(1);\r
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);\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(d_src, d_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
PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(\r
GPU_TYPICAL_MAT_SIZES,\r
Values(CV_8U, CV_16U, CV_32F),\r
- Values(1, 3, 4),\r
+ GPU_CHANNELS_1_3_4,\r
Values(0.2, 0.1, 0.05)))\r
{\r
declare.time(1.0);\r
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);\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(d_src, d_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
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
- Values(1, 3, 4),\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
+ 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
{std::sin(aplha), std::cos(aplha), 0}};\r
cv::Mat M(2, 3, CV_64F, (void*) mat);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\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
+ 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(d_src, d_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
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
- Values(1, 3, 4),\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
+ 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
{0.0, 0.0, 1.0}};\r
cv::Mat M(3, 3, CV_64F, (void*) mat);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\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
+ 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(d_src, d_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
PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine(\r
GPU_TYPICAL_MAT_SIZES,\r
Values(CV_8U, CV_16U, CV_32F),\r
- Values(1, 3, 4),\r
+ GPU_CHANNELS_1_3_4,\r
ALL_BORDER_MODES))\r
{\r
cv::Size size = GET_PARAM(0);\r
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);\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(d_src, d_dst, 5, 5, 5, 5, borderMode);\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
cv::Mat src(size, depth);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::threshold(d_src, d_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(d_src, d_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
cv::Mat src(size, CV_8UC1);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
- cv::gpu::GpuMat d_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(d_src, d_dst, d_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(d_src, d_dst, d_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
cv::Mat src(size, CV_8UC1);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::sqrIntegral(d_src, d_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(d_src, d_dst);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat src(size, depth);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_hist;\r
- cv::gpu::GpuMat d_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(d_src, d_hist, d_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(d_src, d_hist, d_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
int lowerLevel[] = {0, 0, 0, 0};\r
int upperLevel[] = {180, 180, 180, 180};\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_hist[4];\r
- cv::gpu::GpuMat d_buf;\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
+ 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(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat src(size, CV_8UC1);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_hist;\r
- cv::gpu::GpuMat d_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(d_src, d_hist, d_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(d_src, d_hist, d_buf);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat src(size, CV_8UC1);\r
fillRandom(src);\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
+ 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(d_src, d_dst, d_hist, d_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(d_src, d_dst, d_hist, d_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
cv::Mat src(size, CV_32FC1);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::columnSum(d_src, d_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(d_src, d_dst);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);\r
ASSERT_FALSE(image.empty());\r
\r
- cv::gpu::GpuMat d_image(image);\r
- cv::gpu::GpuMat d_dst;\r
- cv::gpu::CannyBuf d_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(d_image, d_buf, d_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(d_image, d_buf, d_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
\r
PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values<string>("gpu/meanshift/cones.png"))\r
{\r
- declare.time(5.0);\r
+ declare.time(15.0);\r
\r
cv::Mat img = readImage(GetParam());\r
ASSERT_FALSE(img.empty());\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
- cv::gpu::GpuMat d_src(rgba);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(rgba);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);\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(d_src, d_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
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
- cv::gpu::GpuMat d_src(rgba);\r
- cv::gpu::GpuMat d_dstr;\r
- cv::gpu::GpuMat d_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(d_src, d_dstr, d_dstsp, 50, 50);\r
+ cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);\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(d_src, d_dstr, d_dstsp, 50, 50);\r
+ FAIL();\r
}\r
}\r
\r
\r
cv::Mat dst;\r
\r
- cv::gpu::GpuMat d_src(rgba);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(rgba);\r
\r
- cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);\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
- cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);\r
+ FAIL();\r
}\r
}\r
\r
//////////////////////////////////////////////////////////////////////\r
// BlendLinear\r
\r
-PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_32F), Values(1, 3, 4)))\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::Size size = GET_PARAM(0);\r
int depth = GET_PARAM(1);\r
cv::Mat img2(size, type);\r
fillRandom(img2);\r
\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
+ if (runOnGpu)\r
+ {\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
+ cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);\r
+ FAIL();\r
}\r
}\r
\r
\r
PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool()))\r
{\r
- declare.time(2.0);\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::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1);\r
- d_image.setTo(cv::Scalar(1.0));\r
+ cv::Mat image(size, CV_32FC1);\r
+ image.setTo(1.0);\r
\r
- cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1);\r
- d_templ.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 d_dst;\r
- cv::gpu::ConvolveBuf d_buf;\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::convolve(d_image, d_templ, d_dst, ccorr, d_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::GpuMat d_dst;\r
+ cv::gpu::ConvolveBuf d_buf;\r
\r
- TEST_CYCLE()\r
- {\r
cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);\r
+ }\r
+ }\r
+ else\r
+ {\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
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
- Values(1, 3, 4),\r
+ GPU_CHANNELS_1_3_4,\r
ALL_TEMPLATE_METHODS))\r
{\r
cv::Size size = GET_PARAM(0);\r
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));\r
fillRandom(templ);\r
\r
- cv::gpu::GpuMat d_image(image);\r
- cv::gpu::GpuMat d_templ(templ);\r
- cv::gpu::GpuMat d_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(d_image, d_templ, d_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(d_image, d_templ, d_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
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
- Values(1, 3, 4),\r
+ GPU_CHANNELS_1_3_4,\r
Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))))\r
{\r
cv::Size size = GET_PARAM(0);\r
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));\r
fillRandom(templ);\r
\r
- cv::gpu::GpuMat d_image(image);\r
- cv::gpu::GpuMat d_templ(templ);\r
- cv::gpu::GpuMat d_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(d_image, d_templ, d_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(d_image, d_templ, d_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
cv::Mat b(size, CV_32FC2);\r
fillRandom(b, 0, 100);\r
\r
- cv::gpu::GpuMat d_a(a);\r
- cv::gpu::GpuMat d_b(b);\r
- cv::gpu::GpuMat d_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(d_a, d_b, d_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(d_a, d_b, d_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
cv::Mat src2(size, CV_32FC2);\r
fillRandom(src2, 0, 100);\r
\r
- cv::gpu::GpuMat d_src1(src1);\r
- cv::gpu::GpuMat d_src2(src2);\r
- cv::gpu::GpuMat d_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(d_src1, d_src2, d_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(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);\r
+ FAIL();\r
}\r
}\r
\r
GPU_TYPICAL_MAT_SIZES,\r
Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))))\r
{\r
- declare.time(2.0);\r
+ declare.time(10.0);\r
\r
cv::Size size = GET_PARAM(0);\r
int flag = GET_PARAM(1);\r
cv::Mat src(size, CV_32FC2);\r
fillRandom(src, 0, 100);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::dft(d_src, d_dst, size, flag);\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(d_src, d_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
Values(3, 5, 7),\r
Values(0, 3, 5, 7)))\r
{\r
- double k = 0.5;\r
-\r
string fileName = GET_PARAM(0);\r
int type = GET_PARAM(1);\r
int borderMode = GET_PARAM(2);\r
\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 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
+ double k = 0.5;\r
\r
- TEST_CYCLE()\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::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
+ else\r
+ {\r
+ cv::Mat dst;\r
+\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
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\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
+ 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
+ cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);\r
\r
- TEST_CYCLE()\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::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);\r
+ cv::Mat dst;\r
+\r
+ cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);\r
+ }\r
}\r
}\r
\r
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);\r
cv::Mat T = cv::Mat::zeros(1, 3, CV_32F);\r
\r
- cv::gpu::GpuMat d_map_x;\r
- cv::gpu::GpuMat d_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
+ 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, d_map_x, d_map_y);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);\r
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);\r
\r
- cv::gpu::GpuMat d_map_x;\r
- cv::gpu::GpuMat d_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
+ 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, d_map_x, d_map_y);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);\r
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);\r
\r
- cv::gpu::GpuMat d_map_x;\r
- cv::gpu::GpuMat d_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
+ 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, d_map_x, d_map_y);\r
+ FAIL();\r
}\r
}\r
\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
- Values(1, 3, 4),\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
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);\r
+ cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);\r
\r
- TEST_CYCLE()\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(d_src, d_dst, size, 30.0, 0, 0, interpolation);\r
+ FAIL();\r
}\r
}\r
\r
PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(\r
GPU_TYPICAL_MAT_SIZES,\r
Values(CV_8U, CV_16U, CV_32F),\r
- Values(1, 3, 4)))\r
+ GPU_CHANNELS_1_3_4))\r
{\r
cv::Size size = GET_PARAM(0);\r
int depth = GET_PARAM(1);\r
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::pyrDown(d_src, d_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(d_src, d_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
PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(\r
GPU_TYPICAL_MAT_SIZES,\r
Values(CV_8U, CV_16U, CV_32F),\r
- Values(1, 3, 4)))\r
+ GPU_CHANNELS_1_3_4))\r
{\r
cv::Size size = GET_PARAM(0);\r
int depth = GET_PARAM(1);\r
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::pyrUp(d_src, d_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(d_src, d_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
cv::Mat src(size, CV_MAKETYPE(depth, info.scn));\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
+ cv::gpu::GpuMat d_dst;\r
\r
- cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);\r
+ cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);\r
+ cv::Mat dst;\r
+\r
+ cv::cvtColor(src, dst, info.code, info.dcn);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::cvtColor(src, dst, info.code, info.dcn);\r
+ }\r
}\r
}\r
\r
\r
const int dstOrder[] = {2, 1, 0, 3};\r
\r
- cv::gpu::GpuMat d_src(src);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
\r
- cv::gpu::swapChannels(d_src, dstOrder);\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(d_src, dstOrder);\r
+ FAIL();\r
}\r
}\r
\r
cv::Mat img2(size, type);\r
fillRandom(img2);\r
\r
- cv::gpu::GpuMat d_img1(img1);\r
- cv::gpu::GpuMat d_img2(img2);\r
- cv::gpu::GpuMat d_dst;\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::alphaComp(d_img1, d_img2, d_dst, alpha_op);\r
+ cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);\r
+ }\r
+ }\r
+ else\r
{\r
- cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);\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), Values(1, 3, 4)))\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
cv::Mat src(size, type);\r
fillRandom(src);\r
\r
- cv::gpu::GpuMat d_src(src);\r
+ if (runOnGpu)\r
+ {\r
+ cv::gpu::GpuMat d_src(src);\r
\r
- cv::gpu::ImagePyramid d_pyr;\r
+ cv::gpu::ImagePyramid d_pyr;\r
\r
- d_pyr.build(d_src, 5);\r
+ d_pyr.build(d_src, 5);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ d_pyr.build(d_src, 5);\r
+ }\r
+ }\r
+ else\r
{\r
- d_pyr.build(d_src, 5);\r
+ FAIL();\r
}\r
}\r
\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), Values(1, 3, 4)))\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
\r
cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_dst;\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
+ cv::gpu::ImagePyramid d_pyr(d_src, 3);\r
\r
- d_pyr.getLayer(d_dst, dstSize);\r
+ d_pyr.getLayer(d_dst, dstSize);\r
\r
- TEST_CYCLE()\r
+ TEST_CYCLE()\r
+ {\r
+ d_pyr.getLayer(d_dst, dstSize);\r
+ }\r
+ }\r
+ else\r
{\r
- d_pyr.getLayer(d_dst, dstSize);\r
+ FAIL();\r
}\r
}\r
\r
//////////////////////////////////////////////////////////////////////\r
// HoughLines\r
\r
-DEF_PARAM_TEST(Sz_DoSort, cv::Size, bool);\r
-\r
-PERF_TEST_P(Sz_DoSort, ImgProc_HoughLines, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))\r
+PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)\r
{\r
declare.time(30.0);\r
\r
- const cv::Size size = GET_PARAM(0);\r
- const bool doSort = GET_PARAM(1);\r
+ const cv::Size size = GetParam();\r
\r
const float rho = 1.0f;\r
- const float theta = CV_PI / 180.0f;\r
+ const float theta = static_cast<float>(CV_PI / 180.0);\r
const int threshold = 300;\r
\r
cv::RNG rng(123456789);\r
\r
cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));\r
\r
- const int numLines = rng.uniform(500, 2000);\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::line(src, p1, p2, cv::Scalar::all(255), 2);\r
}\r
\r
- cv::gpu::GpuMat d_src(src);\r
- cv::gpu::GpuMat d_lines;\r
- cv::gpu::GpuMat d_accum;\r
- cv::gpu::GpuMat d_buf;\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
+ cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);\r
+\r
+ TEST_CYCLE()\r
+ {\r
+ cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);\r
+ }\r
+ }\r
+ else\r
+ {\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
+//////////////////////////////////////////////////////////////////////\r
+// HoughCircles\r
+\r
+DEF_PARAM_TEST(Sz_Dp_MinDist, cv::Size, float, float);\r
+\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
+ 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::RNG rng(123456789);\r
+\r
+ cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));\r
+\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::circle(src, center, radius, cv::Scalar::all(255), -1);\r
+ }\r
+\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
+ 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
+ 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
+//////////////////////////////////////////////////////////////////////\r
+// GeneralizedHough\r
\r
- cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort);\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
- TEST_CYCLE()\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
- cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort);\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