gpu test refactoring
authorAnatoly Baksheev <no@email>
Sat, 25 Sep 2010 16:21:32 +0000 (16:21 +0000)
committerAnatoly Baksheev <no@email>
Sat, 25 Sep 2010 16:21:32 +0000 (16:21 +0000)
13 files changed:
tests/gpu/src/arithm.cpp
tests/gpu/src/imgproc_gpu.cpp
tests/gpu/src/meanshift.cpp
tests/gpu/src/morf_filters.cpp
tests/gpu/src/operator_async_call.cpp
tests/gpu/src/operator_convert_to.cpp
tests/gpu/src/operator_copy_to.cpp
tests/gpu/src/operator_set_to.cpp
tests/gpu/src/split_merge.cpp
tests/gpu/src/stereo_bm.cpp
tests/gpu/src/stereo_bm_async.cpp
tests/gpu/src/stereo_bp.cpp
tests/gpu/src/stereo_csbp.cpp

index 36e0221bd2466ad3a50d99b184f7b2f1dffd940d..366af75533c9d6bb5e50bd5571cd332171fb3543 100644 (file)
@@ -240,7 +240,7 @@ struct CV_GpuNppImageMultiplyTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageMultiplyTest() : CV_GpuArithmTest( "GPU-NppImageMultiply", "multiply" ) {}
 
