refactored gpu perf tests and fixed sanity tests
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 26 Feb 2013 09:49:35 +0000 (13:49 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 26 Feb 2013 09:53:38 +0000 (13:53 +0400)
18 files changed:
modules/gpu/perf/perf_calib3d.cpp
modules/gpu/perf/perf_core.cpp
modules/gpu/perf/perf_denoising.cpp
modules/gpu/perf/perf_features2d.cpp
modules/gpu/perf/perf_filters.cpp
modules/gpu/perf/perf_imgproc.cpp
modules/gpu/perf/perf_labeling.cpp
modules/gpu/perf/perf_main.cpp
modules/gpu/perf/perf_matop.cpp
modules/gpu/perf/perf_objdetect.cpp
modules/gpu/perf/perf_video.cpp
modules/gpu/perf/utility.cpp
modules/gpu/perf/utility.hpp
modules/gpu/src/graphcuts.cpp
modules/gpu/src/imgproc.cpp
modules/gpu/src/mssegmentation.cpp
modules/gpu/src/pyrlk.cpp
modules/gpu/src/warp.cpp

index 906024f640370cef7bb364e6ded8082c48696ac6..b174d9a12ead64622eafa270af3fc6760c871b48 100644 (file)
@@ -3,15 +3,14 @@
 using namespace std;
 using namespace testing;
 
-namespace {
-
 //////////////////////////////////////////////////////////////////////
 // StereoBM
 
 typedef std::tr1::tuple<string, string> pair_string;
 DEF_PARAM_TEST_1(ImagePair, pair_string);
 
-PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png", "gpu/perf/aloeR.png")))
+PERF_TEST_P(ImagePair, Calib3D_StereoBM,
+            Values(pair_string("gpu/perf/aloe.png", "gpu/perf/aloeR.png")))
 {
     declare.time(5.0);
 
@@ -28,18 +27,13 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
     {
         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);
+        const cv::gpu::GpuMat d_imgLeft(imgLeft);
+        const cv::gpu::GpuMat d_imgRight(imgRight);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            d_bm(d_imgLeft, d_imgRight, d_dst);
-        }
+        TEST_CYCLE() d_bm(d_imgLeft, d_imgRight, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -47,12 +41,7 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
 
         cv::Mat dst;
 
-        bm(imgLeft, imgRight, dst);
-
-        TEST_CYCLE()
-        {
-            bm(imgLeft, imgRight, dst);
-        }
+        TEST_CYCLE() bm(imgLeft, imgRight, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -61,7 +50,8 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
 //////////////////////////////////////////////////////////////////////
 // StereoBeliefPropagation
 
-PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
+PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation,
+            Values(pair_string("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
 {
     declare.time(10.0);
 
@@ -77,29 +67,25 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/
     {
         cv::gpu::StereoBeliefPropagation d_bp(ndisp);
 
-        cv::gpu::GpuMat d_imgLeft(imgLeft);
-        cv::gpu::GpuMat d_imgRight(imgRight);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_imgLeft(imgLeft);
+        const cv::gpu::GpuMat d_imgRight(imgRight);
+        cv::gpu::GpuMat dst;
 
-        d_bp(d_imgLeft, d_imgRight, d_dst);
+        TEST_CYCLE() d_bp(d_imgLeft, d_imgRight, dst);
 
-        TEST_CYCLE()
-        {
-            d_bp(d_imgLeft, d_imgRight, d_dst);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy.";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // StereoConstantSpaceBP
 
-PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png")))
+PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP,
+            Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png")))
 {
     declare.time(10.0);
 
@@ -115,29 +101,25 @@ PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/st
     {
         cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
 
-        cv::gpu::GpuMat d_imgLeft(imgLeft);
-        cv::gpu::GpuMat d_imgRight(imgRight);
-        cv::gpu::GpuMat d_dst;
-
-        d_csbp(d_imgLeft, d_imgRight, d_dst);
+        const cv::gpu::GpuMat d_imgLeft(imgLeft);
+        const cv::gpu::GpuMat d_imgRight(imgRight);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            d_csbp(d_imgLeft, d_imgRight, d_dst);
-        }
+        TEST_CYCLE() d_csbp(d_imgLeft, d_imgRight, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy.";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // DisparityBilateralFilter
 
-PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png")))
+PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter,
+            Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png")))
 {
     const cv::Mat img = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
@@ -151,22 +133,17 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
     {
         cv::gpu::DisparityBilateralFilter d_filter(ndisp);
 
-        cv::gpu::GpuMat d_img(img);
-        cv::gpu::GpuMat d_disp(disp);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_img(img);
+        const cv::gpu::GpuMat d_disp(disp);
+        cv::gpu::GpuMat dst;
 
-        d_filter(d_disp, d_img, d_dst);
+        TEST_CYCLE() d_filter(d_disp, d_img, dst);
 
-        TEST_CYCLE()
-        {
-            d_filter(d_disp, d_img, d_dst);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy.";
+        FAIL_NO_CPU();
     }
 }
 
@@ -175,45 +152,42 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
 
 DEF_PARAM_TEST_1(Count, int);
 
-PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
+PERF_TEST_P(Count, Calib3D_TransformPoints,
+            Values(5000, 10000, 20000))
 {
     const int count = GetParam();
 
     cv::Mat src(1, count, CV_32FC3);
-    fillRandom(src, -100, 100);
+    declare.in(src, WARMUP_RNG);
 
     const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
     const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
-        }
+        TEST_CYCLE() cv::gpu::transformPoints(d_src, rvec, tvec, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy.";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // ProjectPoints
 
-PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
+PERF_TEST_P(Count, Calib3D_ProjectPoints,
+            Values(5000, 10000, 20000))
 {
     const int count = GetParam();
 
     cv::Mat src(1, count, CV_32FC3);
-    fillRandom(src, -100, 100);
+    declare.in(src, WARMUP_RNG);
 
     const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
     const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
@@ -221,28 +195,18 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
+        TEST_CYCLE() cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), dst);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
-
-        TEST_CYCLE()
-        {
-            cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
-        }
+        TEST_CYCLE() cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -251,17 +215,18 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
 //////////////////////////////////////////////////////////////////////
 // SolvePnPRansac
 
-PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
+PERF_TEST_P(Count, Calib3D_SolvePnPRansac,
+            Values(5000, 10000, 20000))
 {
     declare.time(10.0);
 
     const int count = GetParam();
 
     cv::Mat object(1, count, CV_32FC3);
-    fillRandom(object, -100, 100);
+    declare.in(object, WARMUP_RNG);
 
     cv::Mat camera_mat(3, 3, CV_32FC1);
-    fillRandom(camera_mat, 0.5, 1);
+    cv::randu(camera_mat, 0.5, 1);
     camera_mat.at<float>(0, 1) = 0.f;
     camera_mat.at<float>(1, 0) = 0.f;
     camera_mat.at<float>(2, 0) = 0.f;
@@ -269,79 +234,66 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
 
     const cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
 
-    std::vector<cv::Point2f> image_vec;
     cv::Mat rvec_gold(1, 3, CV_32FC1);
-    fillRandom(rvec_gold, 0, 1);
+    cv::randu(rvec_gold, 0, 1);
+
     cv::Mat tvec_gold(1, 3, CV_32FC1);
-    fillRandom(tvec_gold, 0, 1);
+    cv::randu(tvec_gold, 0, 1);
+
+    std::vector<cv::Point2f> image_vec;
     cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec);
 
-    cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
+    const cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
 
     cv::Mat rvec;
     cv::Mat tvec;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
+        TEST_CYCLE() cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
-        }
+        GPU_SANITY_CHECK(rvec, 1e-3);
+        GPU_SANITY_CHECK(tvec, 1e-3);
     }
     else
     {
-        cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
+        TEST_CYCLE() cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
 
-        TEST_CYCLE()
-        {
-            cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
-        }
+        CPU_SANITY_CHECK(rvec, 1e-6);
+        CPU_SANITY_CHECK(tvec, 1e-6);
     }
-
-    CPU_SANITY_CHECK(rvec);
-    CPU_SANITY_CHECK(tvec);
 }
 
 //////////////////////////////////////////////////////////////////////
 // ReprojectImageTo3D
 
-PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
+PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16S)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src, 5.0, 30.0);
+    declare.in(src, WARMUP_RNG);
 
     cv::Mat Q(4, 4, CV_32FC1);
-    fillRandom(Q, 0.1, 1.0);
+    cv::randu(Q, 0.1, 1.0);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
+        TEST_CYCLE() cv::gpu::reprojectImageTo3D(d_src, dst, Q);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::reprojectImageTo3D(src, dst, Q);
-
-        TEST_CYCLE()
-        {
-            cv::reprojectImageTo3D(src, dst, Q);
-        }
+        TEST_CYCLE() cv::reprojectImageTo3D(src, dst, Q);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -350,32 +302,27 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES,
 //////////////////////////////////////////////////////////////////////
 // DrawColorDisp
 
-PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
+PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16S)))
 {
     const cv::Size size = GET_PARAM(0);
     const int type = GET_PARAM(1);
 
     cv::Mat src(size, type);
-    fillRandom(src, 0, 255);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::drawColorDisp(d_src, d_dst, 255);
+        TEST_CYCLE() cv::gpu::drawColorDisp(d_src, dst, 255);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::drawColorDisp(d_src, d_dst, 255);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy.";
+        FAIL_NO_CPU();
     }
 }
-
-} // namespace
index b97c4999cd67d11c83f5be0f807b1d8ca2dcd547..d0529e80a4014e811b5adf0b595fd719848a927e 100644 (file)
@@ -2,15 +2,17 @@
 
 using namespace std;
 using namespace testing;
-
-namespace {
+using namespace perf;
 
 #define ARITHM_MAT_DEPTH Values(CV_8U, CV_16U, CV_32F, CV_64F)
 
 //////////////////////////////////////////////////////////////////////
 // Merge
 
-PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4)))
+PERF_TEST_P(Sz_Depth_Cn, Core_Merge,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH,
+                    Values(2, 3, 4)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
@@ -18,7 +20,10 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D
 
     std::vector<cv::Mat> src(channels);
     for (int i = 0; i < channels; ++i)
-        src[i] = cv::Mat(size, depth, cv::Scalar::all(i));
+    {
+        src[i].create(size, depth);
+        declare.in(src[i], WARMUP_RNG);
+    }
 
     if (PERF_RUN_GPU())
     {
@@ -26,11 +31,11 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D
         for (int i = 0; i < channels; ++i)
             d_src[i].upload(src[i]);
 
-        cv::gpu::GpuMat d_dst;
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::merge(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::merge(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-12);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -38,31 +43,37 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D
 
         TEST_CYCLE() cv::merge(src, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-12);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Split
 
-PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4)))
+PERF_TEST_P(Sz_Depth_Cn, Core_Split,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH,
+                    Values(2, 3, 4)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
     const int channels = GET_PARAM(2);
 
-    cv::Mat src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4));
+    cv::Mat src(size, CV_MAKE_TYPE(depth, channels));
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
+        std::vector<cv::gpu::GpuMat> dst;
 
-        std::vector<cv::gpu::GpuMat> d_dst;
+        TEST_CYCLE() cv::gpu::split(d_src, dst);
 
-        TEST_CYCLE() cv::gpu::split(d_src, d_dst);
+        const cv::gpu::GpuMat& dst0 = dst[0];
+        const cv::gpu::GpuMat& dst1 = dst[1];
 
