diff --git a/modules/gpu/perf/perf_calib3d.cpp b/modules/gpu/perf/perf_calib3d.cpp index 343a4e9fad..f62185e007 100644 --- a/modules/gpu/perf/perf_calib3d.cpp +++ b/modules/gpu/perf/perf_calib3d.cpp @@ -15,22 +15,42 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(make_pair("gpu/p { declare.time(5.0); - cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + const cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(imgLeft.empty()); - cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + const cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(imgRight.empty()); - cv::gpu::StereoBM_GPU d_bm(0, 256); - cv::gpu::GpuMat d_imgLeft(imgLeft); - cv::gpu::GpuMat d_imgRight(imgRight); - cv::gpu::GpuMat d_dst; + const int preset = 0; + const int ndisp = 256; - d_bm(d_imgLeft, d_imgRight, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::StereoBM_GPU d_bm(preset, ndisp); + + cv::gpu::GpuMat d_imgLeft(imgLeft); + cv::gpu::GpuMat d_imgRight(imgRight); + cv::gpu::GpuMat d_dst; + d_bm(d_imgLeft, d_imgRight, d_dst); + + TEST_CYCLE() + { + d_bm(d_imgLeft, d_imgRight, d_dst); + } + } + else + { + cv::StereoBM bm(preset, ndisp); + + cv::Mat dst; + + bm(imgLeft, imgRight, dst); + + TEST_CYCLE() + { + bm(imgLeft, imgRight, dst); + } } } @@ -41,22 +61,32 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(make_pair("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png"))) { - cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); + const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); + const cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(disp.empty()); - cv::gpu::DisparityBilateralFilter d_filter(128); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_disp(disp); - cv::gpu::GpuMat d_dst; + const int ndisp = 128; - d_filter(d_disp, d_img, d_dst); - - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::DisparityBilateralFilter d_filter(ndisp); + + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_disp(disp); + cv::gpu::GpuMat d_dst; + d_filter(d_disp, d_img, d_dst); + + TEST_CYCLE() + { + d_filter(d_disp, d_img, d_dst); + } + } + else + { + FAIL(); } } @@ -117,22 +167,29 @@ DEF_PARAM_TEST_1(Count, int); PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000)) { - int count = GetParam(); + const int count = GetParam(); cv::Mat src(1, count, CV_32FC3); fillRandom(src, -100, 100); - cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); + cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); + } + } + else { - cv::gpu::transformPoints(d_src, rvec, tvec, d_dst); + FAIL(); } } @@ -141,23 +198,37 @@ PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000)) PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000)) { - int count = GetParam(); + const int count = GetParam(); cv::Mat src(1, count, CV_32FC3); fillRandom(src, -100, 100); - cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); + const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); + const cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); + cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); + } + } + else { - cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst); + cv::Mat dst; + + cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); + + TEST_CYCLE() + { + cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); + } } } @@ -166,9 +237,9 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000)) PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) { - declare.time(3.0); + declare.time(10.0); - int count = GetParam(); + const int count = GetParam(); cv::Mat object(1, count, CV_32FC3); fillRandom(object, -100, 100); @@ -180,7 +251,7 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) camera_mat.at(2, 0) = 0.f; camera_mat.at(2, 1) = 0.f; - cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); + const cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); std::vector image_vec; cv::Mat rvec_gold(1, 3, CV_32FC1); @@ -194,11 +265,23 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) cv::Mat rvec; cv::Mat tvec; - cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - - TEST_CYCLE() + if (runOnGpu) { cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + + TEST_CYCLE() + { + cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + } + } + else + { + cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + + TEST_CYCLE() + { + cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); + } } } @@ -207,8 +290,8 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000)) PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src, 5.0, 30.0); @@ -216,14 +299,28 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat Q(4, 4, CV_32FC1); fillRandom(Q, 0.1, 1.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); + cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); + } + } + else { - cv::gpu::reprojectImageTo3D(d_src, d_dst, Q); + cv::Mat dst; + + cv::reprojectImageTo3D(src, dst, Q); + + TEST_CYCLE() + { + cv::reprojectImageTo3D(src, dst, Q); + } } } @@ -232,20 +329,27 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S))) { - cv::Size size = GET_PARAM(0); - int type = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int type = GET_PARAM(1); cv::Mat src(size, type); fillRandom(src, 0, 255); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::drawColorDisp(d_src, d_dst, 255); + cv::gpu::drawColorDisp(d_src, d_dst, 255); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::drawColorDisp(d_src, d_dst, 255); + } + } + else { - cv::gpu::drawColorDisp(d_src, d_dst, 255); + FAIL(); } } diff --git a/modules/gpu/perf/perf_core.cpp b/modules/gpu/perf/perf_core.cpp index b56713a70e..90d0d831c9 100644 --- a/modules/gpu/perf/perf_core.cpp +++ b/modules/gpu/perf/perf_core.cpp @@ -12,21 +12,39 @@ namespace { PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - std::vector d_src(channels); + std::vector src(channels); for (int i = 0; i < channels; ++i) - d_src[i] = cv::gpu::GpuMat(size, depth, cv::Scalar::all(i)); + src[i] = cv::Mat(size, depth, cv::Scalar::all(i)); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + std::vector d_src(channels); + for (int i = 0; i < channels; ++i) + d_src[i].upload(src[i]); - cv::gpu::merge(d_src, d_dst); + cv::gpu::GpuMat d_dst; - TEST_CYCLE() - { cv::gpu::merge(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::merge(d_src, d_dst); + } + } + else + { + cv::Mat dst; + + cv::merge(src, dst); + + TEST_CYCLE() + { + cv::merge(src, dst); + } } } @@ -35,19 +53,35 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - cv::gpu::GpuMat d_src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); + cv::Mat src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); - std::vector d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); - cv::gpu::split(d_src, d_dst); + std::vector d_dst; - TEST_CYCLE() - { cv::gpu::split(d_src, d_dst); + + TEST_CYCLE() + { + cv::gpu::split(d_src, d_dst); + } + } + else + { + std::vector dst; + + cv::split(src, dst); + + TEST_CYCLE() + { + cv::split(src, dst); + } } } @@ -56,8 +90,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -65,15 +99,29 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEP cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::add(d_src1, d_src2, d_dst); + cv::gpu::add(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::add(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::add(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::add(src1, src2, dst); + + TEST_CYCLE() + { + cv::add(src1, src2, dst); + } } } @@ -82,22 +130,36 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEP PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::add(d_src, s, d_dst); + cv::gpu::add(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::add(d_src, s, d_dst); + } + } + else { - cv::gpu::add(d_src, s, d_dst); + cv::Mat dst; + + cv::add(src, s, dst); + + TEST_CYCLE() + { + cv::add(src, s, dst); + } } } @@ -106,8 +168,8 @@ PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -115,15 +177,29 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::subtract(d_src1, d_src2, d_dst); + cv::gpu::subtract(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::subtract(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::subtract(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::subtract(src1, src2, dst); + + TEST_CYCLE() + { + cv::subtract(src1, src2, dst); + } } } @@ -132,22 +208,36 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::subtract(d_src, s, d_dst); + cv::gpu::subtract(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::subtract(d_src, s, d_dst); + } + } + else { - cv::gpu::subtract(d_src, s, d_dst); + cv::Mat dst; + + cv::subtract(src, s, dst); + + TEST_CYCLE() + { + cv::subtract(src, s, dst); + } } } @@ -156,8 +246,8 @@ PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -165,15 +255,29 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::multiply(d_src1, d_src2, d_dst); + cv::gpu::multiply(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::multiply(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::multiply(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::multiply(src1, src2, dst); + + TEST_CYCLE() + { + cv::multiply(src1, src2, dst); + } } } @@ -182,22 +286,36 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::multiply(d_src, s, d_dst); + cv::gpu::multiply(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::multiply(d_src, s, d_dst); + } + } + else { - cv::gpu::multiply(d_src, s, d_dst); + cv::Mat dst; + + cv::multiply(src, s, dst); + + TEST_CYCLE() + { + cv::multiply(src, s, dst); + } } } @@ -206,8 +324,8 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -215,15 +333,29 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_ cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::divide(d_src1, d_src2, d_dst); + cv::gpu::divide(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::divide(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::divide(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::divide(src1, src2, dst); + + TEST_CYCLE() + { + cv::divide(src1, src2, dst); + } } } @@ -232,22 +364,36 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_ PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::divide(d_src, s, d_dst); + cv::gpu::divide(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::divide(d_src, s, d_dst); + } + } + else { - cv::gpu::divide(d_src, s, d_dst); + cv::Mat dst; + + cv::divide(src, s, dst); + + TEST_CYCLE() + { + cv::divide(src, s, dst); + } } } @@ -256,22 +402,36 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_M PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); double s = 100.0; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::divide(s, d_src, d_dst); + cv::gpu::divide(s, d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::divide(s, d_src, d_dst); + } + } + else { - cv::gpu::divide(s, d_src, d_dst); + cv::Mat dst; + + cv::divide(s, src, dst); + + TEST_CYCLE() + { + cv::divide(s, src, dst); + } } } @@ -280,8 +440,8 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITH PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -289,15 +449,29 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::absdiff(d_src1, d_src2, d_dst); + cv::gpu::absdiff(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::absdiff(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::absdiff(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::absdiff(src1, src2, dst); + + TEST_CYCLE() + { + cv::absdiff(src1, src2, dst); + } } } @@ -306,22 +480,36 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::absdiff(d_src, s, d_dst); + cv::gpu::absdiff(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::absdiff(d_src, s, d_dst); + } + } + else { - cv::gpu::absdiff(d_src, s, d_dst); + cv::Mat dst; + + cv::absdiff(src, s, dst); + + TEST_CYCLE() + { + cv::absdiff(src, s, dst); + } } } @@ -330,20 +518,27 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_ PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::abs(d_src, d_dst); + cv::gpu::abs(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::abs(d_src, d_dst); + } + } + else { - cv::gpu::abs(d_src, d_dst); + FAIL(); } } @@ -352,20 +547,27 @@ PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::sqr(d_src, d_dst); + cv::gpu::sqr(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::sqr(d_src, d_dst); + } + } + else { - cv::gpu::sqr(d_src, d_dst); + FAIL(); } } @@ -374,20 +576,34 @@ PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_ PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::sqrt(d_src, d_dst); + cv::gpu::sqrt(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::sqrt(d_src, d_dst); + } + } + else { - cv::gpu::sqrt(d_src, d_dst); + cv::Mat dst; + + cv::sqrt(src, dst); + + TEST_CYCLE() + { + cv::sqrt(src, dst); + } } } @@ -396,20 +612,34 @@ PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src, 1.0, 255.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::log(d_src, d_dst); + cv::gpu::log(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::log(d_src, d_dst); + } + } + else { - cv::gpu::log(d_src, d_dst); + cv::Mat dst; + + cv::log(src, dst); + + TEST_CYCLE() + { + cv::log(src, dst); + } } } @@ -418,20 +648,34 @@ PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_ PERF_TEST_P(Sz_Depth, Core_Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src, 1.0, 10.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::exp(d_src, d_dst); + cv::gpu::exp(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::exp(d_src, d_dst); + } + } + else { - cv::gpu::exp(d_src, d_dst); + cv::Mat dst; + + cv::exp(src, dst); + + TEST_CYCLE() + { + cv::exp(src, dst); + } } } @@ -442,21 +686,35 @@ DEF_PARAM_TEST(Sz_Depth_Power, cv::Size, MatDepth, double); PERF_TEST_P(Sz_Depth_Power, Core_Pow, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F), Values(0.3, 2.0, 2.4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - double power = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const double power = GET_PARAM(2); cv::Mat src(size, depth); fillRandom(src, 1.0, 10.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::pow(d_src, power, d_dst); + cv::gpu::pow(d_src, power, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::pow(d_src, power, d_dst); + } + } + else { - cv::gpu::pow(d_src, power, d_dst); + cv::Mat dst; + + cv::pow(src, power, dst); + + TEST_CYCLE() + { + cv::pow(src, power, dst); + } } } @@ -470,9 +728,9 @@ DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CmpCode); PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int cmp_code = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int cmp_code = GET_PARAM(2); cv::Mat src1(size, depth); fillRandom(src1); @@ -480,15 +738,29 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITH cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); + cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); + } + } + else { - cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code); + cv::Mat dst; + + cv::compare(src1, src2, dst, cmp_code); + + TEST_CYCLE() + { + cv::compare(src1, src2, dst, cmp_code); + } } } @@ -497,23 +769,37 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITH PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES)) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int cmp_code = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int cmp_code = GET_PARAM(2); cv::Mat src(size, depth); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::compare(d_src, s, d_dst, cmp_code); + cv::gpu::compare(d_src, s, d_dst, cmp_code); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::compare(d_src, s, d_dst, cmp_code); + } + } + else { - cv::gpu::compare(d_src, s, d_dst, cmp_code); + cv::Mat dst; + + cv::compare(src, s, dst, cmp_code); + + TEST_CYCLE() + { + cv::compare(src, s, dst, cmp_code); + } } } @@ -522,20 +808,34 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, AR PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_not(d_src, d_dst); + cv::gpu::bitwise_not(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_not(d_src, d_dst); + } + } + else { - cv::gpu::bitwise_not(d_src, d_dst); + cv::Mat dst; + + cv::bitwise_not(src, dst); + + TEST_CYCLE() + { + cv::bitwise_not(src, dst); + } } } @@ -544,8 +844,8 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -553,15 +853,29 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_and(d_src1, d_src2, d_dst); + cv::gpu::bitwise_and(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_and(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::bitwise_and(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::bitwise_and(src1, src2, dst); + + TEST_CYCLE() + { + cv::bitwise_and(src1, src2, dst); + } } } @@ -570,25 +884,39 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_and(d_src, s, d_dst); + cv::gpu::bitwise_and(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_and(d_src, s, d_dst); + } + } + else { - cv::gpu::bitwise_and(d_src, s, d_dst); + cv::Mat dst; + + cv::bitwise_and(src, s, dst); + + TEST_CYCLE() + { + cv::bitwise_and(src, s, dst); + } } } @@ -597,8 +925,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, V PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -606,15 +934,29 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(C cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_or(d_src1, d_src2, d_dst); + cv::gpu::bitwise_or(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_or(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::bitwise_or(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::bitwise_or(src1, src2, dst); + + TEST_CYCLE() + { + cv::bitwise_or(src1, src2, dst); + } } } @@ -623,25 +965,39 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(C PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_or(d_src, s, d_dst); + cv::gpu::bitwise_or(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_or(d_src, s, d_dst); + } + } + else { - cv::gpu::bitwise_or(d_src, s, d_dst); + cv::Mat dst; + + cv::bitwise_or(src, s, dst); + + TEST_CYCLE() + { + cv::bitwise_or(src, s, dst); + } } } @@ -650,8 +1006,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Va PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -659,15 +1015,29 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); + cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::bitwise_xor(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::bitwise_xor(src1, src2, dst); + + TEST_CYCLE() + { + cv::bitwise_xor(src1, src2, dst); + } } } @@ -676,25 +1046,39 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values( PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); cv::Scalar s = cv::Scalar::all(100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::bitwise_xor(d_src, s, d_dst); + cv::gpu::bitwise_xor(d_src, s, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::bitwise_xor(d_src, s, d_dst); + } + } + else { - cv::gpu::bitwise_xor(d_src, s, d_dst); + cv::Mat dst; + + cv::bitwise_xor(src, s, dst); + + TEST_CYCLE() + { + cv::bitwise_xor(src, s, dst); + } } } @@ -703,25 +1087,32 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, V PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); - cv::Scalar_ val = cv::Scalar_::all(4); + const cv::Scalar_ val = cv::Scalar_::all(4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::rshift(d_src, val, d_dst); + cv::gpu::rshift(d_src, val, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::rshift(d_src, val, d_dst); + } + } + else { - cv::gpu::rshift(d_src, val, d_dst); + FAIL(); } } @@ -730,25 +1121,32 @@ PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); - int channels = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); + const int channels = GET_PARAM(2); - int type = CV_MAKE_TYPE(depth, channels); + const int type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); fillRandom(src); - cv::Scalar_ val = cv::Scalar_::all(4); + const cv::Scalar_ val = cv::Scalar_::all(4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::lshift(d_src, val, d_dst); + cv::gpu::lshift(d_src, val, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::lshift(d_src, val, d_dst); + } + } + else { - cv::gpu::lshift(d_src, val, d_dst); + FAIL(); } } @@ -757,8 +1155,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -766,15 +1164,29 @@ PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::min(d_src1, d_src2, d_dst); + cv::gpu::min(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::min(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::min(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::min(src1, src2, dst); + + TEST_CYCLE() + { + cv::min(src1, src2, dst); + } } } @@ -783,22 +1195,36 @@ PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - double val = 50.0; + const double val = 50.0; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::min(d_src, val, d_dst); + cv::gpu::min(d_src, val, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::min(d_src, val, d_dst); + } + } + else { - cv::gpu::min(d_src, val, d_dst); + cv::Mat dst; + + cv::min(src, val, dst); + + TEST_CYCLE() + { + cv::min(src, val, dst); + } } } @@ -807,8 +1233,8 @@ PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src1(size, depth); fillRandom(src1); @@ -816,15 +1242,29 @@ PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, cv::Mat src2(size, depth); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::max(d_src1, d_src2, d_dst); + cv::gpu::max(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::max(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::max(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::max(src1, src2, dst); + + TEST_CYCLE() + { + cv::max(src1, src2, dst); + } } } @@ -833,22 +1273,36 @@ PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, PERF_TEST_P(Sz_Depth, Core_MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F))) { - cv::Size size = GET_PARAM(0); - int depth = GET_PARAM(1); + const cv::Size size = GET_PARAM(0); + const int depth = GET_PARAM(1); cv::Mat src(size, depth); fillRandom(src); - double val = 50.0; + const double val = 50.0; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::max(d_src, val, d_dst); + cv::gpu::max(d_src, val, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::max(d_src, val, d_dst); + } + } + else { - cv::gpu::max(d_src, val, d_dst); + cv::Mat dst; + + cv::max(src, val, dst); + + TEST_CYCLE() + { + cv::max(src, val, dst); + } } } @@ -863,10 +1317,10 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine( Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F))) { - cv::Size size = GET_PARAM(0); - int depth1 = GET_PARAM(1); - int depth2 = GET_PARAM(2); - int dst_depth = GET_PARAM(3); + const cv::Size size = GET_PARAM(0); + const int depth1 = GET_PARAM(1); + const int depth2 = GET_PARAM(2); + const int dst_depth = GET_PARAM(3); cv::Mat src1(size, depth1); fillRandom(src1); @@ -874,15 +1328,29 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine( cv::Mat src2(size, depth2); fillRandom(src2); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); + cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); + } + } + else { - cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth); + cv::Mat dst; + + cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); + + TEST_CYCLE() + { + cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); + } } } @@ -901,9 +1369,9 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine( { declare.time(5.0); - cv::Size size = GET_PARAM(0); - int type = GET_PARAM(1); - int flags = GET_PARAM(2); + const cv::Size size = GET_PARAM(0); + const int type = GET_PARAM(1); + const int flags = GET_PARAM(2); cv::Mat src1(size, type); fillRandom(src1); @@ -914,16 +1382,32 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine( cv::Mat src3(size, type); fillRandom(src3); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_src3(src3); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_src3(src3); + cv::gpu::GpuMat d_dst; - cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); + cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); + } + } + else { - cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags); + cv::Mat dst; + + cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); + + declare.time(50.0); + + TEST_CYCLE() + { + cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); + } } } @@ -940,14 +1424,28 @@ PERF_TEST_P(Sz_Type, Core_Transpose, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::transpose(d_src, d_dst); + cv::gpu::transpose(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::transpose(d_src, d_dst); + } + } + else { - cv::gpu::transpose(d_src, d_dst); + cv::Mat dst; + + cv::transpose(src, dst); + + TEST_CYCLE() + { + cv::transpose(src, dst); + } } } @@ -976,14 +1474,28 @@ PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::flip(d_src, d_dst, flipCode); + cv::gpu::flip(d_src, d_dst, flipCode); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::flip(d_src, d_dst, flipCode); + } + } + else { - cv::gpu::flip(d_src, d_dst, flipCode); + cv::Mat dst; + + cv::flip(src, dst, flipCode); + + TEST_CYCLE() + { + cv::flip(src, dst, flipCode); + } } } @@ -1003,14 +1515,28 @@ PERF_TEST_P(Sz_Type, Core_LutOneChannel, Combine( cv::Mat lut(1, 256, CV_8UC1); fillRandom(lut); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::LUT(d_src, lut, d_dst); + cv::gpu::LUT(d_src, lut, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::LUT(d_src, lut, d_dst); + } + } + else { - cv::gpu::LUT(d_src, lut, d_dst); + cv::Mat dst; + + cv::LUT(src, lut, dst); + + TEST_CYCLE() + { + cv::LUT(src, lut, dst); + } } } @@ -1030,14 +1556,28 @@ PERF_TEST_P(Sz_Type, Core_LutMultiChannel, Combine( cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels())); fillRandom(lut); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::LUT(d_src, lut, d_dst); + cv::gpu::LUT(d_src, lut, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::LUT(d_src, lut, d_dst); + } + } + else { - cv::gpu::LUT(d_src, lut, d_dst); + cv::Mat dst; + + cv::LUT(src, lut, dst); + + TEST_CYCLE() + { + cv::LUT(src, lut, dst); + } } } @@ -1051,14 +1591,31 @@ PERF_TEST_P(Sz, Core_MagnitudeComplex, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_32FC2); fillRandom(src, -100.0, 100.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::magnitude(d_src, d_dst); + cv::gpu::magnitude(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::magnitude(d_src, d_dst); + } + } + else { - cv::gpu::magnitude(d_src, d_dst); + cv::Mat xy[2]; + cv::split(src, xy); + + cv::Mat dst; + + cv::magnitude(xy[0], xy[1], dst); + + TEST_CYCLE() + { + cv::magnitude(xy[0], xy[1], dst); + } } } @@ -1072,14 +1629,21 @@ PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_32FC2); fillRandom(src, -100.0, 100.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::magnitudeSqr(d_src, d_dst); + cv::gpu::magnitudeSqr(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::magnitudeSqr(d_src, d_dst); + } + } + else { - cv::gpu::magnitudeSqr(d_src, d_dst); + FAIL(); } } @@ -1096,15 +1660,29 @@ PERF_TEST_P(Sz, Core_Magnitude, GPU_TYPICAL_MAT_SIZES) cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::magnitude(d_src1, d_src2, d_dst); + cv::gpu::magnitude(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::magnitude(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::magnitude(d_src1, d_src2, d_dst); + cv::Mat dst; + + cv::magnitude(src1, src2, dst); + + TEST_CYCLE() + { + cv::magnitude(src1, src2, dst); + } } } @@ -1121,15 +1699,22 @@ PERF_TEST_P(Sz, Core_MagnitudeSqr, GPU_TYPICAL_MAT_SIZES) cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); + cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); + } + } + else { - cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst); + FAIL(); } } @@ -1149,15 +1734,29 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool() cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); + cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); + } + } + else { - cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees); + cv::Mat dst; + + cv::phase(src1, src2, dst, angleInDegrees); + + TEST_CYCLE() + { + cv::phase(src1, src2, dst, angleInDegrees); + } } } @@ -1175,16 +1774,31 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat src2(size, CV_32FC1); fillRandom(src2, -100.0, 100.0); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_magnitude; - cv::gpu::GpuMat d_angle; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_magnitude; + cv::gpu::GpuMat d_angle; - cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); + cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); + } + } + else { - cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees); + cv::Mat magnitude; + cv::Mat angle; + + cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); + + TEST_CYCLE() + { + cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); + } } } @@ -1202,16 +1816,31 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat angle(size, CV_32FC1); fillRandom(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI); - cv::gpu::GpuMat d_magnitude(magnitude); - cv::gpu::GpuMat d_angle(angle); - cv::gpu::GpuMat d_x; - cv::gpu::GpuMat d_y; + if (runOnGpu) + { + cv::gpu::GpuMat d_magnitude(magnitude); + cv::gpu::GpuMat d_angle(angle); + cv::gpu::GpuMat d_x; + cv::gpu::GpuMat d_y; - cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); + cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); + } + } + else { - cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees); + cv::Mat x; + cv::Mat y; + + cv::polarToCart(magnitude, angle, x, y, angleInDegrees); + + TEST_CYCLE() + { + cv::polarToCart(magnitude, angle, x, y, angleInDegrees); + } } } @@ -1228,14 +1857,26 @@ PERF_TEST_P(Sz, Core_MeanStdDev, GPU_TYPICAL_MAT_SIZES) cv::Scalar mean; cv::Scalar stddev; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); + cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); + } + } + else { - cv::gpu::meanStdDev(d_src, mean, stddev, d_buf); + cv::meanStdDev(src, mean, stddev); + + TEST_CYCLE() + { + cv::meanStdDev(src, mean, stddev); + } } } @@ -1258,14 +1899,26 @@ PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine( double dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - dst = cv::gpu::norm(d_src, normType, d_buf); + dst = cv::gpu::norm(d_src, normType, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + dst = cv::gpu::norm(d_src, normType, d_buf); + } + } + else { - dst = cv::gpu::norm(d_src, normType, d_buf); + dst = cv::norm(src, normType); + + TEST_CYCLE() + { + dst = cv::norm(src, normType); + } } } @@ -1289,14 +1942,26 @@ PERF_TEST_P(Sz_Norm, Core_NormDiff, Combine( double dst; - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); - dst = cv::gpu::norm(d_src1, d_src2, normType); + dst = cv::gpu::norm(d_src1, d_src2, normType); - TEST_CYCLE() + TEST_CYCLE() + { + dst = cv::gpu::norm(d_src1, d_src2, normType); + } + } + else { - dst = cv::gpu::norm(d_src1, d_src2, normType); + dst = cv::norm(src1, src2, normType); + + TEST_CYCLE() + { + dst = cv::norm(src1, src2, normType); + } } } @@ -1319,14 +1984,26 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine( cv::Scalar dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - dst = cv::gpu::sum(d_src, d_buf); + dst = cv::gpu::sum(d_src, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + dst = cv::gpu::sum(d_src, d_buf); + } + } + else { - dst = cv::gpu::sum(d_src, d_buf); + dst = cv::sum(src); + + TEST_CYCLE() + { + dst = cv::sum(src); + } } } @@ -1349,14 +2026,21 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine( cv::Scalar dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - dst = cv::gpu::absSum(d_src, d_buf); + dst = cv::gpu::absSum(d_src, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + dst = cv::gpu::absSum(d_src, d_buf); + } + } + else { - dst = cv::gpu::absSum(d_src, d_buf); + FAIL(); } } @@ -1379,14 +2063,21 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine( cv::Scalar dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - dst = cv::gpu::sqrSum(d_src, d_buf); + dst = cv::gpu::sqrSum(d_src, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + dst = cv::gpu::sqrSum(d_src, d_buf); + } + } + else { - dst = cv::gpu::sqrSum(d_src, d_buf); + FAIL(); } } @@ -1405,14 +2096,21 @@ PERF_TEST_P(Sz_Depth, Core_MinMax, Combine( double minVal, maxVal; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); + cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); + } + } + else { - cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf); + FAIL(); } } @@ -1432,14 +2130,26 @@ PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, Combine( double minVal, maxVal; cv::Point minLoc, maxLoc; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_valbuf, d_locbuf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_valbuf, d_locbuf; - cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); + cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); + } + } + else { - cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); + cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); + + TEST_CYCLE() + { + cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); + } } } @@ -1458,14 +2168,26 @@ PERF_TEST_P(Sz_Depth, Core_CountNonZero, Combine( int dst; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_buf; - dst = cv::gpu::countNonZero(d_src, d_buf); + dst = cv::gpu::countNonZero(d_src, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + dst = cv::gpu::countNonZero(d_src, d_buf); + } + } + else { - dst = cv::gpu::countNonZero(d_src, d_buf); + dst = cv::countNonZero(src); + + TEST_CYCLE() + { + dst = cv::countNonZero(src); + } } } @@ -1499,14 +2221,28 @@ PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::reduce(d_src, d_dst, dim, reduceOp); + cv::gpu::reduce(d_src, d_dst, dim, reduceOp); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::reduce(d_src, d_dst, dim, reduceOp); + } + } + else { - cv::gpu::reduce(d_src, d_dst, dim, reduceOp); + cv::Mat dst; + + cv::reduce(src, dst, dim, reduceOp); + + TEST_CYCLE() + { + cv::reduce(src, dst, dim, reduceOp); + } } } diff --git a/modules/gpu/perf/perf_features2d.cpp b/modules/gpu/perf/perf_features2d.cpp index ef9612b549..53b98d4628 100644 --- a/modules/gpu/perf/perf_features2d.cpp +++ b/modules/gpu/perf/perf_features2d.cpp @@ -12,21 +12,39 @@ DEF_PARAM_TEST_1(Image, string); PERF_TEST_P(Image, Features2D_SURF, Values("gpu/perf/aloe.jpg")) { - declare.time(2.0); + declare.time(50.0); cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::SURF_GPU d_surf; + if (runOnGpu) + { + cv::gpu::SURF_GPU d_surf; - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_keypoints, d_descriptors; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints, d_descriptors; - d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); - TEST_CYCLE() + TEST_CYCLE() + { + d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + } + } + else { - d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + cv::SURF surf; + + std::vector keypoints; + cv::Mat descriptors; + + surf(img, cv::noArray(), keypoints, descriptors); + + TEST_CYCLE() + { + keypoints.clear(); + surf(img, cv::noArray(), keypoints, descriptors); + } } } @@ -38,16 +56,31 @@ PERF_TEST_P(Image, Features2D_FAST, Values("gpu/perf/aloe.jpg")) cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::FAST_GPU d_fast(20); + if (runOnGpu) + { + cv::gpu::FAST_GPU d_fast(20); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_keypoints; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints; - d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); + d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); - TEST_CYCLE() + TEST_CYCLE() + { + d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); + } + } + else { - d_fast(d_img, cv::gpu::GpuMat(), d_keypoints); + std::vector keypoints; + + cv::FAST(img, keypoints, 20); + + TEST_CYCLE() + { + keypoints.clear(); + cv::FAST(img, keypoints, 20); + } } } @@ -59,16 +92,34 @@ PERF_TEST_P(Image, Features2D_ORB, Values("gpu/perf/aloe.jpg")) cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::ORB_GPU d_orb(4000); + if (runOnGpu) + { + cv::gpu::ORB_GPU d_orb(4000); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_keypoints, d_descriptors; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_keypoints, d_descriptors; - d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); - TEST_CYCLE() + TEST_CYCLE() + { + d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + } + } + else { - d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors); + cv::ORB orb(4000); + + std::vector keypoints; + cv::Mat descriptors; + + orb(img, cv::noArray(), keypoints, descriptors); + + TEST_CYCLE() + { + keypoints.clear(); + orb(img, cv::noArray(), keypoints, descriptors); + } } } @@ -79,7 +130,7 @@ DEF_PARAM_TEST(DescSize_Norm, int, NormType); PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - declare.time(3.0); + declare.time(20.0); int desc_size = GET_PARAM(0); int normType = GET_PARAM(1); @@ -92,17 +143,33 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Val cv::Mat train(3000, desc_size, type); fillRandom(train); - cv::gpu::BFMatcher_GPU d_matcher(normType); + if (runOnGpu) + { + cv::gpu::BFMatcher_GPU d_matcher(normType); - cv::gpu::GpuMat d_query(query); - cv::gpu::GpuMat d_train(train); - cv::gpu::GpuMat d_trainIdx, d_distance; + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_distance; - d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); - TEST_CYCLE() + TEST_CYCLE() + { + d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + } + } + else { - d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); + cv::BFMatcher matcher(normType); + + std::vector matches; + + matcher.match(query, train, matches); + + TEST_CYCLE() + { + matcher.match(query, train, matches); + } } } @@ -116,7 +183,7 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( Values(2, 3), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - declare.time(3.0); + declare.time(30.0); int desc_size = GET_PARAM(0); int k = GET_PARAM(1); @@ -130,17 +197,33 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( cv::Mat train(3000, desc_size, type); fillRandom(train); - cv::gpu::BFMatcher_GPU d_matcher(normType); + if (runOnGpu) + { + cv::gpu::BFMatcher_GPU d_matcher(normType); - cv::gpu::GpuMat d_query(query); - cv::gpu::GpuMat d_train(train); - cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist; + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist; - d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); + d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); - TEST_CYCLE() + TEST_CYCLE() + { + d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); + } + } + else { - d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k); + cv::BFMatcher matcher(normType); + + std::vector< std::vector > matches; + + matcher.knnMatch(query, train, matches, k); + + TEST_CYCLE() + { + matcher.knnMatch(query, train, matches, k); + } } } @@ -149,7 +232,7 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine( PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { - declare.time(3.0); + declare.time(30.0); int desc_size = GET_PARAM(0); int normType = GET_PARAM(1); @@ -162,17 +245,33 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256 cv::Mat train(3000, desc_size, type); fillRandom(train, 0.0, 1.0); - cv::gpu::BFMatcher_GPU d_matcher(normType); + if (runOnGpu) + { + cv::gpu::BFMatcher_GPU d_matcher(normType); - cv::gpu::GpuMat d_query(query); - cv::gpu::GpuMat d_train(train); - cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance; + cv::gpu::GpuMat d_query(query); + cv::gpu::GpuMat d_train(train); + cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance; - d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); + d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); - TEST_CYCLE() + TEST_CYCLE() + { + d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); + } + } + else { - d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0); + cv::BFMatcher matcher(normType); + + std::vector< std::vector > matches; + + matcher.radiusMatch(query, train, matches, 2.0); + + TEST_CYCLE() + { + matcher.radiusMatch(query, train, matches, 2.0); + } } } diff --git a/modules/gpu/perf/perf_filters.cpp b/modules/gpu/perf/perf_filters.cpp index 71dcd49e2b..64ab829f8e 100644 --- a/modules/gpu/perf/perf_filters.cpp +++ b/modules/gpu/perf/perf_filters.cpp @@ -12,6 +12,8 @@ DEF_PARAM_TEST(Sz_Type_KernelSz, cv::Size, MatType, int); PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), Values(3, 5, 7))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -19,14 +21,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); + cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); + } + } + else { - cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize)); + cv::Mat dst; + + cv::blur(src, dst, cv::Size(ksize, ksize)); + + TEST_CYCLE() + { + cv::blur(src, dst, cv::Size(ksize, ksize)); + } } } @@ -35,6 +51,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -42,15 +60,29 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); + cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); + } + } + else { - cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize); + cv::Mat dst; + + cv::Sobel(src, dst, -1, 1, 1, ksize); + + TEST_CYCLE() + { + cv::Sobel(src, dst, -1, 1, 1, ksize); + } } } @@ -59,21 +91,37 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); + cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); + } + } + else { - cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf); + cv::Mat dst; + + cv::Scharr(src, dst, -1, 1, 0); + + TEST_CYCLE() + { + cv::Scharr(src, dst, -1, 1, 0); + } } } @@ -82,6 +130,8 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -89,15 +139,29 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); + cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); + } + } + else { - cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5); + cv::Mat dst; + + cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); + + TEST_CYCLE() + { + cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); + } } } @@ -106,6 +170,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 3))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -113,14 +179,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::Laplacian(d_src, d_dst, -1, ksize); + cv::gpu::Laplacian(d_src, d_dst, -1, ksize); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::Laplacian(d_src, d_dst, -1, ksize); + } + } + else { - cv::gpu::Laplacian(d_src, d_dst, -1, ksize); + cv::Mat dst; + + cv::Laplacian(src, dst, -1, ksize); + + TEST_CYCLE() + { + cv::Laplacian(src, dst, -1, ksize); + } } } @@ -129,6 +209,8 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); @@ -137,15 +219,29 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::erode(d_src, d_dst, ker, d_buf); + cv::gpu::erode(d_src, d_dst, ker, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::erode(d_src, d_dst, ker, d_buf); + } + } + else { - cv::gpu::erode(d_src, d_dst, ker, d_buf); + cv::Mat dst; + + cv::erode(src, dst, ker); + + TEST_CYCLE() + { + cv::erode(src, dst, ker); + } } } @@ -154,6 +250,8 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); @@ -162,15 +260,29 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::dilate(d_src, d_dst, ker, d_buf); + cv::gpu::dilate(d_src, d_dst, ker, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::dilate(d_src, d_dst, ker, d_buf); + } + } + else { - cv::gpu::dilate(d_src, d_dst, ker, d_buf); + cv::Mat dst; + + cv::dilate(src, dst, ker); + + TEST_CYCLE() + { + cv::dilate(src, dst, ker); + } } } @@ -184,6 +296,8 @@ DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, MorphOp); PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), ALL_MORPH_OPS)) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int morphOp = GET_PARAM(2); @@ -193,16 +307,30 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf1; - cv::gpu::GpuMat d_buf2; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf1; + cv::gpu::GpuMat d_buf2; - cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); + cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); + } + } + else { - cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2); + cv::Mat dst; + + cv::morphologyEx(src, dst, morphOp, ker); + + TEST_CYCLE() + { + cv::morphologyEx(src, dst, morphOp, ker); + } } } @@ -211,6 +339,8 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(3, 5, 7, 9, 11, 13, 15))) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int type = GET_PARAM(1); int ksize = GET_PARAM(2); @@ -221,14 +351,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V cv::Mat kernel(ksize, ksize, CV_32FC1); fillRandom(kernel, 0.0, 1.0); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::filter2D(d_src, d_dst, -1, kernel); + cv::gpu::filter2D(d_src, d_dst, -1, kernel); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::filter2D(d_src, d_dst, -1, kernel); + } + } + else { - cv::gpu::filter2D(d_src, d_dst, -1, kernel); + cv::Mat dst; + + cv::filter2D(src, dst, -1, kernel); + + TEST_CYCLE() + { + cv::filter2D(src, dst, -1, kernel); + } } } diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index a1614a79f3..9104892db4 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -59,7 +59,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine( ALL_BORDER_MODES, ALL_REMAP_MODES)) { - declare.time(3.0); + declare.time(20.0); cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); @@ -78,16 +78,30 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine( generateMap(xmap, ymap, remapMode); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_xmap(xmap); - cv::gpu::GpuMat d_ymap(ymap); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_xmap(xmap); + cv::gpu::GpuMat d_ymap(ymap); + cv::gpu::GpuMat d_dst; - cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + } + } + else { - cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode); + cv::Mat dst; + + cv::remap(src, dst, xmap, ymap, interpolation, borderMode); + + TEST_CYCLE() + { + cv::remap(src, dst, xmap, ymap, interpolation, borderMode); + } } } @@ -103,7 +117,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine( ALL_INTERPOLATIONS, Values(0.5, 0.3, 2.0))) { - declare.time(1.0); + declare.time(20.0); cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); @@ -116,14 +130,28 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + } + } + else { - cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + cv::Mat dst; + + cv::resize(src, dst, cv::Size(), f, f, interpolation); + + TEST_CYCLE() + { + cv::resize(src, dst, cv::Size(), f, f, interpolation); + } } } @@ -151,14 +179,28 @@ PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + } + } + else { - cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation); + cv::Mat dst; + + cv::resize(src, dst, cv::Size(), f, f, interpolation); + + TEST_CYCLE() + { + cv::resize(src, dst, cv::Size(), f, f, interpolation); + } } } @@ -174,6 +216,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine( Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), ALL_BORDER_MODES)) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); int channels = GET_PARAM(2); @@ -190,14 +234,28 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine( {std::sin(aplha), std::cos(aplha), 0}}; cv::Mat M(2, 3, CV_64F, (void*) mat); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); + cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); + } + } + else { - cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode); + cv::Mat dst; + + cv::warpAffine(src, dst, M, size, interpolation, borderMode); + + TEST_CYCLE() + { + cv::warpAffine(src, dst, M, size, interpolation, borderMode); + } } } @@ -211,6 +269,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine( Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), ALL_BORDER_MODES)) { + declare.time(20.0); + cv::Size size = GET_PARAM(0); int depth = GET_PARAM(1); int channels = GET_PARAM(2); @@ -228,14 +288,28 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine( {0.0, 0.0, 1.0}}; cv::Mat M(3, 3, CV_64F, (void*) mat); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); + cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); + } + } + else { - cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode); + cv::Mat dst; + + cv::warpPerspective(src, dst, M, size, interpolation, borderMode); + + TEST_CYCLE() + { + cv::warpPerspective(src, dst, M, size, interpolation, borderMode); + } } } @@ -260,14 +334,28 @@ PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); + cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); + } + } + else { - cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode); + cv::Mat dst; + + cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode); + + TEST_CYCLE() + { + cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode); + } } } @@ -291,14 +379,28 @@ PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine( cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); + cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); + } + } + else { - cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp); + cv::Mat dst; + + cv::threshold(src, dst, 100.0, 255.0, threshOp); + + TEST_CYCLE() + { + cv::threshold(src, dst, 100.0, 255.0, threshOp); + } } } @@ -312,15 +414,29 @@ PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_buf; - cv::gpu::integralBuffered(d_src, d_dst, d_buf); + cv::gpu::integralBuffered(d_src, d_dst, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::integralBuffered(d_src, d_dst, d_buf); + } + } + else { - cv::gpu::integralBuffered(d_src, d_dst, d_buf); + cv::Mat dst; + + cv::integral(src, dst); + + TEST_CYCLE() + { + cv::integral(src, dst); + } } } @@ -334,14 +450,21 @@ PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::sqrIntegral(d_src, d_dst); + cv::gpu::sqrIntegral(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::sqrIntegral(d_src, d_dst); + } + } + else { - cv::gpu::sqrIntegral(d_src, d_dst); + FAIL(); } } @@ -356,15 +479,35 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values( cv::Mat src(size, depth); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_hist; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; - cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); + cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); + } + } + else { - cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180); + int hbins = 30; + float hranges[] = {0.0f, 180.0f}; + int histSize[] = {hbins}; + const float* ranges[] = {hranges}; + int channels[] = {0}; + + cv::Mat hist; + + cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); + + TEST_CYCLE() + { + cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); + } } } @@ -383,15 +526,22 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values( int lowerLevel[] = {0, 0, 0, 0}; int upperLevel[] = {180, 180, 180, 180}; - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_hist[4]; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist[4]; + cv::gpu::GpuMat d_buf; - cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); + cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); + } + } + else { - cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel); + FAIL(); } } @@ -405,15 +555,22 @@ PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_hist; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; - cv::gpu::calcHist(d_src, d_hist, d_buf); + cv::gpu::calcHist(d_src, d_hist, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::calcHist(d_src, d_hist, d_buf); + } + } + else { - cv::gpu::calcHist(d_src, d_hist, d_buf); + FAIL(); } } @@ -427,16 +584,30 @@ PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_8UC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_hist; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_hist; + cv::gpu::GpuMat d_buf; - cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); + cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); + } + } + else { - cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf); + cv::Mat dst; + + cv::equalizeHist(src, dst); + + TEST_CYCLE() + { + cv::equalizeHist(src, dst); + } } } @@ -450,14 +621,21 @@ PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES) cv::Mat src(size, CV_32FC1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::columnSum(d_src, d_dst); + cv::gpu::columnSum(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::columnSum(d_src, d_dst); + } + } + else { - cv::gpu::columnSum(d_src, d_dst); + FAIL(); } } @@ -478,15 +656,29 @@ PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine( cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_dst; - cv::gpu::CannyBuf d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_dst; + cv::gpu::CannyBuf d_buf; - cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); + cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); + } + } + else { - cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient); + cv::Mat dst; + + cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); + + TEST_CYCLE() + { + cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); + } } } @@ -497,7 +689,7 @@ DEF_PARAM_TEST_1(Image, string); PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values("gpu/meanshift/cones.png")) { - declare.time(5.0); + declare.time(15.0); cv::Mat img = readImage(GetParam()); ASSERT_FALSE(img.empty()); @@ -505,14 +697,28 @@ PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values("gpu/meanshift/con cv::Mat rgba; cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - cv::gpu::GpuMat d_src(rgba); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(rgba); + cv::gpu::GpuMat d_dst; - cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); + cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); + } + } + else { - cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50); + cv::Mat dst; + + cv::pyrMeanShiftFiltering(img, dst, 50, 50); + + TEST_CYCLE() + { + cv::pyrMeanShiftFiltering(img, dst, 50, 50); + } } } @@ -529,15 +735,22 @@ PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values("gpu/meanshift/cones.pn cv::Mat rgba; cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA); - cv::gpu::GpuMat d_src(rgba); - cv::gpu::GpuMat d_dstr; - cv::gpu::GpuMat d_dstsp; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(rgba); + cv::gpu::GpuMat d_dstr; + cv::gpu::GpuMat d_dstsp; - cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); + cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); + } + } + else { - cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50); + FAIL(); } } @@ -556,13 +769,20 @@ PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values("gpu/meanshift/ cv::Mat dst; - cv::gpu::GpuMat d_src(rgba); + if (runOnGpu) + { + cv::gpu::GpuMat d_src(rgba); - cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); + cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); + } + } + else { - cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20); + FAIL(); } } @@ -583,17 +803,24 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Val cv::Mat img2(size, type); fillRandom(img2); - cv::gpu::GpuMat d_img1(img1); - cv::gpu::GpuMat d_img2(img2); - cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5)); - cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5)); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_img1(img1); + cv::gpu::GpuMat d_img2(img2); + cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5)); + cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5)); + cv::gpu::GpuMat d_dst; - cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); + cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); + } + } + else { - cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst); + FAIL(); } } @@ -604,26 +831,48 @@ DEF_PARAM_TEST(Sz_KernelSz_Ccorr, cv::Size, int, bool); PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool())) { - declare.time(2.0); + declare.time(10.0); cv::Size size = GET_PARAM(0); int templ_size = GET_PARAM(1); bool ccorr = GET_PARAM(2); - cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1); - d_image.setTo(cv::Scalar(1.0)); + cv::Mat image(size, CV_32FC1); + image.setTo(1.0); - cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); - d_templ.setTo(cv::Scalar(1.0)); + cv::Mat templ(templ_size, templ_size, CV_32FC1); + templ.setTo(1.0); - cv::gpu::GpuMat d_dst; - cv::gpu::ConvolveBuf d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1); + d_image.upload(image); - cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); + cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1); + d_templ.upload(templ); + + cv::gpu::GpuMat d_dst; + cv::gpu::ConvolveBuf d_buf; - TEST_CYCLE() - { cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); + + TEST_CYCLE() + { + cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf); + } + } + else + { + ASSERT_FALSE(ccorr); + + cv::Mat dst; + + cv::filter2D(image, dst, image.depth(), templ); + + TEST_CYCLE() + { + cv::filter2D(image, dst, image.depth(), templ); + } } } @@ -652,15 +901,29 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine( cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn)); fillRandom(templ); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_templ(templ); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_templ(templ); + cv::gpu::GpuMat d_dst; - cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + } + } + else { - cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + cv::Mat dst; + + cv::matchTemplate(image, templ, dst, method); + + TEST_CYCLE() + { + cv::matchTemplate(image, templ, dst, method); + } } }; @@ -684,15 +947,29 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine( cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn)); fillRandom(templ); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_templ(templ); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_templ(templ); + cv::gpu::GpuMat d_dst; - cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + } + } + else { - cv::gpu::matchTemplate(d_image, d_templ, d_dst, method); + cv::Mat dst; + + cv::matchTemplate(image, templ, dst, method); + + TEST_CYCLE() + { + cv::matchTemplate(image, templ, dst, method); + } } }; @@ -716,15 +993,29 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine( cv::Mat b(size, CV_32FC2); fillRandom(b, 0, 100); - cv::gpu::GpuMat d_a(a); - cv::gpu::GpuMat d_b(b); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_a(a); + cv::gpu::GpuMat d_b(b); + cv::gpu::GpuMat d_dst; - cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); + cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); + } + } + else { - cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag); + cv::Mat dst; + + cv::mulSpectrums(a, b, dst, flag); + + TEST_CYCLE() + { + cv::mulSpectrums(a, b, dst, flag); + } } } @@ -743,15 +1034,22 @@ PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES) cv::Mat src2(size, CV_32FC2); fillRandom(src2, 0, 100); - cv::gpu::GpuMat d_src1(src1); - cv::gpu::GpuMat d_src2(src2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src1(src1); + cv::gpu::GpuMat d_src2(src2); + cv::gpu::GpuMat d_dst; - cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); + cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); + } + } + else { - cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false); + FAIL(); } } @@ -762,7 +1060,7 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine( GPU_TYPICAL_MAT_SIZES, Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))) { - declare.time(2.0); + declare.time(10.0); cv::Size size = GET_PARAM(0); int flag = GET_PARAM(1); @@ -770,14 +1068,28 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine( cv::Mat src(size, CV_32FC2); fillRandom(src, 0, 100); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::dft(d_src, d_dst, size, flag); + cv::gpu::dft(d_src, d_dst, size, flag); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::dft(d_src, d_dst, size, flag); + } + } + else { - cv::gpu::dft(d_src, d_dst, size, flag); + cv::Mat dst; + + cv::dft(src, dst, flag); + + TEST_CYCLE() + { + cv::dft(src, dst, flag); + } } } @@ -793,8 +1105,6 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine( Values(3, 5, 7), Values(0, 3, 5, 7))) { - double k = 0.5; - string fileName = GET_PARAM(0); int type = GET_PARAM(1); int borderMode = GET_PARAM(2); @@ -803,20 +1113,35 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine( cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_Dx; - cv::gpu::GpuMat d_Dy; - cv::gpu::GpuMat d_buf; - - cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); + double k = 0.5; - TEST_CYCLE() + if (runOnGpu) { + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_Dx; + cv::gpu::GpuMat d_Dy; + cv::gpu::GpuMat d_buf; + cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); + + TEST_CYCLE() + { + cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode); + } + } + else + { + cv::Mat dst; + + cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode); + + TEST_CYCLE() + { + cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode); + } } } @@ -841,17 +1166,31 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_dst; - cv::gpu::GpuMat d_Dx; - cv::gpu::GpuMat d_Dy; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_dst; + cv::gpu::GpuMat d_Dx; + cv::gpu::GpuMat d_Dy; + cv::gpu::GpuMat d_buf; - cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); + cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); + } + } + else { - cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode); + cv::Mat dst; + + cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode); + + TEST_CYCLE() + { + cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode); + } } } @@ -866,14 +1205,21 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES) cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); cv::Mat T = cv::Mat::zeros(1, 3, CV_32F); - cv::gpu::GpuMat d_map_x; - cv::gpu::GpuMat d_map_y; + if (runOnGpu) + { + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; - cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); + cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); + } + } + else { - cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y); + FAIL(); } } @@ -887,14 +1233,21 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES) cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat d_map_x; - cv::gpu::GpuMat d_map_y; + if (runOnGpu) + { + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; - cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + } + } + else { - cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + FAIL(); } } @@ -908,14 +1261,21 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES) cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1); - cv::gpu::GpuMat d_map_x; - cv::gpu::GpuMat d_map_y; + if (runOnGpu) + { + cv::gpu::GpuMat d_map_x; + cv::gpu::GpuMat d_map_y; - cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + } + } + else { - cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y); + FAIL(); } } @@ -940,14 +1300,21 @@ PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); + cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); + } + } + else { - cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation); + FAIL(); } } @@ -968,14 +1335,28 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::pyrDown(d_src, d_dst); + cv::gpu::pyrDown(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::pyrDown(d_src, d_dst); + } + } + else { - cv::gpu::pyrDown(d_src, d_dst); + cv::Mat dst; + + cv::pyrDown(src, dst); + + TEST_CYCLE() + { + cv::pyrDown(src, dst); + } } } @@ -996,14 +1377,28 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine( cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::pyrUp(d_src, d_dst); + cv::gpu::pyrUp(d_src, d_dst); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::pyrUp(d_src, d_dst); + } + } + else { - cv::gpu::pyrUp(d_src, d_dst); + cv::Mat dst; + + cv::pyrUp(src, dst); + + TEST_CYCLE() + { + cv::pyrUp(src, dst); + } } } @@ -1049,14 +1444,28 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine( cv::Mat src(size, CV_MAKETYPE(depth, info.scn)); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); + cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); + } + } + else { - cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn); + cv::Mat dst; + + cv::cvtColor(src, dst, info.code, info.dcn); + + TEST_CYCLE() + { + cv::cvtColor(src, dst, info.code, info.dcn); + } } } @@ -1072,13 +1481,20 @@ PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES) const int dstOrder[] = {2, 1, 0, 3}; - cv::gpu::GpuMat d_src(src); + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); - cv::gpu::swapChannels(d_src, dstOrder); + cv::gpu::swapChannels(d_src, dstOrder); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::swapChannels(d_src, dstOrder); + } + } + else { - cv::gpu::swapChannels(d_src, dstOrder); + FAIL(); } } @@ -1102,15 +1518,22 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values cv::Mat img2(size, type); fillRandom(img2); - cv::gpu::GpuMat d_img1(img1); - cv::gpu::GpuMat d_img2(img2); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_img1(img1); + cv::gpu::GpuMat d_img2(img2); + cv::gpu::GpuMat d_dst; - cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); + cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); + } + } + else { - cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op); + FAIL(); } } @@ -1128,15 +1551,22 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZE cv::Mat src(size, type); fillRandom(src); - cv::gpu::GpuMat d_src(src); + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); - cv::gpu::ImagePyramid d_pyr; + cv::gpu::ImagePyramid d_pyr; - d_pyr.build(d_src, 5); + d_pyr.build(d_src, 5); - TEST_CYCLE() + TEST_CYCLE() + { + d_pyr.build(d_src, 5); + } + } + else { - d_pyr.build(d_src, 5); + FAIL(); } } @@ -1156,16 +1586,23 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_S cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - cv::gpu::ImagePyramid d_pyr(d_src, 3); + cv::gpu::ImagePyramid d_pyr(d_src, 3); - d_pyr.getLayer(d_dst, dstSize); + d_pyr.getLayer(d_dst, dstSize); - TEST_CYCLE() + TEST_CYCLE() + { + d_pyr.getLayer(d_dst, dstSize); + } + } + else { - d_pyr.getLayer(d_dst, dstSize); + FAIL(); } } @@ -1197,16 +1634,29 @@ PERF_TEST_P(Sz_DoSort, ImgProc_HoughLines, Combine(GPU_TYPICAL_MAT_SIZES, Bool() cv::line(src, p1, p2, cv::Scalar::all(255), 2); } - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_lines; - cv::gpu::GpuMat d_accum; - cv::gpu::GpuMat d_buf; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_lines; + cv::gpu::GpuMat d_accum; + cv::gpu::GpuMat d_buf; - cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); + cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); + } + } + else { - cv::gpu::HoughLines(d_src, d_lines, d_accum, d_buf, rho, theta, threshold, doSort); + std::vector lines; + cv::HoughLines(src, lines, rho, theta, threshold); + + TEST_CYCLE() + { + cv::HoughLines(src, lines, rho, theta, threshold); + } } } diff --git a/modules/gpu/perf/perf_labeling.cpp b/modules/gpu/perf/perf_labeling.cpp index bd1bcf144d..f17dd7d0af 100644 --- a/modules/gpu/perf/perf_labeling.cpp +++ b/modules/gpu/perf/perf_labeling.cpp @@ -7,27 +7,129 @@ namespace { DEF_PARAM_TEST_1(Image, string); -PERF_TEST_P(Image, Labeling_ConnectedComponents, Values("gpu/labeling/aloe-disp.png")) +struct GreedyLabeling { - cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + struct dot + { + int x; + int y; + + static dot make(int i, int j) + { + dot d; d.x = i; d.y = j; + return d; + } + }; + + struct InInterval + { + InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {}; + const int lo, hi; + + bool operator() (const unsigned char a, const unsigned char b) const + { + int d = a - b; + return lo <= d && d <= hi; + } + }; + + GreedyLabeling(cv::Mat img) + : image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];} + + ~GreedyLabeling(){delete[] stack;} + + void operator() (cv::Mat labels) const + { + labels.setTo(cv::Scalar::all(-1)); + InInterval inInt(0, 2); + int cc = -1; + + int* dist_labels = (int*)labels.data; + int pitch = labels.step1(); + + unsigned char* source = (unsigned char*)image.data; + int width = image.cols; + int height = image.rows; + + for (int j = 0; j < image.rows; ++j) + for (int i = 0; i < image.cols; ++i) + { + if (dist_labels[j * pitch + i] != -1) continue; + + dot* top = stack; + dot p = dot::make(i, j); + cc++; + + dist_labels[j * pitch + i] = cc; + + while (top >= stack) + { + int* dl = &dist_labels[p.y * pitch + p.x]; + unsigned char* sp = &source[p.y * image.step1() + p.x]; - // cv::threshold(image, image, 150, 255, CV_THRESH_BINARY); + dl[0] = cc; - cv::gpu::GpuMat mask; - mask.create(image.rows, image.cols, CV_8UC1); + //right + if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1])) + *top++ = dot::make(p.x + 1, p.y); - cv::gpu::GpuMat components; - components.create(image.rows, image.cols, CV_32SC1); + //left + if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1])) + *top++ = dot::make(p.x - 1, p.y); - cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2)); + //bottom + if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()])) + *top++ = dot::make(p.x, p.y + 1); - ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components)); + //top + if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()])) + *top++ = dot::make(p.x, p.y - 1); + p = *--top; + } + } + } + + cv::Mat image; + cv::Mat _labels; + dot* stack; +}; + +PERF_TEST_P(Image, Labeling_ConnectedComponents, Values("gpu/labeling/aloe-disp.png")) +{ declare.time(1.0); - TEST_CYCLE() + cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE); + + if (runOnGpu) + { + cv::gpu::GpuMat mask; + mask.create(image.rows, image.cols, CV_8UC1); + + cv::gpu::GpuMat components; + components.create(image.rows, image.cols, CV_32SC1); + + cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2)); + + ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components)); + + TEST_CYCLE() + { + cv::gpu::labelComponents(mask, components); + } + } + else { - cv::gpu::labelComponents(mask, components); + GreedyLabeling host(image); + + host(host._labels); + + declare.time(1.0); + + TEST_CYCLE() + { + host(host._labels); + } } } diff --git a/modules/gpu/perf/perf_matop.cpp b/modules/gpu/perf/perf_matop.cpp index c014b19da8..cdae962f23 100644 --- a/modules/gpu/perf/perf_matop.cpp +++ b/modules/gpu/perf/perf_matop.cpp @@ -18,13 +18,27 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8 cv::Scalar val(1, 2, 3, 4); - cv::gpu::GpuMat d_src(size, type); + if (runOnGpu) + { + cv::gpu::GpuMat d_src(size, type); - d_src.setTo(val); + d_src.setTo(val); - TEST_CYCLE() + TEST_CYCLE() + { + d_src.setTo(val); + } + } + else { - d_src.setTo(val); + cv::Mat src(size, type); + + src.setTo(val); + + TEST_CYCLE() + { + src.setTo(val); + } } } @@ -47,14 +61,26 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Value cv::Scalar val(1, 2, 3, 4); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_mask(mask); + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_mask(mask); - d_src.setTo(val, d_mask); + d_src.setTo(val, d_mask); - TEST_CYCLE() + TEST_CYCLE() + { + d_src.setTo(val, d_mask); + } + } + else { - d_src.setTo(val, d_mask); + src.setTo(val, mask); + + TEST_CYCLE() + { + src.setTo(val, mask); + } } } @@ -75,15 +101,29 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu cv::Mat mask(size, CV_8UC1); fillRandom(mask, 0, 2); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_mask(mask); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_mask(mask); + cv::gpu::GpuMat d_dst; - d_src.copyTo(d_dst, d_mask); + d_src.copyTo(d_dst, d_mask); - TEST_CYCLE() + TEST_CYCLE() + { + d_src.copyTo(d_dst, d_mask); + } + } + else { - d_src.copyTo(d_dst, d_mask); + cv::Mat dst; + + src.copyTo(dst, mask); + + TEST_CYCLE() + { + src.copyTo(dst, mask); + } } } @@ -101,14 +141,28 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV cv::Mat src(size, depth1); fillRandom(src); - cv::gpu::GpuMat d_src(src); - cv::gpu::GpuMat d_dst; + if (runOnGpu) + { + cv::gpu::GpuMat d_src(src); + cv::gpu::GpuMat d_dst; - d_src.convertTo(d_dst, depth2, 0.5, 1.0); + d_src.convertTo(d_dst, depth2, 0.5, 1.0); - TEST_CYCLE() + TEST_CYCLE() + { + d_src.convertTo(d_dst, depth2, 0.5, 1.0); + } + } + else { - d_src.convertTo(d_dst, depth2, 0.5, 1.0); + cv::Mat dst; + + src.convertTo(dst, depth2, 0.5, 1.0); + + TEST_CYCLE() + { + src.convertTo(dst, depth2, 0.5, 1.0); + } } } diff --git a/modules/gpu/perf/perf_objdetect.cpp b/modules/gpu/perf/perf_objdetect.cpp index 9c1f7919f9..0c4cd5e4c0 100644 --- a/modules/gpu/perf/perf_objdetect.cpp +++ b/modules/gpu/perf/perf_objdetect.cpp @@ -17,16 +17,31 @@ PERF_TEST_P(Image, ObjDetect_HOG, Values("gpu/hog/road.png")) std::vector found_locations; - cv::gpu::GpuMat d_img(img); + if (runOnGpu) + { + cv::gpu::GpuMat d_img(img); - cv::gpu::HOGDescriptor d_hog; - d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); + cv::gpu::HOGDescriptor d_hog; + d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); - d_hog.detectMultiScale(d_img, found_locations); + d_hog.detectMultiScale(d_img, found_locations); - TEST_CYCLE() + TEST_CYCLE() + { + d_hog.detectMultiScale(d_img, found_locations); + } + } + else { - d_hog.detectMultiScale(d_img, found_locations); + cv::HOGDescriptor hog; + hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); + + hog.detectMultiScale(img, found_locations); + + TEST_CYCLE() + { + hog.detectMultiScale(img, found_locations); + } } } @@ -42,18 +57,34 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier, cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::CascadeClassifier_GPU d_cascade; - - ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); + if (runOnGpu) + { + cv::gpu::CascadeClassifier_GPU d_cascade; + ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_objects_buffer; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_objects_buffer; - d_cascade.detectMultiScale(d_img, d_objects_buffer); + d_cascade.detectMultiScale(d_img, d_objects_buffer); - TEST_CYCLE() + TEST_CYCLE() + { + d_cascade.detectMultiScale(d_img, d_objects_buffer); + } + } + else { - d_cascade.detectMultiScale(d_img, d_objects_buffer); + cv::CascadeClassifier cascade; + ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml"))); + + std::vector rects; + + cascade.detectMultiScale(img, rects); + + TEST_CYCLE() + { + cascade.detectMultiScale(img, rects); + } } } @@ -66,18 +97,34 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier, cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(img.empty()); - cv::gpu::CascadeClassifier_GPU d_cascade; - - ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); + if (runOnGpu) + { + cv::gpu::CascadeClassifier_GPU d_cascade; + ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second))); - cv::gpu::GpuMat d_img(img); - cv::gpu::GpuMat d_gpu_rects; + cv::gpu::GpuMat d_img(img); + cv::gpu::GpuMat d_gpu_rects; - d_cascade.detectMultiScale(d_img, d_gpu_rects); + d_cascade.detectMultiScale(d_img, d_gpu_rects); - TEST_CYCLE() + TEST_CYCLE() + { + d_cascade.detectMultiScale(d_img, d_gpu_rects); + } + } + else { - d_cascade.detectMultiScale(d_img, d_gpu_rects); + cv::CascadeClassifier cascade; + ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); + + std::vector rects; + + cascade.detectMultiScale(img, rects); + + TEST_CYCLE() + { + cascade.detectMultiScale(img, rects); + } } } diff --git a/modules/gpu/perf/perf_video.cpp b/modules/gpu/perf/perf_video.cpp index a5a1e4da57..7faea0b880 100644 --- a/modules/gpu/perf/perf_video.cpp +++ b/modules/gpu/perf/perf_video.cpp @@ -3,6 +3,14 @@ using namespace std; using namespace testing; +namespace cv +{ + template<> void Ptr::delete_obj() + { + cvReleaseBGStatModel(&obj); + } +} + namespace { ////////////////////////////////////////////////////// @@ -25,19 +33,26 @@ PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values(make_pair("gpu frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_v; + if (runOnGpu) + { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; - cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, - 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); + cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, + 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); - d_flow(d_frame0, d_frame1, d_u, d_v); + d_flow(d_frame0, d_frame1, d_u, d_v); - TEST_CYCLE() + TEST_CYCLE() + { + d_flow(d_frame0, d_frame1, d_u, d_v); + } + } + else { - d_flow(d_frame0, d_frame1, d_u, d_v); + FAIL(); } } @@ -55,25 +70,32 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values(make_pair("g frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_fu, d_fv; - cv::gpu::GpuMat d_bu, d_bv; + if (runOnGpu) + { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_fu, d_fv; + cv::gpu::GpuMat d_bu, d_bv; - cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, - 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); + cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, + 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); - d_flow(d_frame0, d_frame1, d_fu, d_fv); - d_flow(d_frame1, d_frame0, d_bu, d_bv); + d_flow(d_frame0, d_frame1, d_fu, d_fv); + d_flow(d_frame1, d_frame0, d_bu, d_bv); - cv::gpu::GpuMat d_newFrame; - cv::gpu::GpuMat d_buf; + cv::gpu::GpuMat d_newFrame; + cv::gpu::GpuMat d_buf; - cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); + cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); + } + } + else { - cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf); + FAIL(); } } @@ -91,23 +113,30 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values(mak frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0); frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_v; + if (runOnGpu) + { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; - cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, - 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); + cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/, + 10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); - d_flow(d_frame0, d_frame1, d_u, d_v); + d_flow(d_frame0, d_frame1, d_u, d_v); - cv::gpu::GpuMat d_vertex, d_colors; + cv::gpu::GpuMat d_vertex, d_colors; - cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); + cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); - TEST_CYCLE() + TEST_CYCLE() + { + cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); + } + } + else { - cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors); + FAIL(); } } @@ -124,16 +153,30 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); - cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance); + if (runOnGpu) + { + cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance); - cv::gpu::GpuMat d_image(image); - cv::gpu::GpuMat d_pts; + cv::gpu::GpuMat d_image(image); + cv::gpu::GpuMat d_pts; - d_detector(d_image, d_pts); + d_detector(d_image, d_pts); - TEST_CYCLE() + TEST_CYCLE() + { + d_detector(d_image, d_pts); + } + } + else { - d_detector(d_image, d_pts); + cv::Mat pts; + + cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance); + + TEST_CYCLE() + { + cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance); + } } } @@ -150,6 +193,8 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse Values(1, 2, 3), Values(1, 10, 30))) { + declare.time(20.0); + pair_string imagePair = GET_PARAM(0); bool useGray = GET_PARAM(1); int points = GET_PARAM(2); @@ -169,26 +214,45 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse else cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY); - cv::gpu::GpuMat d_pts; + cv::Mat pts; + cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0); - cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(points, 0.01, 0.0); - d_detector(cv::gpu::GpuMat(gray_frame), d_pts); + if (runOnGpu) + { + cv::gpu::GpuMat d_pts(pts); - cv::gpu::PyrLKOpticalFlow d_pyrLK; - d_pyrLK.winSize = cv::Size(winSize, winSize); - d_pyrLK.maxLevel = levels - 1; - d_pyrLK.iters = iters; + cv::gpu::PyrLKOpticalFlow d_pyrLK; + d_pyrLK.winSize = cv::Size(winSize, winSize); + d_pyrLK.maxLevel = levels - 1; + d_pyrLK.iters = iters; - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_nextPts; - cv::gpu::GpuMat d_status; + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_nextPts; + cv::gpu::GpuMat d_status; - d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); + d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); - TEST_CYCLE() + TEST_CYCLE() + { + d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); + } + } + else { - d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status); + cv::Mat nextPts; + cv::Mat status; + + cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), + cv::Size(winSize, winSize), levels - 1, + cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); + + TEST_CYCLE() + { + cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), + cv::Size(winSize, winSize), levels - 1, + cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); + } } } @@ -216,21 +280,28 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine( cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(frame1.empty()); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_v; + if (runOnGpu) + { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; - cv::gpu::PyrLKOpticalFlow d_pyrLK; - d_pyrLK.winSize = cv::Size(winSize, winSize); - d_pyrLK.maxLevel = levels - 1; - d_pyrLK.iters = iters; + cv::gpu::PyrLKOpticalFlow d_pyrLK; + d_pyrLK.winSize = cv::Size(winSize, winSize); + d_pyrLK.maxLevel = levels - 1; + d_pyrLK.iters = iters; - d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); + d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); - TEST_CYCLE() + TEST_CYCLE() + { + d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); + } + } + else { - d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v); + FAIL(); } } @@ -247,18 +318,47 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values(make_pair cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE); ASSERT_FALSE(frame1.empty()); - cv::gpu::GpuMat d_frame0(frame0); - cv::gpu::GpuMat d_frame1(frame1); - cv::gpu::GpuMat d_u; - cv::gpu::GpuMat d_v; + int numLevels = 5; + double pyrScale = 0.5; + int winSize = 13; + int numIters = 10; + int polyN = 5; + double polySigma = 1.1; + int flags = 0; - cv::gpu::FarnebackOpticalFlow d_farneback; + if (runOnGpu) + { + cv::gpu::GpuMat d_frame0(frame0); + cv::gpu::GpuMat d_frame1(frame1); + cv::gpu::GpuMat d_u; + cv::gpu::GpuMat d_v; + + cv::gpu::FarnebackOpticalFlow d_farneback; + d_farneback.numLevels = numLevels; + d_farneback.pyrScale = pyrScale; + d_farneback.winSize = winSize; + d_farneback.numIters = numIters; + d_farneback.polyN = polyN; + d_farneback.polySigma = polySigma; + d_farneback.flags = flags; - d_farneback(d_frame0, d_frame1, d_u, d_v); + d_farneback(d_frame0, d_frame1, d_u, d_v); - TEST_CYCLE() + TEST_CYCLE() + { + d_farneback(d_frame0, d_frame1, d_u, d_v); + } + } + else { - d_farneback(d_frame0, d_frame1, d_u, d_v); + cv::Mat flow; + + cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); + + TEST_CYCLE() + { + cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); + } } } @@ -269,7 +369,7 @@ DEF_PARAM_TEST_1(Video, string); PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) { - declare.time(10); + declare.time(60); string inputFile = perf::TestBase::getDataPath(GetParam()); @@ -280,20 +380,41 @@ PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/vide cap >> frame; ASSERT_FALSE(frame.empty()); - cv::gpu::GpuMat d_frame(frame); - cv::gpu::FGDStatModel d_model(4); - d_model.create(d_frame); + if (runOnGpu) + { + cv::gpu::GpuMat d_frame(frame); + + cv::gpu::FGDStatModel d_model(4); + d_model.create(d_frame); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); - for (int i = 0; i < 10; ++i) + d_frame.upload(frame); + + startTimer(); next(); + d_model.update(d_frame); + stopTimer(); + } + } + else { - cap >> frame; - ASSERT_FALSE(frame.empty()); + IplImage ipl_frame = frame; + cv::Ptr model(cvCreateFGDStatModel(&ipl_frame)); + + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); - d_frame.upload(frame); + ipl_frame = frame; - startTimer(); next(); - d_model.update(d_frame); - stopTimer(); + startTimer(); next(); + cvUpdateBGStatModel(&ipl_frame, model); + stopTimer(); + } } } @@ -313,10 +434,6 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576. cv::Mat frame; - cv::gpu::GpuMat d_frame; - cv::gpu::MOG_GPU d_mog; - cv::gpu::GpuMat d_foreground; - cap >> frame; ASSERT_FALSE(frame.empty()); @@ -330,30 +447,62 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576. cv::swap(temp, frame); } - d_frame.upload(frame); - - d_mog(d_frame, d_foreground, learningRate); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); + cv::gpu::MOG_GPU d_mog; + cv::gpu::GpuMat d_foreground; - if (cn != 3) + d_mog(d_frame, d_foreground, learningRate); + + for (int i = 0; i < 10; ++i) { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_mog(d_frame, d_foreground, learningRate); + stopTimer(); } + } + else + { + cv::BackgroundSubtractorMOG mog; + cv::Mat foreground; - d_frame.upload(frame); + mog(frame, foreground, learningRate); - startTimer(); next(); - d_mog(d_frame, d_foreground, learningRate); - stopTimer(); + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + startTimer(); next(); + mog(frame, foreground, learningRate); + stopTimer(); + } } } @@ -372,10 +521,6 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v cv::Mat frame; - cv::gpu::GpuMat d_frame; - cv::gpu::MOG2_GPU d_mog2; - cv::gpu::GpuMat d_foreground; - cap >> frame; ASSERT_FALSE(frame.empty()); @@ -389,30 +534,62 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v cv::swap(temp, frame); } - d_frame.upload(frame); - - d_mog2(d_frame, d_foreground); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); + cv::gpu::MOG2_GPU d_mog2; + cv::gpu::GpuMat d_foreground; + + d_mog2(d_frame, d_foreground); - if (cn != 3) + for (int i = 0; i < 10; ++i) { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_mog2(d_frame, d_foreground); + stopTimer(); } + } + else + { + cv::BackgroundSubtractorMOG2 mog2; + cv::Mat foreground; - d_frame.upload(frame); + mog2(frame, foreground); - startTimer(); next(); - d_mog2(d_frame, d_foreground); - stopTimer(); + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + startTimer(); next(); + mog2(frame, foreground); + stopTimer(); + } } } @@ -429,36 +606,70 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/76 cv::Mat frame; - cv::gpu::GpuMat d_frame; - cv::gpu::MOG2_GPU d_mog2; - cv::gpu::GpuMat d_foreground; - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame; + cv::gpu::MOG2_GPU d_mog2; + cv::gpu::GpuMat d_foreground; - if (cn != 3) + for (int i = 0; i < 10; ++i) { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + d_mog2(d_frame, d_foreground); } - d_frame.upload(frame); + cv::gpu::GpuMat d_background; + d_mog2.getBackgroundImage(d_background); - d_mog2(d_frame, d_foreground); + TEST_CYCLE() + { + d_mog2.getBackgroundImage(d_background); + } } + else + { + cv::BackgroundSubtractorMOG2 mog2; + cv::Mat foreground; - cv::gpu::GpuMat d_background; - d_mog2.getBackgroundImage(d_background); + for (int i = 0; i < 10; ++i) + { + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + mog2(frame, foreground); + } - TEST_CYCLE() - { - d_mog2.getBackgroundImage(d_background); + cv::Mat background; + mog2.getBackgroundImage(background); + + TEST_CYCLE() + { + mog2.getBackgroundImage(background); + } } } @@ -487,32 +698,39 @@ PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/v cv::swap(temp, frame); } - cv::gpu::GpuMat d_frame(frame); - cv::gpu::VIBE_GPU d_vibe; - cv::gpu::GpuMat d_foreground; - - d_vibe(d_frame, d_foreground); - - for (int i = 0; i < 10; ++i) + if (runOnGpu) { - cap >> frame; - ASSERT_FALSE(frame.empty()); + cv::gpu::GpuMat d_frame(frame); + cv::gpu::VIBE_GPU d_vibe; + cv::gpu::GpuMat d_foreground; - if (cn != 3) + d_vibe(d_frame, d_foreground); + + for (int i = 0; i < 10; ++i) { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); + cap >> frame; + ASSERT_FALSE(frame.empty()); + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_vibe(d_frame, d_foreground); + stopTimer(); } - - d_frame.upload(frame); - - startTimer(); next(); - d_vibe(d_frame, d_foreground); - stopTimer(); + } + else + { + FAIL(); } } @@ -544,38 +762,76 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a cv::swap(temp, frame); } - cv::gpu::GpuMat d_frame(frame); - cv::gpu::GpuMat d_fgmask; + if (runOnGpu) + { + cv::gpu::GpuMat d_frame(frame); + cv::gpu::GpuMat d_fgmask; - cv::gpu::GMG_GPU d_gmg; - d_gmg.maxFeatures = maxFeatures; + cv::gpu::GMG_GPU d_gmg; + d_gmg.maxFeatures = maxFeatures; - d_gmg(d_frame, d_fgmask); + d_gmg(d_frame, d_fgmask); - for (int i = 0; i < 150; ++i) - { - cap >> frame; - if (frame.empty()) + for (int i = 0; i < 150; ++i) { - cap.open(inputFile); cap >> frame; + if (frame.empty()) + { + cap.open(inputFile); + cap >> frame; + } + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + d_frame.upload(frame); + + startTimer(); next(); + d_gmg(d_frame, d_fgmask); + stopTimer(); } + } + else + { + cv::Mat fgmask; + cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0)); - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } + cv::BackgroundSubtractorGMG gmg; + gmg.set("maxFeatures", maxFeatures); + gmg.initialize(frame.size(), 0.0, 255.0); - d_frame.upload(frame); + gmg(frame, fgmask); - startTimer(); next(); - d_gmg(d_frame, d_fgmask); - stopTimer(); + for (int i = 0; i < 150; ++i) + { + cap >> frame; + if (frame.empty()) + { + cap.open(inputFile); + cap >> frame; + } + + if (cn != 3) + { + cv::Mat temp; + if (cn == 1) + cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); + else + cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); + cv::swap(temp, frame); + } + + startTimer(); next(); + gmg(frame, fgmask); + stopTimer(); + } } } @@ -584,6 +840,8 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi")) { + declare.time(30); + string inputFile = perf::TestBase::getDataPath(GetParam()); string outputFile = cv::tempfile(".avi"); @@ -592,26 +850,45 @@ PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video cv::VideoCapture reader(inputFile); ASSERT_TRUE( reader.isOpened() ); - cv::gpu::VideoWriter_GPU d_writer; - cv::Mat frame; - cv::gpu::GpuMat d_frame; - declare.time(10); + if (runOnGpu) + { + cv::gpu::VideoWriter_GPU d_writer; + + cv::gpu::GpuMat d_frame; + + for (int i = 0; i < 10; ++i) + { + reader >> frame; + ASSERT_FALSE(frame.empty()); + + d_frame.upload(frame); + + if (!d_writer.isOpened()) + d_writer.open(outputFile, frame.size(), FPS); - for (int i = 0; i < 10; ++i) + startTimer(); next(); + d_writer.write(d_frame); + stopTimer(); + } + } + else { - reader >> frame; - ASSERT_FALSE(frame.empty()); + cv::VideoWriter writer; - d_frame.upload(frame); + for (int i = 0; i < 10; ++i) + { + reader >> frame; + ASSERT_FALSE(frame.empty()); - if (!d_writer.isOpened()) - d_writer.open(outputFile, frame.size(), FPS); + if (!writer.isOpened()) + writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size()); - startTimer(); next(); - d_writer.write(d_frame); - stopTimer(); + startTimer(); next(); + writer.write(frame); + stopTimer(); + } } } @@ -624,16 +901,33 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video string inputFile = perf::TestBase::getDataPath(GetParam()); - cv::gpu::VideoReader_GPU d_reader(inputFile); - ASSERT_TRUE( d_reader.isOpened() ); + if (runOnGpu) + { + cv::gpu::VideoReader_GPU d_reader(inputFile); + ASSERT_TRUE( d_reader.isOpened() ); - cv::gpu::GpuMat d_frame; + cv::gpu::GpuMat d_frame; - d_reader.read(d_frame); + d_reader.read(d_frame); - TEST_CYCLE_N(10) + TEST_CYCLE_N(10) + { + d_reader.read(d_frame); + } + } + else { - d_reader.read(d_frame); + cv::VideoCapture reader(inputFile); + ASSERT_TRUE( reader.isOpened() ); + + cv::Mat frame; + + reader >> frame; + + TEST_CYCLE_N(10) + { + reader >> frame; + } } } diff --git a/modules/gpu/perf_cpu/perf_calib3d.cpp b/modules/gpu/perf_cpu/perf_calib3d.cpp deleted file mode 100644 index 8124b808af..0000000000 --- a/modules/gpu/perf_cpu/perf_calib3d.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// StereoBM - -GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo) -{ - cv::Mat img_l = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_l.empty()); - - cv::Mat img_r = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img_r.empty()); - - cv::StereoBM bm(0, 256); - - cv::Mat dst; - - bm(img_l, img_r, dst); - - declare.time(5.0); - - TEST_CYCLE() - { - bm(img_l, img_r, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// ProjectPoints - -IMPLEMENT_PARAM_CLASS(Count, int) - -GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count) -{ - int count = GET_PARAM(1); - - cv::Mat src(1, count, CV_32FC3); - fill(src, -100, 100); - - cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1); - cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1); - cv::Mat dst; - - cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); - - TEST_CYCLE() - { - cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - -////////////////////////////////////////////////////////////////////// -// SolvePnPRansac - -GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count) -{ - int count = GET_PARAM(1); - - cv::Mat object(1, count, CV_32FC3); - fill(object, -100, 100); - - cv::Mat camera_mat(3, 3, CV_32FC1); - fill(camera_mat, 0.5, 1); - camera_mat.at(0, 1) = 0.f; - camera_mat.at(1, 0) = 0.f; - camera_mat.at(2, 0) = 0.f; - camera_mat.at(2, 1) = 0.f; - - cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); - - std::vector image_vec; - cv::Mat rvec_gold(1, 3, CV_32FC1); - fill(rvec_gold, 0, 1); - cv::Mat tvec_gold(1, 3, CV_32FC1); - fill(tvec_gold, 0, 1); - cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec); - - cv::Mat image(1, count, CV_32FC2, &image_vec[0]); - - cv::Mat rvec; - cv::Mat tvec; - - cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - - declare.time(10.0); - - TEST_CYCLE() - { - cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine( - ALL_DEVICES, - testing::Values(5000, 10000, 20000))); - -////////////////////////////////////////////////////////////////////// -// ReprojectImageTo3D - -GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 5.0, 30.0); - - cv::Mat Q(4, 4, CV_32FC1); - fill(Q, 0.1, 1.0); - - cv::Mat dst; - - cv::reprojectImageTo3D(src, dst, Q); - - TEST_CYCLE() - { - cv::reprojectImageTo3D(src, dst, Q); - } -} - -INSTANTIATE_TEST_CASE_P(Calib3D, ReprojectImageTo3D, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S))); - -#endif - diff --git a/modules/gpu/perf_cpu/perf_core.cpp b/modules/gpu/perf_cpu/perf_core.cpp deleted file mode 100644 index fb87009584..0000000000 --- a/modules/gpu/perf_cpu/perf_core.cpp +++ /dev/null @@ -1,1388 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// Merge - -GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - std::vector src(channels); - for (int i = 0; i < channels; ++i) - src[i] = cv::Mat(size, depth, cv::Scalar::all(i)); - - cv::Mat dst; - - cv::merge(src, dst); - - TEST_CYCLE() - { - cv::merge(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Merge, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(2, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Split - -GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - cv::Mat src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4)); - - std::vector dst; - - cv::split(src, dst); - - TEST_CYCLE() - { - cv::split(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Split, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(2, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Add_Mat - -GPU_PERF_TEST(Add_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::add(src1, src2, dst); - - TEST_CYCLE() - { - cv::add(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Add_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Add_Scalar - -GPU_PERF_TEST(Add_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::add(src, s, dst); - - TEST_CYCLE() - { - cv::add(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Add_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Subtract_Mat - -GPU_PERF_TEST(Subtract_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::subtract(src1, src2, dst); - - TEST_CYCLE() - { - cv::subtract(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Subtract_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Subtract_Scalar - -GPU_PERF_TEST(Subtract_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::subtract(src, s, dst); - - TEST_CYCLE() - { - cv::subtract(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Subtract_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Multiply_Mat - -GPU_PERF_TEST(Multiply_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::multiply(src1, src2, dst); - - TEST_CYCLE() - { - cv::multiply(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Multiply_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Multiply_Scalar - -GPU_PERF_TEST(Multiply_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::multiply(src, s, dst); - - TEST_CYCLE() - { - cv::multiply(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Multiply_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Divide_Mat - -GPU_PERF_TEST(Divide_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::divide(src1, src2, dst); - - TEST_CYCLE() - { - cv::divide(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Divide_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Divide_Scalar - -GPU_PERF_TEST(Divide_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::divide(src, s, dst); - - TEST_CYCLE() - { - cv::divide(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Divide_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Divide_Scalar_Inv - -GPU_PERF_TEST(Divide_Scalar_Inv, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - double scale = 100.0; - cv::Mat dst; - - cv::divide(scale, src, dst); - - TEST_CYCLE() - { - cv::divide(scale, src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Divide_Scalar_Inv, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// AbsDiff_Mat - -GPU_PERF_TEST(AbsDiff_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0.0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0.0, 100.0); - - cv::Mat dst; - - cv::absdiff(src1, src2, dst); - - TEST_CYCLE() - { - cv::absdiff(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, AbsDiff_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// AbsDiff_Scalar - -GPU_PERF_TEST(AbsDiff_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Scalar s(1, 2, 3, 4); - cv::Mat dst; - - cv::absdiff(src, s, dst); - - TEST_CYCLE() - { - cv::absdiff(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, AbsDiff_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Sqrt - -GPU_PERF_TEST(Sqrt, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 100.0); - - cv::Mat dst; - - cv::sqrt(src, dst); - - TEST_CYCLE() - { - cv::sqrt(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Sqrt, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Log - -GPU_PERF_TEST(Log, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 1.0, 100.0); - - cv::Mat dst; - - cv::log(src, dst); - - TEST_CYCLE() - { - cv::log(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Log, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Exp - -GPU_PERF_TEST(Exp, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 1.0, 10.0); - - cv::Mat dst; - - cv::exp(src, dst); - - TEST_CYCLE() - { - cv::exp(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Exp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Pow - -GPU_PERF_TEST(Pow, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 1.0, 10.0); - - cv::Mat dst; - - cv::pow(src, 2.3, dst); - - TEST_CYCLE() - { - cv::pow(src, 2.3, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Pow, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16S, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Compare_Mat - -CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE) -#define ALL_CMP_CODES testing::Values(CmpCode(cv::CMP_EQ), CmpCode(cv::CMP_NE), CmpCode(cv::CMP_GT), CmpCode(cv::CMP_GE), CmpCode(cv::CMP_LT), CmpCode(cv::CMP_LE)) - -GPU_PERF_TEST(Compare_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int cmp_code = GET_PARAM(3); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::compare(src1, src2, dst, cmp_code); - - TEST_CYCLE() - { - cv::compare(src1, src2, dst, cmp_code); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Compare_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - ALL_CMP_CODES)); - -////////////////////////////////////////////////////////////////////// -// Compare_Scalar - -GPU_PERF_TEST(Compare_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int cmp_code = GET_PARAM(3); - - cv::Mat src(size, depth); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar::all(50); - cv::Mat dst; - - cv::compare(src, s, dst, cmp_code); - - TEST_CYCLE() - { - cv::compare(src, s, dst, cmp_code); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Compare_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - ALL_CMP_CODES)); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Not - -GPU_PERF_TEST(Bitwise_Not, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_not(src, dst); - - TEST_CYCLE() - { - cv::bitwise_not(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Not, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_And_Mat - -GPU_PERF_TEST(Bitwise_And_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_and(src1, src2, dst); - - TEST_CYCLE() - { - cv::bitwise_and(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_And_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_And_Scalar - -GPU_PERF_TEST(Bitwise_And_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::Mat dst; - - cv::bitwise_and(src, s, dst); - - TEST_CYCLE() - { - cv::bitwise_and(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_And_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Or_Mat - -GPU_PERF_TEST(Bitwise_Or_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_or(src1, src2, dst); - - TEST_CYCLE() - { - cv::bitwise_or(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Or_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Or_Scalar - -GPU_PERF_TEST(Bitwise_Or_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::Mat dst; - - cv::bitwise_or(src, s, dst); - - TEST_CYCLE() - { - cv::bitwise_or(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Or_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Xor_Mat - -GPU_PERF_TEST(Bitwise_Xor_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::bitwise_xor(src1, src2, dst); - - TEST_CYCLE() - { - cv::bitwise_xor(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Xor_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S))); - -////////////////////////////////////////////////////////////////////// -// Bitwise_Xor_Scalar - -GPU_PERF_TEST(Bitwise_Xor_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0, 100.0); - - cv::Scalar s = cv::Scalar(50, 50, 50, 50); - cv::Mat dst; - - cv::bitwise_xor(src, s, dst); - - TEST_CYCLE() - { - cv::bitwise_xor(src, s, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Bitwise_Xor_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S), - testing::Values(1, 3, 4))); - -////////////////////////////////////////////////////////////////////// -// Min_Mat - -GPU_PERF_TEST(Min_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 255.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 255.0); - - cv::Mat dst; - - cv::min(src1, src2, dst); - - TEST_CYCLE() - { - cv::min(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Min_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Min_Scalar - -GPU_PERF_TEST(Min_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 255.0); - - double val = 50.0; - cv::Mat dst; - - cv::min(src, val, dst); - - TEST_CYCLE() - { - cv::min(src, val, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Min_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Max_Mat - -GPU_PERF_TEST(Max_Mat, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src1(size, depth); - fill(src1, 0, 255.0); - - cv::Mat src2(size, depth); - fill(src2, 0, 255.0); - - cv::Mat dst; - - cv::max(src1, src2, dst); - - TEST_CYCLE() - { - cv::max(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Max_Mat, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// Max_Scalar - -GPU_PERF_TEST(Max_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 255.0); - - double val = 50.0; - cv::Mat dst; - - cv::max(src, val, dst); - - TEST_CYCLE() - { - cv::max(src, val, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Max_Scalar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F))); - -////////////////////////////////////////////////////////////////////// -// AddWeighted - -GPU_PERF_TEST(AddWeighted, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth1 = GET_PARAM(2); - int depth2 = GET_PARAM(3); - int dst_depth = GET_PARAM(4); - - cv::Mat src1(size, depth1); - fill(src1, 0, 100.0); - - cv::Mat src2(size, depth2); - fill(src2, 0, 100.0); - - cv::Mat dst; - - cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); - - TEST_CYCLE() - { - cv::addWeighted(src1, 0.5, src2, 0.5, 10.0, dst, dst_depth); - } -} - -INSTANTIATE_TEST_CASE_P(Core, AddWeighted, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F), - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// GEMM - -CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T) -#define ALL_GEMM_FLAGS testing::Values(GemmFlags(0), GemmFlags(cv::GEMM_1_T), GemmFlags(cv::GEMM_2_T), GemmFlags(cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T)) - -GPU_PERF_TEST(GEMM, cv::gpu::DeviceInfo, cv::Size, MatType, GemmFlags) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int flags = GET_PARAM(3); - - cv::Mat src1(size, type); - fill(src1, 0.0, 10.0); - - cv::Mat src2(size, type); - fill(src2, 0.0, 10.0); - - cv::Mat src3(size, type); - fill(src3, 0.0, 10.0); - - cv::Mat dst; - - cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); - - declare.time(50.0); - - TEST_CYCLE() - { - cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags); - } -} - -INSTANTIATE_TEST_CASE_P(Core, GEMM, testing::Combine( - ALL_DEVICES, - testing::Values(cv::Size(512, 512), cv::Size(1024, 1024)), - testing::Values(CV_32FC1, CV_32FC2, CV_64FC1, CV_64FC2), - ALL_GEMM_FLAGS)); - -////////////////////////////////////////////////////////////////////// -// Transpose - -GPU_PERF_TEST(Transpose, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat dst; - - cv::transpose(src, dst); - - TEST_CYCLE() - { - cv::transpose(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Transpose, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1))); - -////////////////////////////////////////////////////////////////////// -// Flip - -enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1}; -CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y) -#define ALL_FLIP_CODES testing::Values(FlipCode(FLIP_BOTH), FlipCode(FLIP_X), FlipCode(FLIP_Y)) - -GPU_PERF_TEST(Flip, cv::gpu::DeviceInfo, cv::Size, MatType, FlipCode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int flipCode = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat dst; - - cv::flip(src, dst, flipCode); - - TEST_CYCLE() - { - cv::flip(src, dst, flipCode); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Flip, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4), - ALL_FLIP_CODES)); - -////////////////////////////////////////////////////////////////////// -// LUT_OneChannel - -GPU_PERF_TEST(LUT_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat lut(1, 256, CV_8UC1); - fill(lut, 0.0, 100.0); - - cv::Mat dst; - - cv::LUT(src, lut, dst); - - TEST_CYCLE() - { - cv::LUT(src, lut, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, LUT_OneChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3))); - -////////////////////////////////////////////////////////////////////// -// LUT_MultiChannel - -GPU_PERF_TEST(LUT_MultiChannel, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 100.0); - - cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels())); - fill(lut, 0.0, 100.0); - - cv::Mat dst; - - cv::LUT(src, lut, dst); - - TEST_CYCLE() - { - cv::LUT(src, lut, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, LUT_MultiChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC3))); - -////////////////////////////////////////////////////////////////////// -// Magnitude_Complex - -GPU_PERF_TEST(Magnitude_Complex, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_32FC2); - fill(src, -100.0, 100.0); - - cv::Mat srcs[2]; - cv::split(src, srcs); - - cv::Mat dst; - - cv::magnitude(srcs[0], srcs[1], dst); - - TEST_CYCLE() - { - cv::magnitude(srcs[0], srcs[1], dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Magnitude_Complex, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Magnitude - -GPU_PERF_TEST(Magnitude, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src1(size, CV_32FC1); - fill(src1, -100.0, 100.0); - - cv::Mat src2(size, CV_32FC1); - fill(src2, -100.0, 100.0); - - cv::Mat dst; - - cv::magnitude(src1, src2, dst); - - TEST_CYCLE() - { - cv::magnitude(src1, src2, dst); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Magnitude, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Phase - -IMPLEMENT_PARAM_CLASS(AngleInDegrees, bool) - -GPU_PERF_TEST(Phase, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) -{ - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); - - cv::Mat src1(size, CV_32FC1); - fill(src1, -100.0, 100.0); - - cv::Mat src2(size, CV_32FC1); - fill(src2, -100.0, 100.0); - - cv::Mat dst; - - cv::phase(src1, src2, dst, angleInDegrees); - - TEST_CYCLE() - { - cv::phase(src1, src2, dst, angleInDegrees); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Phase, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - -////////////////////////////////////////////////////////////////////// -// CartToPolar - -GPU_PERF_TEST(CartToPolar, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) -{ - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); - - cv::Mat src1(size, CV_32FC1); - fill(src1, -100.0, 100.0); - - cv::Mat src2(size, CV_32FC1); - fill(src2, -100.0, 100.0); - - cv::Mat magnitude; - cv::Mat angle; - - cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); - - TEST_CYCLE() - { - cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees); - } -} - -INSTANTIATE_TEST_CASE_P(Core, CartToPolar, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - -////////////////////////////////////////////////////////////////////// -// PolarToCart - -GPU_PERF_TEST(PolarToCart, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees) -{ - cv::Size size = GET_PARAM(1); - bool angleInDegrees = GET_PARAM(2); - - cv::Mat magnitude(size, CV_32FC1); - fill(magnitude, 0.0, 100.0); - - cv::Mat angle(size, CV_32FC1); - fill(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI); - - cv::Mat x; - cv::Mat y; - - cv::polarToCart(magnitude, angle, x, y, angleInDegrees); - - TEST_CYCLE() - { - cv::polarToCart(magnitude, angle, x, y, angleInDegrees); - } -} - -INSTANTIATE_TEST_CASE_P(Core, PolarToCart, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(false, true))); - -////////////////////////////////////////////////////////////////////// -// MeanStdDev - -GPU_PERF_TEST(MeanStdDev, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_8UC1); - fill(src, 0.0, 255.0); - - cv::Scalar mean; - cv::Scalar stddev; - - cv::meanStdDev(src, mean, stddev); - - TEST_CYCLE() - { - cv::meanStdDev(src, mean, stddev); - } -} - -INSTANTIATE_TEST_CASE_P(Core, MeanStdDev, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Norm - -GPU_PERF_TEST(Norm, cv::gpu::DeviceInfo, cv::Size, MatDepth, NormType) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int normType = GET_PARAM(3); - - cv::Mat src(size, depth); - fill(src, 0.0, 255.0); - - double dst; - cv::Mat buf; - - dst = cv::norm(src, normType); - - TEST_CYCLE() - { - dst = cv::norm(src, normType); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Norm, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32S, CV_32F), - testing::Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))); - -////////////////////////////////////////////////////////////////////// -// NormDiff - -GPU_PERF_TEST(NormDiff, cv::gpu::DeviceInfo, cv::Size, NormType) -{ - cv::Size size = GET_PARAM(1); - int normType = GET_PARAM(2); - - cv::Mat src1(size, CV_8UC1); - fill(src1, 0.0, 255.0); - - cv::Mat src2(size, CV_8UC1); - fill(src2, 0.0, 255.0); - - double dst; - - dst = cv::norm(src1, src2, normType); - - TEST_CYCLE() - { - dst = cv::norm(src1, src2, normType); - } -} - -INSTANTIATE_TEST_CASE_P(Core, NormDiff, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2)))); - -////////////////////////////////////////////////////////////////////// -// Sum - -GPU_PERF_TEST(Sum, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Scalar dst; - - dst = cv::sum(src); - - TEST_CYCLE() - { - dst = cv::sum(src); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Sum, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); - -////////////////////////////////////////////////////////////////////// -// MinMaxLoc - -GPU_PERF_TEST(MinMaxLoc, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 255.0); - - double minVal, maxVal; - cv::Point minLoc, maxLoc; - - cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); - - TEST_CYCLE() - { - cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc); - } -} - -INSTANTIATE_TEST_CASE_P(Core, MinMaxLoc, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// CountNonZero - -GPU_PERF_TEST(CountNonZero, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0.0, 1.5); - - int dst; - - dst = cv::countNonZero(src); - - TEST_CYCLE() - { - dst = cv::countNonZero(src); - } -} - -INSTANTIATE_TEST_CASE_P(Core, CountNonZero, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_32F, CV_64F))); - -////////////////////////////////////////////////////////////////////// -// Reduce - -CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) -#define ALL_REDUCE_CODES testing::Values(CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) - -enum {Rows = 0, Cols = 1}; -CV_ENUM(ReduceDim, Rows, Cols) - -GPU_PERF_TEST(Reduce, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, ReduceCode, ReduceDim) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int channels = GET_PARAM(3); - int reduceOp = GET_PARAM(4); - int dim = GET_PARAM(5); - - int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - fill(src, 0.0, 10.0); - - cv::Mat dst; - - cv::reduce(src, dst, dim, reduceOp); - - TEST_CYCLE() - { - cv::reduce(src, dst, dim, reduceOp); - } -} - -INSTANTIATE_TEST_CASE_P(Core, Reduce, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(CV_8U, CV_16U, CV_16S, CV_32F), - testing::Values(1, 2, 3, 4), - ALL_REDUCE_CODES, - testing::Values(ReduceDim(Rows), ReduceDim(Cols)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_cpu_precomp.cpp b/modules/gpu/perf_cpu/perf_cpu_precomp.cpp deleted file mode 100644 index d947dd0258..0000000000 --- a/modules/gpu/perf_cpu/perf_cpu_precomp.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "perf_cpu_precomp.hpp" diff --git a/modules/gpu/perf_cpu/perf_cpu_precomp.hpp b/modules/gpu/perf_cpu/perf_cpu_precomp.hpp deleted file mode 100644 index 12680c7a02..0000000000 --- a/modules/gpu/perf_cpu/perf_cpu_precomp.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX -#endif - -#ifndef __OPENCV_PERF_CPU_PRECOMP_HPP__ -#define __OPENCV_PERF_CPU_PRECOMP_HPP__ - -#include -#include - -#include "cvconfig.h" - -#include "opencv2/ts/ts.hpp" -#include "opencv2/ts/ts_perf.hpp" - -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/video/video.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/nonfree/nonfree.hpp" -#include "opencv2/legacy/legacy.hpp" - -#include "perf_utility.hpp" - -#ifdef GTEST_CREATE_SHARED_LIBRARY -#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined -#endif - -#endif diff --git a/modules/gpu/perf_cpu/perf_features2d.cpp b/modules/gpu/perf_cpu/perf_features2d.cpp deleted file mode 100644 index 74579a64a2..0000000000 --- a/modules/gpu/perf_cpu/perf_features2d.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// SURF - -GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::SURF surf; - - std::vector keypoints; - cv::Mat descriptors; - - surf(img, cv::noArray(), keypoints, descriptors); - - declare.time(50.0); - - TEST_CYCLE() - { - keypoints.clear(); - surf(img, cv::noArray(), keypoints, descriptors); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// FAST - -GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - std::vector keypoints; - - cv::FAST(img, keypoints, 20); - - TEST_CYCLE() - { - keypoints.clear(); - cv::FAST(img, keypoints, 20); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// ORB - -GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::ORB orb(4000); - - std::vector keypoints; - cv::Mat descriptors; - - orb(img, cv::noArray(), keypoints, descriptors); - - TEST_CYCLE() - { - keypoints.clear(); - orb(img, cv::noArray(), keypoints, descriptors); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_match - -IMPLEMENT_PARAM_CLASS(DescriptorSize, int) - -GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType) -{ - int desc_size = GET_PARAM(1); - int normType = GET_PARAM(2); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query(3000, desc_size, type); - fill(query, 0.0, 10.0); - - cv::Mat train(3000, desc_size, type); - fill(train, 0.0, 10.0); - - cv::BFMatcher matcher(normType); - - std::vector matches; - - matcher.match(query, train, matches); - - declare.time(20.0); - - TEST_CYCLE() - { - matcher.match(query, train, matches); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_knnMatch - -IMPLEMENT_PARAM_CLASS(K, int) - -GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType) -{ - int desc_size = GET_PARAM(1); - int k = GET_PARAM(2); - int normType = GET_PARAM(3); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query(3000, desc_size, type); - fill(query, 0.0, 10.0); - - cv::Mat train(3000, desc_size, type); - fill(train, 0.0, 10.0); - - cv::BFMatcher matcher(normType); - - std::vector< std::vector > matches; - - matcher.knnMatch(query, train, matches, k); - - declare.time(30.0); - - TEST_CYCLE() - { - matcher.knnMatch(query, train, matches, k); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(K(2), K(3)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -////////////////////////////////////////////////////////////////////// -// BruteForceMatcher_radiusMatch - -GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType) -{ - int desc_size = GET_PARAM(1); - int normType = GET_PARAM(2); - - int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F; - - cv::Mat query(3000, desc_size, type); - fill(query, 0.0, 1.0); - - cv::Mat train(3000, desc_size, type); - fill(train, 0.0, 1.0); - - cv::BFMatcher matcher(normType); - - std::vector< std::vector > matches; - - matcher.radiusMatch(query, train, matches, 2.0); - - declare.time(30.0); - - TEST_CYCLE() - { - matcher.radiusMatch(query, train, matches, 2.0); - } -} - -INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine( - ALL_DEVICES, - testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)), - testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_filters.cpp b/modules/gpu/perf_cpu/perf_filters.cpp deleted file mode 100644 index ab0be3bad9..0000000000 --- a/modules/gpu/perf_cpu/perf_filters.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -IMPLEMENT_PARAM_CLASS(KernelSize, int) - -////////////////////////////////////////////////////////////////////// -// Blur - -GPU_PERF_TEST(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::blur(src, dst, cv::Size(ksize, ksize)); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::blur(src, dst, cv::Size(ksize, ksize)); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Blur, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7)))); - -////////////////////////////////////////////////////////////////////// -// Sobel - -GPU_PERF_TEST(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Sobel(src, dst, -1, 1, 1, ksize); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::Sobel(src, dst, -1, 1, 1, ksize); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Sobel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -////////////////////////////////////////////////////////////////////// -// Scharr - -GPU_PERF_TEST(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Scharr(src, dst, -1, 1, 0); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::Scharr(src, dst, -1, 1, 0); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Scharr, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)))); - -////////////////////////////////////////////////////////////////////// -// GaussianBlur - -GPU_PERF_TEST(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, GaussianBlur, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -////////////////////////////////////////////////////////////////////// -// Laplacian - -GPU_PERF_TEST(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Laplacian(src, dst, -1, ksize); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::Laplacian(src, dst, -1, ksize); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Laplacian, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)), - testing::Values(KernelSize(1), KernelSize(3)))); - -////////////////////////////////////////////////////////////////////// -// Erode - -GPU_PERF_TEST(Erode, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - - cv::Mat dst; - - cv::erode(src, dst, ker); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::erode(src, dst, ker); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Erode, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); - -////////////////////////////////////////////////////////////////////// -// Dilate - -GPU_PERF_TEST(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - - cv::Mat dst; - - cv::dilate(src, dst, ker); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::dilate(src, dst, ker); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Dilate, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); - -////////////////////////////////////////////////////////////////////// -// MorphologyEx - -CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT) -#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT)) - -GPU_PERF_TEST(MorphologyEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int morphOp = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat dst; - - cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); - - cv::morphologyEx(src, dst, morphOp, ker); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::morphologyEx(src, dst, morphOp, ker); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, MorphologyEx, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)), - ALL_MORPH_OPS)); - -////////////////////////////////////////////////////////////////////// -// Filter2D - -GPU_PERF_TEST(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int ksize = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0.0, 255.0); - - cv::Mat kernel(ksize, ksize, CV_32FC1); - fill(kernel, 0.0, 1.0); - - cv::Mat dst; - - cv::filter2D(src, dst, -1, kernel); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::filter2D(src, dst, -1, kernel); - } -} - -INSTANTIATE_TEST_CASE_P(Filters, Filter2D, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)), - testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_imgproc.cpp b/modules/gpu/perf_cpu/perf_imgproc.cpp deleted file mode 100644 index 1b3c0951c6..0000000000 --- a/modules/gpu/perf_cpu/perf_imgproc.cpp +++ /dev/null @@ -1,771 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// Remap - -GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat xmap(size, CV_32FC1); - fill(xmap, 0, size.width); - - cv::Mat ymap(size, CV_32FC1); - fill(ymap, 0, size.height); - - cv::Mat dst; - - cv::remap(src, dst, xmap, ymap, interpolation, borderMode); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::remap(src, dst, xmap, ymap, interpolation, borderMode); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - - -////////////////////////////////////////////////////////////////////// -// Resize - -IMPLEMENT_PARAM_CLASS(Scale, double) - -GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Scale) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - double f = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::resize(src, dst, cv::Size(), f, f, interpolation); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::resize(src, dst, cv::Size(), f, f, interpolation); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), - Interpolation(cv::INTER_CUBIC), Interpolation(cv::INTER_AREA)), - testing::Values(Scale(0.5), Scale(0.3), Scale(2.0)))); - -GPU_PERF_TEST(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, Scale) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = cv::INTER_AREA; - double f = GET_PARAM(3); - - cv::Mat src_host(size, type); - fill(src_host, 0, 255); - - cv::Mat src(src_host); - cv::Mat dst; - - cv::resize(src, dst, cv::Size(), f, f, interpolation); - - declare.time(1.0); - - TEST_CYCLE() - { - cv::resize(src, dst, cv::Size(), f, f, interpolation); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, ResizeArea, testing::Combine( - ALL_DEVICES, - testing::Values(perf::sz1080p, cv::Size(4096, 2048)), - testing::Values(MatType(CV_8UC1)/*, MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)*/), - testing::Values(Scale(0.2),Scale(0.1),Scale(0.05)))); - -////////////////////////////////////////////////////////////////////// -// WarpAffine - -GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - const double aplha = CV_PI / 4; - double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, - {std::sin(aplha), std::cos(aplha), 0}}; - cv::Mat M(2, 3, CV_64F, (void*) mat); - - cv::warpAffine(src, dst, M, size, interpolation, borderMode); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::warpAffine(src, dst, M, size, interpolation, borderMode); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - -////////////////////////////////////////////////////////////////////// -// WarpPerspective - -GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int interpolation = GET_PARAM(3); - int borderMode = GET_PARAM(4); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - const double aplha = CV_PI / 4; - double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2}, - {std::sin(aplha), std::cos(aplha), 0}, - {0.0, 0.0, 1.0}}; - cv::Mat M(3, 3, CV_64F, (void*) mat); - - cv::warpPerspective(src, dst, M, size, interpolation, borderMode); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::warpPerspective(src, dst, M, size, interpolation, borderMode); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - -////////////////////////////////////////////////////////////////////// -// CopyMakeBorder - -GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, BorderMode) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - int borderType = GET_PARAM(3); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); - - TEST_CYCLE() - { - cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP)))); - -////////////////////////////////////////////////////////////////////// -// Threshold - -CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV) -#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV)) - -GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, MatDepth, ThreshOp) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - int threshOp = GET_PARAM(3); - - cv::Mat src(size, depth); - fill(src, 0, 255); - - cv::Mat dst; - - cv::threshold(src, dst, 100.0, 255.0, threshOp); - - TEST_CYCLE() - { - cv::threshold(src, dst, 100.0, 255.0, threshOp); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)), - ALL_THRESH_OPS)); - -////////////////////////////////////////////////////////////////////// -// Integral - -GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_8UC1); - fill(src, 0, 255); - - cv::Mat dst; - - cv::integral(src, dst); - - TEST_CYCLE() - { - cv::integral(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// HistEven_OneChannel - -GPU_PERF_TEST(HistEven_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - - cv::Mat src(size, depth); - fill(src, 0, 255); - - int hbins = 30; - float hranges[] = {0.0f, 180.0f}; - cv::Mat hist; - int histSize[] = {hbins}; - const float* ranges[] = {hranges}; - int channels[] = {0}; - - cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); - - TEST_CYCLE() - { - cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_OneChannel, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S)))); - -////////////////////////////////////////////////////////////////////// -// EqualizeHist - -GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size) -{ - cv::Size size = GET_PARAM(1); - - cv::Mat src(size, CV_8UC1); - fill(src, 0, 255); - - cv::Mat dst; - - cv::equalizeHist(src, dst); - - TEST_CYCLE() - { - cv::equalizeHist(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES)); - -////////////////////////////////////////////////////////////////////// -// Canny - -IMPLEMENT_PARAM_CLASS(AppertureSize, int) -IMPLEMENT_PARAM_CLASS(L2gradient, bool) - -GPU_PERF_TEST(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient) -{ - int apperture_size = GET_PARAM(1); - bool useL2gradient = GET_PARAM(2); - - cv::Mat image = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image.empty()); - - cv::Mat dst; - - cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); - - TEST_CYCLE() - { - cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine( - ALL_DEVICES, - testing::Values(AppertureSize(3), AppertureSize(5)), - testing::Values(L2gradient(false), L2gradient(true)))); - -////////////////////////////////////////////////////////////////////// -// MeanShiftFiltering - -GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/meanshift/cones.png"); - ASSERT_FALSE(img.empty()); - - cv::Mat dst; - - cv::pyrMeanShiftFiltering(img, dst, 50, 50); - - declare.time(15.0); - - TEST_CYCLE() - { - cv::pyrMeanShiftFiltering(img, dst, 50, 50); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES); - -////////////////////////////////////////////////////////////////////// -// Convolve - -IMPLEMENT_PARAM_CLASS(KSize, int) -IMPLEMENT_PARAM_CLASS(Ccorr, bool) - -GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr) -{ - cv::Size size = GET_PARAM(1); - int templ_size = GET_PARAM(2); - bool ccorr = GET_PARAM(3); - - ASSERT_FALSE(ccorr); - - cv::Mat image(size, CV_32FC1); - image.setTo(1.0); - - cv::Mat templ(templ_size, templ_size, CV_32FC1); - templ.setTo(1.0); - - cv::Mat dst; - - cv::filter2D(image, dst, image.depth(), templ); - - declare.time(10.0); - - TEST_CYCLE() - { - cv::filter2D(image, dst, image.depth(), templ); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(KSize(3), KSize(9), KSize(17), KSize(27), KSize(32), KSize(64)), - testing::Values(Ccorr(false), Ccorr(true)))); - -//////////////////////////////////////////////////////////////////////////////// -// MatchTemplate_8U - -CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED) -#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED)) - -IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size) - -GPU_PERF_TEST(MatchTemplate_8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod) -{ - cv::Size size = GET_PARAM(1); - cv::Size templ_size = GET_PARAM(2); - int cn = GET_PARAM(3); - int method = GET_PARAM(4); - - cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn)); - fill(image, 0, 255); - - cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn)); - fill(templ, 0, 255); - - cv::Mat dst; - - cv::matchTemplate(image, templ, dst, method); - - TEST_CYCLE() - { - cv::matchTemplate(image, templ, dst, method); - } -}; - -INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_8U, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))), - testing::Values(Channels(1), Channels(3), Channels(4)), - ALL_TEMPLATE_METHODS)); - -//////////////////////////////////////////////////////////////////////////////// -// MatchTemplate_32F - -GPU_PERF_TEST(MatchTemplate_32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod) -{ - cv::Size size = GET_PARAM(1); - cv::Size templ_size = GET_PARAM(2); - int cn = GET_PARAM(3); - int method = GET_PARAM(4); - - cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn)); - fill(image, 0, 255); - - cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn)); - fill(templ, 0, 255); - - cv::Mat dst; - - cv::matchTemplate(image, templ, dst, method); - - TEST_CYCLE() - { - cv::matchTemplate(image, templ, dst, method); - } -}; - -INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_32F, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR)))); - -////////////////////////////////////////////////////////////////////// -// MulSpectrums - -CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT) - -GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags) -{ - cv::Size size = GET_PARAM(1); - int flag = GET_PARAM(2); - - cv::Mat a(size, CV_32FC2); - fill(a, 0, 100); - - cv::Mat b(size, CV_32FC2); - fill(b, 0, 100); - - cv::Mat dst; - - cv::mulSpectrums(a, b, dst, flag); - - TEST_CYCLE() - { - cv::mulSpectrums(a, b, dst, flag); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS)))); - -////////////////////////////////////////////////////////////////////// -// Dft - -GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size, DftFlags) -{ - cv::Size size = GET_PARAM(1); - int flag = GET_PARAM(2); - - cv::Mat src(size, CV_32FC2); - fill(src, 0, 100); - - cv::Mat dst; - - cv::dft(src, dst, flag); - - declare.time(10.0); - - TEST_CYCLE() - { - cv::dft(src, dst, flag); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE)))); - -////////////////////////////////////////////////////////////////////// -// CornerHarris - -IMPLEMENT_PARAM_CLASS(BlockSize, int) -IMPLEMENT_PARAM_CLASS(ApertureSize, int) - -GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize) -{ - int type = GET_PARAM(1); - int borderType = GET_PARAM(2); - int blockSize = GET_PARAM(3); - int apertureSize = GET_PARAM(4); - - cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - - cv::Mat dst; - - double k = 0.5; - - cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderType); - - TEST_CYCLE() - { - cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderType); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine( - ALL_DEVICES, - testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), - testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)), - testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7)))); - -////////////////////////////////////////////////////////////////////// -// CornerMinEigenVal - -GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize) -{ - int type = GET_PARAM(1); - int borderType = GET_PARAM(2); - int blockSize = GET_PARAM(3); - int apertureSize = GET_PARAM(4); - - cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0); - - cv::Mat dst; - - cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderType); - - TEST_CYCLE() - { - cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderType); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine( - ALL_DEVICES, - testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)), - testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)), - testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)), - testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7)))); - -////////////////////////////////////////////////////////////////////// -// PyrDown - -GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::pyrDown(src, dst); - - TEST_CYCLE() - { - cv::pyrDown(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - -////////////////////////////////////////////////////////////////////// -// PyrUp - -GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat dst; - - cv::pyrUp(src, dst); - - TEST_CYCLE() - { - cv::pyrUp(src, dst); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)))); - -////////////////////////////////////////////////////////////////////// -// CvtColor - -GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, MatDepth, CvtColorInfo) -{ - cv::Size size = GET_PARAM(1); - int depth = GET_PARAM(2); - CvtColorInfo info = GET_PARAM(3); - - cv::Mat src(size, CV_MAKETYPE(depth, info.scn)); - fill(src, 0, 255); - - cv::Mat dst; - - cv::cvtColor(src, dst, info.code, info.dcn); - - TEST_CYCLE() - { - cv::cvtColor(src, dst, info.code, info.dcn); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)), - testing::Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), - CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), - CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA), - CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ), - CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb), - CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2YUV), - CvtColorInfo(3, 3, cv::COLOR_YUV2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2HSV), - CvtColorInfo(3, 3, cv::COLOR_HSV2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2HLS), - CvtColorInfo(3, 3, cv::COLOR_HLS2BGR), - CvtColorInfo(3, 3, cv::COLOR_BGR2Lab), - CvtColorInfo(3, 3, cv::COLOR_RGB2Lab), - CvtColorInfo(3, 3, cv::COLOR_BGR2Luv), - CvtColorInfo(3, 3, cv::COLOR_RGB2Luv), - CvtColorInfo(3, 3, cv::COLOR_Lab2BGR), - CvtColorInfo(3, 3, cv::COLOR_Lab2RGB), - CvtColorInfo(3, 3, cv::COLOR_Luv2BGR), - CvtColorInfo(3, 3, cv::COLOR_Luv2RGB), - CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR), - CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR), - CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA)))); - -////////////////////////////////////////////////////////////////////// -// HoughLines - -IMPLEMENT_PARAM_CLASS(DoSort, bool) - -GPU_PERF_TEST(HoughLines, cv::gpu::DeviceInfo, cv::Size, DoSort) -{ - declare.time(30.0); - - const cv::Size size = GET_PARAM(1); - - const float rho = 1.0f; - const float theta = CV_PI / 180.0f; - const int threshold = 300; - - cv::RNG rng(123456789); - - cv::Mat src(size, CV_8UC1, cv::Scalar::all(0)); - - const int numLines = rng.uniform(500, 2000); - for (int i = 0; i < numLines; ++i) - { - cv::Point p1(rng.uniform(0, src.cols), rng.uniform(0, src.rows)); - cv::Point p2(rng.uniform(0, src.cols), rng.uniform(0, src.rows)); - cv::line(src, p1, p2, cv::Scalar::all(255), 2); - } - - std::vector lines; - cv::HoughLines(src, lines, rho, theta, threshold); - - TEST_CYCLE() - { - cv::HoughLines(src, lines, rho, theta, threshold); - } -} - -INSTANTIATE_TEST_CASE_P(ImgProc, HoughLines, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(DoSort(false), DoSort(true)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_labeling.cpp b/modules/gpu/perf_cpu/perf_labeling.cpp deleted file mode 100644 index ddf9c3d9bb..0000000000 --- a/modules/gpu/perf_cpu/perf_labeling.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -//M*/ - -#include "perf_precomp.hpp" - -#ifdef HAVE_CUDA - -namespace { - - struct GreedyLabeling - { - struct dot - { - int x; - int y; - - static dot make(int i, int j) - { - dot d; d.x = i; d.y = j; - return d; - } - }; - - struct InInterval - { - InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {}; - const int lo, hi; - - bool operator() (const unsigned char a, const unsigned char b) const - { - int d = a - b; - return lo <= d && d <= hi; - } - }; - - GreedyLabeling(cv::Mat img) - : image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];} - - ~GreedyLabeling(){delete[] stack;} - - void operator() (cv::Mat labels) const - { - labels.setTo(cv::Scalar::all(-1)); - InInterval inInt(0, 2); - int cc = -1; - - int* dist_labels = (int*)labels.data; - int pitch = labels.step1(); - - unsigned char* source = (unsigned char*)image.data; - int width = image.cols; - int height = image.rows; - - for (int j = 0; j < image.rows; ++j) - for (int i = 0; i < image.cols; ++i) - { - if (dist_labels[j * pitch + i] != -1) continue; - - dot* top = stack; - dot p = dot::make(i, j); - cc++; - - dist_labels[j * pitch + i] = cc; - - while (top >= stack) - { - int* dl = &dist_labels[p.y * pitch + p.x]; - unsigned char* sp = &source[p.y * image.step1() + p.x]; - - dl[0] = cc; - - //right - if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1])) - *top++ = dot::make(p.x + 1, p.y); - - //left - if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1])) - *top++ = dot::make(p.x - 1, p.y); - - //bottom - if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()])) - *top++ = dot::make(p.x, p.y + 1); - - //top - if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()])) - *top++ = dot::make(p.x, p.y - 1); - - p = *--top; - } - } - } - - cv::Mat image; - cv::Mat _labels; - dot* stack; - }; -} - -GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size) -{ - cv::gpu::DeviceInfo devInfo = GET_PARAM(0); - cv::gpu::setDevice(devInfo.deviceID()); - - cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE); - - GreedyLabeling host(image); - - host(host._labels); - - declare.time(1.0); - - TEST_CYCLE() - { - host(host._labels); - } -} - -INSTANTIATE_TEST_CASE_P(Labeling, ConnectedComponents, testing::Combine(ALL_DEVICES, testing::Values(cv::Size(261, 262)))); - -#endif \ No newline at end of file diff --git a/modules/gpu/perf_cpu/perf_main.cpp b/modules/gpu/perf_cpu/perf_main.cpp deleted file mode 100644 index 6fcf56d0b0..0000000000 --- a/modules/gpu/perf_cpu/perf_main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - perf::TestBase::Init(argc, argv); - return RUN_ALL_TESTS(); -} - -#else - -int main() -{ - printf("OpenCV was built without CUDA support\n"); - return 0; -} - -#endif diff --git a/modules/gpu/perf_cpu/perf_matop.cpp b/modules/gpu/perf_cpu/perf_matop.cpp deleted file mode 100644 index 7c46eee80e..0000000000 --- a/modules/gpu/perf_cpu/perf_matop.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////////////////////// -// SetTo - -GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - cv::Scalar val(1, 2, 3, 4); - - src.setTo(val); - - TEST_CYCLE() - { - src.setTo(val); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - -////////////////////////////////////////////////////////////////////// -// SetToMasked - -GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat mask(size, CV_8UC1); - fill(mask, 0, 2); - - cv::Scalar val(1, 2, 3, 4); - - src.setTo(val, mask); - - TEST_CYCLE() - { - src.setTo(val, mask); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - -////////////////////////////////////////////////////////////////////// -// CopyToMasked - -GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType) -{ - cv::Size size = GET_PARAM(1); - int type = GET_PARAM(2); - - cv::Mat src(size, type); - fill(src, 0, 255); - - cv::Mat mask(size, CV_8UC1); - fill(mask, 0, 2); - - cv::Mat dst; - - src.copyTo(dst, mask); - - TEST_CYCLE() - { - src.copyTo(dst, mask); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), - MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), - MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4), - MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4)))); - -////////////////////////////////////////////////////////////////////// -// ConvertTo - -GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth) -{ - cv::Size size = GET_PARAM(1); - int depth1 = GET_PARAM(2); - int depth2 = GET_PARAM(3); - - cv::Mat src(size, depth1); - fill(src, 0, 255); - - cv::Mat dst; - - src.convertTo(dst, depth2, 0.5, 1.0); - - TEST_CYCLE() - { - src.convertTo(dst, depth2, 0.5, 1.0); - } -} - -INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine( - ALL_DEVICES, - GPU_TYPICAL_MAT_SIZES, - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)), - testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)))); - -#endif diff --git a/modules/gpu/perf_cpu/perf_objdetect.cpp b/modules/gpu/perf_cpu/perf_objdetect.cpp deleted file mode 100644 index d9ae2b7c8f..0000000000 --- a/modules/gpu/perf_cpu/perf_objdetect.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -/////////////////////////////////////////////////////////////// -// HOG - -GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - std::vector found_locations; - - cv::HOGDescriptor hog; - hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); - - hog.detectMultiScale(img, found_locations); - - TEST_CYCLE() - { - hog.detectMultiScale(img, found_locations); - } -} - -INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES); - -/////////////////////////////////////////////////////////////// -// HaarClassifier - -GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::CascadeClassifier cascade; - - ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml"))); - - std::vector rects; - - cascade.detectMultiScale(img, rects); - - TEST_CYCLE() - { - cascade.detectMultiScale(img, rects); - } -} - -INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES); - -//===================== LBP cascade ==========================// -GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo) -{ - cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(img.empty()); - - cv::CascadeClassifier cascade; - - ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml"))); - - std::vector rects; - - cascade.detectMultiScale(img, rects); - - TEST_CYCLE() - { - cascade.detectMultiScale(img, rects); - } -} - -INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES); - -#endif diff --git a/modules/gpu/perf_cpu/perf_utility.cpp b/modules/gpu/perf_cpu/perf_utility.cpp deleted file mode 100644 index 541e6fdc7b..0000000000 --- a/modules/gpu/perf_cpu/perf_utility.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -using namespace std; -using namespace cv; -using namespace cv::gpu; - -void fill(Mat& m, double a, double b) -{ - RNG rng(123456789); - rng.fill(m, RNG::UNIFORM, a, b); -} - -void PrintTo(const CvtColorInfo& info, ostream* os) -{ - static const char* str[] = - { - "BGR2BGRA", - "BGRA2BGR", - "BGR2RGBA", - "RGBA2BGR", - "BGR2RGB", - "BGRA2RGBA", - - "BGR2GRAY", - "RGB2GRAY", - "GRAY2BGR", - "GRAY2BGRA", - "BGRA2GRAY", - "RGBA2GRAY", - - "BGR2BGR565", - "RGB2BGR565", - "BGR5652BGR", - "BGR5652RGB", - "BGRA2BGR565", - "RGBA2BGR565", - "BGR5652BGRA", - "BGR5652RGBA", - - "GRAY2BGR565", - "BGR5652GRAY", - - "BGR2BGR555", - "RGB2BGR555", - "BGR5552BGR", - "BGR5552RGB", - "BGRA2BGR555", - "RGBA2BGR555", - "BGR5552BGRA", - "BGR5552RGBA", - - "GRAY2BGR555", - "BGR5552GRAY", - - "BGR2XYZ", - "RGB2XYZ", - "XYZ2BGR", - "XYZ2RGB", - - "BGR2YCrCb", - "RGB2YCrCb", - "YCrCb2BGR", - "YCrCb2RGB", - - "BGR2HSV", - "RGB2HSV", - - "", - "", - - "BGR2Lab", - "RGB2Lab", - - "BayerBG2BGR", - "BayerGB2BGR", - "BayerRG2BGR", - "BayerGR2BGR", - - "BGR2Luv", - "RGB2Luv", - - "BGR2HLS", - "RGB2HLS", - - "HSV2BGR", - "HSV2RGB", - - "Lab2BGR", - "Lab2RGB", - "Luv2BGR", - "Luv2RGB", - - "HLS2BGR", - "HLS2RGB", - - "BayerBG2BGR_VNG", - "BayerGB2BGR_VNG", - "BayerRG2BGR_VNG", - "BayerGR2BGR_VNG", - - "BGR2HSV_FULL", - "RGB2HSV_FULL", - "BGR2HLS_FULL", - "RGB2HLS_FULL", - - "HSV2BGR_FULL", - "HSV2RGB_FULL", - "HLS2BGR_FULL", - "HLS2RGB_FULL", - - "LBGR2Lab", - "LRGB2Lab", - "LBGR2Luv", - "LRGB2Luv", - - "Lab2LBGR", - "Lab2LRGB", - "Luv2LBGR", - "Luv2LRGB", - - "BGR2YUV", - "RGB2YUV", - "YUV2BGR", - "YUV2RGB", - - "BayerBG2GRAY", - "BayerGB2GRAY", - "BayerRG2GRAY", - "BayerGR2GRAY", - - //YUV 4:2:0 formats family - "YUV2RGB_NV12", - "YUV2BGR_NV12", - "YUV2RGB_NV21", - "YUV2BGR_NV21", - - "YUV2RGBA_NV12", - "YUV2BGRA_NV12", - "YUV2RGBA_NV21", - "YUV2BGRA_NV21", - - "YUV2RGB_YV12", - "YUV2BGR_YV12", - "YUV2RGB_IYUV", - "YUV2BGR_IYUV", - - "YUV2RGBA_YV12", - "YUV2BGRA_YV12", - "YUV2RGBA_IYUV", - "YUV2BGRA_IYUV", - - "YUV2GRAY_420", - - //YUV 4:2:2 formats family - "YUV2RGB_UYVY", - "YUV2BGR_UYVY", - "YUV2RGB_VYUY", - "YUV2BGR_VYUY", - - "YUV2RGBA_UYVY", - "YUV2BGRA_UYVY", - "YUV2RGBA_VYUY", - "YUV2BGRA_VYUY", - - "YUV2RGB_YUY2", - "YUV2BGR_YUY2", - "YUV2RGB_YVYU", - "YUV2BGR_YVYU", - - "YUV2RGBA_YUY2", - "YUV2BGRA_YUY2", - "YUV2RGBA_YVYU", - "YUV2BGRA_YVYU", - - "YUV2GRAY_UYVY", - "YUV2GRAY_YUY2", - - // alpha premultiplication - "RGBA2mRGBA", - "mRGBA2RGBA", - - "COLORCVT_MAX" - }; - - *os << str[info.code]; -} - -void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os) -{ - *os << info.name(); -} - -Mat readImage(const string& fileName, int flags) -{ - return imread(perf::TestBase::getDataPath(fileName), flags); -} - -const vector& devices() -{ - static vector devs; - static bool first = true; - - if (first) - { - int deviceCount = getCudaEnabledDeviceCount(); - - devs.reserve(deviceCount); - - for (int i = 0; i < deviceCount; ++i) - { - DeviceInfo info(i); - if (info.isCompatible()) - devs.push_back(info); - } - - first = false; - } - - return devs; -} diff --git a/modules/gpu/perf_cpu/perf_utility.hpp b/modules/gpu/perf_cpu/perf_utility.hpp deleted file mode 100644 index 8693cfc3c0..0000000000 --- a/modules/gpu/perf_cpu/perf_utility.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__ -#define __OPENCV_PERF_GPU_UTILITY_HPP__ - -void fill(cv::Mat& m, double a, double b); - -using perf::MatType; -using perf::MatDepth; - -CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP) - CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA) -CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING) - -struct CvtColorInfo -{ - int scn; - int dcn; - int code; - - explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {} -}; - -void PrintTo(const CvtColorInfo& info, std::ostream* os); - -#define IMPLEMENT_PARAM_CLASS(name, type) \ - class name \ - { \ - public: \ - name ( type arg = type ()) : val_(arg) {} \ - operator type () const {return val_;} \ - private: \ - type val_; \ - }; \ - inline void PrintTo( name param, std::ostream* os) \ - { \ - *os << #name << " = " << testing::PrintToString(static_cast< type >(param)); \ - } - -IMPLEMENT_PARAM_CLASS(Channels, int) - -namespace cv { namespace gpu -{ - void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os); -}} - -#define GPU_PERF_TEST(name, ...) \ - struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \ - { \ - public: \ - name() {} \ - protected: \ - void PerfTestBody(); \ - }; \ - TEST_P(name, perf){ RunPerfTestBody(); } \ - void name :: PerfTestBody() - -#define GPU_PERF_TEST_1(name, param_type) \ - struct name : perf::TestBaseWithParam< param_type > \ - { \ - public: \ - name() {} \ - protected: \ - void PerfTestBody(); \ - }; \ - TEST_P(name, perf){ RunPerfTestBody(); } \ - void name :: PerfTestBody() - -#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500)) - -cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); - -const std::vector& devices(); - -#define ALL_DEVICES testing::ValuesIn(devices()) - -#define GET_PARAM(k) std::tr1::get< k >(GetParam()) - -#endif // __OPENCV_PERF_GPU_UTILITY_HPP__ diff --git a/modules/gpu/perf_cpu/perf_video.cpp b/modules/gpu/perf_cpu/perf_video.cpp deleted file mode 100644 index 2c3aeb31ce..0000000000 --- a/modules/gpu/perf_cpu/perf_video.cpp +++ /dev/null @@ -1,466 +0,0 @@ -#include "perf_cpu_precomp.hpp" - -#ifdef HAVE_CUDA - -////////////////////////////////////////////////////// -// GoodFeaturesToTrack - -IMPLEMENT_PARAM_CLASS(MinDistance, double) - -GPU_PERF_TEST(GoodFeaturesToTrack, cv::gpu::DeviceInfo, MinDistance) -{ - double minDistance = GET_PARAM(1); - - cv::Mat image = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(image.empty()); - - cv::Mat corners; - - cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance); - - TEST_CYCLE() - { - cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance); - } -} - -INSTANTIATE_TEST_CASE_P(Video, GoodFeaturesToTrack, testing::Combine( - ALL_DEVICES, - testing::Values(MinDistance(0.0), MinDistance(3.0)))); - -////////////////////////////////////////////////////// -// PyrLKOpticalFlowSparse - -IMPLEMENT_PARAM_CLASS(GraySource, bool) -IMPLEMENT_PARAM_CLASS(Points, int) -IMPLEMENT_PARAM_CLASS(WinSize, int) -IMPLEMENT_PARAM_CLASS(Levels, int) -IMPLEMENT_PARAM_CLASS(Iters, int) - -GPU_PERF_TEST(PyrLKOpticalFlowSparse, cv::gpu::DeviceInfo, GraySource, Points, WinSize, Levels, Iters) -{ - bool useGray = GET_PARAM(1); - int points = GET_PARAM(2); - int win_size = GET_PARAM(3); - int levels = GET_PARAM(4); - int iters = GET_PARAM(5); - - cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame0.empty()); - - cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR); - ASSERT_FALSE(frame1.empty()); - - cv::Mat gray_frame; - if (useGray) - gray_frame = frame0; - else - cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY); - - cv::Mat pts; - cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0); - - cv::Mat nextPts; - cv::Mat status; - - cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), - cv::Size(win_size, win_size), levels - 1, - cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); - - declare.time(20.0); - - TEST_CYCLE() - { - cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(), - cv::Size(win_size, win_size), levels - 1, - cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01)); - } -} - -INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowSparse, testing::Combine( - ALL_DEVICES, - testing::Values(GraySource(true), GraySource(false)), - testing::Values(Points(1000), Points(2000), Points(4000), Points(8000)), - testing::Values(WinSize(9), WinSize(13), WinSize(17), WinSize(21)), - testing::Values(Levels(1), Levels(2), Levels(3)), - testing::Values(Iters(1), Iters(10), Iters(30)))); - -////////////////////////////////////////////////////// -// FarnebackOpticalFlowTest - -GPU_PERF_TEST_1(FarnebackOpticalFlowTest, cv::gpu::DeviceInfo) -{ - cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame0.empty()); - - cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE); - ASSERT_FALSE(frame1.empty()); - - cv::Mat flow; - - int numLevels = 5; - double pyrScale = 0.5; - int winSize = 13; - int numIters = 10; - int polyN = 5; - double polySigma = 1.1; - int flags = 0; - - cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); - - declare.time(10); - - TEST_CYCLE() - { - cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags); - } -} - -INSTANTIATE_TEST_CASE_P(Video, FarnebackOpticalFlowTest, ALL_DEVICES); - -////////////////////////////////////////////////////// -// FGDStatModel - -namespace cv -{ - template<> void Ptr::delete_obj() - { - cvReleaseBGStatModel(&obj); - } -} - -GPU_PERF_TEST(FGDStatModel, cv::gpu::DeviceInfo, std::string) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - cap >> frame; - ASSERT_FALSE(frame.empty()); - - IplImage ipl_frame = frame; - cv::Ptr model(cvCreateFGDStatModel(&ipl_frame)); - - declare.time(60); - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - ipl_frame = frame; - - startTimer(); - next(); - - cvUpdateBGStatModel(&ipl_frame, model); - - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, FGDStatModel, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -////////////////////////////////////////////////////// -// MOG - -IMPLEMENT_PARAM_CLASS(LearningRate, double) - -GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - double learningRate = GET_PARAM(3); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - - cv::BackgroundSubtractorMOG mog; - cv::Mat foreground; - - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - mog(frame, foreground, learningRate); - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - startTimer(); next(); - mog(frame, foreground, learningRate); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, MOG, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3)/*, Channels(4)*/), - testing::Values(LearningRate(0.0), LearningRate(0.01)))); - -////////////////////////////////////////////////////// -// MOG2 - -GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - - cv::BackgroundSubtractorMOG2 mog2; - cv::Mat foreground; - - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - mog2(frame, foreground); - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - startTimer(); next(); - mog2(frame, foreground); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, MOG2_update, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3)/*, Channels(4)*/))); - -GPU_PERF_TEST(MOG2_getBackgroundImage, cv::gpu::DeviceInfo, std::string, Channels) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - - cv::BackgroundSubtractorMOG2 mog2; - cv::Mat foreground; - - for (int i = 0; i < 10; ++i) - { - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - mog2(frame, foreground); - } - - cv::Mat background; - mog2.getBackgroundImage(background); - - TEST_CYCLE() - { - mog2.getBackgroundImage(background); - } -} - -INSTANTIATE_TEST_CASE_P(Video, MOG2_getBackgroundImage, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(/*Channels(1),*/ Channels(3)/*, Channels(4)*/))); - -////////////////////////////////////////////////////// -// GMG - -IMPLEMENT_PARAM_CLASS(MaxFeatures, int) - -GPU_PERF_TEST(GMG, cv::gpu::DeviceInfo, std::string, Channels, MaxFeatures) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - int cn = GET_PARAM(2); - int maxFeatures = GET_PARAM(3); - - cv::VideoCapture cap(inputFile); - ASSERT_TRUE(cap.isOpened()); - - cv::Mat frame; - cap >> frame; - ASSERT_FALSE(frame.empty()); - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - cv::Mat fgmask; - cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0)); - - cv::BackgroundSubtractorGMG gmg; - gmg.set("maxFeatures", maxFeatures); - gmg.initialize(frame.size(), 0.0, 255.0); - - gmg(frame, fgmask); - - for (int i = 0; i < 150; ++i) - { - cap >> frame; - if (frame.empty()) - { - cap.open(inputFile); - cap >> frame; - } - - if (cn != 3) - { - cv::Mat temp; - if (cn == 1) - cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY); - else - cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA); - cv::swap(temp, frame); - } - - startTimer(); next(); - gmg(frame, fgmask); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, GMG, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")), - testing::Values(Channels(1), Channels(3), Channels(4)), - testing::Values(MaxFeatures(20), MaxFeatures(40), MaxFeatures(60)))); - -////////////////////////////////////////////////////// -// VideoWriter - -#ifdef WIN32 - -GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string) -{ - const double FPS = 25.0; - - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - std::string outputFile = cv::tempfile(".avi"); - - cv::VideoCapture reader(inputFile); - ASSERT_TRUE( reader.isOpened() ); - - cv::VideoWriter writer; - - cv::Mat frame; - - declare.time(30); - - for (int i = 0; i < 10; ++i) - { - reader >> frame; - ASSERT_FALSE(frame.empty()); - - if (!writer.isOpened()) - writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size()); - - startTimer(); next(); - writer.write(frame); - stopTimer(); - } -} - -INSTANTIATE_TEST_CASE_P(Video, VideoWriter, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -#endif // WIN32 - -////////////////////////////////////////////////////// -// VideoReader - -GPU_PERF_TEST(VideoReader, cv::gpu::DeviceInfo, std::string) -{ - std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1)); - - cv::VideoCapture reader(inputFile); - ASSERT_TRUE( reader.isOpened() ); - - cv::Mat frame; - - reader >> frame; - - declare.time(20); - - TEST_CYCLE_N(10) - { - reader >> frame; - } -} - -INSTANTIATE_TEST_CASE_P(Video, VideoReader, testing::Combine( - ALL_DEVICES, - testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")))); - -#endif