-    int CV_GpuNppImageMultiplyTest::test( const Mat& mat1, const Mat& mat2 )
+    int test( const Mat& mat1, const Mat& mat2 )
     {
         if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
         {
@@ -266,7 +266,7 @@ struct CV_GpuNppImageDivideTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageDivideTest() : CV_GpuArithmTest( "GPU-NppImageDivide", "divide" ) {}
 
-    int CV_GpuNppImageDivideTest::test( const Mat& mat1, const Mat& mat2 )
+    int test( const Mat& mat1, const Mat& mat2 )
     {
         if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
         {
@@ -292,7 +292,7 @@ struct CV_GpuNppImageTransposeTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageTransposeTest() : CV_GpuArithmTest( "GPU-NppImageTranspose", "transpose" ) {}
 
-    int CV_GpuNppImageTransposeTest::test( const Mat& mat1, const Mat& )
+    int test( const Mat& mat1, const Mat& )
     {
         if (mat1.type() != CV_8UC1)
         {
@@ -317,7 +317,7 @@ struct CV_GpuNppImageAbsdiffTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageAbsdiffTest() : CV_GpuArithmTest( "GPU-NppImageAbsdiff", "absdiff" ) {}
 
-    int CV_GpuNppImageAbsdiffTest::test( const Mat& mat1, const Mat& mat2 )
+    int test( const Mat& mat1, const Mat& mat2 )
     {
         if (mat1.type() != CV_8UC1 && mat1.type() != CV_32FC1)
         {
@@ -343,7 +343,7 @@ struct CV_GpuNppImageCompareTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageCompareTest() : CV_GpuArithmTest( "GPU-NppImageCompare", "compare" ) {}
 
-    int CV_GpuNppImageCompareTest::test( const Mat& mat1, const Mat& mat2 )
+    int test( const Mat& mat1, const Mat& mat2 )
     {
         if (mat1.type() != CV_32FC1)
         {
@@ -383,7 +383,7 @@ struct CV_GpuNppImageMeanStdDevTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageMeanStdDevTest() : CV_GpuArithmTest( "GPU-NppImageMeanStdDev", "meanStdDev" ) {}
 
-    int CV_GpuNppImageMeanStdDevTest::test( const Mat& mat1, const Mat& )
+    int test( const Mat& mat1, const Mat& )
     {
         if (mat1.type() != CV_8UC1)
         {
@@ -424,7 +424,7 @@ struct CV_GpuNppImageNormTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageNormTest() : CV_GpuArithmTest( "GPU-NppImageNorm", "norm" ) {}
 
-    int CV_GpuNppImageNormTest::test( const Mat& mat1, const Mat& mat2 )
+    int test( const Mat& mat1, const Mat& mat2 )
     {
         if (mat1.type() != CV_8UC1)
         {
@@ -462,7 +462,7 @@ struct CV_GpuNppImageFlipTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageFlipTest() : CV_GpuArithmTest( "GPU-NppImageFlip", "flip" ) {}
 
-    int CV_GpuNppImageFlipTest::test( const Mat& mat1, const Mat& )
+    int test( const Mat& mat1, const Mat& )
     {
         if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4)
         {
@@ -501,7 +501,7 @@ struct CV_GpuNppImageSumTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageSumTest() : CV_GpuArithmTest( "GPU-NppImageSum", "sum" ) {}
 
-    int CV_GpuNppImageSumTest::test( const Mat& mat1, const Mat& )
+    int test( const Mat& mat1, const Mat& )
     {
         if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4)
         {
@@ -524,7 +524,7 @@ struct CV_GpuNppImageMinNaxTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageMinNaxTest() : CV_GpuArithmTest( "GPU-NppImageMinNax", "minNax" ) {}
 
-    int CV_GpuNppImageMinNaxTest::test( const Mat& mat1, const Mat& )
+    int test( const Mat& mat1, const Mat& )
     {
         if (mat1.type() != CV_8UC1)
         {
@@ -549,7 +549,7 @@ struct CV_GpuNppImageLUTTest : public CV_GpuArithmTest
 {
     CV_GpuNppImageLUTTest() : CV_GpuArithmTest( "GPU-NppImageLUT", "LUT" ) {}
 
-    int CV_GpuNppImageLUTTest::test( const Mat& mat1, const Mat& )
+    int test( const Mat& mat1, const Mat& )
     {
         if (mat1.type() != CV_8UC1)
         {
@@ -572,7 +572,9 @@ struct CV_GpuNppImageLUTTest : public CV_GpuArithmTest
     }
 };
 
-
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 
 // If we comment some tests, we may foget/miss to uncomment it after.
 // Placing all test definitions in one place 
index 74076cfd9d6ee9d3cd122a82dcd5512f6bb5c04e..19e499329eace8afb8238a20b2a3020567579f20 100644 (file)
@@ -54,8 +54,8 @@ using namespace gpu;
 class CV_GpuImageProcTest : public CvTest
 {
 public:
-    CV_GpuImageProcTest(const char* test_name, const char* test_funcs);
-    virtual ~CV_GpuImageProcTest();
+    CV_GpuImageProcTest(const char* test_name, const char* test_funcs) : CvTest(test_name, test_funcs) {}
+    virtual ~CV_GpuImageProcTest() {}
 
 protected:
     void run(int);
@@ -70,11 +70,6 @@ protected:
     int CheckNorm(const Mat& m1, const Mat& m2);
 };
 
-CV_GpuImageProcTest::CV_GpuImageProcTest(const char* test_name, const char* test_funcs): CvTest(test_name, test_funcs)
-{
-}
-
-CV_GpuImageProcTest::~CV_GpuImageProcTest() {}
 
 int CV_GpuImageProcTest::test8UC1(const Mat& img)
 {
@@ -188,352 +183,284 @@ void CV_GpuImageProcTest::run( int )
 
 ////////////////////////////////////////////////////////////////////////////////
 // threshold
-class CV_GpuNppImageThresholdTest : public CV_GpuImageProcTest
+struct CV_GpuNppImageThresholdTest : public CV_GpuImageProcTest
 {
 public:
-    CV_GpuNppImageThresholdTest();
-
-protected:
-    virtual int test(const Mat& img);
-};
+    CV_GpuNppImageThresholdTest() : CV_GpuImageProcTest( "GPU-NppImageThreshold", "threshold" ) {}
 
-CV_GpuNppImageThresholdTest::CV_GpuNppImageThresholdTest(): CV_GpuImageProcTest( "GPU-NppImageThreshold", "threshold" )
-{
-}
-
-int CV_GpuNppImageThresholdTest::test(const Mat& img)
-{
-    if (img.type() != CV_32FC1)
+    int test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
-
-    cv::RNG rng(*ts->get_rng());
-    const double thresh = rng;
+        if (img.type() != CV_32FC1)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
 
-    cv::Mat cpuRes;
-    cv::threshold(img, cpuRes, thresh, 0.0, THRESH_TRUNC);
+        cv::RNG rng(*ts->get_rng());
+        const double thresh = rng;
 
-    GpuMat gpu1(img);
-    GpuMat gpuRes;
-    cv::gpu::threshold(gpu1, gpuRes, thresh);
+        cv::Mat cpuRes;
+        cv::threshold(img, cpuRes, thresh, 0.0, THRESH_TRUNC);
 
-    return CheckNorm(cpuRes, gpuRes);
-}
+        GpuMat gpu1(img);
+        GpuMat gpuRes;
+        cv::gpu::threshold(gpu1, gpuRes, thresh);
 
-CV_GpuNppImageThresholdTest CV_GpuNppImageThreshold_test;
+        return CheckNorm(cpuRes, gpuRes);
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // resize
-class CV_GpuNppImageResizeTest : public CV_GpuImageProcTest
+struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest
 {
-public:
-    CV_GpuNppImageResizeTest();
-
-protected:
-    virtual int test(const Mat& img);
-};
-
-CV_GpuNppImageResizeTest::CV_GpuNppImageResizeTest(): CV_GpuImageProcTest( "GPU-NppImageResize", "resize" )
-{
-}
-
-int CV_GpuNppImageResizeTest::test(const Mat& img)
-{
-    if (img.type() != CV_8UC1 && img.type() != CV_8UC4)
+    CV_GpuNppImageResizeTest() : CV_GpuImageProcTest( "GPU-NppImageResize", "resize" ) {}
+    int test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
+        if (img.type() != CV_8UC1 && img.type() != CV_8UC4)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
 
-    int interpolations[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4};
-    const char* interpolations_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_LANCZOS4"};
-    int interpolations_num = sizeof(interpolations) / sizeof(int);
+        int interpolations[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4};
+        const char* interpolations_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_LANCZOS4"};
+        int interpolations_num = sizeof(interpolations) / sizeof(int);
 
-    int test_res = CvTS::OK;
+        int test_res = CvTS::OK;
 
-    for (int i = 0; i < interpolations_num; ++i)
-    {
-        ts->printf(CvTS::LOG, "\nInterpolation type: %s\n", interpolations_str[i]);
-
-        Mat cpu_res;
-        cv::resize(img, cpu_res, Size(), 0.5, 0.5, interpolations[i]);
+        for (int i = 0; i < interpolations_num; ++i)
+        {
+            ts->printf(CvTS::LOG, "\nInterpolation type: %s\n", interpolations_str[i]);
 
-        GpuMat gpu1(img), gpu_res;
-        cv::gpu::resize(gpu1, gpu_res, Size(), 0.5, 0.5, interpolations[i]);
+            Mat cpu_res;
+            cv::resize(img, cpu_res, Size(), 0.5, 0.5, interpolations[i]);
 
-        if (CheckNorm(cpu_res, gpu_res) != CvTS::OK)
-            test_res = CvTS::FAIL_GENERIC;
-    }
+            GpuMat gpu1(img), gpu_res;
+            cv::gpu::resize(gpu1, gpu_res, Size(), 0.5, 0.5, interpolations[i]);
 
-    return test_res;
-}
+            if (CheckNorm(cpu_res, gpu_res) != CvTS::OK)
+                test_res = CvTS::FAIL_GENERIC;
+        }
 
-//CV_GpuNppImageResizeTest CV_GpuNppImageResize_test;
+        return test_res;
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // copyMakeBorder
-class CV_GpuNppImageCopyMakeBorderTest : public CV_GpuImageProcTest
+struct CV_GpuNppImageCopyMakeBorderTest : public CV_GpuImageProcTest
 {
-public:
-    CV_GpuNppImageCopyMakeBorderTest();
-
-protected:
-    virtual int test(const Mat& img);
-};
+    CV_GpuNppImageCopyMakeBorderTest() : CV_GpuImageProcTest( "GPU-NppImageCopyMakeBorder", "copyMakeBorder" ) {}
 
-CV_GpuNppImageCopyMakeBorderTest::CV_GpuNppImageCopyMakeBorderTest(): CV_GpuImageProcTest( "GPU-NppImageCopyMakeBorder", "copyMakeBorder" )
-{
-}
-
-int CV_GpuNppImageCopyMakeBorderTest::test(const Mat& img)
-{
-    if (img.type() != CV_8UC1 && img.type() != CV_8UC4 && img.type() != CV_32SC1)
+    int test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
-
-    cv::RNG rng(*ts->get_rng());
-    int top = rng.uniform(1, 10);
-    int botton = rng.uniform(1, 10);
-    int left = rng.uniform(1, 10);
-    int right = rng.uniform(1, 10);
-    cv::Scalar val(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
+        if (img.type() != CV_8UC1 && img.type() != CV_8UC4 && img.type() != CV_32SC1)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
 
-    Mat cpudst;
-    cv::copyMakeBorder(img, cpudst, top, botton, left, right, BORDER_CONSTANT, val);
+        cv::RNG rng(*ts->get_rng());
+        int top = rng.uniform(1, 10);
+        int botton = rng.uniform(1, 10);
+        int left = rng.uniform(1, 10);
+        int right = rng.uniform(1, 10);
+        cv::Scalar val(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
 
-    GpuMat gpu1(img);
-    GpuMat gpudst;    
-    cv::gpu::copyMakeBorder(gpu1, gpudst, top, botton, left, right, val);
+        Mat cpudst;
+        cv::copyMakeBorder(img, cpudst, top, botton, left, right, BORDER_CONSTANT, val);
 
-    return CheckNorm(cpudst, gpudst);
-}
+        GpuMat gpu1(img);
+        GpuMat gpudst;    
+        cv::gpu::copyMakeBorder(gpu1, gpudst, top, botton, left, right, val);
 
-CV_GpuNppImageCopyMakeBorderTest CV_GpuNppImageCopyMakeBorder_test;
+        return CheckNorm(cpudst, gpudst);
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // warpAffine
-class CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest
+struct CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest
 {
-public:
-    CV_GpuNppImageWarpAffineTest();
+    CV_GpuNppImageWarpAffineTest() : CV_GpuImageProcTest( "GPU-NppImageWarpAffine", "warpAffine" ) {}
 
-protected:
-    virtual int test(const Mat& img);
-};
-
-CV_GpuNppImageWarpAffineTest::CV_GpuNppImageWarpAffineTest(): CV_GpuImageProcTest( "GPU-NppImageWarpAffine", "warpAffine" )
-{
-}
-
-int CV_GpuNppImageWarpAffineTest::test(const Mat& img)
-{
-    if (img.type() == CV_32SC1)
+    int test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
-    
-    static const double coeffs[2][3] = 
-    { 
-        {cos(3.14 / 6), -sin(3.14 / 6), 100.0}, 
-        {sin(3.14 / 6), cos(3.14 / 6), -100.0}
-    };
-    Mat M(2, 3, CV_64F, (void*)coeffs);
-
-    int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};
-    const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};
-    int flags_num = sizeof(flags) / sizeof(int);
+        if (img.type() == CV_32SC1)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
+        
+        static const double coeffs[2][3] = 
+        { 
+            {cos(3.14 / 6), -sin(3.14 / 6), 100.0}, 
+            {sin(3.14 / 6), cos(3.14 / 6), -100.0}
+        };
+        Mat M(2, 3, CV_64F, (void*)coeffs);
 
-    int test_res = CvTS::OK;
+        int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};
+        const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};
+        int flags_num = sizeof(flags) / sizeof(int);
 
-    for (int i = 0; i < flags_num; ++i)
-    {
-        ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]);
+        int test_res = CvTS::OK;
 
-        Mat cpudst;
-        cv::warpAffine(img, cpudst, M, img.size(), flags[i]);
+        for (int i = 0; i < flags_num; ++i)
+        {
+            ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]);
 
-        GpuMat gpu1(img);
-        GpuMat gpudst;
-        cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]);
-        
-        if (CheckNorm(cpudst, gpudst) != CvTS::OK)
-            test_res = CvTS::FAIL_GENERIC;
-    }
+            Mat cpudst;
+            cv::warpAffine(img, cpudst, M, img.size(), flags[i]);
 
-    return test_res;
-}
+            GpuMat gpu1(img);
+            GpuMat gpudst;
+            cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]);
+            
+            if (CheckNorm(cpudst, gpudst) != CvTS::OK)
+                test_res = CvTS::FAIL_GENERIC;
+        }
 
-//CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;
+        return test_res;
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // warpPerspective
-class CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest
+struct CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest
 {
-public:
-    CV_GpuNppImageWarpPerspectiveTest();
+    CV_GpuNppImageWarpPerspectiveTest() : CV_GpuImageProcTest( "GPU-NppImageWarpPerspective", "warpPerspective" ) {}
 
-protected:
-    virtual int test(const Mat& img);
-};
 
-CV_GpuNppImageWarpPerspectiveTest::CV_GpuNppImageWarpPerspectiveTest(): CV_GpuImageProcTest( "GPU-NppImageWarpPerspective", "warpPerspective" )
-{
-}
-
-int CV_GpuNppImageWarpPerspectiveTest::test(const Mat& img)
-{
-    if (img.type() == CV_32SC1)
+    int test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
-    
-    static const double coeffs[3][3] = 
-    {
-        {cos(3.14 / 6), -sin(3.14 / 6), 100.0}, 
-        {sin(3.14 / 6), cos(3.14 / 6), -100.0}, 
-        {0.0, 0.0, 1.0}
-    };
-    Mat M(3, 3, CV_64F, (void*)coeffs);
-
-    int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};
-    const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};
-    int flags_num = sizeof(flags) / sizeof(int);
+        if (img.type() == CV_32SC1)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
+        
+        static const double coeffs[3][3] = 
+        {
+            {cos(3.14 / 6), -sin(3.14 / 6), 100.0}, 
+            {sin(3.14 / 6), cos(3.14 / 6), -100.0}, 
+            {0.0, 0.0, 1.0}
+        };
+        Mat M(3, 3, CV_64F, (void*)coeffs);
 
-    int test_res = CvTS::OK;
+        int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};
+        const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};
+        int flags_num = sizeof(flags) / sizeof(int);
 
-    for (int i = 0; i < flags_num; ++i)
-    {
-        ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]);
+        int test_res = CvTS::OK;
 
-        Mat cpudst;
-        cv::warpPerspective(img, cpudst, M, img.size(), flags[i]);
+        for (int i = 0; i < flags_num; ++i)
+        {
+            ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]);
 
-        GpuMat gpu1(img);
-        GpuMat gpudst;
-        cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]);
+            Mat cpudst;
+            cv::warpPerspective(img, cpudst, M, img.size(), flags[i]);
 
-        if (CheckNorm(cpudst, gpudst) != CvTS::OK)
-            test_res = CvTS::FAIL_GENERIC;
-    }
+            GpuMat gpu1(img);
+            GpuMat gpudst;
+            cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]);
 