-        cv::gpu::GpuMat first = d_dst[0];
-        GPU_SANITY_CHECK(first, 1e-12);
+        GPU_SANITY_CHECK(dst0);
+        GPU_SANITY_CHECK(dst1);
     }
     else
     {
@@ -70,33 +81,39 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_D
 
         TEST_CYCLE() cv::split(src, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-12);
+        const cv::Mat& dst0 = dst[0];
+        const cv::Mat& dst1 = dst[1];
+
+        CPU_SANITY_CHECK(dst0);
+        CPU_SANITY_CHECK(dst1);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // AddMat
 
-PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_AddMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::add(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::add(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -104,31 +121,34 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEP
 
         TEST_CYCLE() cv::add(src1, src2, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // AddScalar
 
-PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_AddScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s(1, 2, 3, 4);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::add(d_src, s, d_dst);
+        TEST_CYCLE() cv::gpu::add(d_src, s, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -136,33 +156,35 @@ PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_
 
         TEST_CYCLE() cv::add(src, s, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // SubtractMat
 
-PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_SubtractMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::subtract(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::subtract(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -170,31 +192,34 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA
 
         TEST_CYCLE() cv::subtract(src1, src2, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // SubtractScalar
 
-PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_SubtractScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s(1, 2, 3, 4);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::subtract(d_src, s, d_dst);
+        TEST_CYCLE() cv::gpu::subtract(d_src, s, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -202,33 +227,35 @@ PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM
 
         TEST_CYCLE() cv::subtract(src, s, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MultiplyMat
 
-PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_MultiplyMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::multiply(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::multiply(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -236,33 +263,34 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MA
 
         TEST_CYCLE() cv::multiply(src1, src2, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MultiplyScalar
 
-PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_MultiplyScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s(1, 2, 3, 4);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::multiply(d_src, s, d_dst);
+        TEST_CYCLE() cv::gpu::multiply(d_src, s, dst);
 
-        TEST_CYCLE() cv::gpu::multiply(d_src, s, d_dst);
-
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -270,33 +298,35 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM
 
         TEST_CYCLE() cv::multiply(src, s, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // DivideMat
 
-PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_DivideMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::divide(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::divide(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -304,31 +334,34 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_
 
         TEST_CYCLE() cv::divide(src1, src2, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // DivideScalar
 
-PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_DivideScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s(1, 2, 3, 4);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::divide(d_src, s, d_dst);
+        TEST_CYCLE() cv::gpu::divide(d_src, s, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -336,31 +369,34 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_M
 
         TEST_CYCLE() cv::divide(src, s, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // DivideScalarInv
 
-PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_DivideScalarInv,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    double s = 100.0;
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::divide(s, d_src, d_dst);
+        TEST_CYCLE() cv::gpu::divide(s[0], d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -368,33 +404,35 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITH
 
         TEST_CYCLE() cv::divide(s, src, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // AbsDiffMat
 
-PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_AbsDiffMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::absdiff(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::absdiff(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -402,31 +440,34 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT
 
         TEST_CYCLE() cv::absdiff(src1, src2, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // AbsDiffScalar
 
-PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
+PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s(1, 2, 3, 4);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::absdiff(d_src, s, d_dst);
+        TEST_CYCLE() cv::gpu::absdiff(d_src, s, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -434,75 +475,87 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_
 
         TEST_CYCLE() cv::absdiff(src, s, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Abs
 
-PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_Abs,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_16S, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::abs(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::abs(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
+    }
+    else
+    {
+        FAIL_NO_CPU();
     }
-    else FAIL_NO_CPU();
 }
 
 //////////////////////////////////////////////////////////////////////
 // Sqr
 
-PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_Sqr,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16S, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::sqr(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::sqr(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
+    }
+    else
+    {
+        FAIL_NO_CPU();
     }
-    else FAIL_NO_CPU();
 }
 
 //////////////////////////////////////////////////////////////////////
 // Sqrt
 
-PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_Sqrt,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16S, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    cv::randu(src, 0, 100000);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::sqrt(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::sqrt(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -510,29 +563,31 @@ PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV
 
         TEST_CYCLE() cv::sqrt(src, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Log
 
-PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_Log,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16S, CV_32F)))
 {
     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::randu(src, 0, 100000);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::log(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::log(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -540,37 +595,39 @@ PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_
 
         TEST_CYCLE() cv::log(src, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Exp
 
-PERF_TEST_P(Sz_Depth, Core_Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_Exp,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16S, CV_32F)))
 {
     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::randu(src, 0, 10);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::exp(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::exp(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() TEST_CYCLE() cv::exp(src, dst);
+        TEST_CYCLE() cv::exp(src, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -579,31 +636,34 @@ PERF_TEST_P(Sz_Depth, Core_Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_
 
 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)))
+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)))
 {
     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);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::pow(d_src, power, d_dst);
+        TEST_CYCLE() cv::gpu::pow(d_src, power, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::pow(src, power,dst);
+        TEST_CYCLE() cv::pow(src, power, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -615,27 +675,30 @@ CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv:
 
 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))
+PERF_TEST_P(Sz_Depth_Code, Core_CompareMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH,
+                    ALL_CMP_CODES))
 {
     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);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code);
+        TEST_CYCLE() cv::gpu::compare(d_src1, d_src2, dst, cmp_code);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -650,25 +713,29 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITH
 //////////////////////////////////////////////////////////////////////
 // CompareScalar
 
-PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES))
+PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    ARITHM_MAT_DEPTH,
+                    ALL_CMP_CODES))
 {
     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);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s = cv::Scalar::all(100);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::compare(d_src, s, d_dst, cmp_code);
+        TEST_CYCLE() cv::gpu::compare(d_src, s, dst, cmp_code);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -683,28 +750,30 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, AR
 //////////////////////////////////////////////////////////////////////
 // BitwiseNot
 
-PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
+PERF_TEST_P(Sz_Depth, Core_BitwiseNot,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_not(d_src,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_not(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_not(src,dst);
+        TEST_CYCLE() cv::bitwise_not(src, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -713,39 +782,46 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_
 //////////////////////////////////////////////////////////////////////
 // BitwiseAndMat
 
-PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
+PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_and(d_src1, d_src2,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_and(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_and(src1, src2,dst);
+        TEST_CYCLE() cv::bitwise_and(src1, src2, dst);
+
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BitwiseAndScalar
 
-PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S),
+                    GPU_CHANNELS_1_3_4))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
@@ -754,24 +830,26 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, V
     const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s = cv::Scalar::all(100);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
+    cv::Scalar_<int> is = s;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_and(d_src, s,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_and(d_src, is, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_and(src, s,dst);
+        TEST_CYCLE() cv::bitwise_and(src, is, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -780,32 +858,34 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, V
 //////////////////////////////////////////////////////////////////////
 // BitwiseOrMat
 
-PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
+PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_or(d_src1, d_src2,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_or(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_or(src1, src2,dst);
+        TEST_CYCLE() cv::bitwise_or(src1, src2, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -814,7 +894,10 @@ PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(C
 //////////////////////////////////////////////////////////////////////
 // BitwiseOrScalar
 
-PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S),
+                    GPU_CHANNELS_1_3_4))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
@@ -823,24 +906,26 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Va
     const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s = cv::Scalar::all(100);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
+    cv::Scalar_<int> is = s;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_or(d_src, s,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_or(d_src, is, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_or(src, s,dst);
+        TEST_CYCLE() cv::bitwise_or(src, is, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -849,39 +934,46 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Va
 //////////////////////////////////////////////////////////////////////
 // BitwiseXorMat
 
-PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
+PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_xor(d_src1, d_src2,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_xor(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_xor(src1, src2,dst);
+        TEST_CYCLE() cv::bitwise_xor(src1, src2, dst);
+
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BitwiseXorScalar
 
-PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S),
+                    GPU_CHANNELS_1_3_4))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
@@ -890,24 +982,26 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, V
     const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar s = cv::Scalar::all(100);
+    cv::Scalar s;
+    declare.in(s, WARMUP_RNG);
+    cv::Scalar_<int> is = s;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::bitwise_xor(d_src, s,d_dst);
+        TEST_CYCLE() cv::gpu::bitwise_xor(d_src, is, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::bitwise_xor(src, s,dst);
+        TEST_CYCLE() cv::bitwise_xor(src, is, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -916,7 +1010,10 @@ PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, V
 //////////////////////////////////////////////////////////////////////
 // RShift
 
-PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_RShift,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S),
+                    GPU_CHANNELS_1_3_4))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
@@ -925,18 +1022,18 @@ PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
     const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     const cv::Scalar_<int> val = cv::Scalar_<int>::all(4);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::rshift(d_src, val,d_dst);
+        TEST_CYCLE() cv::gpu::rshift(d_src, val, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -947,7 +1044,10 @@ PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
 //////////////////////////////////////////////////////////////////////
 // LShift
 
-PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_LShift,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S),
+                    GPU_CHANNELS_1_3_4))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
@@ -956,18 +1056,18 @@ PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
     const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     const cv::Scalar_<int> val = cv::Scalar_<int>::all(4);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::lshift(d_src, val,d_dst);
+        TEST_CYCLE() cv::gpu::lshift(d_src, val, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -978,32 +1078,34 @@ PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
 //////////////////////////////////////////////////////////////////////
 // MinMat
 
-PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_MinMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::min(d_src1, d_src2,d_dst);
+        TEST_CYCLE() cv::gpu::min(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::min(src1, src2,dst);
+        TEST_CYCLE() cv::min(src1, src2, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1012,30 +1114,33 @@ PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U,
 //////////////////////////////////////////////////////////////////////
 // MinScalar
 
-PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_MinScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    const double val = 50.0;
+    cv::Scalar val;
+    declare.in(val, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::min(d_src, val,d_dst);
+        TEST_CYCLE() cv::gpu::min(d_src, val[0], dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::min(src, val,dst);
+        TEST_CYCLE() cv::min(src, val[0], dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1044,32 +1149,34 @@ PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
 //////////////////////////////////////////////////////////////////////
 // MaxMat
 
-PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_MaxMat,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src1(size, depth);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::max(d_src1, d_src2,d_dst);
+        TEST_CYCLE() cv::gpu::max(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::max(src1, src2,dst);
+        TEST_CYCLE() cv::max(src1, src2, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1078,30 +1185,33 @@ PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U,
 //////////////////////////////////////////////////////////////////////
 // MaxScalar
 
-PERF_TEST_P(Sz_Depth, Core_MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
+PERF_TEST_P(Sz_Depth, Core_MaxScalar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth = GET_PARAM(1);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    const double val = 50.0;
+    cv::Scalar val;
+    declare.in(val, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::max(d_src, val,d_dst);
+        TEST_CYCLE() cv::gpu::max(d_src, val[0], dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::max(src, val,dst);
+        TEST_CYCLE() cv::max(src, val[0], dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1112,11 +1222,11 @@ PERF_TEST_P(Sz_Depth, Core_MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
 
 DEF_PARAM_TEST(Sz_3Depth, cv::Size, MatDepth, MatDepth, MatDepth);
 
-PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F, CV_64F),
-    Values(CV_8U, CV_16U, CV_32F, CV_64F),
-    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
+PERF_TEST_P(Sz_3Depth, Core_AddWeighted,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
 {
     const cv::Size size = GET_PARAM(0);
     const int depth1 = GET_PARAM(1);
@@ -1124,20 +1234,20 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine(
     const int dst_depth = GET_PARAM(3);
 
     cv::Mat src1(size, depth1);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, depth2);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth);
+        TEST_CYCLE() cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, dst, dst_depth);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1157,76 +1267,76 @@ CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T)
 
 DEF_PARAM_TEST(Sz_Type_Flags, cv::Size, MatType, GemmFlags);
 
-PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine(
-    Values(cv::Size(512, 512), cv::Size(1024, 1024)),
-    Values(CV_32FC1, CV_32FC2, CV_64FC1, CV_64FC2),
-    ALL_GEMM_FLAGS))
+PERF_TEST_P(Sz_Type_Flags, Core_GEMM,
+            Combine(Values(cv::Size(512, 512), cv::Size(1024, 1024)),
+                    Values(CV_32FC1, CV_32FC2, CV_64FC1),
+                    ALL_GEMM_FLAGS))
 {
-    declare.time(5.0);
-
     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);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, type);
-    fillRandom(src2);
+    declare.in(src2, WARMUP_RNG);
 
     cv::Mat src3(size, type);
-    fillRandom(src3);
+    declare.in(src3, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_src3(src3);
-        cv::gpu::GpuMat d_dst;
+        declare.time(5.0);
+
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        const cv::gpu::GpuMat d_src3(src3);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags);
+        TEST_CYCLE() cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, dst, flags);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        cv::Mat dst;
-
         declare.time(50.0);
 
+        cv::Mat dst;
+
         TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst, flags);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Transpose
 
-PERF_TEST_P(Sz_Type, Core_Transpose, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1)))
+PERF_TEST_P(Sz_Type, Core_Transpose,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1)))
 {
-    cv::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);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::transpose(d_src,d_dst);
+        TEST_CYCLE() cv::gpu::transpose(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        TEST_CYCLE() cv::transpose(src,dst);
+        TEST_CYCLE() cv::transpose(src, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1241,30 +1351,30 @@ CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Code, cv::Size, MatDepth, MatCn, FlipCode);
 
-PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    ALL_FLIP_CODES))
+PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    ALL_FLIP_CODES))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int flipCode = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int flipCode = GET_PARAM(3);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::flip(d_src, d_dst, flipCode);
+        TEST_CYCLE() cv::gpu::flip(d_src, dst, flipCode);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1279,27 +1389,27 @@ PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, Combine(
 //////////////////////////////////////////////////////////////////////
 // LutOneChannel
 
-PERF_TEST_P(Sz_Type, Core_LutOneChannel, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8UC1, CV_8UC3)))
+PERF_TEST_P(Sz_Type, Core_LutOneChannel,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8UC1, CV_8UC3)))
 {
-    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);
+    declare.in(src, WARMUP_RNG);
 
     cv::Mat lut(1, 256, CV_8UC1);
-    fillRandom(lut);
+    declare.in(lut, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::LUT(d_src, lut,d_dst);
+        TEST_CYCLE() cv::gpu::LUT(d_src, lut, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1314,27 +1424,27 @@ PERF_TEST_P(Sz_Type, Core_LutOneChannel, Combine(
 //////////////////////////////////////////////////////////////////////
 // LutMultiChannel
 
-PERF_TEST_P(Sz_Type, Core_LutMultiChannel, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values<MatType>(CV_8UC3)))
+PERF_TEST_P(Sz_Type, Core_LutMultiChannel,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values<MatType>(CV_8UC3)))
 {
-    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);
+    declare.in(src, WARMUP_RNG);
 
     cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels()));
-    fillRandom(lut);
+    declare.in(lut, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::LUT(d_src, lut,d_dst);
+        TEST_CYCLE() cv::gpu::LUT(d_src, lut, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1349,21 +1459,22 @@ PERF_TEST_P(Sz_Type, Core_LutMultiChannel, Combine(
 //////////////////////////////////////////////////////////////////////
 // MagnitudeComplex
 
-PERF_TEST_P(Sz, Core_MagnitudeComplex, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, Core_MagnitudeComplex,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_32FC2);
-    fillRandom(src, -100.0, 100.0);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::magnitude(d_src,d_dst);
+        TEST_CYCLE() cv::gpu::magnitude(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1374,28 +1485,29 @@ PERF_TEST_P(Sz, Core_MagnitudeComplex, GPU_TYPICAL_MAT_SIZES)
 
         TEST_CYCLE() cv::magnitude(xy[0], xy[1], dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MagnitudeSqrComplex
 
-PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, Core_MagnitudeSqrComplex,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_32FC2);
-    fillRandom(src, -100.0, 100.0);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::magnitudeSqr(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::magnitudeSqr(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1406,25 +1518,26 @@ PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES)
 //////////////////////////////////////////////////////////////////////
 // Magnitude
 
-PERF_TEST_P(Sz, Core_Magnitude, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, Core_Magnitude,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src1(size, CV_32FC1);
-    fillRandom(src1, -100.0, 100.0);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, CV_32FC1);
-    fillRandom(src2, -100.0, 100.0);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::magnitude(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::magnitude(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1432,33 +1545,33 @@ PERF_TEST_P(Sz, Core_Magnitude, GPU_TYPICAL_MAT_SIZES)
 
         TEST_CYCLE() cv::magnitude(src1, src2, dst);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
-
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MagnitudeSqr
 
-PERF_TEST_P(Sz, Core_MagnitudeSqr, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, Core_MagnitudeSqr,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src1(size, CV_32FC1);
-    fillRandom(src1, -100.0, 100.0);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, CV_32FC1);
-    fillRandom(src2, -100.0, 100.0);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst);
+        TEST_CYCLE() cv::gpu::magnitudeSqr(d_src1, d_src2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1471,26 +1584,28 @@ PERF_TEST_P(Sz, Core_MagnitudeSqr, GPU_TYPICAL_MAT_SIZES)
 
 DEF_PARAM_TEST(Sz_AngleInDegrees, cv::Size, bool);
 
-PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))
+PERF_TEST_P(Sz_AngleInDegrees, Core_Phase,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Bool()))
 {
-    cv::Size size = GET_PARAM(0);
-    bool angleInDegrees = GET_PARAM(1);
+    const cv::Size size = GET_PARAM(0);
+    const bool angleInDegrees = GET_PARAM(1);
 
     cv::Mat src1(size, CV_32FC1);
-    fillRandom(src1, -100.0, 100.0);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, CV_32FC1);
-    fillRandom(src2, -100.0, 100.0);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees);
+        TEST_CYCLE() cv::gpu::phase(d_src1, d_src2, dst, angleInDegrees);
 
-        GPU_SANITY_CHECK(d_dst, 1e-8);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1498,36 +1613,37 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool()
 
         TEST_CYCLE() cv::phase(src1, src2, dst, angleInDegrees);
 
-        CPU_SANITY_CHECK(dst, 1e-8);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // CartToPolar
 
-PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))
+PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Bool()))
 {
-    cv::Size size = GET_PARAM(0);
-    bool angleInDegrees = GET_PARAM(1);
+    const cv::Size size = GET_PARAM(0);
+    const bool angleInDegrees = GET_PARAM(1);
 
     cv::Mat src1(size, CV_32FC1);
-    fillRandom(src1, -100.0, 100.0);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, CV_32FC1);
-    fillRandom(src2, -100.0, 100.0);
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
-        cv::gpu::GpuMat d_magnitude;
-        cv::gpu::GpuMat d_angle;
-
-        TEST_CYCLE() cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees);
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat magnitude;
+        cv::gpu::GpuMat angle;
 
-        GPU_SANITY_CHECK(d_magnitude, 1e-8);
-        GPU_SANITY_CHECK(d_angle, 1e-8);
+        TEST_CYCLE() cv::gpu::cartToPolar(d_src1, d_src2, magnitude, angle, angleInDegrees);
 
+        GPU_SANITY_CHECK(magnitude);
+        GPU_SANITY_CHECK(angle);
     }
     else
     {
@@ -1536,36 +1652,38 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES,
 
         TEST_CYCLE() cv::cartToPolar(src1, src2, magnitude, angle, angleInDegrees);
 
-        CPU_SANITY_CHECK(magnitude, 1e-8);
-        CPU_SANITY_CHECK(angle, 1e-8);
+        CPU_SANITY_CHECK(magnitude);
+        CPU_SANITY_CHECK(angle);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // PolarToCart
 
-PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))
+PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Bool()))
 {
-    cv::Size size = GET_PARAM(0);
-    bool angleInDegrees = GET_PARAM(1);
+    const cv::Size size = GET_PARAM(0);
+    const bool angleInDegrees = GET_PARAM(1);
 
     cv::Mat magnitude(size, CV_32FC1);
-    fillRandom(magnitude, 0.0, 100.0);
+    declare.in(magnitude, WARMUP_RNG);
 
     cv::Mat angle(size, CV_32FC1);
-    fillRandom(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI);
+    declare.in(angle, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_magnitude(magnitude);
-        cv::gpu::GpuMat d_angle(angle);
-        cv::gpu::GpuMat d_x;
-        cv::gpu::GpuMat d_y;
+        const cv::gpu::GpuMat d_magnitude(magnitude);
+        const cv::gpu::GpuMat d_angle(angle);
+        cv::gpu::GpuMat x;
+        cv::gpu::GpuMat y;
 
-        TEST_CYCLE() cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees);
+        TEST_CYCLE() cv::gpu::polarToCart(d_magnitude, d_angle, x, y, angleInDegrees);
 
-        GPU_SANITY_CHECK(d_x, 1e-8);
-        GPU_SANITY_CHECK(d_y, 1e-8);
+        GPU_SANITY_CHECK(x);
+        GPU_SANITY_CHECK(y);
     }
     else
     {
@@ -1574,37 +1692,45 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES,
 
         TEST_CYCLE() cv::polarToCart(magnitude, angle, x, y, angleInDegrees);
 
-        CPU_SANITY_CHECK(x, 1e-8);
-        CPU_SANITY_CHECK(y, 1e-8);
+        CPU_SANITY_CHECK(x);
+        CPU_SANITY_CHECK(y);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MeanStdDev
 
-PERF_TEST_P(Sz, Core_MeanStdDev, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, Core_MeanStdDev,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_8UC1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Scalar mean;
-    cv::Scalar stddev;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        cv::Scalar gpu_mean;
+        cv::Scalar gpu_stddev;
+
+        TEST_CYCLE() cv::gpu::meanStdDev(d_src, gpu_mean, gpu_stddev, d_buf);
 
-        TEST_CYCLE() cv::gpu::meanStdDev(d_src, mean, stddev, d_buf);
+        SANITY_CHECK(gpu_mean);
+        SANITY_CHECK(gpu_stddev);
     }
     else
     {
-        TEST_CYCLE() cv::meanStdDev(src, mean, stddev);
-    }
+        cv::Scalar cpu_mean;
+        cv::Scalar cpu_stddev;
+
+        TEST_CYCLE() cv::meanStdDev(src, cpu_mean, cpu_stddev);
 
-    GPU_SANITY_CHECK(stddev, 1e-6);
+        SANITY_CHECK(cpu_mean);
+        SANITY_CHECK(cpu_stddev);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -1612,33 +1738,36 @@ PERF_TEST_P(Sz, Core_MeanStdDev, GPU_TYPICAL_MAT_SIZES)
 
 DEF_PARAM_TEST(Sz_Depth_Norm, cv::Size, MatDepth, NormType);
 
-PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32S, CV_32F),
-    Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
+PERF_TEST_P(Sz_Depth_Norm, Core_Norm,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32S, CV_32F),
+                    Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int normType = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int normType = GET_PARAM(2);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
-
-    double dst;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        double gpu_dst;
+
+        TEST_CYCLE() gpu_dst = cv::gpu::norm(d_src, normType, d_buf);
 
-        TEST_CYCLE() dst = cv::gpu::norm(d_src, normType, cv::gpu::GpuMat(), d_buf);
+        SANITY_CHECK(gpu_dst, 1e-6, ERROR_RELATIVE);
     }
     else
     {
-        TEST_CYCLE() dst = cv::norm(src, normType);
-    }
+        double cpu_dst;
+
+        TEST_CYCLE() cpu_dst = cv::norm(src, normType);
 
-    SANITY_CHECK(dst, 1e-6);
+        SANITY_CHECK(cpu_dst, 1e-6, ERROR_RELATIVE);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -1646,99 +1775,103 @@ PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine(
 
 DEF_PARAM_TEST(Sz_Norm, cv::Size, NormType);
 
-PERF_TEST_P(Sz_Norm, Core_NormDiff, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
+PERF_TEST_P(Sz_Norm, Core_NormDiff,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
 {
-    cv::Size size = GET_PARAM(0);
-    int normType = GET_PARAM(1);
+    const cv::Size size = GET_PARAM(0);
+    const int normType = GET_PARAM(1);
 
     cv::Mat src1(size, CV_8UC1);
-    fillRandom(src1);
+    declare.in(src1, WARMUP_RNG);
 
     cv::Mat src2(size, CV_8UC1);
-    fillRandom(src2);
-
-    double dst;
+    declare.in(src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src1(src1);
-        cv::gpu::GpuMat d_src2(src2);
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        double gpu_dst;
+
+        TEST_CYCLE() gpu_dst = cv::gpu::norm(d_src1, d_src2, normType);
 
-        TEST_CYCLE() dst = cv::gpu::norm(d_src1, d_src2, normType);
+        SANITY_CHECK(gpu_dst);
 
     }
     else
     {
-        TEST_CYCLE() dst = cv::norm(src1, src2, normType);
-    }
+        double cpu_dst;
+
+        TEST_CYCLE() cpu_dst = cv::norm(src1, src2, normType);
 
-    SANITY_CHECK(dst, 1e-6);
+        SANITY_CHECK(cpu_dst);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Sum
 
-PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_Sum,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_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 dst;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        cv::Scalar gpu_dst;
 
-        TEST_CYCLE() dst = cv::gpu::sum(d_src, cv::gpu::GpuMat(), d_buf);
+        TEST_CYCLE() gpu_dst = cv::gpu::sum(d_src, d_buf);
+
+        SANITY_CHECK(gpu_dst, 1e-5, ERROR_RELATIVE);
     }
     else
     {
-        TEST_CYCLE() dst = cv::sum(src);
-    }
+        cv::Scalar cpu_dst;
 
-    double error = (depth == CV_32F) ? 3e+1 : 1e-6;
-    SANITY_CHECK(dst,  error);
+        TEST_CYCLE() cpu_dst = cv::sum(src);
+
+        SANITY_CHECK(cpu_dst, 1e-6, ERROR_RELATIVE);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
 // SumAbs
 
-PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_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 dst;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        cv::Scalar gpu_dst;
 
-        TEST_CYCLE() dst = cv::gpu::absSum(d_src, cv::gpu::GpuMat(), d_buf);
+        TEST_CYCLE() gpu_dst = cv::gpu::absSum(d_src, d_buf);
 
-        SANITY_CHECK(dst, 1e-6);
+        SANITY_CHECK(gpu_dst, 1e-6, ERROR_RELATIVE);
     }
     else
     {
@@ -1749,30 +1882,29 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine(
 //////////////////////////////////////////////////////////////////////
 // SumSqr
 
-PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values<MatDepth>(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values<MatDepth>(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_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 dst;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        cv::Scalar gpu_dst;
 
-        TEST_CYCLE() dst = cv::gpu::sqrSum(d_src, cv::gpu::GpuMat(), d_buf);
+        TEST_CYCLE() gpu_dst = cv::gpu::sqrSum(d_src, d_buf);
 
-        SANITY_CHECK(dst, 1e-6);
+        SANITY_CHECK(gpu_dst, 1e-6, ERROR_RELATIVE);
     }
     else
     {
@@ -1783,98 +1915,106 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine(
 //////////////////////////////////////////////////////////////////////
 // MinMax
 
-PERF_TEST_P(Sz_Depth, Core_MinMax, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
+PERF_TEST_P(Sz_Depth, Core_MinMax,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
 {
-    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 minVal, maxVal;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        double gpu_minVal, gpu_maxVal;
 
-        TEST_CYCLE() cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf);
+        TEST_CYCLE() cv::gpu::minMax(d_src, &gpu_minVal, &gpu_maxVal, cv::gpu::GpuMat(), d_buf);
 
-        SANITY_CHECK(minVal);
-        SANITY_CHECK(maxVal);
+        SANITY_CHECK(gpu_minVal);
+        SANITY_CHECK(gpu_maxVal);
     }
     else
     {
-        FAIL_NO_CPU();
+        double cpu_minVal, cpu_maxVal;
+
+        TEST_CYCLE() cv::minMaxLoc(src, &cpu_minVal, &cpu_maxVal);
+
+        SANITY_CHECK(cpu_minVal);
+        SANITY_CHECK(cpu_maxVal);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MinMaxLoc
 
-PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
+PERF_TEST_P(Sz_Depth, Core_MinMaxLoc,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
 {
-    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 minVal, maxVal;
-    cv::Point minLoc, maxLoc;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_valbuf, d_locbuf;
+        double gpu_minVal, gpu_maxVal;
+        cv::Point gpu_minLoc, gpu_maxLoc;
 
-        TEST_CYCLE() cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf);
+        TEST_CYCLE() cv::gpu::minMaxLoc(d_src, &gpu_minVal, &gpu_maxVal, &gpu_minLoc, &gpu_maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf);
+
+        SANITY_CHECK(gpu_minVal);
+        SANITY_CHECK(gpu_maxVal);
     }
     else
     {
-        TEST_CYCLE() cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);
-    }
+        double cpu_minVal, cpu_maxVal;
+        cv::Point cpu_minLoc, cpu_maxLoc;
 
-    SANITY_CHECK(minVal, 1e-12);
-    SANITY_CHECK(maxVal, 1e-12);
+        TEST_CYCLE() cv::minMaxLoc(src, &cpu_minVal, &cpu_maxVal, &cpu_minLoc, &cpu_maxLoc);
 
-    // unsupported by peft system
-    //SANITY_CHECK(minLoc);
-    //SANITY_CHECK(maxLoc);
+        SANITY_CHECK(cpu_minVal);
+        SANITY_CHECK(cpu_maxVal);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
 // CountNonZero
 
-PERF_TEST_P(Sz_Depth, Core_CountNonZero, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
+PERF_TEST_P(Sz_Depth, Core_CountNonZero,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
 {
-    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);
-
-    int dst = 0;
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_buf;
+        int gpu_dst = 0;
+
+        TEST_CYCLE() gpu_dst = cv::gpu::countNonZero(d_src, d_buf);
 
-        TEST_CYCLE() dst = cv::gpu::countNonZero(d_src, d_buf);
+        SANITY_CHECK(gpu_dst);
     }
     else
     {
-        TEST_CYCLE() dst = cv::countNonZero(src);
-    }
+        int cpu_dst = 0;
+
+        TEST_CYCLE() cpu_dst = cv::countNonZero(src);
 
-    SANITY_CHECK(dst);
+        SANITY_CHECK(cpu_dst);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -1889,32 +2029,32 @@ CV_ENUM(ReduceDim, Rows, Cols)
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Code_Dim, cv::Size, MatDepth, MatCn, ReduceCode, ReduceDim);
 
-PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_16S, CV_32F),
-    Values(1, 2, 3, 4),
-    ALL_REDUCE_CODES,
-    ALL_REDUCE_DIMS))
+PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_16S, CV_32F),
+                    Values(1, 2, 3, 4),
+                    ALL_REDUCE_CODES,
+                    ALL_REDUCE_DIMS))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int reduceOp = GET_PARAM(3);
-    int dim = GET_PARAM(4);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int reduceOp = GET_PARAM(3);
+    const int dim = GET_PARAM(4);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE() cv::gpu::reduce(d_src, d_dst, dim, reduceOp);
+        TEST_CYCLE() cv::gpu::reduce(d_src, dst, dim, reduceOp);
 
-        GPU_SANITY_CHECK(d_dst, 1);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
@@ -1922,43 +2062,41 @@ PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, Combine(
 
         TEST_CYCLE() cv::reduce(src, dst, dim, reduceOp);
 
-        CPU_SANITY_CHECK(dst, 1);
+        CPU_SANITY_CHECK(dst);
     }
 }
-
 //////////////////////////////////////////////////////////////////////
 // Normalize
 
 DEF_PARAM_TEST(Sz_Depth_NormType, cv::Size, MatDepth, NormType);
 
-PERF_TEST_P(Sz_Depth_NormType, Core_Normalize, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F, CV_64F),
-    Values(NormType(cv::NORM_INF),
-           NormType(cv::NORM_L1),
-           NormType(cv::NORM_L2),
-           NormType(cv::NORM_MINMAX))
-    ))
+PERF_TEST_P(Sz_Depth_NormType, Core_Normalize,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    Values(NormType(cv::NORM_INF),
+                           NormType(cv::NORM_L1),
+                           NormType(cv::NORM_L2),
+                           NormType(cv::NORM_MINMAX))))
 {
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int norm_type = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int norm_type = GET_PARAM(2);
 
-    double alpha = 1;
-    double beta = 0;
+    const double alpha = 1;
+    const double beta = 0;
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_norm_buf, d_cvt_buf;
 
-        TEST_CYCLE() cv::gpu::normalize(d_src, d_dst, alpha, beta, norm_type, type, cv::gpu::GpuMat(), d_norm_buf, d_cvt_buf);
+        TEST_CYCLE() cv::gpu::normalize(d_src, dst, alpha, beta, norm_type, type, cv::gpu::GpuMat(), d_norm_buf, d_cvt_buf);
 
-        GPU_SANITY_CHECK(d_dst, 1);
+        GPU_SANITY_CHECK(dst, 1e-6);
     }
     else
     {
@@ -1966,8 +2104,6 @@ PERF_TEST_P(Sz_Depth_NormType, Core_Normalize, Combine(
 
         TEST_CYCLE() cv::normalize(src, dst, alpha, beta, norm_type, type);
 
-        CPU_SANITY_CHECK(dst, 1);
+        CPU_SANITY_CHECK(dst);
     }
 }
-
-} // namespace
index ed63177ddbfca54a05a10ee787e6d8b5b2125b81..6f03994bd98c89be0079297d50df38491157e02d 100644 (file)
@@ -3,8 +3,7 @@
 using namespace std;
 using namespace testing;
 
-#define GPU_DENOISING_IMAGE_SIZES testing::Values(perf::szVGA, perf::szXGA, perf::sz720p, perf::sz1080p)
-
+#define GPU_DENOISING_IMAGE_SIZES testing::Values(perf::szVGA, perf::sz720p)
 
 //////////////////////////////////////////////////////////////////////
 // BilateralFilter
@@ -12,96 +11,86 @@ using namespace testing;
 DEF_PARAM_TEST(Sz_Depth_Cn_KernelSz, cv::Size, MatDepth, MatCn, int);
 
 PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
-            Combine(GPU_DENOISING_IMAGE_SIZES, Values(CV_8U, CV_32F), GPU_CHANNELS_1_3, Values(3, 5, 9)))
+            Combine(GPU_DENOISING_IMAGE_SIZES,
+                    Values(CV_8U, CV_32F),
+                    GPU_CHANNELS_1_3,
+                    Values(3, 5, 9)))
 {
     declare.time(60.0);
 
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int kernel_size = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int kernel_size = GET_PARAM(3);
 
-    float sigma_color = 7;
-    float sigma_spatial = 5;
-    int borderMode = cv::BORDER_REFLECT101;
+    const float sigma_color = 7;
+    const float sigma_spatial = 5;
+    const int borderMode = cv::BORDER_REFLECT101;
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-     if (PERF_RUN_GPU())
+    if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
-        }
+        TEST_CYCLE() cv::gpu::bilateralFilter(d_src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
-
-        TEST_CYCLE()
-        {
-            cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
-        }
+        TEST_CYCLE() cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
 
         CPU_SANITY_CHECK(dst);
     }
 }
 
-
 //////////////////////////////////////////////////////////////////////
 // nonLocalMeans
 
 DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
 
 PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
-            Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), GPU_CHANNELS_1_3, Values(21), Values(5, 7)))
+            Combine(GPU_DENOISING_IMAGE_SIZES,
+                    Values<MatDepth>(CV_8U),
+                    GPU_CHANNELS_1_3,
+                    Values(21),
+                    Values(5)))
 {
     declare.time(60.0);
 
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-
-    int search_widow_size = GET_PARAM(3);
-    int block_size = GET_PARAM(4);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int search_widow_size = GET_PARAM(3);
+    const int block_size = GET_PARAM(4);
 
-    float h = 10;
-    int borderMode = cv::BORDER_REFLECT101;
+    const float h = 10;
+    const int borderMode = cv::BORDER_REFLECT101;
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
+        TEST_CYCLE() cv::gpu::nonLocalMeans(d_src, dst, h, search_widow_size, block_size, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -112,46 +101,41 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
 DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
 
 PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
-            Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), GPU_CHANNELS_1_3, Values(21), Values(7)))
+            Combine(GPU_DENOISING_IMAGE_SIZES,
+                    Values<MatDepth>(CV_8U),
+                    GPU_CHANNELS_1_3,
+                    Values(21),
+                    Values(7)))
 {
-    declare.time(150.0);
-
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
+    declare.time(60.0);
 
-    int search_widow_size = GET_PARAM(2);
-    int block_size = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int search_widow_size = GET_PARAM(2);
+    const int block_size = GET_PARAM(3);
 
-    float h = 10;
-    int type = CV_MAKE_TYPE(depth, 1);
+    const float h = 10;
+    const int type = CV_MAKE_TYPE(depth, 1);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
         cv::gpu::FastNonLocalMeansDenoising fnlmd;
 
-        fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
-        }
+        TEST_CYCLE() fnlmd.simpleMethod(d_src, dst, h, search_widow_size, block_size);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
-        cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
 
-        TEST_CYCLE()
-        {
-            cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
-        }
+        TEST_CYCLE() cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -163,47 +147,41 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
 DEF_PARAM_TEST(Sz_Depth_WinSz_BlockSz, cv::Size, MatDepth, int, int);
 
 PERF_TEST_P(Sz_Depth_WinSz_BlockSz, Denoising_FastNonLocalMeansColored,
-            Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), Values(21), Values(7)))
+            Combine(GPU_DENOISING_IMAGE_SIZES,
+                    Values<MatDepth>(CV_8U),
+                    Values(21),
+                    Values(7)))
 {
-    declare.time(350.0);
-
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
+    declare.time(60.0);
 
-    int search_widow_size = GET_PARAM(2);
-    int block_size = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int search_widow_size = GET_PARAM(2);
+    const int block_size = GET_PARAM(3);
 
-    float h = 10;
-    int type = CV_MAKE_TYPE(depth, 3);
+    const float h = 10;
+    const int type = CV_MAKE_TYPE(depth, 3);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
         cv::gpu::FastNonLocalMeansDenoising fnlmd;
 
-        fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
-        }
+        TEST_CYCLE() fnlmd.labMethod(d_src, dst, h, h, search_widow_size, block_size);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
-        cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
 
-        TEST_CYCLE()
-        {
-            cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
-        }
+        TEST_CYCLE() cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
 
         CPU_SANITY_CHECK(dst);
     }
-}
\ No newline at end of file
+}
index a93cef9b336d620561724e0f681bf25034457f79..67de9a1eac1e29192cf32ef23129b7aa5e03f8e8 100644 (file)
 using namespace std;
 using namespace testing;
 
-namespace {
+struct KeypointIdxCompare
+{
+    std::vector<cv::KeyPoint>* keypoints;
+
+    explicit KeypointIdxCompare(std::vector<cv::KeyPoint>* _keypoints) : keypoints(_keypoints) {}
+
+    bool operator ()(size_t i1, size_t i2) const
+    {
+        cv::KeyPoint kp1 = (*keypoints)[i1];
+        cv::KeyPoint kp2 = (*keypoints)[i2];
+        if (kp1.pt.x != kp2.pt.x)
+            return kp1.pt.x < kp2.pt.x;
+        if (kp1.pt.y != kp2.pt.y)
+            return kp1.pt.y < kp2.pt.y;
+        if (kp1.response != kp2.response)
+            return kp1.response < kp2.response;
+        return kp1.octave < kp2.octave;
+    }
+};
+
+static void sortKeyPoints(std::vector<cv::KeyPoint>& keypoints, cv::InputOutputArray _descriptors = cv::noArray())
+{
+    std::vector<size_t> indexies(keypoints.size());
+    for (size_t i = 0; i < indexies.size(); ++i)
+        indexies[i] = i;
+
+    std::sort(indexies.begin(), indexies.end(), KeypointIdxCompare(&keypoints));
+
+    std::vector<cv::KeyPoint> new_keypoints;
+    cv::Mat new_descriptors;
+
+    new_keypoints.resize(keypoints.size());
+
+    cv::Mat descriptors;
+    if (_descriptors.needed())
+    {
+        descriptors = _descriptors.getMat();
+        new_descriptors.create(descriptors.size(), descriptors.type());
+    }
+
+    for (size_t i = 0; i < indexies.size(); ++i)
+    {
+        size_t new_idx = indexies[i];
+        new_keypoints[i] = keypoints[new_idx];
+        if (!new_descriptors.empty())
+            descriptors.row((int) new_idx).copyTo(new_descriptors.row((int) i));
+    }
+
+    keypoints.swap(new_keypoints);
+    if (_descriptors.needed())
+        new_descriptors.copyTo(_descriptors);
+}
 
 //////////////////////////////////////////////////////////////////////
 // SURF
 
 DEF_PARAM_TEST_1(Image, string);
 
-PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.png"))
+PERF_TEST_P(Image, Features2D_SURF,
+            Values<string>("gpu/perf/aloe.png"))
 {
     declare.time(50.0);
 
-    cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    const cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
 
     if (PERF_RUN_GPU())
     {
         cv::gpu::SURF_GPU d_surf;
 
-        cv::gpu::GpuMat d_img(img);
+        const cv::gpu::GpuMat d_img(img);
         cv::gpu::GpuMat d_keypoints, d_descriptors;
 
-        d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
+        TEST_CYCLE() d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
+
+        std::vector<cv::KeyPoint> gpu_keypoints;
+        d_surf.downloadKeypoints(d_keypoints, gpu_keypoints);
 
-        TEST_CYCLE()
-        {
-            d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
-        }
+        cv::Mat gpu_descriptors(d_descriptors);
 
-        GPU_SANITY_CHECK(d_descriptors, 1e-4);
-        GPU_SANITY_CHECK_KEYPOINTS(SURF, d_keypoints);
+        sortKeyPoints(gpu_keypoints, gpu_descriptors);
+
+        SANITY_CHECK_KEYPOINTS(gpu_keypoints);
+        SANITY_CHECK(gpu_descriptors);
     }
     else
     {
         cv::SURF surf;
 
-        std::vector<cv::KeyPoint> keypoints;
-        cv::Mat descriptors;
-
-        surf(img, cv::noArray(), keypoints, descriptors);
+        std::vector<cv::KeyPoint> cpu_keypoints;
+        cv::Mat cpu_descriptors;
 
-        TEST_CYCLE()
-        {
-            keypoints.clear();
-            surf(img, cv::noArray(), keypoints, descriptors);
-        }
+        TEST_CYCLE() surf(img, cv::noArray(), cpu_keypoints, cpu_descriptors);
 
-        SANITY_CHECK_KEYPOINTS(keypoints);
-        SANITY_CHECK(descriptors, 1e-4);
+        SANITY_CHECK_KEYPOINTS(cpu_keypoints);
+        SANITY_CHECK(cpu_descriptors);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // FAST
 
-PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.png"))
+DEF_PARAM_TEST(Image_Threshold_NonMaxSupression, string, int, bool);
+
+PERF_TEST_P(Image_Threshold_NonMaxSupression, Features2D_FAST,
+            Combine(Values<string>("gpu/perf/aloe.png"),
+                    Values(20),
+                    Bool()))
 {
-    cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    const cv::Mat img = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
 
+    const int threshold = GET_PARAM(1);
+    const bool nonMaxSuppersion = GET_PARAM(2);
+
     if (PERF_RUN_GPU())
     {
-        cv::gpu::FAST_GPU d_fast(20);
+        cv::gpu::FAST_GPU d_fast(threshold, nonMaxSuppersion, 0.5);
 
-        cv::gpu::GpuMat d_img(img);
+        const cv::gpu::GpuMat d_img(img);
         cv::gpu::GpuMat d_keypoints;
 
-        d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
+        TEST_CYCLE() d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
+
+        std::vector<cv::KeyPoint> gpu_keypoints;
+        d_fast.downloadKeypoints(d_keypoints, gpu_keypoints);
 
-        TEST_CYCLE()
-        {
-            d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
-        }
+        sortKeyPoints(gpu_keypoints);
 
-        GPU_SANITY_CHECK_RESPONSE(FAST, d_keypoints);
+        SANITY_CHECK_KEYPOINTS(gpu_keypoints);
     }
     else
     {
-        std::vector<cv::KeyPoint> keypoints;
+        std::vector<cv::KeyPoint> cpu_keypoints;
 
-        cv::FAST(img, keypoints, 20);
+        TEST_CYCLE() cv::FAST(img, cpu_keypoints, threshold, nonMaxSuppersion);
 
-        TEST_CYCLE()
-        {
-            keypoints.clear();
-            cv::FAST(img, keypoints, 20);
-        }
-
-        SANITY_CHECK_KEYPOINTS(keypoints);
+        SANITY_CHECK_KEYPOINTS(cpu_keypoints);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // ORB
 
-PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
+DEF_PARAM_TEST(Image_NFeatures, string, int);
+
+PERF_TEST_P(Image_NFeatures, Features2D_ORB,
+            Combine(Values<string>("gpu/perf/aloe.png"),
+                    Values(4000)))
 {
-    cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    const cv::Mat img = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
 
+    const int nFeatures = GET_PARAM(1);
+
     if (PERF_RUN_GPU())
     {
-        cv::gpu::ORB_GPU d_orb(4000);
+        cv::gpu::ORB_GPU d_orb(nFeatures);
 
-        cv::gpu::GpuMat d_img(img);
+        const cv::gpu::GpuMat d_img(img);
         cv::gpu::GpuMat d_keypoints, d_descriptors;
 
-        d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
+        TEST_CYCLE() d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
+
+        std::vector<cv::KeyPoint> gpu_keypoints;
+        d_orb.downloadKeyPoints(d_keypoints, gpu_keypoints);
+
+        cv::Mat gpu_descriptors(d_descriptors);
 
-        TEST_CYCLE()
-        {
-            d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
-        }
+        gpu_keypoints.resize(10);
+        gpu_descriptors = gpu_descriptors.rowRange(0, 10);
 
-        GPU_SANITY_CHECK_KEYPOINTS(ORB, d_keypoints);
-        GPU_SANITY_CHECK(d_descriptors);
+        sortKeyPoints(gpu_keypoints, gpu_descriptors);
+
+        SANITY_CHECK_KEYPOINTS(gpu_keypoints);
+        SANITY_CHECK(gpu_descriptors);
     }
     else
     {
-        cv::ORB orb(4000);
-
-        std::vector<cv::KeyPoint> keypoints;
-        cv::Mat descriptors;
+        cv::ORB orb(nFeatures);
 
-        orb(img, cv::noArray(), keypoints, descriptors);
+        std::vector<cv::KeyPoint> cpu_keypoints;
+        cv::Mat cpu_descriptors;
 
-        TEST_CYCLE()
-        {
-            keypoints.clear();
-            orb(img, cv::noArray(), keypoints, descriptors);
-        }
+        TEST_CYCLE() orb(img, cv::noArray(), cpu_keypoints, cpu_descriptors);
 
-        SANITY_CHECK_KEYPOINTS(keypoints);
-        SANITY_CHECK(descriptors);
+        SANITY_CHECK_KEYPOINTS(cpu_keypoints);
+        SANITY_CHECK(cpu_descriptors);
     }
 }
 
@@ -144,166 +199,165 @@ PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
 
 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))))
+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(20.0);
 
-    int desc_size = GET_PARAM(0);
-    int normType = GET_PARAM(1);
+    const int desc_size = GET_PARAM(0);
+    const int normType = GET_PARAM(1);
 
-    int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
+    const int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
 
     cv::Mat query(3000, desc_size, type);
-    fillRandom(query);
+    declare.in(query, WARMUP_RNG);
 
     cv::Mat train(3000, desc_size, type);
-    fillRandom(train);
+    declare.in(train, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
         cv::gpu::BFMatcher_GPU d_matcher(normType);
 
-        cv::gpu::GpuMat d_query(query);
-        cv::gpu::GpuMat d_train(train);
+        const cv::gpu::GpuMat d_query(query);
+        const cv::gpu::GpuMat d_train(train);
         cv::gpu::GpuMat d_trainIdx, d_distance;
 
-        d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
+        TEST_CYCLE() d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
 
-        TEST_CYCLE()
-        {
-            d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
-        }
+        std::vector<cv::DMatch> gpu_matches;
+        d_matcher.matchDownload(d_trainIdx, d_distance, gpu_matches);
 
-        GPU_SANITY_CHECK(d_trainIdx);
-        GPU_SANITY_CHECK(d_distance);
+        SANITY_CHECK_MATCHES(gpu_matches);
     }
     else
     {
         cv::BFMatcher matcher(normType);
 
-        std::vector<cv::DMatch> matches;
-
-        matcher.match(query, train, matches);
+        std::vector<cv::DMatch> cpu_matches;
 
-        TEST_CYCLE()
-        {
-            matcher.match(query, train, matches);
-        }
+        TEST_CYCLE() matcher.match(query, train, cpu_matches);
 
-        SANITY_CHECK(matches);
+        SANITY_CHECK_MATCHES(cpu_matches);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BFKnnMatch
 
+static void toOneRowMatches(const std::vector< std::vector<cv::DMatch> >& src, std::vector<cv::DMatch>& dst)
+{
+    dst.clear();
+    for (size_t i = 0; i < src.size(); ++i)
+        for (size_t j = 0; j < src[i].size(); ++j)
+            dst.push_back(src[i][j]);
+}
+
 DEF_PARAM_TEST(DescSize_K_Norm, int, int, NormType);
 
-PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
-    Values(64, 128, 256),
-    Values(2, 3),
-    Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
+PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch,
+            Combine(Values(64, 128, 256),
+                    Values(2, 3),
+                    Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
 {
     declare.time(30.0);
 
-    int desc_size = GET_PARAM(0);
-    int k = GET_PARAM(1);
-    int normType = GET_PARAM(2);
+    const int desc_size = GET_PARAM(0);
+    const int k = GET_PARAM(1);
+    const int normType = GET_PARAM(2);
 
-    int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
+    const int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
 
     cv::Mat query(3000, desc_size, type);
-    fillRandom(query);
+    declare.in(query, WARMUP_RNG);
 
     cv::Mat train(3000, desc_size, type);
-    fillRandom(train);
+    declare.in(train, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
         cv::gpu::BFMatcher_GPU d_matcher(normType);
 
-        cv::gpu::GpuMat d_query(query);
-        cv::gpu::GpuMat d_train(train);
+        const cv::gpu::GpuMat d_query(query);
+        const cv::gpu::GpuMat d_train(train);
         cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist;
 
-        d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
+        TEST_CYCLE() d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
+
+        std::vector< std::vector<cv::DMatch> > matchesTbl;
+        d_matcher.knnMatchDownload(d_trainIdx, d_distance, matchesTbl);
 
-        TEST_CYCLE()
-        {
-            d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
-        }
+        std::vector<cv::DMatch> gpu_matches;
+        toOneRowMatches(matchesTbl, gpu_matches);
 
-        GPU_SANITY_CHECK(d_trainIdx);
-        GPU_SANITY_CHECK(d_distance);
+        SANITY_CHECK_MATCHES(gpu_matches);
     }
     else
     {
         cv::BFMatcher matcher(normType);
 
-        std::vector< std::vector<cv::DMatch> > matches;
+        std::vector< std::vector<cv::DMatch> > matchesTbl;
 
-        matcher.knnMatch(query, train, matches, k);
+        TEST_CYCLE() matcher.knnMatch(query, train, matchesTbl, k);
 
-        TEST_CYCLE()
-        {
-            matcher.knnMatch(query, train, matches, k);
-        }
+        std::vector<cv::DMatch> cpu_matches;
+        toOneRowMatches(matchesTbl, cpu_matches);
 
-        SANITY_CHECK(matches);
+        SANITY_CHECK_MATCHES(cpu_matches);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BFRadiusMatch
 
-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))))
+PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch,
+            Combine(Values(64, 128, 256),
+                    Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
 {
     declare.time(30.0);
 
-    int desc_size = GET_PARAM(0);
-    int normType = GET_PARAM(1);
+    const int desc_size = GET_PARAM(0);
+    const int normType = GET_PARAM(1);
 
-    int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
+    const int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
+    const float maxDistance = 10000;
 
     cv::Mat query(3000, desc_size, type);
-    fillRandom(query, 0.0, 1.0);
+    declare.in(query, WARMUP_RNG);
 
     cv::Mat train(3000, desc_size, type);
-    fillRandom(train, 0.0, 1.0);
+    declare.in(train, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
         cv::gpu::BFMatcher_GPU d_matcher(normType);
 
-        cv::gpu::GpuMat d_query(query);
-        cv::gpu::GpuMat d_train(train);
+        const cv::gpu::GpuMat d_query(query);
+        const cv::gpu::GpuMat d_train(train);
         cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance;
 
-        d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
+        TEST_CYCLE() d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, maxDistance);
 
-        TEST_CYCLE()
-        {
-            d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
-        }
+        std::vector< std::vector<cv::DMatch> > matchesTbl;
+        d_matcher.radiusMatchDownload(d_trainIdx, d_distance, d_nMatches, matchesTbl);
 
-        GPU_SANITY_CHECK(d_trainIdx);
-        GPU_SANITY_CHECK(d_distance);
+        std::vector<cv::DMatch> gpu_matches;
+        toOneRowMatches(matchesTbl, gpu_matches);
+
+        SANITY_CHECK_MATCHES(gpu_matches);
     }
     else
     {
         cv::BFMatcher matcher(normType);
 
-        std::vector< std::vector<cv::DMatch> > matches;
+        std::vector< std::vector<cv::DMatch> > matchesTbl;
 
-        matcher.radiusMatch(query, train, matches, 2.0);
+        TEST_CYCLE() matcher.radiusMatch(query, train, matchesTbl, maxDistance);
 
-        TEST_CYCLE()
-        {
-            matcher.radiusMatch(query, train, matches, 2.0);
-        }
+        std::vector<cv::DMatch> cpu_matches;
+        toOneRowMatches(matchesTbl, cpu_matches);
 
-        SANITY_CHECK(matches);
+        SANITY_CHECK_MATCHES(cpu_matches);
     }
 }
-
-} // namespace
index 7faf93e979c2747a20aaa9275317c3fdff6856f8..3516954a6c8bfdd037b9febf6610c80ba3679df0 100644 (file)
@@ -3,48 +3,39 @@
 using namespace std;
 using namespace testing;
 
-namespace {
-
 //////////////////////////////////////////////////////////////////////
 // Blur
 
 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)))
+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);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int ksize = GET_PARAM(2);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
-        }
+        TEST_CYCLE() cv::gpu::blur(d_src, dst, cv::Size(ksize, ksize));
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::blur(src, dst, cv::Size(ksize, ksize));
-
-        TEST_CYCLE()
-        {
-            cv::blur(src, dst, cv::Size(ksize, ksize));
-        }
+        TEST_CYCLE() cv::blur(src, dst, cv::Size(ksize, ksize));
 
         CPU_SANITY_CHECK(dst);
     }