-    return test_res;
-}
+            if (CheckNorm(cpudst, gpudst) != CvTS::OK)
+                test_res = CvTS::FAIL_GENERIC;
+        }
 
-//CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;
+        return test_res;
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // integral
-class CV_GpuNppImageIntegralTest : public CV_GpuImageProcTest
-{
-public:
-    CV_GpuNppImageIntegralTest();
-
-protected:
-    virtual int test(const Mat& img);
-};
-
-CV_GpuNppImageIntegralTest::CV_GpuNppImageIntegralTest(): CV_GpuImageProcTest( "GPU-NppImageIntegral", "integral" )
+struct CV_GpuNppImageIntegralTest : public CV_GpuImageProcTest
 {
-}
+    CV_GpuNppImageIntegralTest() : CV_GpuImageProcTest( "GPU-NppImageIntegral", "integral" ) {}
 
-int CV_GpuNppImageIntegralTest::test(const Mat& img)
-{
-    if (img.type() != CV_8UC1)
+    int CV_GpuNppImageIntegralTest::test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
-
-    Mat cpusum, cpusqsum;
-    cv::integral(img, cpusum, cpusqsum, CV_32S);
+        if (img.type() != CV_8UC1)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
 
-    GpuMat gpu1(img);
-    GpuMat gpusum, gpusqsum;
-    cv::gpu::integral(gpu1, gpusum, gpusqsum);
+        Mat cpusum, cpusqsum;
+        cv::integral(img, cpusum, cpusqsum, CV_32S);
 
-    gpusqsum.convertTo(gpusqsum, CV_64F);
+        GpuMat gpu1(img);
+        GpuMat gpusum, gpusqsum;
+        cv::gpu::integral(gpu1, gpusum, gpusqsum);
 
-    int test_res = CvTS::OK;
+        gpusqsum.convertTo(gpusqsum, CV_64F);
 
-    if (CheckNorm(cpusum, gpusum) != CvTS::OK)
-    {
-        ts->printf(CvTS::LOG, "\nSum failed\n");
-        test_res = CvTS::FAIL_GENERIC;
-    }
-    if (CheckNorm(cpusqsum, gpusqsum) != CvTS::OK)
-    {
-        ts->printf(CvTS::LOG, "\nSquared sum failed\n");
-        test_res = CvTS::FAIL_GENERIC;
-    }
+        int test_res = CvTS::OK;
 
-    return test_res;
-}
+        if (CheckNorm(cpusum, gpusum) != CvTS::OK)
+        {
+            ts->printf(CvTS::LOG, "\nSum failed\n");
+            test_res = CvTS::FAIL_GENERIC;
+        }
+        if (CheckNorm(cpusqsum, gpusqsum) != CvTS::OK)
+        {
+            ts->printf(CvTS::LOG, "\nSquared sum failed\n");
+            test_res = CvTS::FAIL_GENERIC;
+        }
 
-CV_GpuNppImageIntegralTest CV_GpuNppImageIntegral_test;
+        return test_res;
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // blur
-class CV_GpuNppImageBlurTest : public CV_GpuImageProcTest
+struct CV_GpuNppImageBlurTest : public CV_GpuImageProcTest
 {
-public:
-    CV_GpuNppImageBlurTest();
+    CV_GpuNppImageBlurTest() : CV_GpuImageProcTest( "GPU-NppImageBlur", "blur" ) {}
 
-protected:
-    virtual int test(const Mat& img);
-};
-
-CV_GpuNppImageBlurTest::CV_GpuNppImageBlurTest(): CV_GpuImageProcTest( "GPU-NppImageBlur", "blur" )
-{
-}
-
-int CV_GpuNppImageBlurTest::test(const Mat& img)
-{
-    if (img.type() != CV_8UC1 && img.type() != CV_8UC4)
+    int test(const Mat& img)
     {
-        ts->printf(CvTS::LOG, "\nUnsupported type\n");
-        return CvTS::OK;
-    }
+        if (img.type() != CV_8UC1 && img.type() != CV_8UC4)
+        {
+            ts->printf(CvTS::LOG, "\nUnsupported type\n");
+            return CvTS::OK;
+        }
 
-    int ksizes[] = {3, 5, 7};
-    int ksizes_num = sizeof(ksizes) / sizeof(int);
+        int ksizes[] = {3, 5, 7};
+        int ksizes_num = sizeof(ksizes) / sizeof(int);
 
-    int test_res = CvTS::OK;
+        int test_res = CvTS::OK;
 
-    for (int i = 0; i < ksizes_num; ++i)
-    {
-        ts->printf(CvTS::LOG, "\nksize = %d\n", ksizes[i]);
-
-        Mat cpudst;
-        cv::blur(img, cpudst, Size(ksizes[i], ksizes[i]));
+        for (int i = 0; i < ksizes_num; ++i)
+        {
+            ts->printf(CvTS::LOG, "\nksize = %d\n", ksizes[i]);
 
-        GpuMat gpu1(img);
-        GpuMat gpudst;
-        cv::gpu::blur(gpu1, gpudst, Size(ksizes[i], ksizes[i]));
+            Mat cpudst;
+            cv::blur(img, cpudst, Size(ksizes[i], ksizes[i]));
 
-        cv::Mat c;
-        cv::absdiff(cpudst, gpudst, c);
+            GpuMat gpu1(img);
+            GpuMat gpudst;
+            cv::gpu::blur(gpu1, gpudst, Size(ksizes[i], ksizes[i]));
 
-        if (CheckNorm(cpudst, gpudst) != CvTS::OK)
-            test_res = CvTS::FAIL_GENERIC;
-    }
+            cv::Mat c;
+            cv::absdiff(cpudst, gpudst, c);
 
-    return test_res;
-}
+            if (CheckNorm(cpudst, gpudst) != CvTS::OK)
+                test_res = CvTS::FAIL_GENERIC;
+        }
 
-//CV_GpuNppImageBlurTest CV_GpuNppImageBlur_test;
+        return test_res;
+    }
+};
 
 ////////////////////////////////////////////////////////////////////////////////
 // cvtColor
 class CV_GpuCvtColorTest : public CvTest
 {
 public:
-    CV_GpuCvtColorTest();
+    CV_GpuCvtColorTest() : CvTest("GPU-NppCvtColor", "cvtColor") {}
+    ~CV_GpuCvtColorTest() {};
 
 protected:
     void run(int);
@@ -541,9 +468,6 @@ protected:
     int CheckNorm(const Mat& m1, const Mat& m2);
 };
 
-CV_GpuCvtColorTest::CV_GpuCvtColorTest(): CvTest("GPU-NppCvtColor", "cvtColor")
-{
-}
 
 int CV_GpuCvtColorTest::CheckNorm(const Mat& m1, const Mat& m2)
 {
@@ -610,4 +534,19 @@ void CV_GpuCvtColorTest::run( int )
     ts->set_failed_test_info(testResult);
 }
 
-CV_GpuCvtColorTest CV_GpuCvtColor_test;
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+// If we comment some tests, we may foget/miss to uncomment it after.
+// Placing all test definitions in one place 
+// makes us know about what tests are commented.
+
+CV_GpuNppImageThresholdTest CV_GpuNppImageThreshold_test;\r
+CV_GpuNppImageResizeTest CV_GpuNppImageResize_test;\r
+CV_GpuNppImageCopyMakeBorderTest CV_GpuNppImageCopyMakeBorder_test;\r
+CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;\r
+CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;\r
+CV_GpuNppImageIntegralTest CV_GpuNppImageIntegral_test;\r
+CV_GpuNppImageBlurTest CV_GpuNppImageBlur_test;\r
+CV_GpuCvtColorTest CV_GpuCvtColor_test;
\ No newline at end of file
index 224db58a0d0df58251bc194caa5c6c857b177230..06bf9f95d410862bca195d9c7e75a4f9d6846e40 100644 (file)
 #include <string>\r
 \r
 \r