@@ -57,38 +48,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int ksize = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int ksize = GET_PARAM(2);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
+        TEST_CYCLE() cv::gpu::Sobel(d_src, dst, -1, 1, 1, d_buf, ksize);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::Sobel(src, dst, -1, 1, 1, ksize);
-
-        TEST_CYCLE()
-        {
-            cv::Sobel(src, dst, -1, 1, 1, ksize);
-        }
+        TEST_CYCLE() cv::Sobel(src, dst, -1, 1, 1, ksize);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -101,37 +82,27 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
 {
     declare.time(20.0);
 
-    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);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
+        TEST_CYCLE() cv::gpu::Scharr(d_src, dst, -1, 1, 0, d_buf);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::Scharr(src, dst, -1, 1, 0);
-
-        TEST_CYCLE()
-        {
-            cv::Scharr(src, dst, -1, 1, 0);
-        }
+        TEST_CYCLE() cv::Scharr(src, dst, -1, 1, 0);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -144,38 +115,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int ksize = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int ksize = GET_PARAM(2);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
-        }
+        TEST_CYCLE() cv::gpu::GaussianBlur(d_src, dst, cv::Size(ksize, ksize), d_buf, 0.5);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
-
-        TEST_CYCLE()
-        {
-            cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
-        }
+        TEST_CYCLE() cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -188,37 +149,27 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES,
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int ksize = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int ksize = GET_PARAM(2);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
-        }
+        TEST_CYCLE() cv::gpu::Laplacian(d_src, dst, -1, ksize);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::Laplacian(src, dst, -1, ksize);
-
-        TEST_CYCLE()
-        {
-            cv::Laplacian(src, dst, -1, ksize);
-        }
+        TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -231,39 +182,29 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC
 {
     declare.time(20.0);
 
-    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);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
+    const cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::erode(d_src, d_dst, ker, d_buf);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::erode(d_src, d_dst, ker, d_buf);
-        }
+        TEST_CYCLE() cv::gpu::erode(d_src, dst, ker, d_buf);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::erode(src, dst, ker);
-
-        TEST_CYCLE()
-        {
-            cv::erode(src, dst, ker);
-        }
+        TEST_CYCLE() cv::erode(src, dst, ker);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -276,39 +217,29 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
 {
     declare.time(20.0);
 
-    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);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
+    const cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::dilate(d_src, d_dst, ker, d_buf);
+        TEST_CYCLE() cv::gpu::dilate(d_src, dst, ker, d_buf);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::dilate(d_src, d_dst, ker, d_buf);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::dilate(src, dst, ker);
-
-        TEST_CYCLE()
-        {
-            cv::dilate(src, dst, ker);
-        }
+        TEST_CYCLE() cv::dilate(src, dst, ker);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -326,41 +257,31 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int morphOp = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int morphOp = GET_PARAM(2);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
+    const cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf1;
         cv::gpu::GpuMat d_buf2;
 