-class CV_GpuMeanShiftTest : public CvTest\r
+struct CV_GpuMeanShiftTest : public CvTest\r
 {\r
-public:\r
-    CV_GpuMeanShiftTest();\r
+    CV_GpuMeanShiftTest(): CvTest( "GPU-MeanShift", "MeanShift" ){}\r
 \r
-protected:\r
-    void run(int);\r
-};\r
-\r
-CV_GpuMeanShiftTest::CV_GpuMeanShiftTest(): CvTest( "GPU-MeanShift", "MeanShift" ){}\r
-\r
-void CV_GpuMeanShiftTest::run(int)\r
-{\r
-    int spatialRad = 30;\r
-    int colorRad = 30;\r
-\r
-    cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");\r
-    cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");\r
-\r
-    if (img.empty() || img_template.empty())\r
+    void run(int)\r
     {\r
-        ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
-        return;\r
-    }\r
+        int spatialRad = 30;\r
+        int colorRad = 30;\r
 \r
-    cv::Mat rgba;\r
-    cvtColor(img, rgba, CV_BGR2BGRA);\r
+        cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");\r
+        cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");\r
 \r
-    try\r
-    {\r
-        cv::gpu::GpuMat res;\r
-        cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );\r
-        if (res.type() != CV_8UC4)\r
+        if (img.empty() || img_template.empty())\r
         {\r
-            ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+            ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
             return;\r
         }\r
 \r
-        cv::Mat result;\r
-        res.download(result);\r
+        cv::Mat rgba;\r
+        cvtColor(img, rgba, CV_BGR2BGRA);\r
 \r
-        uchar maxDiff = 0;\r
-        for (int j = 0; j < result.rows; ++j)\r
+        try\r
         {\r
-            const uchar* res_line = result.ptr<uchar>(j);\r
-            const uchar* ref_line = img_template.ptr<uchar>(j);\r
+            cv::gpu::GpuMat res;\r
+            cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );\r
+            if (res.type() != CV_8UC4)\r
+            {\r
+                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+                return;\r
+            }\r
 \r
-            for (int i = 0; i < result.cols; ++i)\r
+            cv::Mat result;\r
+            res.download(result);\r
+\r
+            uchar maxDiff = 0;\r
+            for (int j = 0; j < result.rows; ++j)\r
             {\r
-                for (int k = 0; k < 3; ++k)\r
+                const uchar* res_line = result.ptr<uchar>(j);\r
+                const uchar* ref_line = img_template.ptr<uchar>(j);\r
+\r
+                for (int i = 0; i < result.cols; ++i)\r
                 {\r
-                    const uchar& ch1 = res_line[result.channels()*i + k];\r
-                    const uchar& ch2 = ref_line[img_template.channels()*i + k];\r
-                    uchar diff = static_cast<uchar>(abs(ch1 - ch2));\r
-                    if (maxDiff < diff)\r
-                        maxDiff = diff;\r
+                    for (int k = 0; k < 3; ++k)\r
+                    {\r
+                        const uchar& ch1 = res_line[result.channels()*i + k];\r
+                        const uchar& ch2 = ref_line[img_template.channels()*i + k];\r
+                        uchar diff = static_cast<uchar>(abs(ch1 - ch2));\r
+                        if (maxDiff < diff)\r
+                            maxDiff = diff;\r
+                    }\r
                 }\r
             }\r
+            if (maxDiff > 0) \r
+            {\r
+                ts->printf(CvTS::LOG, "\nMeanShift maxDiff = %d\n", maxDiff);\r
+                ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
+                return;\r
+            }\r
         }\r
-        if (maxDiff > 0) \r
+        catch(const cv::Exception& e)\r
         {\r
-            ts->printf(CvTS::LOG, "\nMeanShift maxDiff = %d\n", maxDiff);\r
-            ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
+            if (!check_and_treat_gpu_exception(e, ts))\r
+                throw;\r
             return;\r
         }\r
+\r
+        ts->set_failed_test_info(CvTS::OK);\r
     }\r
-    catch(const cv::Exception& e)\r
-    {\r
-        if (!check_and_treat_gpu_exception(e, ts))\r
-            throw;\r
-        return;\r
-    }\r
 \r
-    ts->set_failed_test_info(CvTS::OK);\r
-}\r
+};\r
+\r
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////\r
 \r
 CV_GpuMeanShiftTest CV_GpuMeanShift_test;\r
index d2d4d12398d90fcbe2c21510207f9b8e1d593432..617430ae3d9d70600970c526414f396d41d85448 100644 (file)
@@ -147,8 +147,6 @@ protected:
     }
 };
 
-CV_GpuErodeTest CV_GpuErode_test;
-
 ////////////////////////////////////////////////////////////////////////////////
 // Dilate
 class CV_GpuDilateTest : public CV_GpuNppMorphogyTest
@@ -173,8 +171,6 @@ protected:
     }
 };
 
-CV_GpuDilateTest CV_GpuDilate_test;
-
 ////////////////////////////////////////////////////////////////////////////////
 // Dilate
 class CV_GpuMorphExTest : public CV_GpuNppMorphogyTest
@@ -211,4 +207,13 @@ protected:
     }
 };
 
-CV_GpuMorphExTest CV_GpuMorphEx_test;
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+CV_GpuErodeTest CV_GpuErode_test;
+CV_GpuDilateTest CV_GpuDilate_test;
+CV_GpuMorphExTest CV_GpuMorphEx_test;
\ No newline at end of file
index 821e36718bb4f7bdab619dec37952c04d17880e4..2a8b19a93f128796de4d01d8341e7fc847c6fae0 100644 (file)
@@ -58,8 +58,13 @@ using namespace gpu;
 class CV_GpuMatAsyncCallTest : public CvTest
 {
     public:
-        CV_GpuMatAsyncCallTest();
-        ~CV_GpuMatAsyncCallTest();
+        CV_GpuMatAsyncCallTest() : CvTest( "GPU-MatOperatorAsyncCall", "async" )
+        {
+             rows = 234;
+            cols = 123;
+
+        }
+        ~CV_GpuMatAsyncCallTest() {}
 
     protected:
         void run(int);
@@ -72,21 +77,8 @@ class CV_GpuMatAsyncCallTest : public CvTest
         int cols;
 };
 
-CV_GpuMatAsyncCallTest::CV_GpuMatAsyncCallTest(): CvTest( "GPU-MatOperatorAsyncCall", "async" )
-{
-    rows = 234;
-    cols = 123;
-
-    //#define PRINT_MATRIX
-}
-
-CV_GpuMatAsyncCallTest::~CV_GpuMatAsyncCallTest() {}
-
 template<typename T>
-void CV_GpuMatAsyncCallTest::print_mat(const T & mat, const std::string & name) const
-{
-    cv::imshow(name, mat);
-}
+void CV_GpuMatAsyncCallTest::print_mat(const T & mat, const std::string & name) const { cv::imshow(name, mat); }
 
 bool CV_GpuMatAsyncCallTest::compare_matrix(cv::Mat & cpumat)
 {
@@ -160,4 +152,10 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
         ts->set_failed_test_info(CvTS::FAIL_GENERIC);
 }
 
-//CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+
+CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
index ab7b015f8e58bd4287159e77d2da622b2542c0f1..5b8111172a976f64ad2911946c0df846794898d3 100644 (file)
@@ -55,16 +55,13 @@ using namespace gpu;
 class CV_GpuMatOpConvertToTest : public CvTest
 {
     public:
-        CV_GpuMatOpConvertToTest();
-        ~CV_GpuMatOpConvertToTest();
+        CV_GpuMatOpConvertToTest() : CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {}
+        ~CV_GpuMatOpConvertToTest() {}
 
     protected:
         void run(int);
 };
 
-CV_GpuMatOpConvertToTest::CV_GpuMatOpConvertToTest(): CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {}
-CV_GpuMatOpConvertToTest::~CV_GpuMatOpConvertToTest() {}
-
 void CV_GpuMatOpConvertToTest::run(int /* start_from */)
 {
     const Size img_size(67, 35);
@@ -123,4 +120,8 @@ void CV_GpuMatOpConvertToTest::run(int /* start_from */)
     ts->set_failed_test_info(passed ? CvTS::OK : CvTS::FAIL_GENERIC);
 }
 
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 CV_GpuMatOpConvertToTest CV_GpuMatOpConvertToTest_test;
index f6ecf7d1d62af376bfd0ce4eb32cd02846fc39f9..56a6f115c851b9e46abd63e7cf06a2afa5e49530 100644 (file)
@@ -58,8 +58,12 @@ using namespace gpu;
 class CV_GpuMatOpCopyToTest : public CvTest
 {
     public:
-        CV_GpuMatOpCopyToTest();
-        ~CV_GpuMatOpCopyToTest();
+        CV_GpuMatOpCopyToTest() : CvTest( "GPU-MatOperatorCopyTo", "copyTo" ) 
+        {
+            rows = 234;
+            cols = 123;
+        }
+        ~CV_GpuMatOpCopyToTest() {}
 
     protected:
         void run(int);
@@ -72,21 +76,8 @@ class CV_GpuMatOpCopyToTest : public CvTest
         int cols;
 };
 
-CV_GpuMatOpCopyToTest::CV_GpuMatOpCopyToTest(): CvTest( "GPU-MatOperatorCopyTo", "copyTo" )
-{
-    rows = 234;
-    cols = 123;
-
-    //#define PRINT_MATRIX
-}
-
-CV_GpuMatOpCopyToTest::~CV_GpuMatOpCopyToTest() {}
-
 template<typename T>
-void CV_GpuMatOpCopyToTest::print_mat(const T & mat, const std::string & name) const
-{
-    cv::imshow(name, mat);
-}
+void CV_GpuMatOpCopyToTest::print_mat(const T & mat, const std::string & name) const { cv::imshow(name, mat); }
 
 bool CV_GpuMatOpCopyToTest::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
 {
@@ -161,4 +152,9 @@ void CV_GpuMatOpCopyToTest::run( int /* start_from */)
         ts->set_failed_test_info(CvTS::FAIL_GENERIC);
 }
 
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 CV_GpuMatOpCopyToTest CV_GpuMatOpCopyTo_test;
index c208ea924b5d1eebec0853581321932f7fc033fb..e5d28ca6dcd8e6913b39aadbcc9184212ddba7e0 100644 (file)
@@ -58,7 +58,7 @@ class CV_GpuMatOpSetToTest : public CvTest
 {
 public:
     CV_GpuMatOpSetToTest();
-    ~CV_GpuMatOpSetToTest();
+    ~CV_GpuMatOpSetToTest() {}
 
 protected:
     void run(int);
@@ -85,7 +85,6 @@ CV_GpuMatOpSetToTest::CV_GpuMatOpSetToTest(): CvTest( "GPU-MatOperatorSetTo", "s
     //#define PRINT_MATRIX
 }
 
-CV_GpuMatOpSetToTest::~CV_GpuMatOpSetToTest() {}
 
 void CV_GpuMatOpSetToTest::print_mat(cv::Mat & mat, std::string name )
 {
@@ -154,4 +153,9 @@ void CV_GpuMatOpSetToTest::run( int /* start_from */)
         ts->set_failed_test_info(CvTS::FAIL_GENERIC);
 }
 
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 CV_GpuMatOpSetToTest CV_GpuMatOpSetTo_test;
index fcbec178a03379795f70d0046d3220e6a9089626..e662cd9faeada25dcc645d3b295a6eecc7bf19e0 100644 (file)
@@ -9,13 +9,16 @@
 using namespace std;\r
 using namespace cv;\r
 \r
+////////////////////////////////////////////////////////////////////////////////
+// Merge\r
+\r
 struct CV_MergeTest : public CvTest\r
 {\r
     CV_MergeTest() : CvTest("GPU-Merge", "merge") {}\r
     void can_merge(size_t rows, size_t cols);\r
     void can_merge_submatrixes(size_t rows, size_t cols);\r
     void run(int);\r
-} merge_test;\r
+};\r
 \r
 \r
 void CV_MergeTest::can_merge(size_t rows, size_t cols)\r
@@ -40,17 +43,17 @@ void CV_MergeTest::can_merge(size_t rows, size_t cols)
 \r
             Mat host_dst = dev_dst;\r
 \r
-            double err = norm(dst, host_dst, NORM_INF);
-
-            if (err > 1e-3)
-            {
-                //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);
-                //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);
-                //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);
-                //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);
-                //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);
-                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
-                return;
+            double err = norm(dst, host_dst, NORM_INF);\r
+\r
+            if (err > 1e-3)\r
+            {\r
+                //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
+                //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
+                //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
+                //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
+                //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
+                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+                return;\r
             }\r
         }\r
 }\r
@@ -81,22 +84,21 @@ void CV_MergeTest::can_merge_submatrixes(size_t rows, size_t cols)
 \r
             Mat host_dst = dev_dst;\r
 \r
-            double err = norm(dst, host_dst, NORM_INF);
-
-            if (err > 1e-3)
-            {
-                //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);
-                //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);
-                //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);
-                //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);
-                //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);
-                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
-                return;
+            double err = norm(dst, host_dst, NORM_INF);\r
+\r
+            if (err > 1e-3)\r
+            {\r
+                //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
+                //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
+                //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
+                //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
+                //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
+                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+                return;\r
             }\r
         }\r
 }\r
 \r
-\r
 void CV_MergeTest::run(int) \r
 {\r
     try\r
@@ -108,22 +110,24 @@ void CV_MergeTest::run(int)
         can_merge_submatrixes(1, 7);\r
         can_merge_submatrixes(53, 7);\r
     }\r
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;        
+    catch(const cv::Exception& e)\r
+    {\r
+        if (!check_and_treat_gpu_exception(e, ts))\r
+            throw;        \r
     }    \r
 }\r
 \r
 \r
+////////////////////////////////////////////////////////////////////////////////
+// Split\r
+\r
 struct CV_SplitTest : public CvTest\r
 {\r
     CV_SplitTest() : CvTest("GPU-Split", "split") {}\r
     void can_split(size_t rows, size_t cols);    \r
     void can_split_submatrix(size_t rows, size_t cols);\r
     void run(int);\r
-} split_test;\r
-\r
+};\r
 \r
 void CV_SplitTest::can_split(size_t rows, size_t cols)\r
 {\r
@@ -147,24 +151,22 @@ void CV_SplitTest::can_split(size_t rows, size_t cols)
             for (size_t i = 0; i < num_channels; ++i)\r
             {\r
                 Mat host_dst = dev_dst[i];\r
-                double err = norm(dst[i], host_dst, NORM_INF);
-
-                if (err > 1e-3)
-                {
-                    //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);
-                    //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);
-                    //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);
-                    //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);
-                    //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);
-                    ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
-                    return;
+                double err = norm(dst[i], host_dst, NORM_INF);\r
+\r
+                if (err > 1e-3)\r
+                {\r
+                    //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
+                    //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
+                    //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
+                    //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
+                    //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
+                    ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+                    return;\r
                 }\r
             }\r
         }\r
 }\r
 \r