-        cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
+        TEST_CYCLE() cv::gpu::morphologyEx(d_src, dst, morphOp, ker, d_buf1, d_buf2);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::morphologyEx(src, dst, morphOp, ker);
-
-        TEST_CYCLE()
-        {
-            cv::morphologyEx(src, dst, morphOp, ker);
-        }
+        TEST_CYCLE() cv::morphologyEx(src, dst, morphOp, ker);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -373,43 +294,31 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int ksize = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int ksize = GET_PARAM(2);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     cv::Mat kernel(ksize, ksize, CV_32FC1);
-    fillRandom(kernel, 0.0, 1.0);
+    declare.in(kernel, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::filter2D(d_src, d_dst, -1, kernel);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::filter2D(d_src, d_dst, -1, kernel);
-        }
+        TEST_CYCLE() cv::gpu::filter2D(d_src, dst, -1, kernel);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::filter2D(src, dst, -1, kernel);
-
-        TEST_CYCLE()
-        {
-            cv::filter2D(src, dst, -1, kernel);
-        }
+        TEST_CYCLE() cv::filter2D(src, dst, -1, kernel);
 
         CPU_SANITY_CHECK(dst);
     }
 }
-
-} // namespace
index e3d488ec94e6becf3f518cf9d53f7ef0c01fc3b8..62915c85ce0dd33d03e8247a30ba6ebb544e774c 100644 (file)
@@ -2,13 +2,12 @@
 
 using namespace std;
 using namespace testing;
-
-namespace {
+using namespace perf;
 
 //////////////////////////////////////////////////////////////////////
 // Remap
 
-enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};
+enum { HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH };
 CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH);
 #define ALL_REMAP_MODES ValuesIn(RemapMode::all())
 
@@ -51,59 +50,50 @@ void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode)
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border_Mode, cv::Size, MatDepth, MatCn, Interpolation, BorderMode, RemapMode);
 
-PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
-    ALL_BORDER_MODES,
-    ALL_REMAP_MODES))
+PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
+                    ALL_BORDER_MODES,
+                    ALL_REMAP_MODES))
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int interpolation = GET_PARAM(3);
-    int borderMode = GET_PARAM(4);
-    int remapMode = GET_PARAM(5);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int interpolation = GET_PARAM(3);
+    const int borderMode = GET_PARAM(4);
+    const int remapMode = GET_PARAM(5);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     cv::Mat xmap(size, CV_32FC1);
     cv::Mat ymap(size, CV_32FC1);
-
     generateMap(xmap, ymap, remapMode);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_xmap(xmap);
-        cv::gpu::GpuMat d_ymap(ymap);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_xmap(xmap);
+        const cv::gpu::GpuMat d_ymap(ymap);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
-        }
+        TEST_CYCLE() cv::gpu::remap(d_src, dst, d_xmap, d_ymap, interpolation, borderMode);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
+        TEST_CYCLE() cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -112,50 +102,42 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine(
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Scale, cv::Size, MatDepth, MatCn, Interpolation, double);
 
-PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    ALL_INTERPOLATIONS,
-    Values(0.5, 0.3, 2.0)))
+PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    ALL_INTERPOLATIONS,
+                    Values(0.5, 0.3, 2.0)))
 {
     declare.time(20.0);
 
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int interpolation = GET_PARAM(3);
-    double f = GET_PARAM(4);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int interpolation = GET_PARAM(3);
+    const double f = GET_PARAM(4);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
+        TEST_CYCLE() cv::gpu::resize(d_src, dst, cv::Size(), f, f, interpolation);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::resize(src, dst, cv::Size(), f, f, interpolation);
+        TEST_CYCLE() cv::resize(src, dst, cv::Size(), f, f, interpolation);
 
-        TEST_CYCLE()
-        {
-            cv::resize(src, dst, cv::Size(), f, f, interpolation);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -164,49 +146,41 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine(
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Scale, cv::Size, MatDepth, MatCn, double);
 
-PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    Values(0.2, 0.1, 0.05)))
+PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    Values(0.2, 0.1, 0.05)))
 {
     declare.time(1.0);
 
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int interpolation = cv::INTER_AREA;
-    double f = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int interpolation = cv::INTER_AREA;
+    const double f = GET_PARAM(3);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
+        TEST_CYCLE() cv::gpu::resize(d_src, dst, cv::Size(), f, f, interpolation);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::resize(src, dst, cv::Size(), f, f, interpolation);
+        TEST_CYCLE() cv::resize(src, dst, cv::Size(), f, f, interpolation);
 
-        TEST_CYCLE()
-        {
-            cv::resize(src, dst, cv::Size(), f, f, interpolation);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -215,111 +189,98 @@ PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border, cv::Size, MatDepth, MatCn, Interpolation, BorderMode);
 
-PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
-    ALL_BORDER_MODES))
+PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    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);
-    int interpolation = GET_PARAM(3);
-    int borderMode = GET_PARAM(4);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int interpolation = GET_PARAM(3);
+    const int borderMode = GET_PARAM(4);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     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);
+    const double mat[2 * 3] =
+    {
+        std::cos(aplha), -std::sin(aplha), src.cols / 2,
+        std::sin(aplha),  std::cos(aplha), 0
+    };
+    const cv::Mat M(2, 3, CV_64F, (void*) mat);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);
-        }
+        TEST_CYCLE() cv::gpu::warpAffine(d_src, dst, M, size, interpolation, borderMode);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::warpAffine(src, dst, M, size, interpolation, borderMode);
+        TEST_CYCLE() cv::warpAffine(src, dst, M, size, interpolation, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::warpAffine(src, dst, M, size, interpolation, borderMode);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // WarpPerspective
 
-PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
-    ALL_BORDER_MODES))
+PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    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);
-    int interpolation = GET_PARAM(3);
-    int borderMode = GET_PARAM(4);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int interpolation = GET_PARAM(3);
+    const int borderMode = GET_PARAM(4);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     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);
+    const cv::Mat M(3, 3, CV_64F, (void*) mat);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);
+        TEST_CYCLE() cv::gpu::warpPerspective(d_src, dst, M, size, interpolation, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
+        TEST_CYCLE() cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -328,46 +289,38 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine(
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Border, cv::Size, MatDepth, MatCn, BorderMode);
 
-PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    ALL_BORDER_MODES))
+PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    ALL_BORDER_MODES))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int borderMode = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int borderMode = GET_PARAM(3);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);
-        }
+        TEST_CYCLE() cv::gpu::copyMakeBorder(d_src, dst, 5, 5, 5, 5, borderMode);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);
+        TEST_CYCLE() cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -379,168 +332,145 @@ CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv
 
 DEF_PARAM_TEST(Sz_Depth_Op, cv::Size, MatDepth, ThreshOp);
 
-PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F, CV_64F),
-    ALL_THRESH_OPS))
+PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+            Values(CV_8U, CV_16U, CV_32F, CV_64F),
+            ALL_THRESH_OPS))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int threshOp = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int threshOp = GET_PARAM(2);
 
     cv::Mat src(size, depth);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);
-        }
+        TEST_CYCLE() cv::gpu::threshold(d_src, dst, 100.0, 255.0, threshOp);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::threshold(src, dst, 100.0, 255.0, threshOp);
+        TEST_CYCLE() cv::threshold(src, dst, 100.0, 255.0, threshOp);
 
-        TEST_CYCLE()
-        {
-            cv::threshold(src, dst, 100.0, 255.0, threshOp);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Integral
 
-PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_Integral,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_8UC1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::integralBuffered(d_src, d_dst, d_buf);
+        TEST_CYCLE() cv::gpu::integralBuffered(d_src, dst, d_buf);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::integralBuffered(d_src, d_dst, d_buf);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::integral(src, dst);
+        TEST_CYCLE() cv::integral(src, dst);
 
-        TEST_CYCLE()
-        {
-            cv::integral(src, dst);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // IntegralSqr
 
-PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_IntegralSqr,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_8UC1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::sqrIntegral(d_src, d_dst);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::sqrIntegral(d_src, d_dst);
-        }
+        TEST_CYCLE() cv::gpu::sqrIntegral(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // HistEvenC1
 
-PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S)))
+PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, 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);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_hist;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);
-        }
+        TEST_CYCLE() cv::gpu::histEven(d_src, dst, d_buf, 30, 0, 180);
 
-        GPU_SANITY_CHECK(d_hist);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        int hbins = 30;
-        float hranges[] = {0.0f, 180.0f};
-        int histSize[] = {hbins};
+        const int hbins = 30;
+        const float hranges[] = {0.0f, 180.0f};
+        const int histSize[] = {hbins};
         const float* ranges[] = {hranges};
-        int channels[] = {0};
+        const int channels[] = {0};
 
-        cv::Mat hist;
+        cv::Mat dst;
 
-        cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);
+        TEST_CYCLE() cv::calcHist(&src, 1, channels, cv::Mat(), dst, 1, histSize, ranges);
 
-        TEST_CYCLE()
-        {
-            cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // HistEvenC4
 
-PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S)))
+PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, 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, CV_MAKE_TYPE(depth, 4));
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     int histSize[] = {30, 30, 30, 30};
     int lowerLevel[] = {0, 0, 0, 0};
@@ -548,121 +478,109 @@ PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_hist[4];
-        cv::gpu::GpuMat d_buf, d_hist0;
+        cv::gpu::GpuMat d_buf;
 
-        cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
+        TEST_CYCLE() cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
-        }
-
-        GPU_SANITY_CHECK(d_hist0);
+        cv::Mat cpu_hist0, cpu_hist1, cpu_hist2, cpu_hist3;
+        d_hist[0].download(cpu_hist0);
+        d_hist[1].download(cpu_hist1);
+        d_hist[2].download(cpu_hist2);
+        d_hist[3].download(cpu_hist3);
+        SANITY_CHECK(cpu_hist0);
+        SANITY_CHECK(cpu_hist1);
+        SANITY_CHECK(cpu_hist2);
+        SANITY_CHECK(cpu_hist3);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // CalcHist
 
-PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_CalcHist,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_8UC1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_hist;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::calcHist(d_src, d_hist);
+        TEST_CYCLE() cv::gpu::calcHist(d_src, dst);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::calcHist(d_src, d_hist);
-        }
-
-        GPU_SANITY_CHECK(d_hist);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // EqualizeHist
 
-PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_EqualizeHist,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_8UC1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_hist;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);
-        }
+        TEST_CYCLE() cv::gpu::equalizeHist(d_src, dst, d_hist, d_buf);
 
-        GPU_SANITY_CHECK(d_hist);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::equalizeHist(src, dst);
+        TEST_CYCLE() cv::equalizeHist(src, dst);
 
-        TEST_CYCLE()
-        {
-            cv::equalizeHist(src, dst);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // ColumnSum
 
-PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_ColumnSum,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_32FC1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::columnSum(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::columnSum(d_src, dst);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::columnSum(d_src, d_dst);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -671,43 +589,38 @@ PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES)
 
 DEF_PARAM_TEST(Image_AppertureSz_L2gradient, string, int, bool);
 
-PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine(
-    Values("perf/800x600.png", "perf/1280x1024.png", "perf/1680x1050.png"),
-    Values(3, 5),
-    Bool()))
+PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny,
+            Combine(Values("perf/800x600.png", "perf/1280x1024.png", "perf/1680x1050.png"),
+                    Values(3, 5),
+                    Bool()))
 {
-    string fileName = GET_PARAM(0);
-    int apperture_size = GET_PARAM(1);
-    bool useL2gradient = GET_PARAM(2);
+    const string fileName = GET_PARAM(0);
+    const int apperture_size = GET_PARAM(1);
+    const bool useL2gradient = GET_PARAM(2);
 
-    cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
+    const cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(image.empty());
 
+    const double low_thresh = 50.0;
+    const double high_thresh = 100.0;
+
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_image(image);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_image(image);
+        cv::gpu::GpuMat dst;
         cv::gpu::CannyBuf d_buf;
 
-        cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);
+        TEST_CYCLE() cv::gpu::Canny(d_image, d_buf, dst, low_thresh, high_thresh, apperture_size, useL2gradient);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);
+        TEST_CYCLE() cv::Canny(image, dst, low_thresh, high_thresh, apperture_size, useL2gradient);
 
-        TEST_CYCLE()
-        {
-            cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
@@ -716,148 +629,142 @@ PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine(
 
 DEF_PARAM_TEST_1(Image, string);
 
-PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values<string>("gpu/meanshift/cones.png"))
+PERF_TEST_P(Image, ImgProc_MeanShiftFiltering,
+            Values<string>("gpu/meanshift/cones.png"))
 {
     declare.time(15.0);
 
-    cv::Mat img = readImage(GetParam());
+    const cv::Mat img = readImage(GetParam());
     ASSERT_FALSE(img.empty());
 
     cv::Mat rgba;
     cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
 
+    const int sp = 50;
+    const int sr = 50;
+
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(rgba);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);
+        const cv::gpu::GpuMat d_src(rgba);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);
-        }
+        TEST_CYCLE() cv::gpu::meanShiftFiltering(d_src, dst, sp, sr);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::pyrMeanShiftFiltering(img, dst, 50, 50);
+        TEST_CYCLE() cv::pyrMeanShiftFiltering(img, dst, sp, sr);
 
-        TEST_CYCLE()
-        {
-            cv::pyrMeanShiftFiltering(img, dst, 50, 50);
-        }
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MeanShiftProc
 
-PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values<string>("gpu/meanshift/cones.png"))
+PERF_TEST_P(Image, ImgProc_MeanShiftProc,
+            Values<string>("gpu/meanshift/cones.png"))
 {
     declare.time(5.0);
 
-    cv::Mat img = readImage(GetParam());
+    const cv::Mat img = readImage(GetParam());
     ASSERT_FALSE(img.empty());
 
     cv::Mat rgba;
     cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
 
+    const int sp = 50;
+    const int sr = 50;
+
     if (PERF_RUN_GPU())
     {
-        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);
+        const cv::gpu::GpuMat d_src(rgba);
+        cv::gpu::GpuMat dstr;
+        cv::gpu::GpuMat dstsp;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);
-        }
+        TEST_CYCLE() cv::gpu::meanShiftProc(d_src, dstr, dstsp, sp, sr);
 
-        GPU_SANITY_CHECK(d_dstr);
+        GPU_SANITY_CHECK(dstr);
+        GPU_SANITY_CHECK(dstsp);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // MeanShiftSegmentation
 
-PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values<string>("gpu/meanshift/cones.png"))
+PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation,
+            Values<string>("gpu/meanshift/cones.png"))
 {
     declare.time(5.0);
 
-    cv::Mat img = readImage(GetParam());
+    const cv::Mat img = readImage(GetParam());
     ASSERT_FALSE(img.empty());
 
     cv::Mat rgba;
     cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
 
-    cv::Mat dst;
+    const int sp = 10;
+    const int sr = 10;
+    const int minsize = 20;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(rgba);
+        const cv::gpu::GpuMat d_src(rgba);
+        cv::Mat dst;
 
-        cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);
-        }
+        TEST_CYCLE() cv::gpu::meanShiftSegmentation(d_src, dst, sp, sr, minsize);
 
         GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BlendLinear
 
-PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_32F), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_32F),
+                    GPU_CHANNELS_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 img1(size, type);
-    fillRandom(img1);
-
     cv::Mat img2(size, type);
-    fillRandom(img2);
+    declare.in(img1, img2, WARMUP_RNG);
+
+    const cv::Mat weights1(size, CV_32FC1, cv::Scalar::all(0.5));
+    const cv::Mat weights2(size, CV_32FC1, cv::Scalar::all(0.5));
 
     if (PERF_RUN_GPU())
     {
-        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);
+        const cv::gpu::GpuMat d_img1(img1);
+        const cv::gpu::GpuMat d_img2(img2);
+        const cv::gpu::GpuMat d_weights1(weights1);
+        const cv::gpu::GpuMat d_weights2(weights2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);
-        }
+        TEST_CYCLE() cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -866,19 +773,20 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Val
 
 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()))
+PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(17, 27, 32, 64),
+                    Bool()))
 {
     declare.time(10.0);
 
-    cv::Size size = GET_PARAM(0);
-    int templ_size = GET_PARAM(1);
-    bool ccorr = GET_PARAM(2);
-
-    cv::Mat image(size, CV_32FC1);
-    image.setTo(1.0);
+    const cv::Size size = GET_PARAM(0);
+    const int templ_size = GET_PARAM(1);
+    const bool ccorr = GET_PARAM(2);
 
-    cv::Mat templ(templ_size, templ_size, CV_32FC1);
-    templ.setTo(1.0);
+    const cv::Mat image(size, CV_32FC1);
+    const cv::Mat templ(templ_size, templ_size, CV_32FC1);
+    declare.in(image, templ, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
@@ -888,30 +796,21 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES,
         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::GpuMat dst;
         cv::gpu::ConvolveBuf d_buf;
 
-        cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);
-        }
+        TEST_CYCLE() cv::gpu::convolve(d_image, d_templ, dst, ccorr, d_buf);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        ASSERT_FALSE(ccorr);
+        if (ccorr)
+            FAIL_NO_CPU();
 
         cv::Mat dst;
 
-        cv::filter2D(image, dst, image.depth(), templ);
-
-        TEST_CYCLE()
-        {
-            cv::filter2D(image, dst, image.depth(), templ);
-        }
+        TEST_CYCLE() cv::filter2D(image, dst, image.depth(), templ);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -925,48 +824,36 @@ CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::T
 
 DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, MatCn, TemplateMethod);
 
-PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
-    GPU_CHANNELS_1_3_4,
-    ALL_TEMPLATE_METHODS))
+PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
+                    GPU_CHANNELS_1_3_4,
+                    ALL_TEMPLATE_METHODS))
 {
-    cv::Size size = GET_PARAM(0);
-    cv::Size templ_size = GET_PARAM(1);
-    int cn = GET_PARAM(2);
-    int method = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const cv::Size templ_size = GET_PARAM(1);
+    const int cn = GET_PARAM(2);
+    const int method = GET_PARAM(3);
 
     cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn));
-    fillRandom(image);
-
     cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));
-    fillRandom(templ);
+    declare.in(image, templ, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_image(image);
-        cv::gpu::GpuMat d_templ(templ);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_image(image);
+        const cv::gpu::GpuMat d_templ(templ);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
-        }
+        TEST_CYCLE() cv::gpu::matchTemplate(d_image, d_templ, dst, method);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
     }
     else
     {
         cv::Mat dst;
 
-        cv::matchTemplate(image, templ, dst, method);
-
-        TEST_CYCLE()
-        {
-            cv::matchTemplate(image, templ, dst, method);
-        }
+        TEST_CYCLE() cv::matchTemplate(image, templ, dst, method);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -975,48 +862,36 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(
 ////////////////////////////////////////////////////////////////////////////////
 // MatchTemplate32F
 
-PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
-    GPU_CHANNELS_1_3_4,
-    Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))))
+PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
+                    GPU_CHANNELS_1_3_4,
+                    Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))))
 {
-    cv::Size size = GET_PARAM(0);
-    cv::Size templ_size = GET_PARAM(1);
-    int cn = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const cv::Size templ_size = GET_PARAM(1);
+    const int cn = GET_PARAM(2);
     int method = GET_PARAM(3);
 
     cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn));
-    fillRandom(image);
-
     cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));
-    fillRandom(templ);
+    declare.in(image, templ, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_image(image);
-        cv::gpu::GpuMat d_templ(templ);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_image(image);
+        const cv::gpu::GpuMat d_templ(templ);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
+        TEST_CYCLE() cv::gpu::matchTemplate(d_image, d_templ, dst, method);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
     }
     else
     {
         cv::Mat dst;
 
-        cv::matchTemplate(image, templ, dst, method);
-
-        TEST_CYCLE()
-        {
-            cv::matchTemplate(image, templ, dst, method);
-        }
+        TEST_CYCLE() cv::matchTemplate(image, templ, dst, method);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1029,44 +904,32 @@ CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMP
 
 DEF_PARAM_TEST(Sz_Flags, cv::Size, DftFlags);
 
-PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(0, DftFlags(cv::DFT_ROWS))))
+PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(0, DftFlags(cv::DFT_ROWS))))
 {
-    cv::Size size = GET_PARAM(0);
-    int flag = GET_PARAM(1);
+    const cv::Size size = GET_PARAM(0);
+    const int flag = GET_PARAM(1);
 
     cv::Mat a(size, CV_32FC2);
-    fillRandom(a, 0, 100);
-
     cv::Mat b(size, CV_32FC2);
-    fillRandom(b, 0, 100);
+    declare.in(a, b, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_a(a);
-        cv::gpu::GpuMat d_b(b);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_a(a);
+        const cv::gpu::GpuMat d_b(b);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);
+        TEST_CYCLE() cv::gpu::mulSpectrums(d_a, d_b, dst, flag);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::mulSpectrums(a, b, dst, flag);
-
-        TEST_CYCLE()
-        {
-            cv::mulSpectrums(a, b, dst, flag);
-        }
+        TEST_CYCLE() cv::mulSpectrums(a, b, dst, flag);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1075,78 +938,62 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(
 //////////////////////////////////////////////////////////////////////
 // MulAndScaleSpectrums
 
-PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
-    float scale = 1.f / size.area();
+    const float scale = 1.f / size.area();
 
     cv::Mat src1(size, CV_32FC2);
-    fillRandom(src1, 0, 100);
-
     cv::Mat src2(size, CV_32FC2);
-    fillRandom(src2, 0, 100);
+    declare.in(src1,src2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        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);
+        const cv::gpu::GpuMat d_src1(src1);
+        const cv::gpu::GpuMat d_src2(src2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);
-        }
+        TEST_CYCLE() cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, dst, cv::DFT_ROWS, scale, false);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // Dft
 
-PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))))
+PERF_TEST_P(Sz_Flags, ImgProc_Dft,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))))
 {
     declare.time(10.0);
 
-    cv::Size size = GET_PARAM(0);
-    int flag = GET_PARAM(1);
+    const cv::Size size = GET_PARAM(0);
+    const int flag = GET_PARAM(1);
 
     cv::Mat src(size, CV_32FC2);
-    fillRandom(src, 0, 100);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::dft(d_src, d_dst, size, flag);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::dft(d_src, d_dst, size, flag);
-        }
+        TEST_CYCLE() cv::gpu::dft(d_src, dst, size, flag);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
     }
     else
     {
         cv::Mat dst;
 
-        cv::dft(src, dst, flag);
-
-        TEST_CYCLE()
-        {
-            cv::dft(src, dst, flag);
-        }
+        TEST_CYCLE() cv::dft(src, dst, flag);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1157,52 +1004,43 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(
 
 DEF_PARAM_TEST(Image_Type_Border_BlockSz_ApertureSz, string, MatType, BorderMode, int, int);
 
-PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(
-    Values<string>("gpu/stereobm/aloe-L.png"),
-    Values(CV_8UC1, CV_32FC1),
-    Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
-    Values(3, 5, 7),
-    Values(0, 3, 5, 7)))
+PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris,
+            Combine(Values<string>("gpu/stereobm/aloe-L.png"),
+                    Values(CV_8UC1, CV_32FC1),
+                    Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
+                    Values(3, 5, 7),
+                    Values(0, 3, 5, 7)))
 {
-    string fileName = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int borderMode = GET_PARAM(2);
-    int blockSize = GET_PARAM(3);
-    int apertureSize = GET_PARAM(4);
+    const string fileName = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int borderMode = GET_PARAM(2);
+    const int blockSize = GET_PARAM(3);
+    const int apertureSize = GET_PARAM(4);
 
     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);
 
-    double k = 0.5;
+    const double k = 0.5;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_img(img);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_img(img);
+        cv::gpu::GpuMat 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);
-        }
+        TEST_CYCLE() cv::gpu::cornerHarris(d_img, dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
-
-        TEST_CYCLE()
-        {
-            cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
-        }
+        TEST_CYCLE() cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1211,18 +1049,18 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(
 //////////////////////////////////////////////////////////////////////
 // CornerMinEigenVal
 
-PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Combine(
-    Values<string>("gpu/stereobm/aloe-L.png"),
-    Values(CV_8UC1, CV_32FC1),
-    Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
-    Values(3, 5, 7),
-    Values(0, 3, 5, 7)))
+PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal,
+            Combine(Values<string>("gpu/stereobm/aloe-L.png"),
+                    Values(CV_8UC1, CV_32FC1),
+                    Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
+                    Values(3, 5, 7),
+                    Values(0, 3, 5, 7)))
 {
-    string fileName = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int borderMode = GET_PARAM(2);
-    int blockSize = GET_PARAM(3);
-    int apertureSize = GET_PARAM(4);
+    const string fileName = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int borderMode = GET_PARAM(2);
+    const int blockSize = GET_PARAM(3);
+    const int apertureSize = GET_PARAM(4);
 
     cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
@@ -1231,31 +1069,21 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_img(img);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_img(img);
+        cv::gpu::GpuMat dst;
         cv::gpu::GpuMat d_Dx;
         cv::gpu::GpuMat d_Dy;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);
+        TEST_CYCLE() cv::gpu::cornerMinEigenVal(d_img, dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
-
-        TEST_CYCLE()
-        {
-            cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
-        }
+        TEST_CYCLE() cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1264,95 +1092,82 @@ PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Com
 //////////////////////////////////////////////////////////////////////
 // BuildWarpPlaneMaps
 
-PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
-    cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
-    cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
-    cv::Mat T = cv::Mat::zeros(1, 3, CV_32F);
+    const cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
+    const cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
+    const cv::Mat T = cv::Mat::zeros(1, 3, CV_32F);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_map_x;
-        cv::gpu::GpuMat d_map_y;
+        cv::gpu::GpuMat map_x;
+        cv::gpu::GpuMat map_y;
 
-        cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y);
+        TEST_CYCLE() cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, map_x, map_y);
 
-        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);
-        }
-
-        GPU_SANITY_CHECK(d_map_x);
-        GPU_SANITY_CHECK(d_map_y);
+        GPU_SANITY_CHECK(map_x);
+        GPU_SANITY_CHECK(map_y);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BuildWarpCylindricalMaps
 
-PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
-    cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
-    cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
+    const cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
+    const cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_map_x;
-        cv::gpu::GpuMat d_map_y;
+        cv::gpu::GpuMat map_x;
+        cv::gpu::GpuMat map_y;
 
-        cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
-        }
+        TEST_CYCLE() cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y);
 
-        GPU_SANITY_CHECK(d_map_x);
-        GPU_SANITY_CHECK(d_map_y);
+        GPU_SANITY_CHECK(map_x);
+        GPU_SANITY_CHECK(map_y);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // BuildWarpSphericalMaps
 
-PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
-    cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
-    cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
+    const cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
+    const cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_map_x;
-        cv::gpu::GpuMat d_map_y;
-
-        cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
-        }
+        cv::gpu::GpuMat map_x;
+        cv::gpu::GpuMat map_y;
 
-        GPU_SANITY_CHECK(d_map_x);
-        GPU_SANITY_CHECK(d_map_y);
+        TEST_CYCLE() cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, map_x, map_y);
 
+        GPU_SANITY_CHECK(map_x);
+        GPU_SANITY_CHECK(map_y);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -1361,83 +1176,68 @@ PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES)
 
 DEF_PARAM_TEST(Sz_Depth_Cn_Inter, cv::Size, MatDepth, MatCn, Interpolation);
 
-PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4,
-    Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))))
+PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4,
+                    Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    int channels = GET_PARAM(2);
-    int interpolation = GET_PARAM(3);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const int channels = GET_PARAM(2);
+    const int interpolation = GET_PARAM(3);
 
-    int type = CV_MAKE_TYPE(depth, channels);
+    const int type = CV_MAKE_TYPE(depth, channels);
 
     cv::Mat src(size, type);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);
-        }
+        TEST_CYCLE() cv::gpu::rotate(d_src, dst, size, 30.0, 0, 0, interpolation);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // PyrDown
 
-PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_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);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::pyrDown(d_src, d_dst);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::pyrDown(d_src, d_dst);
-        }
+        TEST_CYCLE() cv::gpu::pyrDown(d_src, dst);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::pyrDown(src, dst);
-
-        TEST_CYCLE()
-        {
-            cv::pyrDown(src, dst);
-        }
+        TEST_CYCLE() cv::pyrDown(src, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1446,44 +1246,34 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(
 //////////////////////////////////////////////////////////////////////
 // PyrUp
 
-PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_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);
+    declare.in(src, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::pyrUp(d_src, d_dst);
+        TEST_CYCLE() cv::gpu::pyrUp(d_src, dst);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::pyrUp(d_src, d_dst);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        cv::pyrUp(src, dst);
-
-        TEST_CYCLE()
-        {
-            cv::pyrUp(src, dst);
-        }
+        TEST_CYCLE() cv::pyrUp(src, dst);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1494,67 +1284,86 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(
 
 DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CvtColorInfo);
 
-PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(
-    GPU_TYPICAL_MAT_SIZES,
-    Values(CV_8U, CV_16U, CV_32F),
-    Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),
-           CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),
-           CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),
-           CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),
-           CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),
-           CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),
-           CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),
-           CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),
-           CvtColorInfo(3, 3, cv::COLOR_LBGR2Lab),
-           CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),
-           CvtColorInfo(3, 3, cv::COLOR_LBGR2Luv),
-           CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),
-           CvtColorInfo(3, 3, cv::COLOR_Lab2LBGR),
-           CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),
-           CvtColorInfo(3, 3, cv::COLOR_Luv2LRGB),
-           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))))
+PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_32F),
+                    Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),
+                           CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),
+                           CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),
+                           CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),
+                           CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),
+                           CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),
+                           CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),
+                           CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),
+                           CvtColorInfo(3, 3, cv::COLOR_LBGR2Lab),
+                           CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),
+                           CvtColorInfo(3, 3, cv::COLOR_LBGR2Luv),
+                           CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),
+                           CvtColorInfo(3, 3, cv::COLOR_Lab2LBGR),
+                           CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),
+                           CvtColorInfo(3, 3, cv::COLOR_Luv2LRGB))))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth = GET_PARAM(1);
-    CvtColorInfo info = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const CvtColorInfo info = GET_PARAM(2);
 
     cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
-    fillRandom(src);
+    cv::randu(src, 0, depth == CV_8U ? 255.0 : 1.0);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);
-        }
+        TEST_CYCLE() cv::gpu::cvtColor(d_src, dst, info.code, info.dcn);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst, 1e-4);
     }
     else
     {
         cv::Mat dst;
 
-        cv::cvtColor(src, dst, info.code, info.dcn);
+        TEST_CYCLE() cv::cvtColor(src, dst, info.code, info.dcn);
 
-        TEST_CYCLE()
-        {
-            cv::cvtColor(src, dst, info.code, info.dcn);
-        }
+        CPU_SANITY_CHECK(dst);
+    }
+}
+
+PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColorBayer,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U),
+                    Values(CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR),
+                           CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR),
+                           CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR),
+                           CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR))))
+{
+    const cv::Size size = GET_PARAM(0);
+    const int depth = GET_PARAM(1);
+    const CvtColorInfo info = GET_PARAM(2);
+
+    cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
+    declare.in(src, WARMUP_RNG);
+
+    if (PERF_RUN_GPU())
+    {
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
+
+        TEST_CYCLE() cv::gpu::cvtColor(d_src, dst, info.code, info.dcn);
+
+        GPU_SANITY_CHECK(dst);
+    }
+    else
+    {
+        cv::Mat dst;
+
+        TEST_CYCLE() cv::cvtColor(src, dst, info.code, info.dcn);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -1563,31 +1372,27 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(
 //////////////////////////////////////////////////////////////////////
 // SwapChannels
 
-PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_SwapChannels,
+            GPU_TYPICAL_MAT_SIZES)
 {
-    cv::Size size = GetParam();
+    const cv::Size size = GetParam();
 
     cv::Mat src(size, CV_8UC4);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
 
     const int dstOrder[] = {2, 1, 0, 3};
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst(src);
 
-        cv::gpu::swapChannels(d_src, dstOrder);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::swapChannels(d_src, dstOrder);
-        }
+        TEST_CYCLE() cv::gpu::swapChannels(dst, dstOrder);
 
-        GPU_SANITY_CHECK(d_src);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -1599,113 +1404,116 @@ CV_ENUM(AlphaOp, cv::gpu::ALPHA_OVER, cv::gpu::ALPHA_IN, cv::gpu::ALPHA_OUT, cv:
 
 DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp);
 
-PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4), ALL_ALPHA_OPS))
+PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4),
+                    ALL_ALPHA_OPS))
 {
-    cv::Size size = GET_PARAM(0);
-    int type = GET_PARAM(1);
-    int alpha_op = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int type = GET_PARAM(1);
+    const int alpha_op = GET_PARAM(2);
 
     cv::Mat img1(size, type);
-    fillRandom(img1);
-
     cv::Mat img2(size, type);
-    fillRandom(img2);
+    declare.in(img1, img2, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        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);
+        const cv::gpu::GpuMat d_img1(img1);
+        const cv::gpu::GpuMat d_img2(img2);
+        cv::gpu::GpuMat dst;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);
-        }
+        TEST_CYCLE() cv::gpu::alphaComp(d_img1, d_img2, dst, alpha_op);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // ImagePyramidBuild
 
-PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4))
 {
-    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);
+    declare.in(src, WARMUP_RNG);
+
+    const int nLayers = 5;
+    const cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
 
         cv::gpu::ImagePyramid d_pyr;
 
-        d_pyr.build(d_src, 5);
+        TEST_CYCLE() d_pyr.build(d_src, nLayers);
 
-        TEST_CYCLE()
-        {
-            d_pyr.build(d_src, 5);
-        }
+        cv::gpu::GpuMat dst;
+        d_pyr.getLayer(dst, dstSize);
 
-        GPU_SANITY_CHECK(d_src);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // ImagePyramidGetLayer
 
-PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F),
+                    GPU_CHANNELS_1_3_4))
 {
-    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);
+    declare.in(src, WARMUP_RNG);
 
-    cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);
+    const int nLayers = 3;
+    const cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
-
-        cv::gpu::ImagePyramid d_pyr(d_src, 3);
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        d_pyr.getLayer(d_dst, dstSize);
+        cv::gpu::ImagePyramid d_pyr(d_src, nLayers);
 
-        TEST_CYCLE()
-        {
-            d_pyr.getLayer(d_dst, dstSize);
-        }
+        TEST_CYCLE() d_pyr.getLayer(dst, dstSize);
 
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
-namespace {
+//////////////////////////////////////////////////////////////////////
+// HoughLines
+
+namespace
+{
     struct Vec4iComparator
     {
         bool operator()(const cv::Vec4i& a, const cv::Vec4i b) const
@@ -1735,10 +1543,8 @@ namespace {
     };
 }
 
-//////////////////////////////////////////////////////////////////////
-// HoughLines
-
-PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
+PERF_TEST_P(Sz, ImgProc_HoughLines,
+            GPU_TYPICAL_MAT_SIZES)
 {
     declare.time(30.0);
 
@@ -1748,49 +1554,35 @@ PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
     const float theta = static_cast<float>(CV_PI / 180.0);
     const int threshold = 300;
 
-    cv::RNG rng(123456789);
-
     cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));
-
-    const int numLines = rng.uniform(100, 300);
-    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);
-    }
+    cv::line(src, cv::Point(0, 100), cv::Point(src.cols, 100), cv::Scalar::all(255), 1);
+    cv::line(src, cv::Point(0, 200), cv::Point(src.cols, 200), cv::Scalar::all(255), 1);
+    cv::line(src, cv::Point(0, 400), cv::Point(src.cols, 400), cv::Scalar::all(255), 1);
+    cv::line(src, cv::Point(100, 0), cv::Point(100, src.rows), cv::Scalar::all(255), 1);
+    cv::line(src, cv::Point(200, 0), cv::Point(200, src.rows), cv::Scalar::all(255), 1);
+    cv::line(src, cv::Point(400, 0), cv::Point(400, src.rows), cv::Scalar::all(255), 1);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_lines;
         cv::gpu::HoughLinesBuf d_buf;
 
-        cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);
+        TEST_CYCLE() cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);
-        }
-
-        cv::Mat h_lines(d_lines);
-        cv::Vec2f* begin = (cv::Vec2f*)(h_lines.ptr<char>(0));
-        cv::Vec2f* end = (cv::Vec2f*)(h_lines.ptr<char>(0) + (h_lines.cols) * 2 * sizeof(float));
+        cv::Mat gpu_lines(d_lines.row(0));
+        cv::Vec2f* begin = gpu_lines.ptr<cv::Vec2f>(0);
+        cv::Vec2f* end = begin + gpu_lines.cols;
         std::sort(begin, end, Vec2fComparator());
-        SANITY_CHECK(h_lines);
+        SANITY_CHECK(gpu_lines);
     }
     else
     {
-        std::vector<cv::Vec2f> lines;
-        cv::HoughLines(src, lines, rho, theta, threshold);
+        std::vector<cv::Vec2f> cpu_lines;
 
-        TEST_CYCLE()
-        {
-            cv::HoughLines(src, lines, rho, theta, threshold);
-        }
+        TEST_CYCLE() cv::HoughLines(src, cpu_lines, rho, theta, threshold);
 
-        std::sort(lines.begin(), lines.end(), Vec2fComparator());
-        SANITY_CHECK(lines);
+        SANITY_CHECK(cpu_lines);
     }
 }
 
@@ -1799,11 +1591,12 @@ PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
 
 DEF_PARAM_TEST_1(Image, std::string);
 
-PERF_TEST_P(Image, ImgProc_HoughLinesP, testing::Values("cv/shared/pic5.png", "stitching/a1.png"))
+PERF_TEST_P(Image, ImgProc_HoughLinesP,
+            testing::Values("cv/shared/pic5.png", "stitching/a1.png"))
 {
     declare.time(30.0);
 
-    std::string fileName = getDataPath(GetParam());
+    const std::string fileName = getDataPath(GetParam());
 
     const float rho = 1.0f;
     const float theta = static_cast<float>(CV_PI / 180.0);
@@ -1811,42 +1604,33 @@ PERF_TEST_P(Image, ImgProc_HoughLinesP, testing::Values("cv/shared/pic5.png", "s
     const int minLineLenght = 50;
     const int maxLineGap = 5;
 
-    cv::Mat image = cv::imread(fileName, cv::IMREAD_GRAYSCALE);
+    const cv::Mat image = cv::imread(fileName, cv::IMREAD_GRAYSCALE);
+    ASSERT_FALSE(image.empty());
 
     cv::Mat mask;
     cv::Canny(image, mask, 50, 100);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_mask(mask);
+        const cv::gpu::GpuMat d_mask(mask);
         cv::gpu::GpuMat d_lines;
         cv::gpu::HoughLinesBuf d_buf;
 
-        cv::gpu::HoughLinesP(d_mask, d_lines, d_buf, rho, theta, minLineLenght, maxLineGap);
+        TEST_CYCLE() cv::gpu::HoughLinesP(d_mask, d_lines, d_buf, rho, theta, minLineLenght, maxLineGap);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::HoughLinesP(d_mask, d_lines, d_buf, rho, theta, minLineLenght, maxLineGap);
-        }
-
-        cv::Mat h_lines(d_lines);
-        cv::Vec4i* begin = h_lines.ptr<cv::Vec4i>();
-        cv::Vec4i* end = h_lines.ptr<cv::Vec4i>() + h_lines.cols;
+        cv::Mat gpu_lines(d_lines);
+        cv::Vec4i* begin = gpu_lines.ptr<cv::Vec4i>();
+        cv::Vec4i* end = begin + gpu_lines.cols;
         std::sort(begin, end, Vec4iComparator());
-        SANITY_CHECK(h_lines);
+        SANITY_CHECK(gpu_lines);
     }
     else
     {
-        std::vector<cv::Vec4i> lines;
-        cv::HoughLinesP(mask, lines, rho, theta, threshold, minLineLenght, maxLineGap);
+        std::vector<cv::Vec4i> cpu_lines;
 
-        TEST_CYCLE()
-        {
-            cv::HoughLinesP(mask, lines, rho, theta, threshold, minLineLenght, maxLineGap);
-        }
+        TEST_CYCLE() cv::HoughLinesP(mask, cpu_lines, rho, theta, threshold, minLineLenght, maxLineGap);
 
-        std::sort(lines.begin(), lines.end(), Vec4iComparator());
-        SANITY_CHECK(lines);
+        SANITY_CHECK(cpu_lines);
     }
 }
 
@@ -1855,7 +1639,10 @@ PERF_TEST_P(Image, ImgProc_HoughLinesP, testing::Values("cv/shared/pic5.png", "s
 
 DEF_PARAM_TEST(Sz_Dp_MinDist, cv::Size, float, float);
 
-PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES, Values(1.0f, 2.0f, 4.0f), Values(1.0f, 10.0f)))
+PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(1.0f, 2.0f, 4.0f),
+                    Values(1.0f)))
 {
     declare.time(30.0);
 
@@ -1868,51 +1655,32 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES,
     const int cannyThreshold = 100;
     const int votesThreshold = 15;
 
-    cv::RNG rng(123456789);
-
     cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));
-
-    const int numCircles = rng.uniform(50, 100);
-    for (int i = 0; i < numCircles; ++i)
-    {
-        cv::Point center(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
-        const int radius = rng.uniform(minRadius, maxRadius + 1);
-
-        cv::circle(src, center, radius, cv::Scalar::all(255), -1);
-    }
+    cv::circle(src, cv::Point(100, 100), 20, cv::Scalar::all(255), -1);
+    cv::circle(src, cv::Point(200, 200), 25, cv::Scalar::all(255), -1);
+    cv::circle(src, cv::Point(200, 100), 25, cv::Scalar::all(255), -1);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_src(src);
         cv::gpu::GpuMat d_circles;
         cv::gpu::HoughCirclesBuf d_buf;
 
-        cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
-
-        TEST_CYCLE()
-        {
-            cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
-        }
+        TEST_CYCLE() cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
 
-        cv::Mat h_circles(d_circles);
-        cv::Vec3f* begin = (cv::Vec3f*)(h_circles.ptr<char>(0));
-        cv::Vec3f* end = (cv::Vec3f*)(h_circles.ptr<char>(0) + (h_circles.cols) * 3 * sizeof(float));
+        cv::Mat gpu_circles(d_circles);
+        cv::Vec3f* begin = gpu_circles.ptr<cv::Vec3f>(0);
+        cv::Vec3f* end = begin + gpu_circles.cols;
         std::sort(begin, end, Vec3fComparator());
-        SANITY_CHECK(h_circles);
+        SANITY_CHECK(gpu_circles);
     }
     else
     {
-        std::vector<cv::Vec3f> circles;
+        std::vector<cv::Vec3f> cpu_circles;
 
-        cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
+        TEST_CYCLE() cv::HoughCircles(src, cpu_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
 
-        TEST_CYCLE()
-        {
-            cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
-        }
-
-        std::sort(circles.begin(), circles.end(), Vec3fComparator());
-        SANITY_CHECK(circles);
+        SANITY_CHECK(cpu_circles);
     }
 }
 
@@ -1923,9 +1691,9 @@ CV_FLAGS(GHMethod, cv::GHT_POSITION, cv::GHT_SCALE, cv::GHT_ROTATION);
 
 DEF_PARAM_TEST(Method_Sz, GHMethod, cv::Size);
 
-PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
-            Values(GHMethod(cv::GHT_POSITION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE), GHMethod(cv::GHT_POSITION | cv::GHT_ROTATION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE | cv::GHT_ROTATION)),
-            GPU_TYPICAL_MAT_SIZES))
+PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough,
+            Combine(Values(GHMethod(cv::GHT_POSITION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE), GHMethod(cv::GHT_POSITION | cv::GHT_ROTATION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE | cv::GHT_ROTATION)),
+                    GPU_TYPICAL_MAT_SIZES))
 {
     declare.time(10);
 
@@ -1936,6 +1704,7 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
     ASSERT_FALSE(templ.empty());
 
     cv::Mat image(imageSize, CV_8UC1, cv::Scalar::all(0));
+    templ.copyTo(image(cv::Rect(50, 50, templ.cols, templ.rows)));
 
     cv::RNG rng(123456789);
     const int objCount = rng.uniform(5, 15);
@@ -1967,10 +1736,10 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_edges(edges);
-        cv::gpu::GpuMat d_dx(dx);
-        cv::gpu::GpuMat d_dy(dy);
-        cv::gpu::GpuMat d_position;
+        const cv::gpu::GpuMat d_edges(edges);
+        const cv::gpu::GpuMat d_dx(dx);
+        const cv::gpu::GpuMat d_dy(dy);
+        cv::gpu::GpuMat posAndVotes;
 
         cv::Ptr<cv::gpu::GeneralizedHough_GPU> d_hough = cv::gpu::GeneralizedHough_GPU::create(method);
         if (method & cv::GHT_ROTATION)
@@ -1981,14 +1750,10 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
 
         d_hough->setTemplate(cv::gpu::GpuMat(templ));
 
-        d_hough->detect(d_edges, d_dx, d_dy, d_position);
-
-        TEST_CYCLE()
-        {
-            d_hough->detect(d_edges, d_dx, d_dy, d_position);
-        }
+        TEST_CYCLE() d_hough->detect(d_edges, d_dx, d_dy, posAndVotes);
 
-        GPU_SANITY_CHECK(d_position);
+        const cv::gpu::GpuMat positions(1, posAndVotes.cols, CV_32FC4, posAndVotes.data);
+        GPU_SANITY_CHECK(positions);
     }
     else
     {
@@ -2003,16 +1768,8 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
 
         hough->setTemplate(templ);
 
-        hough->detect(edges, dx, dy, positions);
+        TEST_CYCLE() hough->detect(edges, dx, dy, positions);
 
-        TEST_CYCLE()
-        {
-            hough->detect(edges, dx, dy, positions);
-        }
-
-        CPU_SANITY_CHECK(dx);
-        CPU_SANITY_CHECK(dy);
+        CPU_SANITY_CHECK(positions);
     }
 }
-
-} // namespace
index 3b10ba3bef9e09c3be568b03d78d2088030d7dd7..15d286bafe66157f7a9b5359609b3779e826ea10 100644 (file)
@@ -3,8 +3,6 @@
 using namespace std;
 using namespace testing;
 
-namespace {
-
 DEF_PARAM_TEST_1(Image, string);
 
 struct GreedyLabeling
@@ -100,28 +98,45 @@ struct GreedyLabeling
     dot* stack;
 };
 
-PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/aloe-disp.png"))
+PERF_TEST_P(Image, Labeling_ConnectivityMask,
+            Values<string>("gpu/labeling/aloe-disp.png"))
 {
     declare.time(1.0);
 
-    cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    const cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    ASSERT_FALSE(image.empty());
 
     if (PERF_RUN_GPU())
     {
+        cv::gpu::GpuMat d_image(image);
         cv::gpu::GpuMat mask;
-        mask.create(image.rows, image.cols, CV_8UC1);
 
-        cv::gpu::GpuMat components;
-        components.create(image.rows, image.cols, CV_32SC1);
+        TEST_CYCLE() cv::gpu::connectivityMask(d_image, mask, cv::Scalar::all(0), cv::Scalar::all(2));
 
-        cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
+        GPU_SANITY_CHECK(mask);
+    }
+    else
+    {
+        FAIL_NO_CPU();
+    }
+}
 
-        ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
+PERF_TEST_P(Image, Labeling_ConnectedComponents,
+            Values<string>("gpu/labeling/aloe-disp.png"))
+{
+    declare.time(1.0);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::labelComponents(mask, components);
-        }
+    const cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    ASSERT_FALSE(image.empty());
+
+    if (PERF_RUN_GPU())
+    {
+        cv::gpu::GpuMat d_mask;
+        cv::gpu::connectivityMask(cv::gpu::GpuMat(image), d_mask, cv::Scalar::all(0), cv::Scalar::all(2));
+
+        cv::gpu::GpuMat components;
+
+        TEST_CYCLE() cv::gpu::labelComponents(d_mask, components);
 
         GPU_SANITY_CHECK(components);
     }
@@ -129,17 +144,9 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
     {
         GreedyLabeling host(image);
 
-        host(host._labels);
+        TEST_CYCLE() host(host._labels);
 
-        declare.time(1.0);
-
-        TEST_CYCLE()
-        {
-            host(host._labels);
-        }
-
-        CPU_SANITY_CHECK(host._labels);
+        cv::Mat components = host._labels;
+        CPU_SANITY_CHECK(components);
     }
 }
-
-} // namespace
index f8eb23d098f401d61cd25e0aebcba6510e20d1b5..312b744482b6ba4ef9882c4c434876c6303413b5 100644 (file)
@@ -1,7 +1,5 @@
 #include "perf_precomp.hpp"
 
-namespace{
-
 static void printOsInfo()
 {
 #if defined _WIN32
@@ -69,6 +67,4 @@ static void printCudaInfo()
 #endif
 }
 
-}
-
-CV_PERF_TEST_MAIN(gpu, printCudaInfo())
\ No newline at end of file
+CV_PERF_TEST_MAIN(gpu, printCudaInfo())
index b6d4a110f99d11e5ef209bd7a1afa4d595b3ee34..aeea1b5181390dd268997e49366780a0f8787308 100644 (file)
 using namespace std;
 using namespace testing;
 
-namespace {
-
 //////////////////////////////////////////////////////////////////////
 // SetTo
 
-PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    GPU_CHANNELS_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::Scalar val(1, 2, 3, 4);
+    const cv::Scalar val(1, 2, 3, 4);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(size, type);
-
-        d_src.setTo(val);
+        cv::gpu::GpuMat dst(size, type);
 
-        TEST_CYCLE()
-        {
-            d_src.setTo(val);
-        }
+        TEST_CYCLE() dst.setTo(val);
 
-        GPU_SANITY_CHECK(d_src);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        cv::Mat src(size, type);
+        cv::Mat dst(size, type);
 
-        src.setTo(val);
+        TEST_CYCLE() dst.setTo(val);
 
-        TEST_CYCLE()
-        {
-            src.setTo(val);
-        }
-
-        CPU_SANITY_CHECK(src);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // SetToMasked
 
-PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    GPU_CHANNELS_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::Mat mask(size, CV_8UC1);
-    fillRandom(mask, 0, 2);
+    declare.in(src, mask, WARMUP_RNG);
 
-    cv::Scalar val(1, 2, 3, 4);
+    const cv::Scalar val(1, 2, 3, 4);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_mask(mask);
-
-        d_src.setTo(val, d_mask);
+        cv::gpu::GpuMat dst(src);
+        const cv::gpu::GpuMat d_mask(mask);
 
-        TEST_CYCLE()
-        {
-            d_src.setTo(val, d_mask);
-        }
+        TEST_CYCLE() dst.setTo(val, d_mask);
 
-        GPU_SANITY_CHECK(d_src);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        src.setTo(val, mask);
+        cv::Mat dst = src;
 
-        TEST_CYCLE()
-        {
-            src.setTo(val, mask);
-        }
+        TEST_CYCLE() dst.setTo(val, mask);
 
-        CPU_SANITY_CHECK(src);
+        CPU_SANITY_CHECK(dst);
     }
 }
 
 //////////////////////////////////////////////////////////////////////
 // CopyToMasked
 
-PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    GPU_CHANNELS_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::Mat mask(size, CV_8UC1);
-    fillRandom(mask, 0, 2);
+    declare.in(src, mask, WARMUP_RNG);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_mask(mask);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        const cv::gpu::GpuMat d_mask(mask);
+        cv::gpu::GpuMat dst(d_src.size(), d_src.type(), cv::Scalar::all(0));
 
-        d_src.copyTo(d_dst, d_mask);
+        TEST_CYCLE() d_src.copyTo(dst, d_mask);
 
-        TEST_CYCLE()
-        {
-            d_src.copyTo(d_dst, d_mask);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
-        cv::Mat dst;
+        cv::Mat dst(src.size(), src.type(), cv::Scalar::all(0));
 
-        src.copyTo(dst, mask);
-
-        TEST_CYCLE()
-        {
-            src.copyTo(dst, mask);
-        }
+        TEST_CYCLE() src.copyTo(dst, mask);
 
         CPU_SANITY_CHECK(dst);
     }
@@ -144,42 +119,36 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu
 
 DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
 
-PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F)))
+PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo,
+            Combine(GPU_TYPICAL_MAT_SIZES,
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F),
+                    Values(CV_8U, CV_16U, CV_32F, CV_64F)))
 {
-    cv::Size size = GET_PARAM(0);
-    int depth1 = GET_PARAM(1);
-    int depth2 = GET_PARAM(2);
+    const cv::Size size = GET_PARAM(0);
+    const int depth1 = GET_PARAM(1);
+    const int depth2 = GET_PARAM(2);
 
     cv::Mat src(size, depth1);
-    fillRandom(src);
+    declare.in(src, WARMUP_RNG);
+
+    const double a = 0.5;
+    const double b = 1.0;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_src(src);
-        cv::gpu::GpuMat d_dst;
+        const cv::gpu::GpuMat d_src(src);
+        cv::gpu::GpuMat dst;
 
-        d_src.convertTo(d_dst, depth2, 0.5, 1.0);
+        TEST_CYCLE() d_src.convertTo(dst, depth2, a, b);
 
-        TEST_CYCLE()
-        {
-            d_src.convertTo(d_dst, depth2, 0.5, 1.0);
-        }
-
-        GPU_SANITY_CHECK(d_dst);
+        GPU_SANITY_CHECK(dst);
     }
     else
     {
         cv::Mat dst;
 
-        src.convertTo(dst, depth2, 0.5, 1.0);
-
-        TEST_CYCLE()
-        {
-            src.convertTo(dst, depth2, 0.5, 1.0);
-        }
+        TEST_CYCLE() src.convertTo(dst, depth2, a, b);
 
         CPU_SANITY_CHECK(dst);
     }
 }
-
-} // namespace
index 6d040ac02fa623dc215d716dd99a3da6a5ac280c..969ac107626cef3419bcb1a338ddfcd2d84368eb 100644 (file)
@@ -3,90 +3,47 @@
 using namespace std;
 using namespace testing;
 
-namespace {
-
 ///////////////////////////////////////////////////////////////
 // HOG
 
 DEF_PARAM_TEST_1(Image, string);
 
-PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
+PERF_TEST_P(Image, ObjDetect_HOG,
+            Values<string>("gpu/hog/road.png",
+                           "gpu/caltech/image_00000009_0.png",
+                           "gpu/caltech/image_00000032_0.png",
+                           "gpu/caltech/image_00000165_0.png",
+                           "gpu/caltech/image_00000261_0.png",
+                           "gpu/caltech/image_00000469_0.png",
+                           "gpu/caltech/image_00000527_0.png",
+                           "gpu/caltech/image_00000574_0.png"))
 {
-    cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
+    const cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
 
-    std::vector<cv::Rect> found_locations;
-
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_img(img);
+        const cv::gpu::GpuMat d_img(img);
+        std::vector<cv::Rect> gpu_found_locations;
 
         cv::gpu::HOGDescriptor d_hog;
         d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
 
-        d_hog.detectMultiScale(d_img, found_locations);
+        TEST_CYCLE() d_hog.detectMultiScale(d_img, gpu_found_locations);
 
-        TEST_CYCLE()
-        {
-            d_hog.detectMultiScale(d_img, found_locations);
-        }
+        SANITY_CHECK(gpu_found_locations);
     }
     else
     {
-        cv::HOGDescriptor hog;
-        hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
-
-        hog.detectMultiScale(img, found_locations);
-
-        TEST_CYCLE()
-        {
-            hog.detectMultiScale(img, found_locations);
-        }
-    }
-
-    SANITY_CHECK(found_locations);
-}
-
-//===========test for CalTech data =============//
-DEF_PARAM_TEST_1(HOG, string);
-
-PERF_TEST_P(HOG, CalTech, Values<string>("gpu/caltech/image_00000009_0.png", "gpu/caltech/image_00000032_0.png",
-    "gpu/caltech/image_00000165_0.png", "gpu/caltech/image_00000261_0.png", "gpu/caltech/image_00000469_0.png",
-    "gpu/caltech/image_00000527_0.png", "gpu/caltech/image_00000574_0.png"))
-{
-    cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
-    ASSERT_FALSE(img.empty());
-
-    std::vector<cv::Rect> found_locations;
-
-    if (PERF_RUN_GPU())
-    {
-        cv::gpu::GpuMat d_img(img);
-
-        cv::gpu::HOGDescriptor d_hog;
-        d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
-
-        d_hog.detectMultiScale(d_img, found_locations);
+        std::vector<cv::Rect> cpu_found_locations;
 
-        TEST_CYCLE()
-        {
-            d_hog.detectMultiScale(d_img, found_locations);
-        }
-    }
-    else
-    {
         cv::HOGDescriptor hog;
         hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
 
-        hog.detectMultiScale(img, found_locations);
+        TEST_CYCLE() hog.detectMultiScale(img, cpu_found_locations);
 
-        TEST_CYCLE()
-        {
-            hog.detectMultiScale(img, found_locations);
-        }
+        SANITY_CHECK(cpu_found_locations);
     }
-
-    SANITY_CHECK(found_locations);
 }
 
 ///////////////////////////////////////////////////////////////