-\r
-\r
 void CV_SplitTest::can_split_submatrix(size_t rows, size_t cols)\r
 {\r
     for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
@@ -188,23 +190,22 @@ void CV_SplitTest::can_split_submatrix(size_t rows, size_t cols)
             for (size_t i = 0; i < num_channels; ++i)\r
             {\r
                 Mat host_dst = dev_dst[i];\r
-                double err = norm(dst[i], host_dst, NORM_INF);
-
-                if (err > 1e-3)
-                {
-                    //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);
-                    //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);
-                    //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);
-                    //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);
-                    //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);
-                    ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
-                    return;
+                double err = norm(dst[i], host_dst, NORM_INF);\r
+\r
+                if (err > 1e-3)\r
+                {\r
+                    //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
+                    //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
+                    //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
+                    //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
+                    //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
+                    ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+                    return;\r
                 }\r
             }\r
         }\r
 }\r
 \r
-\r
 void CV_SplitTest::run(int)\r
 {\r
     try \r
@@ -216,21 +217,23 @@ void CV_SplitTest::run(int)
         can_split_submatrix(1, 7);\r
         can_split_submatrix(7, 53);\r
     }\r
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;        
+    catch(const cv::Exception& e)\r
+    {\r
+        if (!check_and_treat_gpu_exception(e, ts))\r
+            throw;        \r
     }    \r
 }\r
 \r
+
+////////////////////////////////////////////////////////////////////////////////
+// Split and merge\r
 \r
 struct CV_SplitMergeTest : public CvTest\r
 {\r
     CV_SplitMergeTest() : CvTest("GPU-SplitMerge", "split merge") {}\r
     void can_split_merge(size_t rows, size_t cols);    \r
     void run(int);\r
-} split_merge_test;\r
-\r
+};\r
 \r
 void CV_SplitMergeTest::can_split_merge(size_t rows, size_t cols) {\r
     for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
@@ -244,16 +247,16 @@ void CV_SplitMergeTest::can_split_merge(size_t rows, size_t cols) {
             gpu::GpuMat dev_final(rows, cols, CV_MAKETYPE(depth, num_channels));\r
             cv::gpu::merge(dev_vec, dev_final);\r
 \r
-            double err = cv::norm((Mat)dev_orig, (Mat)dev_final, NORM_INF);
-            if (err > 1e-3)
-            {
-                //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);
-                //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);
-                //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);
-                //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);
-                //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);
-                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
-                return;
+            double err = cv::norm((Mat)dev_orig, (Mat)dev_final, NORM_INF);\r
+            if (err > 1e-3)\r
+            {\r
+                //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
+                //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
+                //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
+                //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
+                //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
+                ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+                return;\r
             }\r
         }\r
 }\r
@@ -267,9 +270,23 @@ void CV_SplitMergeTest::run(int)
         can_split_merge(1, 7);\r
         can_split_merge(7, 53);\r
     }\r
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;        
+    catch(const cv::Exception& e)\r
+    {\r
+        if (!check_and_treat_gpu_exception(e, ts))\r
+            throw;        \r
     }    \r
 }\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+// If we comment some tests, we may foget/miss to uncomment it after.
+// Placing all test definitions in one place 
+// makes us know about what tests are commented.\r
+\r
+\r
+CV_SplitTest split_test;\r
+CV_MergeTest merge_test;\r
+CV_SplitMergeTest split_merge_test;\r
index 682c7d19d1d9029366fbe3976c06c3ac30233ae4..b9211e04767aad912460850fff633541bda3ce0e 100644 (file)
 #include <string>
 
 
-class CV_GpuStereoBMTest : public CvTest
+struct CV_GpuStereoBMTest : public CvTest
 {
-public:
-       CV_GpuStereoBMTest();
+       CV_GpuStereoBMTest() : CvTest( "GPU-StereoBM", "StereoBM" ){}
+    ~CV_GpuStereoBMTest() {}
 
-protected:
-       void run(int);
-};
-
-CV_GpuStereoBMTest::CV_GpuStereoBMTest(): CvTest( "GPU-StereoBM", "StereoBM" ){}
-
-void CV_GpuStereoBMTest::run(int )
-{
-       cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png", 0);
-       cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png", 0);
-       cv::Mat img_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
-
-    if (img_l.empty() || img_r.empty() || img_reference.empty())
+    void run(int )
     {
-        ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
-        return;
-    }
+           cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png", 0);
+           cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png", 0);
+           cv::Mat img_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
 
-    try
-    {
-           cv::gpu::GpuMat disp;
-           cv::gpu::StereoBM_GPU bm(0, 128, 19);
-           bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
+        if (img_l.empty() || img_r.empty() || img_reference.empty())
+        {
+            ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
+            return;
+        }
+
+        try
+        {
+               cv::gpu::GpuMat disp;
+               cv::gpu::StereoBM_GPU bm(0, 128, 19);
+               bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
 
-           disp.convertTo(disp, img_reference.type());
-           double norm = cv::norm(disp, img_reference, cv::NORM_INF);
+               disp.convertTo(disp, img_reference.type());
+               double norm = cv::norm(disp, img_reference, cv::NORM_INF);
 
-           if (norm >= 100) 
+               if (norm >= 100) 
+            {
+                ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
+                   ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+                return;
+            }
+        }
+        catch(const cv::Exception& e)
         {
-            ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
-               ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+            if (!check_and_treat_gpu_exception(e, ts))
+                throw;
             return;
         }
+
+        ts->set_failed_test_info(CvTS::OK);
     }
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;
-        return;
-    }
+};
 
-    ts->set_failed_test_info(CvTS::OK);
-}
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 
 CV_GpuStereoBMTest CV_GpuStereoBM_test;
index 5d1255cb5d6b33878089c3e5087ec92246c3beb5..0ffc3f4aa64ccff692d4ac140497fb5fc3f5212e 100644 (file)
 using namespace cv;
 using namespace std;
 