@@ -96,9 +53,9 @@ typedef pair<string, string> pair_string;
 DEF_PARAM_TEST_1(ImageAndCascade, pair_string);
 
 PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
-    Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/perf/haarcascade_frontalface_alt.xml")))
+            Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/perf/haarcascade_frontalface_alt.xml")))
 {
-    cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
 
     if (PERF_RUN_GPU())
@@ -106,33 +63,28 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
         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;
+        const cv::gpu::GpuMat d_img(img);
+        cv::gpu::GpuMat objects_buffer;
+        int detections_num = 0;
 
-        d_cascade.detectMultiScale(d_img, d_objects_buffer);
+        TEST_CYCLE() detections_num = d_cascade.detectMultiScale(d_img, objects_buffer);
 
-        TEST_CYCLE()
-        {
-            d_cascade.detectMultiScale(d_img, d_objects_buffer);
-        }
-
-        GPU_SANITY_CHECK(d_objects_buffer);
+        std::vector<cv::Rect> gpu_rects(detections_num);
+        cv::Mat gpu_rects_mat(1, detections_num, cv::DataType<cv::Rect>::type, &gpu_rects[0]);
+        objects_buffer.colRange(0, detections_num).download(gpu_rects_mat);
+        cv::groupRectangles(gpu_rects, 3, 0.2);
+        SANITY_CHECK(gpu_rects);
     }
     else
     {
         cv::CascadeClassifier cascade;
         ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
 
-        std::vector<cv::Rect> rects;
-
-        cascade.detectMultiScale(img, rects);
+        std::vector<cv::Rect> cpu_rects;
 
-        TEST_CYCLE()
-        {
-            cascade.detectMultiScale(img, rects);
-        }
+        TEST_CYCLE() cascade.detectMultiScale(img, cpu_rects);
 
-        CPU_SANITY_CHECK(rects);
+        SANITY_CHECK(cpu_rects);
     }
 }
 
@@ -140,9 +92,9 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
 // LBP cascade
 
 PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
-    Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml")))
+            Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml")))
 {
-    cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(img.empty());
 
     if (PERF_RUN_GPU())
@@ -150,34 +102,27 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
         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;
+        const cv::gpu::GpuMat d_img(img);
+        cv::gpu::GpuMat objects_buffer;
+        int detections_num = 0;
 
-        d_cascade.detectMultiScale(d_img, d_gpu_rects);
+        TEST_CYCLE() detections_num = d_cascade.detectMultiScale(d_img, objects_buffer);
 
-        TEST_CYCLE()
-        {
-            d_cascade.detectMultiScale(d_img, d_gpu_rects);
-        }
-
-        GPU_SANITY_CHECK(d_gpu_rects);
+        std::vector<cv::Rect> gpu_rects(detections_num);
+        cv::Mat gpu_rects_mat(1, detections_num, cv::DataType<cv::Rect>::type, &gpu_rects[0]);
+        objects_buffer.colRange(0, detections_num).download(gpu_rects_mat);
+        cv::groupRectangles(gpu_rects, 3, 0.2);
+        SANITY_CHECK(gpu_rects);
     }
     else
     {
         cv::CascadeClassifier cascade;
         ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
 
-        std::vector<cv::Rect> rects;
-
-        cascade.detectMultiScale(img, rects);
+        std::vector<cv::Rect> cpu_rects;
 
-        TEST_CYCLE()
-        {
-            cascade.detectMultiScale(img, rects);
-        }
+        TEST_CYCLE() cascade.detectMultiScale(img, cpu_rects);
 
-        CPU_SANITY_CHECK(rects);
+        SANITY_CHECK(cpu_rects);
     }
 }
-
-} // namespace
\ No newline at end of file
index 83213a161365ccac1ded19a5fb8013d15b436005..7d8fed623168a39de35f2d3bf5b4746c19092149 100644 (file)
@@ -2,6 +2,7 @@
 
 using namespace std;
 using namespace testing;
+using namespace perf;
 
 namespace cv
 {
@@ -11,60 +12,15 @@ namespace cv
     }
 }
 
-namespace {
-
 //////////////////////////////////////////////////////
-// BroxOpticalFlow
+// InterpolateFrames
 
 typedef pair<string, string> pair_string;
 
 DEF_PARAM_TEST_1(ImagePair, pair_string);
 
-PERF_TEST_P(ImagePair, Video_BroxOpticalFlow,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
-{
-    declare.time(10);
-
-    cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
-    ASSERT_FALSE(frame0.empty());
-
-    cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
-    ASSERT_FALSE(frame1.empty());
-
-    frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
-    frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
-
-    if (PERF_RUN_GPU())
-    {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_u;
-        cv::gpu::GpuMat d_v;
-
-        cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
-                                        10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
-
-        d_flow(d_frame0, d_frame1, d_u, d_v);
-
-        TEST_CYCLE()
-        {
-            d_flow(d_frame0, d_frame1, d_u, d_v);
-        }
-
-        GPU_SANITY_CHECK(d_u);
-        GPU_SANITY_CHECK(d_v);
-    }
-    else
-    {
-        FAIL() << "No such CPU implementation analogy";
-    }
-}
-
-//////////////////////////////////////////////////////
-// InterpolateFrames
-
 PERF_TEST_P(ImagePair, Video_InterpolateFrames,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
@@ -77,8 +33,8 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames,
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
         cv::gpu::GpuMat d_fu, d_fv;
         cv::gpu::GpuMat d_bu, d_bv;
 
@@ -88,24 +44,16 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames,
         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 newFrame;
         cv::gpu::GpuMat d_buf;
 
-        cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
+        TEST_CYCLE() cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, newFrame, d_buf);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
-        }
-
-        GPU_SANITY_CHECK(d_fu);
-        GPU_SANITY_CHECK(d_fv);
-        GPU_SANITY_CHECK(d_bu);
-        GPU_SANITY_CHECK(d_bv);
+        GPU_SANITY_CHECK(newFrame);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -113,7 +61,7 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames,
 // CreateOpticalFlowNeedleMap
 
 PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
@@ -126,31 +74,26 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_u;
-        cv::gpu::GpuMat d_v;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u;
+        cv::gpu::GpuMat v;
 
         cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
                                         10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
 
-        d_flow(d_frame0, d_frame1, d_u, d_v);
-
-        cv::gpu::GpuMat d_vertex, d_colors;
+        d_flow(d_frame0, d_frame1, u, v);
 
-        cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
+        cv::gpu::GpuMat vertex, colors;
 
-        TEST_CYCLE()
-        {
-            cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
-        }
+        TEST_CYCLE() cv::gpu::createOpticalFlowNeedleMap(u, v, vertex, colors);
 
-        GPU_SANITY_CHECK(d_vertex);
-        GPU_SANITY_CHECK(d_colors);
+        GPU_SANITY_CHECK(vertex);
+        GPU_SANITY_CHECK(colors);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -160,71 +103,103 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
 DEF_PARAM_TEST(Image_MinDistance, string, double);
 
 PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack,
-    Combine(Values<string>("gpu/perf/aloe.png"), Values(0.0, 3.0)))
+            Combine(Values<string>("gpu/perf/aloe.png"),
+                    Values(0.0, 3.0)))
 {
-    string fileName = GET_PARAM(0);
-    double minDistance = GET_PARAM(1);
+    const string fileName = GET_PARAM(0);
+    const double minDistance = GET_PARAM(1);
 
-    cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
+    const cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(image.empty());
 
+    const int maxCorners = 8000;
+    const double qualityLevel = 0.01;
+
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
-
-        cv::gpu::GpuMat d_image(image);
-        cv::gpu::GpuMat d_pts;
+        cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(maxCorners, qualityLevel, minDistance);
 
-        d_detector(d_image, d_pts);
+        const cv::gpu::GpuMat d_image(image);
+        cv::gpu::GpuMat pts;
 
-        TEST_CYCLE()
-        {
-            d_detector(d_image, d_pts);
-        }
+        TEST_CYCLE() d_detector(d_image, pts);
 
-        GPU_SANITY_CHECK(d_pts);
+        GPU_SANITY_CHECK(pts);
     }
     else
     {
         cv::Mat pts;
 
-        cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
-
-        TEST_CYCLE()
-        {
-            cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
-        }
+        TEST_CYCLE() cv::goodFeaturesToTrack(image, pts, maxCorners, qualityLevel, minDistance);
 
         CPU_SANITY_CHECK(pts);
     }
 }
 
+//////////////////////////////////////////////////////
+// BroxOpticalFlow
+
+PERF_TEST_P(ImagePair, Video_BroxOpticalFlow,
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+{
+    declare.time(10);
+
+    cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    ASSERT_FALSE(frame0.empty());
+
+    cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
+    ASSERT_FALSE(frame1.empty());
+
+    frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
+    frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
+
+    if (PERF_RUN_GPU())
+    {
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u;
+        cv::gpu::GpuMat v;
+
+        cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
+                                        10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
+
+        TEST_CYCLE() d_flow(d_frame0, d_frame1, u, v);
+
+        GPU_SANITY_CHECK(u);
+        GPU_SANITY_CHECK(v);
+    }
+    else
+    {
+        FAIL_NO_CPU();
+    }
+}
+
 //////////////////////////////////////////////////////
 // PyrLKOpticalFlowSparse
 
 DEF_PARAM_TEST(ImagePair_Gray_NPts_WinSz_Levels_Iters, pair_string, bool, int, int, int, int);
 
-PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse, Combine(
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
-    Bool(),
-    Values(1000, 2000, 4000, 8000),
-    Values(9, 13, 17, 21),
-    Values(1, 2, 3),
-    Values(1, 10, 30)))
+PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse,
+            Combine(Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
+                    Bool(),
+                    Values(8000),
+                    Values(21),
+                    Values(1, 3),
+                    Values(1, 30)))
 {
     declare.time(20.0);
 
-    pair_string imagePair = GET_PARAM(0);
-    bool useGray = GET_PARAM(1);
-    int points = GET_PARAM(2);
-    int winSize = GET_PARAM(3);
-    int levels = GET_PARAM(4);
-    int iters = GET_PARAM(5);
+    const pair_string imagePair = GET_PARAM(0);
+    const bool useGray = GET_PARAM(1);
+    const int points = GET_PARAM(2);
+    const int winSize = GET_PARAM(3);
+    const int levels = GET_PARAM(4);
+    const int iters = GET_PARAM(5);
 
-    cv::Mat frame0 = readImage(imagePair.first, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
+    const cv::Mat frame0 = readImage(imagePair.first, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
     ASSERT_FALSE(frame0.empty());
 
-    cv::Mat frame1 = readImage(imagePair.second, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
+    const cv::Mat frame1 = readImage(imagePair.second, useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
     ASSERT_FALSE(frame1.empty());
 
     cv::Mat gray_frame;
@@ -238,36 +213,28 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
+        const cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
 
         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;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat nextPts;
+        cv::gpu::GpuMat status;
 
-        d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
+        TEST_CYCLE() d_pyrLK.sparse(d_frame0, d_frame1, d_pts, nextPts, status);
 
-        TEST_CYCLE()
-        {
-            d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
-        }
-
-        GPU_SANITY_CHECK(d_status);
+        GPU_SANITY_CHECK(nextPts);
+        GPU_SANITY_CHECK(status);
     }
     else
     {
         cv::Mat nextPts;
         cv::Mat status;
 
-        cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
-                                 cv::Size(winSize, winSize), levels - 1,
-                                 cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
-
         TEST_CYCLE()
         {
             cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
@@ -275,6 +242,7 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
                                      cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
         }
 
+        CPU_SANITY_CHECK(nextPts);
         CPU_SANITY_CHECK(status);
     }
 }
@@ -284,50 +252,45 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
 
 DEF_PARAM_TEST(ImagePair_WinSz_Levels_Iters, pair_string, int, int, int);
 
-PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
-    Values(3, 5, 7, 9, 13, 17, 21),
-    Values(1, 2, 3),
-    Values(1, 10)))
+PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense,
+            Combine(Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")),
+                    Values(3, 5, 7, 9, 13, 17, 21),
+                    Values(1, 3),
+                    Values(1, 10)))
 {
     declare.time(30);
 
-    pair_string imagePair = GET_PARAM(0);
-    int winSize = GET_PARAM(1);
-    int levels = GET_PARAM(2);
-    int iters = GET_PARAM(3);
+    const pair_string imagePair = GET_PARAM(0);
+    const int winSize = GET_PARAM(1);
+    const int levels = GET_PARAM(2);
+    const int iters = GET_PARAM(3);
 
-    cv::Mat frame0 = readImage(imagePair.first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame0 = readImage(imagePair.first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
 
-    cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame1.empty());
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_u;
-        cv::gpu::GpuMat d_v;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u;
+        cv::gpu::GpuMat v;
 
         cv::gpu::PyrLKOpticalFlow d_pyrLK;
         d_pyrLK.winSize = cv::Size(winSize, winSize);
         d_pyrLK.maxLevel = levels - 1;
         d_pyrLK.iters = iters;
 
-        d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
-
-        TEST_CYCLE()
-        {
-            d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
-        }
+        TEST_CYCLE() d_pyrLK.dense(d_frame0, d_frame1, u, v);
 
-        GPU_SANITY_CHECK(d_u);
-        GPU_SANITY_CHECK(d_v);
+        GPU_SANITY_CHECK(u);
+        GPU_SANITY_CHECK(v);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -335,30 +298,30 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
 // FarnebackOpticalFlow
 
 PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     declare.time(10);
 
-    cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
 
-    cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame1.empty());
 
-    int numLevels = 5;
-    double pyrScale = 0.5;
-    int winSize = 13;
-    int numIters = 10;
-    int polyN = 5;
-    double polySigma = 1.1;
-    int flags = 0;
+    const int numLevels = 5;
+    const double pyrScale = 0.5;
+    const int winSize = 13;
+    const int numIters = 10;
+    const int polyN = 5;
+    const double polySigma = 1.1;
+    const int flags = 0;
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_u;
-        cv::gpu::GpuMat d_v;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u;
+        cv::gpu::GpuMat v;
 
         cv::gpu::FarnebackOpticalFlow d_farneback;
         d_farneback.numLevels = numLevels;
@@ -369,26 +332,16 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow,
         d_farneback.polySigma = polySigma;
         d_farneback.flags = flags;
 
-        d_farneback(d_frame0, d_frame1, d_u, d_v);
+        TEST_CYCLE() d_farneback(d_frame0, d_frame1, u, v);
 
-        TEST_CYCLE()
-        {
-            d_farneback(d_frame0, d_frame1, d_u, d_v);
-        }
-
-        GPU_SANITY_CHECK(d_u);
-        GPU_SANITY_CHECK(d_v);
+        GPU_SANITY_CHECK(u, 1e-4);
+        GPU_SANITY_CHECK(v, 1e-4);
     }
     else
     {
         cv::Mat flow;
 
-        cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
-
-        TEST_CYCLE()
-        {
-            cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
-        }
+        TEST_CYCLE() cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
 
         CPU_SANITY_CHECK(flow);
     }
@@ -398,34 +351,29 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow,
 // OpticalFlowDual_TVL1
 
 PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     declare.time(20);
 
-    cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
 
-    cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame1.empty());
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_flowx;
-        cv::gpu::GpuMat d_flowy;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u;
+        cv::gpu::GpuMat v;
 
         cv::gpu::OpticalFlowDual_TVL1_GPU d_alg;
 
-        d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
+        TEST_CYCLE() d_alg(d_frame0, d_frame1, u, v);
 
-        TEST_CYCLE()
-        {
-            d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
-        }
-
-        GPU_SANITY_CHECK(d_flowx);
-        GPU_SANITY_CHECK(d_flowy);
+        GPU_SANITY_CHECK(u);
+        GPU_SANITY_CHECK(v);
     }
     else
     {
@@ -433,12 +381,7 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
 
         cv::Ptr<cv::DenseOpticalFlow> alg = cv::createOptFlow_DualTVL1();
 
-        alg->calc(frame0, frame1, flow);
-
-        TEST_CYCLE()
-        {
-            alg->calc(frame0, frame1, flow);
-        }
+        TEST_CYCLE() alg->calc(frame0, frame1, flow);
 
         CPU_SANITY_CHECK(flow);
     }
@@ -466,98 +409,73 @@ void calcOpticalFlowBM(const cv::Mat& prev, const cv::Mat& curr,
 }
 
 PERF_TEST_P(ImagePair, Video_OpticalFlowBM,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     declare.time(400);
 
-    cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
 
-    cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame1.empty());
 
-    cv::Size block_size(16, 16);
-    cv::Size shift_size(1, 1);
-    cv::Size max_range(16, 16);
+    const cv::Size block_size(16, 16);
+    const cv::Size shift_size(1, 1);
+    const cv::Size max_range(16, 16);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_velx, d_vely, buf;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u, v, buf;
 
-        cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
+        TEST_CYCLE() cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, u, v, buf);
 
-        TEST_CYCLE()
-        {
-            cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
-        }
-
-        GPU_SANITY_CHECK(d_velx);
-        GPU_SANITY_CHECK(d_vely);
+        GPU_SANITY_CHECK(u);
+        GPU_SANITY_CHECK(v);
     }
     else
     {
-        cv::Mat velx, vely;
-
-        calcOpticalFlowBM(frame0, frame1, block_size, shift_size, max_range, false, velx, vely);
+        cv::Mat u, v;
 
-        TEST_CYCLE()
-        {
-            calcOpticalFlowBM(frame0, frame1, block_size, shift_size, max_range, false, velx, vely);
-        }
+        TEST_CYCLE() calcOpticalFlowBM(frame0, frame1, block_size, shift_size, max_range, false, u, v);
 
-        CPU_SANITY_CHECK(velx);
-        CPU_SANITY_CHECK(vely);
+        CPU_SANITY_CHECK(u);
+        CPU_SANITY_CHECK(v);
     }
 }
 
 PERF_TEST_P(ImagePair, Video_FastOpticalFlowBM,
-    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     declare.time(400);
 
-    cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
 
-    cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
+    const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame1.empty());
 
-    cv::Size block_size(16, 16);
-    cv::Size shift_size(1, 1);
-    cv::Size max_range(16, 16);
+    const cv::Size block_size(16, 16);
+    const cv::Size shift_size(1, 1);
+    const cv::Size max_range(16, 16);
 
     if (PERF_RUN_GPU())
     {
-        cv::gpu::GpuMat d_frame0(frame0);
-        cv::gpu::GpuMat d_frame1(frame1);
-        cv::gpu::GpuMat d_velx, d_vely;
+        const cv::gpu::GpuMat d_frame0(frame0);
+        const cv::gpu::GpuMat d_frame1(frame1);
+        cv::gpu::GpuMat u, v;
 
         cv::gpu::FastOpticalFlowBM fastBM;
 
-        fastBM(d_frame0, d_frame1, d_velx, d_vely, max_range.width, block_size.width);
-
-        TEST_CYCLE()
-        {
-            fastBM(d_frame0, d_frame1, d_velx, d_vely, max_range.width, block_size.width);
-        }
+        TEST_CYCLE() fastBM(d_frame0, d_frame1, u, v, max_range.width, block_size.width);
 
-        GPU_SANITY_CHECK(d_velx);
-        GPU_SANITY_CHECK(d_vely);
+        GPU_SANITY_CHECK(u);
+        GPU_SANITY_CHECK(v);
     }
     else
     {
-        cv::Mat velx, vely;
-
-        calcOpticalFlowBM(frame0, frame1, block_size, shift_size, max_range, false, velx, vely);
-
-        TEST_CYCLE()
-        {
-            calcOpticalFlowBM(frame0, frame1, block_size, shift_size, max_range, false, velx, vely);
-        }
-
-        CPU_SANITY_CHECK(velx);
-        CPU_SANITY_CHECK(vely);
+        FAIL_NO_CPU();
     }
 }
 