-class CV_GpuMatAsyncCallStereoBMTest : public CvTest
+struct CV_GpuMatAsyncCallStereoBMTest : public CvTest
 {
     public:
-        CV_GpuMatAsyncCallStereoBMTest();
-        ~CV_GpuMatAsyncCallStereoBMTest();
+        CV_GpuMatAsyncCallStereoBMTest() : CvTest( "GPU-MatAsyncCallStereoBM", "asyncStereoBM" ) {}
+        ~CV_GpuMatAsyncCallStereoBMTest() {}
 
-    protected:
-        void run(int);
-};
-
-CV_GpuMatAsyncCallStereoBMTest::CV_GpuMatAsyncCallStereoBMTest(): CvTest( "GPU-MatAsyncCallStereoBM", "asyncStereoBM" )
-{}
-
-CV_GpuMatAsyncCallStereoBMTest::~CV_GpuMatAsyncCallStereoBMTest() {}
-
-void CV_GpuMatAsyncCallStereoBMTest::run( int /* start_from */)
-{
-       cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png", 0);
-       cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png", 0);
-       cv::Mat img_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
-
-    if (img_l.empty() || img_r.empty() || img_reference.empty())
+    void run( int /* start_from */)
     {
-        ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
-        return;
-    }
-
-    try
-    {
-           cv::gpu::GpuMat disp;
-           cv::gpu::StereoBM_GPU bm(0, 128, 19);
-
-           cv::gpu::Stream stream;
+           cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png", 0);
+           cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png", 0);
+           cv::Mat img_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
 
-           for (size_t i = 0; i < 50; i++)
-           {
-                   bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp, stream);
-           }
-
-           stream.waitForCompletion();
-           disp.convertTo(disp, img_reference.type());
-           double norm = cv::norm(disp, img_reference, cv::NORM_INF);
+        if (img_l.empty() || img_r.empty() || img_reference.empty())
+        {
+            ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
+            return;
+        }
 
-           if (norm >= 100) 
+        try
+        {
+               cv::gpu::GpuMat disp;
+               cv::gpu::StereoBM_GPU bm(0, 128, 19);
+
+               cv::gpu::Stream stream;
+
+               for (size_t i = 0; i < 50; i++)
+               {
+                       bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp, stream);
+               }
+
+               stream.waitForCompletion();
+               disp.convertTo(disp, img_reference.type());
+               double norm = cv::norm(disp, img_reference, cv::NORM_INF);
+
+               if (norm >= 100) 
+            {
+                ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
+                   ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+                return;
+            }
+        }
+        catch(const cv::Exception& e)
         {
-            ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
-               ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+            if (!check_and_treat_gpu_exception(e, ts))
+                throw;
             return;
         }
+
+        ts->set_failed_test_info(CvTS::OK);
     }
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;
-        return;
-    }
+};
 
-    ts->set_failed_test_info(CvTS::OK);
-}
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 
 CV_GpuMatAsyncCallStereoBMTest CV_GpuMatAsyncCallStereoBMTest_test;
index a6baf908017b70cc381e9238dcc2cdbcee714f42..601c78feefa345d37c94842c9b96da65f5339817 100644 (file)
 #include <string>
 
 
-class CV_GpuStereoBPTest : public CvTest
+struct CV_GpuStereoBPTest : public CvTest
 {
-    public:
-        CV_GpuStereoBPTest();
-    protected:
-        void run(int);
-};
-
-CV_GpuStereoBPTest::CV_GpuStereoBPTest(): CvTest( "GPU-StereoBP", "StereoBP" ){}
-
-void CV_GpuStereoBPTest::run(int )
-{
-    cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");
-    cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");
-    cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", 0);
-
-    if (img_l.empty() || img_r.empty() || img_template.empty())
+    CV_GpuStereoBPTest() : CvTest( "GPU-StereoBP", "StereoBP" ){}
+    ~CV_GpuStereoBPTest() {}
+  
+    void run(int )
     {
-        ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
-        return;
-    }
+        cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");
+        cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");
+        cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", 0);
 
-    try
-    {
-        cv::gpu::GpuMat disp;
-        cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
+        if (img_l.empty() || img_r.empty() || img_template.empty())
+        {
+            ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
+            return;
+        }
+
+        try
+        {
+            cv::gpu::GpuMat disp;
+            cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
 
-        bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
+            bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
 
-        //cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);
+            //cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);
 
-        disp.convertTo(disp, img_template.type());
+            disp.convertTo(disp, img_template.type());
 
-        double norm = cv::norm(disp, img_template, cv::NORM_INF);
-           if (norm >= 0.5) 
+            double norm = cv::norm(disp, img_template, cv::NORM_INF);
+               if (norm >= 0.5) 
+            {
+                ts->printf(CvTS::LOG, "\nStereoBP norm = %f\n", norm);
+                ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+                return;
+            }
+        }
+        catch(const cv::Exception& e)
         {
-            ts->printf(CvTS::LOG, "\nStereoBP norm = %f\n", norm);
-            ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+            if (!check_and_treat_gpu_exception(e, ts))
+                throw;
             return;
         }
+
+        ts->set_failed_test_info(CvTS::OK);
     }
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;
-        return;
-    }
+};
 
-    ts->set_failed_test_info(CvTS::OK);
-}
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 
 CV_GpuStereoBPTest CV_GpuStereoBP_test;
index 3d80c6df52549cdde4a57ab9ddb4678f003744ce..c0cacb732f7ea76a41889c00d3672bd4d26ea60c 100644 (file)
 #include <iostream>
 #include <string>
 
-
-class CV_GpuStereoCSBPTest : public CvTest
-{
-    public:
-        CV_GpuStereoCSBPTest();
-    protected:
-        void run(int);
-};
-
-CV_GpuStereoCSBPTest::CV_GpuStereoCSBPTest(): CvTest( "GPU-StereoCSBP", "ConstantSpaceStereoBP" ){}
-
-void CV_GpuStereoCSBPTest::run(int )
+struct CV_GpuStereoCSBPTest : public CvTest
 {
-    cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-L.png");
-    cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-R.png");
-    cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", 0);
+    CV_GpuStereoCSBPTest() : CvTest( "GPU-StereoCSBP", "ConstantSpaceStereoBP" ){}
+    ~CV_GpuStereoCSBPTest() {}
 
-    if (img_l.empty() || img_r.empty() || img_template.empty())
+    void run(int )
     {
-        ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
-        return;
-    }
+        cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-L.png");
+        cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-R.png");
+        cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", 0);
 
-    try
-    {
-        cv::gpu::GpuMat disp;
-        cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
+        if (img_l.empty() || img_r.empty() || img_template.empty())
+        {
+            ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
+            return;
+        }
+
+        try
+        {
+            cv::gpu::GpuMat disp;
+            cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
 
-        bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
+            bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
 
-        //cv::imwrite(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", disp);
+            //cv::imwrite(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", disp);
 
-        disp.convertTo(disp, img_template.type());
+            disp.convertTo(disp, img_template.type());
 
-        double norm = cv::norm(disp, img_template, cv::NORM_INF);
-           if (norm >= 0.5) 
+            double norm = cv::norm(disp, img_template, cv::NORM_INF);
+            if (norm >= 0.5) 
+            {
+                ts->printf(CvTS::LOG, "\nConstantSpaceStereoBP norm = %f\n", norm);
+                ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+                return;
+            }
+        }
+        catch(const cv::Exception& e)
         {
-            ts->printf(CvTS::LOG, "\nConstantSpaceStereoBP norm = %f\n", norm);
-            ts->set_failed_test_info(CvTS::FAIL_GENERIC);
+            if (!check_and_treat_gpu_exception(e, ts))
+                throw;
             return;
         }
+
+        ts->set_failed_test_info(CvTS::OK);
     }
-    catch(const cv::Exception& e)
-    {
-        if (!check_and_treat_gpu_exception(e, ts))
-            throw;
-        return;
-    }
+};
 
-    ts->set_failed_test_info(CvTS::OK);
-}
+/////////////////////////////////////////////////////////////////////////////
+/////////////////// tests registration  /////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
 
 CV_GpuStereoCSBPTest CV_GpuCSStereoBP_test;