@@ -566,11 +484,12 @@ PERF_TEST_P(ImagePair, Video_FastOpticalFlowBM,
 
 DEF_PARAM_TEST_1(Video, string);
 
-PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
+PERF_TEST_P(Video, Video_FGDStatModel,
+            Values(string("gpu/video/768x576.avi")))
 {
     declare.time(60);
 
-    string inputFile = perf::TestBase::getDataPath(GetParam());
+    const string inputFile = perf::TestBase::getDataPath(GetParam());
 
     cv::VideoCapture cap(inputFile);
     ASSERT_TRUE(cap.isOpened());
@@ -597,6 +516,12 @@ PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi",
             d_model.update(d_frame);
             stopTimer();
         }
+
+        const cv::gpu::GpuMat background = d_model.background;
+        const cv::gpu::GpuMat foreground = d_model.foreground;
+
+        GPU_SANITY_CHECK(background, 1e-2, ERROR_RELATIVE);
+        GPU_SANITY_CHECK(foreground, 1e-2, ERROR_RELATIVE);
     }
     else
     {
@@ -614,6 +539,12 @@ PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi",
             cvUpdateBGStatModel(&ipl_frame, model);
             stopTimer();
         }
+
+        const cv::Mat background = model->background;
+        const cv::Mat foreground = model->foreground;
+
+        CPU_SANITY_CHECK(background);
+        CPU_SANITY_CHECK(foreground);
     }
 }
 
@@ -622,12 +553,14 @@ PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi",
 
 DEF_PARAM_TEST(Video_Cn_LearningRate, string, MatCn, double);
 
-PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
-    Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(0.0, 0.01)))
+PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
+            Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
+                    GPU_CHANNELS_1_3_4,
+                    Values(0.0, 0.01)))
 {
-    string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
-    int cn = GET_PARAM(1);
-    float learningRate = static_cast<float>(GET_PARAM(2));
+    const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
+    const int cn = GET_PARAM(1);
+    const float learningRate = static_cast<float>(GET_PARAM(2));
 
     cv::VideoCapture cap(inputFile);
     ASSERT_TRUE(cap.isOpened());
@@ -651,9 +584,9 @@ PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
     {
         cv::gpu::GpuMat d_frame(frame);
         cv::gpu::MOG_GPU d_mog;
-        cv::gpu::GpuMat d_foreground;
+        cv::gpu::GpuMat foreground;
 
-        d_mog(d_frame, d_foreground, learningRate);
+        d_mog(d_frame, foreground, learningRate);
 
         for (int i = 0; i < 10; ++i)
         {
@@ -673,9 +606,11 @@ PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
             d_frame.upload(frame);
 
             startTimer(); next();
-            d_mog(d_frame, d_foreground, learningRate);
+            d_mog(d_frame, foreground, learningRate);
             stopTimer();
         }
+
+        GPU_SANITY_CHECK(foreground);
     }
     else
     {
@@ -703,6 +638,8 @@ PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
             mog(frame, foreground, learningRate);
             stopTimer();
         }
+
+        CPU_SANITY_CHECK(foreground);
     }
 }
 
@@ -711,11 +648,12 @@ PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
 
 DEF_PARAM_TEST(Video_Cn, string, int);
 
-PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
-    Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Video_Cn, Video_MOG2,
+            Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
+                    GPU_CHANNELS_1_3_4))
 {
-    string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
-    int cn = GET_PARAM(1);
+    const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
+    const int cn = GET_PARAM(1);
 
     cv::VideoCapture cap(inputFile);
     ASSERT_TRUE(cap.isOpened());
@@ -739,9 +677,9 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
     {
         cv::gpu::GpuMat d_frame(frame);
         cv::gpu::MOG2_GPU d_mog2;
-        cv::gpu::GpuMat d_foreground;
+        cv::gpu::GpuMat foreground;
 
-        d_mog2(d_frame, d_foreground);
+        d_mog2(d_frame, foreground);
 
         for (int i = 0; i < 10; ++i)
         {
@@ -761,9 +699,11 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
             d_frame.upload(frame);
 
             startTimer(); next();
-            d_mog2(d_frame, d_foreground);
+            d_mog2(d_frame, foreground);
             stopTimer();
         }
+
+        GPU_SANITY_CHECK(foreground);
     }
     else
     {
@@ -791,6 +731,8 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
             mog2(frame, foreground);
             stopTimer();
         }
+
+        CPU_SANITY_CHECK(foreground);
     }
 }
 
@@ -798,10 +740,11 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
 // MOG2GetBackgroundImage
 
 PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
-    Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
+            Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
+                    GPU_CHANNELS_1_3_4))
 {
-    string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
-    int cn = GET_PARAM(1);
+    const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
+    const int cn = GET_PARAM(1);
 
     cv::VideoCapture cap(inputFile);
     ASSERT_TRUE(cap.isOpened());
@@ -834,15 +777,11 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
             d_mog2(d_frame, d_foreground);
         }
 
-        cv::gpu::GpuMat d_background;
-        d_mog2.getBackgroundImage(d_background);
+        cv::gpu::GpuMat background;
 
-        TEST_CYCLE()
-        {
-            d_mog2.getBackgroundImage(d_background);
-        }
+        TEST_CYCLE() d_mog2.getBackgroundImage(background);
 
-        GPU_SANITY_CHECK(d_background);
+        GPU_SANITY_CHECK(background, 1);
     }
     else
     {
@@ -868,12 +807,8 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
         }
 
         cv::Mat background;
-        mog2.getBackgroundImage(background);
 
-        TEST_CYCLE()
-        {
-            mog2.getBackgroundImage(background);
-        }
+        TEST_CYCLE() mog2.getBackgroundImage(background);
 
         CPU_SANITY_CHECK(background);
     }
@@ -882,11 +817,12 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
 //////////////////////////////////////////////////////
 // VIBE
 
-PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
-    Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4))
+PERF_TEST_P(Video_Cn, Video_VIBE,
+            Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
+                    GPU_CHANNELS_1_3_4))
 {
-    string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
-    int cn = GET_PARAM(1);
+    const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
+    const int cn = GET_PARAM(1);
 
     cv::VideoCapture cap(inputFile);
     ASSERT_TRUE(cap.isOpened());
@@ -908,10 +844,10 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
     if (PERF_RUN_GPU())
     {
         cv::gpu::GpuMat d_frame(frame);
-        cv::gpu::VIBE_GPU d_vibe;
-        cv::gpu::GpuMat d_foreground;
+        cv::gpu::VIBE_GPU vibe;
+        cv::gpu::GpuMat foreground;
 
-        d_vibe(d_frame, d_foreground);
+        vibe(d_frame, foreground);
 
         for (int i = 0; i < 10; ++i)
         {
@@ -931,13 +867,15 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
             d_frame.upload(frame);
 
             startTimer(); next();
-            d_vibe(d_frame, d_foreground);
+            vibe(d_frame, foreground);
             stopTimer();
         }
+
+        GPU_SANITY_CHECK(foreground);
     }
     else
     {
-        FAIL() << "No such CPU implementation analogy";
+        FAIL_NO_CPU();
     }
 }
 
@@ -946,12 +884,14 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
 
 DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, MatCn, int);
 
-PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
-    Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4, Values(20, 40, 60)))
+PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
+            Combine(Values(string("gpu/video/768x576.avi")),
+                    GPU_CHANNELS_1_3_4,
+                    Values(20, 40, 60)))
 {
-    std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
-    int cn = GET_PARAM(1);
-    int maxFeatures = GET_PARAM(2);
+    const std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
+    const int cn = GET_PARAM(1);
+    const int maxFeatures = GET_PARAM(2);
 
     cv::VideoCapture cap(inputFile);
     ASSERT_TRUE(cap.isOpened());
@@ -973,12 +913,12 @@ PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
     if (PERF_RUN_GPU())
     {
         cv::gpu::GpuMat d_frame(frame);
-        cv::gpu::GpuMat d_fgmask;
+        cv::gpu::GpuMat foreground;
 
         cv::gpu::GMG_GPU d_gmg;
         d_gmg.maxFeatures = maxFeatures;
 
-        d_gmg(d_frame, d_fgmask);
+        d_gmg(d_frame, foreground);
 
         for (int i = 0; i < 150; ++i)
         {
@@ -1003,20 +943,22 @@ PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
             d_frame.upload(frame);
 
             startTimer(); next();
-            d_gmg(d_frame, d_fgmask);
+            d_gmg(d_frame, foreground);
             stopTimer();
         }
+
+        GPU_SANITY_CHECK(foreground);
     }
     else
     {
-        cv::Mat fgmask;
+        cv::Mat foreground;
         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);
+        gmg(frame, foreground);
 
         for (int i = 0; i < 150; ++i)
         {
@@ -1039,21 +981,60 @@ PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
             }
 
             startTimer(); next();
-            gmg(frame, fgmask);
+            gmg(frame, foreground);
             stopTimer();
         }
+
+        CPU_SANITY_CHECK(foreground);
+    }
+}
+
+#ifdef HAVE_NVCUVID
+
+//////////////////////////////////////////////////////
+// VideoReader
+
+PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
+{
+    declare.time(20);
+
+    const string inputFile = perf::TestBase::getDataPath(GetParam());
+
+    if (PERF_RUN_GPU())
+    {
+        cv::gpu::VideoReader_GPU d_reader(inputFile);
+        ASSERT_TRUE( d_reader.isOpened() );
+
+        cv::gpu::GpuMat frame;
+
+        TEST_CYCLE_N(10) d_reader.read(frame);
+
+        GPU_SANITY_CHECK(frame);
+    }
+    else
+    {
+        cv::VideoCapture reader(inputFile);
+        ASSERT_TRUE( reader.isOpened() );
+
+        cv::Mat frame;
+
+        TEST_CYCLE_N(10) reader >> frame;
+
+        CPU_SANITY_CHECK(frame);
     }
 }
 
 //////////////////////////////////////////////////////
 // VideoWriter
 
-PERF_TEST_P(Video, DISABLED_Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
+#ifdef WIN32
+
+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");
+    const string inputFile = perf::TestBase::getDataPath(GetParam());
+    const string outputFile = cv::tempfile(".avi");
 
     const double FPS = 25.0;
 
@@ -1100,49 +1081,10 @@ PERF_TEST_P(Video, DISABLED_Video_VideoWriter, Values("gpu/video/768x576.avi", "
             stopTimer();
         }
     }
-}
-
-//////////////////////////////////////////////////////
-// VideoReader
-
-PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
-{
-    declare.time(20);
-
-    string inputFile = perf::TestBase::getDataPath(GetParam());
 
-    if (PERF_RUN_GPU())
-    {
-        cv::gpu::VideoReader_GPU d_reader(inputFile);
-        ASSERT_TRUE( d_reader.isOpened() );
-
-        cv::gpu::GpuMat d_frame;
-
-        d_reader.read(d_frame);
-
-        TEST_CYCLE_N(10)
-        {
-            d_reader.read(d_frame);
-        }
-
-        GPU_SANITY_CHECK(d_frame);
-    }
-    else
-    {
-        cv::VideoCapture reader(inputFile);
-        ASSERT_TRUE( reader.isOpened() );
-
-        cv::Mat frame;
-
-        reader >> frame;
-
-        TEST_CYCLE_N(10)
-        {
-            reader >> frame;
-        }
-
-        CPU_SANITY_CHECK(frame);
-    }
+    SANITY_CHECK(frame);
 }
 
-} // namespace
+#endif // WIN32
+
+#endif // HAVE_NVCUVID
index c3099030b2054e5759e330228af233724b860721..16c61e0c7de39f58df5ac99af429344aa69f15aa 100644 (file)
@@ -2,13 +2,6 @@
 
 using namespace std;
 using namespace cv;
-using namespace cv::gpu;
-
-void fillRandom(Mat& m, double a, double b)
-{
-    RNG rng(123456789);
-    rng.fill(m, RNG::UNIFORM, Scalar::all(a), Scalar::all(b));
-}
 
 Mat readImage(const string& fileName, int flags)
 {
@@ -188,4 +181,4 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
     };
 
     *os << str[info.code];
-}
\ No newline at end of file
+}
index 6782b937680b02aca0cb4726d9a29432b9309dd2..cff4cdd77d67928ada502dc2a5f7a6d9c1d844be 100644 (file)
@@ -2,11 +2,9 @@
 #define __OPENCV_PERF_GPU_UTILITY_HPP__
 
 #include "opencv2/core/core.hpp"
-#include "opencv2/core/gpumat.hpp"
 #include "opencv2/imgproc/imgproc.hpp"
 #include "opencv2/ts/ts_perf.hpp"
 
-void fillRandom(cv::Mat& m, double a = 0.0, double b = 255.0);
 cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
 
 using perf::MatType;
@@ -17,12 +15,13 @@ CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONS
 
 CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
 #define ALL_INTERPOLATIONS testing::ValuesIn(Interpolation::all())
+
 CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING, cv::NORM_MINMAX)
 
-const int Gray = 1, TwoChannel = 2, BGR = 3, BGRA = 4;
+enum { Gray = 1, TwoChannel = 2, BGR = 3, BGRA = 4 };
 CV_ENUM(MatCn, Gray, TwoChannel, BGR, BGRA)
-#define GPU_CHANNELS_1_3_4 testing::Values(Gray, BGR, BGRA)
-#define GPU_CHANNELS_1_3 testing::Values(Gray, BGR)
+#define GPU_CHANNELS_1_3_4 testing::Values(MatCn(Gray), MatCn(BGR), MatCn(BGRA))
+#define GPU_CHANNELS_1_3 testing::Values(MatCn(Gray), MatCn(BGR))
 
 struct CvtColorInfo
 {
@@ -30,7 +29,8 @@ struct CvtColorInfo
     int dcn;
     int code;
 
-    explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
+    CvtColorInfo() {}
+    explicit CvtColorInfo(int scn_, int dcn_, int code_) : scn(scn_), dcn(dcn_), code(code_) {}
 };
 void PrintTo(const CvtColorInfo& info, std::ostream* os);
 
@@ -46,39 +46,18 @@ DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, MatCn);
 
 #define GPU_TYPICAL_MAT_SIZES testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p)
 
-#define GPU_SANITY_CHECK(dmat, ...) \
-    do{ \
-        cv::Mat d##dmat(dmat); \
-        SANITY_CHECK(d##dmat, ## __VA_ARGS__); \
-    } while(0)
+#define FAIL_NO_CPU() FAIL() << "No such CPU implementation analogy"
 
-#define CPU_SANITY_CHECK(cmat, ...) \
+#define GPU_SANITY_CHECK(mat, ...) \
     do{ \
-        SANITY_CHECK(cmat, ## __VA_ARGS__); \
+        cv::Mat gpu_##mat(mat); \
+        SANITY_CHECK(gpu_##mat, ## __VA_ARGS__); \
     } while(0)
 
-#define GPU_SANITY_CHECK_KEYPOINTS(alg, dmat, ...)                                          \
-    do{                                                                                     \
-        cv::Mat d##dmat(dmat);                                                              \
-        cv::Mat __pt_x      = d##dmat.row(cv::gpu::alg##_GPU::X_ROW);                       \
-        cv::Mat __pt_y      = d##dmat.row(cv::gpu::alg##_GPU::Y_ROW);                       \
-        cv::Mat __angle     = d##dmat.row(cv::gpu::alg##_GPU::ANGLE_ROW);                   \
-        cv::Mat __octave    = d##dmat.row(cv::gpu::alg##_GPU::OCTAVE_ROW);                               \
-        cv::Mat __size      = d##dmat.row(cv::gpu::alg##_GPU::SIZE_ROW);                                 \
-        ::perf::Regression::add(this, std::string(#dmat) + "-pt-x-row",     __pt_x,     ## __VA_ARGS__); \
-        ::perf::Regression::add(this, std::string(#dmat) + "-pt-y-row",     __pt_y,     ## __VA_ARGS__); \
-        ::perf::Regression::add(this, std::string(#dmat) + "-angle-row",    __angle,    ## __VA_ARGS__); \
-        ::perf::Regression::add(this, std::string(#dmat) + "octave-row",    __octave,   ## __VA_ARGS__); \
-        ::perf::Regression::add(this, std::string(#dmat) + "-pt-size-row",  __size,     ## __VA_ARGS__); \
-    } while(0)
-
-#define GPU_SANITY_CHECK_RESPONSE(alg, dmat, ...) \
-    do{                                                                                     \
-        cv::Mat d##dmat(dmat);                                                              \
-        cv::Mat __response  = d##dmat.row(cv::gpu::alg##_GPU::RESPONSE_ROW);                \
-        ::perf::Regression::add(this, std::string(#dmat) + "-response-row", __response, ## __VA_ARGS__); \
+#define CPU_SANITY_CHECK(mat, ...) \
+    do{ \
+        cv::Mat cpu_##mat(mat); \
+        SANITY_CHECK(cpu_##mat, ## __VA_ARGS__); \
     } while(0)
 
-#define FAIL_NO_CPU()   FAIL() << "No such CPU implementation analogy"
-
 #endif // __OPENCV_PERF_GPU_UTILITY_HPP__
index ab1607059a0540e1a4e92160f3255b22c690c6d2..49230e65a9c069ef17c919c06e9ac713a12a9bd8 100644 (file)
@@ -104,12 +104,12 @@ void cv::gpu::connectivityMask(const GpuMat& image, GpuMat& mask, const cv::Scal
 
 void cv::gpu::labelComponents(const GpuMat& mask, GpuMat& components, int flags, Stream& s)
 {
-    if (!TargetArchs::builtWith(SHARED_ATOMICS) || !DeviceInfo().supports(SHARED_ATOMICS))
-        CV_Error(CV_StsNotImplemented, "The device doesn't support shared atomics and communicative synchronization!");
     CV_Assert(!mask.empty() && mask.type() == CV_8U);
 
-    if (mask.size() != components.size() || components.type() != CV_32SC1)
-        components.create(mask.size(), CV_32SC1);
+    if (!deviceSupports(SHARED_ATOMICS))
+        CV_Error(CV_StsNotImplemented, "The device doesn't support shared atomics and communicative synchronization!");
+
+    components.create(mask.size(), CV_32SC1);
 
     cudaStream_t stream = StreamAccessor::getStream(s);
     device::ccl::labelComponents(mask, components, flags, stream);
index 31847171858e40664844086fe0f6b8af0fcb629f..d9ca46844e2c47ae2172404c1f6419a6a7c0bc44 100644 (file)
@@ -522,6 +522,7 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
     CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);
 
     dst.create(dsize, src.type());
+    dst.setTo(Scalar::all(0));
 
     funcs[src.depth()][src.channels() - 1](src, dst, dsize, angle, xShift, yShift, interpolation, StreamAccessor::getStream(stream));
 }
index 39c0b5c686544e6dfc8776cf2793b4fb40a32fe8..65b05b7c748d76c87647e87fc20a6f382ab20da5 100644 (file)
@@ -382,6 +382,7 @@ void cv::gpu::meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr,
             dstcol[0] = static_cast<uchar>(sumcol[0] / comps.size[parent]);
             dstcol[1] = static_cast<uchar>(sumcol[1] / comps.size[parent]);
             dstcol[2] = static_cast<uchar>(sumcol[2] / comps.size[parent]);
+            dstcol[3] = 255;
         }
     }
 }
index 148bcb5dd94efb8115ed6ed2c1fc5f65ca9be5b7..ffc035c0223eaa954c5740610cc5f6b7d3fcd42c 100644 (file)
@@ -209,6 +209,8 @@ void cv::gpu::PyrLKOpticalFlow::dense(const GpuMat& prevImg, const GpuMat& nextI
     ensureSizeIsEnough(prevImg.size(), CV_32FC1, vPyr_[0]);
     ensureSizeIsEnough(prevImg.size(), CV_32FC1, uPyr_[1]);
     ensureSizeIsEnough(prevImg.size(), CV_32FC1, vPyr_[1]);
+    uPyr_[0].setTo(Scalar::all(0));
+    vPyr_[0].setTo(Scalar::all(0));
     uPyr_[1].setTo(Scalar::all(0));
     vPyr_[1].setTo(Scalar::all(0));
 
index 0fb19addaae8a515fac289caef12ce99fc43ce98..827d5219f14d6c73f671149284a05c3eeeb3090f 100644 (file)
@@ -232,10 +232,8 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
     };
 
     bool useNpp = borderMode == BORDER_CONSTANT && ofs.x == 0 && ofs.y == 0 && useNppTab[src.depth()][src.channels() - 1][interpolation];
-    #ifdef linux
-        // NPP bug on float data
-        useNpp = useNpp && src.depth() != CV_32F;
-    #endif
+    // NPP bug on float data
+    useNpp = useNpp && src.depth() != CV_32F;
 
     if (useNpp)
     {
@@ -372,10 +370,8 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
     };
 
     bool useNpp = borderMode == BORDER_CONSTANT && ofs.x == 0 && ofs.y == 0 && useNppTab[src.depth()][src.channels() - 1][interpolation];
-    #ifdef linux
-        // NPP bug on float data
-        useNpp = useNpp && src.depth() != CV_32F;
-    #endif
+    // NPP bug on float data
+    useNpp = useNpp && src.depth() != CV_32F;
 
     if (useNpp)
     {