refactored gpu module tests
authorVladislav Vinogradov <no@email>
Wed, 29 Jun 2011 10:14:16 +0000 (10:14 +0000)
committerVladislav Vinogradov <no@email>
Wed, 29 Jun 2011 10:14:16 +0000 (10:14 +0000)
37 files changed:
modules/gpu/include/opencv2/gpu/gpu.hpp
modules/gpu/src/calib3d.cpp
modules/gpu/src/cuda/brute_force_matcher.cu
modules/gpu/src/cuda/mathfunc.cu
modules/gpu/src/element_operations.cpp
modules/gpu/test/nvidia/NCVAutoTestLister.hpp
modules/gpu/test/nvidia/main_nvidia.cpp
modules/gpu/test/test_arithm.cpp
modules/gpu/test/test_bitwise_oper.cpp [deleted file]
modules/gpu/test/test_blend.cpp [deleted file]
modules/gpu/test/test_brute_force_matcher.cpp [deleted file]
modules/gpu/test/test_calib3d.cpp
modules/gpu/test/test_dft_routines.cpp [deleted file]
modules/gpu/test/test_features2d.cpp
modules/gpu/test/test_filters.cpp
modules/gpu/test/test_gpu_base.cpp [new file with mode: 0644]
modules/gpu/test/test_gpu_base.hpp [new file with mode: 0644]
modules/gpu/test/test_hog.cpp
modules/gpu/test/test_imgproc.cpp [new file with mode: 0644]
modules/gpu/test/test_imgproc_gpu.cpp [deleted file]
modules/gpu/test/test_main.cpp
modules/gpu/test/test_match_template.cpp [deleted file]
modules/gpu/test/test_matop.cpp [new file with mode: 0644]
modules/gpu/test/test_meanshift.cpp [deleted file]
modules/gpu/test/test_mssegmentation.cpp [deleted file]
modules/gpu/test/test_nvidia.cpp
modules/gpu/test/test_operator_async_call.cpp [deleted file]
modules/gpu/test/test_operator_convert_to.cpp [deleted file]
modules/gpu/test/test_operator_copy_to.cpp [deleted file]
modules/gpu/test/test_operator_set_to.cpp [deleted file]
modules/gpu/test/test_precomp.cpp
modules/gpu/test/test_precomp.hpp
modules/gpu/test/test_split_merge.cpp [deleted file]
modules/gpu/test/test_stereo_bm.cpp [deleted file]
modules/gpu/test/test_stereo_bm_async.cpp [deleted file]
modules/gpu/test/test_stereo_bp.cpp [deleted file]
modules/gpu/test/test_stereo_csbp.cpp [deleted file]

index 7c1ebb7..9cd0709 100644 (file)
@@ -124,6 +124,8 @@ namespace cv
             // Checks whether the GPU module can be run on the given device\r
             bool isCompatible() const;\r
 \r
+            int deviceID() const { return device_id_; }\r
+\r
         private:\r
             void query();\r
             void queryMemory(size_t& free_memory, size_t& total_memory) const;\r
@@ -517,14 +519,14 @@ namespace cv
         //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
         CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
         //! multiplies matrix to a scalar (c = a * s)\r
-        //! supports CV_32FC1 and CV_32FC2 type\r
+        //! supports CV_32FC1 type\r
         CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());\r
 \r
         //! computes element-wise quotient of the two arrays (c = a / b)\r
         //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
         CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
         //! computes element-wise quotient of matrix and scalar (c = a / s)\r
-        //! supports CV_32FC1 and CV_32FC2 type\r
+        //! supports CV_32FC1 type\r
         CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());\r
 \r
         //! computes exponent of each matrix element (b = e**a)\r
@@ -1412,9 +1414,9 @@ namespace cv
             void radiusMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, float maxDistance,\r
                 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);\r
 \r
-        private:\r
             DistType distType;\r
 \r
+        private:\r
             std::vector<GpuMat> trainDescCollection;\r
         };\r
 \r
index 84db041..301ea81 100644 (file)
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#if !defined(HAVE_CUDA)
-
-void cv::gpu::transformPoints(const GpuMat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }
-
-void cv::gpu::projectPoints(const GpuMat&, const Mat&, const Mat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }
-
-void cv::gpu::solvePnPRansac(const Mat&, const Mat&, const Mat&, const Mat&, Mat&, Mat&, bool, int, float, int, vector<int>*) { throw_nogpu(); }
-
-#else
-
-using namespace cv;
-using namespace cv::gpu;
-
-namespace cv { namespace gpu { namespace transform_points 
-{
-    void call(const DevMem2D_<float3> src, const float* rot, const float* transl, DevMem2D_<float3> dst, cudaStream_t stream);
-}}}
-
-namespace
-{
-    void transformPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec, GpuMat& dst, cudaStream_t stream)
-    {
-        CV_Assert(src.rows == 1 && src.cols > 0 && src.type() == CV_32FC3);
-        CV_Assert(rvec.size() == Size(3, 1) && rvec.type() == CV_32F);
-        CV_Assert(tvec.size() == Size(3, 1) && tvec.type() == CV_32F);
-
-        // Convert rotation vector into matrix
-        Mat rot;
-        Rodrigues(rvec, rot);
-
-        dst.create(src.size(), src.type());
-        transform_points::call(src, rot.ptr<float>(), tvec.ptr<float>(), dst, stream);
-    }
-}
-
-void cv::gpu::transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, GpuMat& dst, Stream& stream)
-{
-    ::transformPointsCaller(src, rvec, tvec, dst, StreamAccessor::getStream(stream));
-}
-
-namespace cv { namespace gpu { namespace project_points 
-{
-    void call(const DevMem2D_<float3> src, const float* rot, const float* transl, const float* proj, DevMem2D_<float2> dst, cudaStream_t stream);
-}}}
-
-
-namespace
-{
-    void projectPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec, const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, cudaStream_t stream)
-    {
-        CV_Assert(src.rows == 1 && src.cols > 0 && src.type() == CV_32FC3);
-        CV_Assert(rvec.size() == Size(3, 1) && rvec.type() == CV_32F);
-        CV_Assert(tvec.size() == Size(3, 1) && tvec.type() == CV_32F);
-        CV_Assert(camera_mat.size() == Size(3, 3) && camera_mat.type() == CV_32F);
-        CV_Assert(dist_coef.empty()); // Undistortion isn't supported
-
-        // Convert rotation vector into matrix
-        Mat rot;
-        Rodrigues(rvec, rot);
-
-        dst.create(src.size(), CV_32FC2);
-        project_points::call(src, rot.ptr<float>(), tvec.ptr<float>(), camera_mat.ptr<float>(), dst,stream);
-    }
-}
-
-void cv::gpu::projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, Stream& stream)
-{
-    ::projectPointsCaller(src, rvec, tvec, camera_mat, dist_coef, dst, StreamAccessor::getStream(stream));
-}
-
-
-namespace cv { namespace gpu { namespace solve_pnp_ransac
-{
-    int maxNumIters();
-
-    void computeHypothesisScores(
-            const int num_hypotheses, const int num_points, const float* rot_matrices,
-            const float3* transl_vectors, const float3* object, const float2* image,
-            const float dist_threshold, int* hypothesis_scores);
-}}}
-
-namespace
-{
-    // Selects subset_size random different points from [0, num_points - 1] range
-    void selectRandom(int subset_size, int num_points, vector<int>& subset)
-    {
-        subset.resize(subset_size);
-        for (int i = 0; i < subset_size; ++i)
-        {
-            bool was;
-            do
-            {
-                subset[i] = rand() % num_points;
-                was = false;
-                for (int j = 0; j < i; ++j)
-                    if (subset[j] == subset[i])
-                    {
-                        was = true;
-                        break;
-                    }
-            } while (was);
-        }
-    }
-
-    // Computes rotation, translation pair for small subsets if the input data
-    class TransformHypothesesGenerator
-    {
-    public:
-        TransformHypothesesGenerator(const Mat& object_, const Mat& image_, const Mat& dist_coef_, 
-                                     const Mat& camera_mat_, int num_points_, int subset_size_, 
-                                     Mat rot_matrices_, Mat transl_vectors_)
-                : object(&object_), image(&image_), dist_coef(&dist_coef_), camera_mat(&camera_mat_), 
-                  num_points(num_points_), subset_size(subset_size_), rot_matrices(rot_matrices_), 
-                  transl_vectors(transl_vectors_) {}
-
-        void operator()(const BlockedRange& range) const
-        {
-            // Input data for generation of the current hypothesis
-            vector<int> subset_indices(subset_size);
-            Mat_<Point3f> object_subset(1, subset_size);
-            Mat_<Point2f> image_subset(1, subset_size);
-
-            // Current hypothesis data
-            Mat rot_vec(1, 3, CV_64F);
-            Mat rot_mat(3, 3, CV_64F);
-            Mat transl_vec(1, 3, CV_64F);
-
-            for (int iter = range.begin(); iter < range.end(); ++iter)
-            {
-                selectRandom(subset_size, num_points, subset_indices);
-                for (int i = 0; i < subset_size; ++i)
-                {
-                   object_subset(0, i) = object->at<Point3f>(subset_indices[i]);
-                   image_subset(0, i) = image->at<Point2f>(subset_indices[i]);
-                }
-
-                solvePnP(object_subset, image_subset, *camera_mat, *dist_coef, rot_vec, transl_vec);
-
-                // Remember translation vector
-                Mat transl_vec_ = transl_vectors.colRange(iter * 3, (iter + 1) * 3);
-                transl_vec = transl_vec.reshape(0, 1);
-                transl_vec.convertTo(transl_vec_, CV_32F);
-
-                // Remember rotation matrix
-                Rodrigues(rot_vec, rot_mat);
-                Mat rot_mat_ = rot_matrices.colRange(iter * 9, (iter + 1) * 9).reshape(0, 3);
-                rot_mat.convertTo(rot_mat_, CV_32F);
-            }
-        }
-
-        const Mat* object;
-        const Mat* image;
-        const Mat* dist_coef;
-        const Mat* camera_mat;
-        int num_points;
-        int subset_size;
-
-        // Hypotheses storage (global)
-        Mat rot_matrices;
-        Mat transl_vectors;
-    };
-}
-
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                           License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of the copyright holders may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#if !defined(HAVE_CUDA)\r
+\r
+void cv::gpu::transformPoints(const GpuMat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+\r
+void cv::gpu::projectPoints(const GpuMat&, const Mat&, const Mat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+\r
+void cv::gpu::solvePnPRansac(const Mat&, const Mat&, const Mat&, const Mat&, Mat&, Mat&, bool, int, float, int, vector<int>*) { throw_nogpu(); }\r
+\r
+#else\r
+\r
+using namespace cv;\r
+using namespace cv::gpu;\r
+\r
+namespace cv { namespace gpu { namespace transform_points \r
+{\r
+    void call(const DevMem2D_<float3> src, const float* rot, const float* transl, DevMem2D_<float3> dst, cudaStream_t stream);\r
+}}}\r
+\r
+namespace\r
+{\r
+    void transformPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec, GpuMat& dst, cudaStream_t stream)\r
+    {\r
+        CV_Assert(src.rows == 1 && src.cols > 0 && src.type() == CV_32FC3);\r
+        CV_Assert(rvec.size() == Size(3, 1) && rvec.type() == CV_32F);\r
+        CV_Assert(tvec.size() == Size(3, 1) && tvec.type() == CV_32F);\r
+\r
+        // Convert rotation vector into matrix\r
+        Mat rot;\r
+        Rodrigues(rvec, rot);\r
+\r
+        dst.create(src.size(), src.type());\r
+        transform_points::call(src, rot.ptr<float>(), tvec.ptr<float>(), dst, stream);\r
+    }\r
+}\r
+\r
+void cv::gpu::transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, GpuMat& dst, Stream& stream)\r
+{\r
+    ::transformPointsCaller(src, rvec, tvec, dst, StreamAccessor::getStream(stream));\r
+}\r
+\r
+namespace cv { namespace gpu { namespace project_points \r
+{\r
+    void call(const DevMem2D_<float3> src, const float* rot, const float* transl, const float* proj, DevMem2D_<float2> dst, cudaStream_t stream);\r
+}}}\r
+\r
+\r
+namespace\r
+{\r
+    void projectPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec, const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, cudaStream_t stream)\r
+    {\r
+        CV_Assert(src.rows == 1 && src.cols > 0 && src.type() == CV_32FC3);\r
+        CV_Assert(rvec.size() == Size(3, 1) && rvec.type() == CV_32F);\r
+        CV_Assert(tvec.size() == Size(3, 1) && tvec.type() == CV_32F);\r
+        CV_Assert(camera_mat.size() == Size(3, 3) && camera_mat.type() == CV_32F);\r
+        CV_Assert(dist_coef.empty()); // Undistortion isn't supported\r
+\r
+        // Convert rotation vector into matrix\r
+        Mat rot;\r
+        Rodrigues(rvec, rot);\r
+\r
+        dst.create(src.size(), CV_32FC2);\r
+        project_points::call(src, rot.ptr<float>(), tvec.ptr<float>(), camera_mat.ptr<float>(), dst,stream);\r
+    }\r
+}\r
+\r
+void cv::gpu::projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, Stream& stream)\r
+{\r
+    ::projectPointsCaller(src, rvec, tvec, camera_mat, dist_coef, dst, StreamAccessor::getStream(stream));\r
+}\r
+\r
+\r
+namespace cv { namespace gpu { namespace solve_pnp_ransac\r
+{\r
+    int maxNumIters();\r
+\r
+    void computeHypothesisScores(\r
+            const int num_hypotheses, const int num_points, const float* rot_matrices,\r
+            const float3* transl_vectors, const float3* object, const float2* image,\r
+            const float dist_threshold, int* hypothesis_scores);\r
+}}}\r
+\r
+namespace\r
+{\r
+    // Selects subset_size random different points from [0, num_points - 1] range\r
+    void selectRandom(int subset_size, int num_points, vector<int>& subset)\r
+    {\r
+        subset.resize(subset_size);\r
+        for (int i = 0; i < subset_size; ++i)\r
+        {\r
+            bool was;\r
+            do\r
+            {\r
+                subset[i] = rand() % num_points;\r
+                was = false;\r
+                for (int j = 0; j < i; ++j)\r
+                    if (subset[j] == subset[i])\r
+                    {\r
+                        was = true;\r
+                        break;\r
+                    }\r
+            } while (was);\r
+        }\r
+    }\r
+\r
+    // Computes rotation, translation pair for small subsets if the input data\r
+    class TransformHypothesesGenerator\r
+    {\r
+    public:\r
+        TransformHypothesesGenerator(const Mat& object_, const Mat& image_, const Mat& dist_coef_, \r
+                                     const Mat& camera_mat_, int num_points_, int subset_size_, \r
+                                     Mat rot_matrices_, Mat transl_vectors_)\r
+                : object(&object_), image(&image_), dist_coef(&dist_coef_), camera_mat(&camera_mat_), \r
+                  num_points(num_points_), subset_size(subset_size_), rot_matrices(rot_matrices_), \r
+                  transl_vectors(transl_vectors_) {}\r
+\r
+        void operator()(const BlockedRange& range) const\r
+        {\r
+            // Input data for generation of the current hypothesis\r
+            vector<int> subset_indices(subset_size);\r
+            Mat_<Point3f> object_subset(1, subset_size);\r
+            Mat_<Point2f> image_subset(1, subset_size);\r
+\r
+            // Current hypothesis data\r
+            Mat rot_vec(1, 3, CV_64F);\r
+            Mat rot_mat(3, 3, CV_64F);\r
+            Mat transl_vec(1, 3, CV_64F);\r
+\r
+            for (int iter = range.begin(); iter < range.end(); ++iter)\r
+            {\r
+                selectRandom(subset_size, num_points, subset_indices);\r
+                for (int i = 0; i < subset_size; ++i)\r
+                {\r
+                   object_subset(0, i) = object->at<Point3f>(subset_indices[i]);\r
+                   image_subset(0, i) = image->at<Point2f>(subset_indices[i]);\r
+                }\r
+\r
+                solvePnP(object_subset, image_subset, *camera_mat, *dist_coef, rot_vec, transl_vec);\r
+\r
+                // Remember translation vector\r
+                Mat transl_vec_ = transl_vectors.colRange(iter * 3, (iter + 1) * 3);\r
+                transl_vec = transl_vec.reshape(0, 1);\r
+                transl_vec.convertTo(transl_vec_, CV_32F);\r
+\r
+                // Remember rotation matrix\r
+                Rodrigues(rot_vec, rot_mat);\r
+                Mat rot_mat_ = rot_matrices.colRange(iter * 9, (iter + 1) * 9).reshape(0, 3);\r
+                rot_mat.convertTo(rot_mat_, CV_32F);\r
+            }\r
+        }\r
+\r
+        const Mat* object;\r
+        const Mat* image;\r
+        const Mat* dist_coef;\r
+        const Mat* camera_mat;\r
+        int num_points;\r
+        int subset_size;\r
+\r
+        // Hypotheses storage (global)\r
+        Mat rot_matrices;\r
+        Mat transl_vectors;\r
+    };\r
+}\r
+\r
 void cv::gpu::solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat,\r
                              const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess,\r
                              int num_iters, float max_dist, int min_inlier_count, \r
-                             vector<int>* inliers)
-{
-    CV_Assert(object.rows == 1 && object.cols > 0 && object.type() == CV_32FC3);
-    CV_Assert(image.rows == 1 && image.cols > 0 && image.type() == CV_32FC2);
-    CV_Assert(object.cols == image.cols);
-    CV_Assert(camera_mat.size() == Size(3, 3) && camera_mat.type() == CV_32F);
-    CV_Assert(!use_extrinsic_guess); // We don't support initial guess for now
-    CV_Assert(num_iters <= solve_pnp_ransac::maxNumIters());
-
-    const int subset_size = 4;
-    const int num_points = object.cols;
-    CV_Assert(num_points >= subset_size);
-
-    // Unapply distortion and intrinsic camera transformations
-    Mat eye_camera_mat = Mat::eye(3, 3, CV_32F);
-    Mat empty_dist_coef;
-    Mat image_normalized;
-    undistortPoints(image, image_normalized, camera_mat, dist_coef, Mat(), eye_camera_mat);
-
-    // Hypotheses storage (global)
-    Mat rot_matrices(1, num_iters * 9, CV_32F);
-    Mat transl_vectors(1, num_iters * 3, CV_32F);
-
-    // Generate set of hypotheses using small subsets of the input data
-    TransformHypothesesGenerator body(object, image_normalized, empty_dist_coef, eye_camera_mat, 
-                                      num_points, subset_size, rot_matrices, transl_vectors);
-    parallel_for(BlockedRange(0, num_iters), body);
-
-    // Compute scores (i.e. number of inliers) for each hypothesis
-    GpuMat d_object(object);
-    GpuMat d_image_normalized(image_normalized);
-    GpuMat d_hypothesis_scores(1, num_iters, CV_32S);
-    solve_pnp_ransac::computeHypothesisScores(
-            num_iters, num_points, rot_matrices.ptr<float>(), transl_vectors.ptr<float3>(),
-            d_object.ptr<float3>(), d_image_normalized.ptr<float2>(), max_dist * max_dist, 
-            d_hypothesis_scores.ptr<int>());
-
-    // Find the best hypothesis index
-    Point best_idx;
-    double best_score;
-    minMaxLoc(d_hypothesis_scores, NULL, &best_score, NULL, &best_idx);
-    int num_inliers = static_cast<int>(best_score);
-
-    // Extract the best hypothesis data
-
-    Mat rot_mat = rot_matrices.colRange(best_idx.x * 9, (best_idx.x + 1) * 9).reshape(0, 3);
-    Rodrigues(rot_mat, rvec);
-    rvec = rvec.reshape(0, 1);
-
-    tvec = transl_vectors.colRange(best_idx.x * 3, (best_idx.x + 1) * 3).clone();
-    tvec = tvec.reshape(0, 1);
-
-    // Build vector of inlier indices
-    if (inliers != NULL)
-    {
-        inliers->clear();
-        inliers->reserve(num_inliers);
-
-        Point3f p, p_transf;
-        Point2f p_proj;
-        const float* rot = rot_mat.ptr<float>();
-        const float* transl = tvec.ptr<float>();
-
-        for (int i = 0; i < num_points; ++i)
-        {
-            p = object.at<Point3f>(0, i);
-            p_transf.x = rot[0] * p.x + rot[1] * p.y + rot[2] * p.z + transl[0];
-            p_transf.y = rot[3] * p.x + rot[4] * p.y + rot[5] * p.z + transl[1];
-            p_transf.z = rot[6] * p.x + rot[7] * p.y + rot[8] * p.z + transl[2];
-            p_proj.x = p_transf.x / p_transf.z;
-            p_proj.y = p_transf.y / p_transf.z;
-            if (norm(p_proj - image_normalized.at<Point2f>(0, i)) < max_dist)
-                inliers->push_back(i);
-        }
-    }
-}
-
-#endif
-
-
+                             vector<int>* inliers)\r
+{\r
+    CV_Assert(object.rows == 1 && object.cols > 0 && object.type() == CV_32FC3);\r
+    CV_Assert(image.rows == 1 && image.cols > 0 && image.type() == CV_32FC2);\r
+    CV_Assert(object.cols == image.cols);\r
+    CV_Assert(camera_mat.size() == Size(3, 3) && camera_mat.type() == CV_32F);\r
+    CV_Assert(!use_extrinsic_guess); // We don't support initial guess for now\r
+    CV_Assert(num_iters <= solve_pnp_ransac::maxNumIters());\r
+\r
+    const int subset_size = 4;\r
+    const int num_points = object.cols;\r
+    CV_Assert(num_points >= subset_size);\r
+\r
+    // Unapply distortion and intrinsic camera transformations\r
+    Mat eye_camera_mat = Mat::eye(3, 3, CV_32F);\r
+    Mat empty_dist_coef;\r
+    Mat image_normalized;\r
+    undistortPoints(image, image_normalized, camera_mat, dist_coef, Mat(), eye_camera_mat);\r
+\r
+    // Hypotheses storage (global)\r
+    Mat rot_matrices(1, num_iters * 9, CV_32F);\r
+    Mat transl_vectors(1, num_iters * 3, CV_32F);\r
+\r
+    // Generate set of hypotheses using small subsets of the input data\r
+    TransformHypothesesGenerator body(object, image_normalized, empty_dist_coef, eye_camera_mat, \r
+                                      num_points, subset_size, rot_matrices, transl_vectors);\r
+    parallel_for(BlockedRange(0, num_iters), body);\r
+\r
+    // Compute scores (i.e. number of inliers) for each hypothesis\r
+    GpuMat d_object(object);\r
+    GpuMat d_image_normalized(image_normalized);\r
+    GpuMat d_hypothesis_scores(1, num_iters, CV_32S);\r
+    solve_pnp_ransac::computeHypothesisScores(\r
+            num_iters, num_points, rot_matrices.ptr<float>(), transl_vectors.ptr<float3>(),\r
+            d_object.ptr<float3>(), d_image_normalized.ptr<float2>(), max_dist * max_dist, \r
+            d_hypothesis_scores.ptr<int>());\r
+\r
+    // Find the best hypothesis index\r
+    Point best_idx;\r
+    double best_score;\r
+    minMaxLoc(d_hypothesis_scores, NULL, &best_score, NULL, &best_idx);\r
+    int num_inliers = static_cast<int>(best_score);\r
+\r
+    // Extract the best hypothesis data\r
+\r
+    Mat rot_mat = rot_matrices.colRange(best_idx.x * 9, (best_idx.x + 1) * 9).reshape(0, 3);\r
+    Rodrigues(rot_mat, rvec);\r
+    rvec = rvec.reshape(0, 1);\r
+\r
+    tvec = transl_vectors.colRange(best_idx.x * 3, (best_idx.x + 1) * 3).clone();\r
+    tvec = tvec.reshape(0, 1);\r
+\r
+    // Build vector of inlier indices\r
+    if (inliers != NULL)\r
+    {\r
+        inliers->clear();\r
+        inliers->reserve(num_inliers);\r
+\r
+        Point3f p, p_transf;\r
+        Point2f p_proj;\r
+        const float* rot = rot_mat.ptr<float>();\r
+        const float* transl = tvec.ptr<float>();\r
+\r
+        for (int i = 0; i < num_points; ++i)\r
+        {\r
+            p = object.at<Point3f>(0, i);\r
+            p_transf.x = rot[0] * p.x + rot[1] * p.y + rot[2] * p.z + transl[0];\r
+            p_transf.y = rot[3] * p.x + rot[4] * p.y + rot[5] * p.z + transl[1];\r
+            p_transf.z = rot[6] * p.x + rot[7] * p.y + rot[8] * p.z + transl[2];\r
+            p_proj.x = p_transf.x / p_transf.z;\r
+            p_proj.y = p_transf.y / p_transf.z;\r
+            if (norm(p_proj - image_normalized.at<Point2f>(0, i)) < max_dist)\r
+                inliers->push_back(i);\r
+        }\r
+    }\r
+}\r
+\r
+#endif\r
+\r
+\r
index fa06589..27b8e53 100644 (file)
@@ -646,9 +646,9 @@ namespace cv { namespace gpu { namespace bfmatcher
             matchCached_caller<16, 16, 64, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
         else if (queryDescs.cols < 128)\r
             matchCached_caller<16, 16, 128, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
-        else if (queryDescs.cols == 128)\r
+        else if (queryDescs.cols == 128 && cc_12)\r
             matchCached_caller<16, 16, 128, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
-        else if (queryDescs.cols < 256)\r
+        else if (queryDescs.cols < 256 && cc_12)\r
             matchCached_caller<16, 16, 256, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
         else if (queryDescs.cols == 256 && cc_12)\r
             matchCached_caller<16, 16, 256, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
index bed7a04..f685625 100644 (file)
@@ -82,7 +82,9 @@ namespace cv { namespace gpu { namespace mathfunc
     {\r
         static __device__ __forceinline__ void calc(int x, int y, float x_data, float y_data, float* dst, size_t dst_step, float scale)\r
         {\r
-            dst[y * dst_step + x] = scale * atan2f(y_data, x_data);\r
+            float angle = atan2f(y_data, x_data);\r
+            angle += (angle < 0) * 2.0 * CV_PI;\r
+            dst[y * dst_step + x] = scale * angle;\r
         }\r
     };\r
     template <typename Mag, typename Angle>\r
index 7123a83..3fdba4a 100644 (file)
@@ -211,22 +211,42 @@ void cv::gpu::subtract(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream&
 \r
 void cv::gpu::multiply(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream& stream)\r
 {\r
-    typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream);\r
-    static const caller_t callers[] = {0, NppArithmScalar<1, nppiMulC_32f_C1R>::calc, NppArithmScalar<2, nppiMulC_32fc_C1R>::calc};\r
+    CV_Assert(src.type() == CV_32FC1);\r
 \r
-    CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);\r
+    dst.create(src.size(), src.type());\r
 \r
-    callers[src.channels()](src, sc, dst, StreamAccessor::getStream(stream));\r
+    NppiSize sz;\r
+    sz.width  = src.cols;\r
+    sz.height = src.rows;\r
+\r
+    cudaStream_t cudaStream = StreamAccessor::getStream(stream);\r
+\r
+    NppStreamHandler h(cudaStream);\r
+\r
+    nppSafeCall( nppiMulC_32f_C1R(src.ptr<Npp32f>(), src.step, (Npp32f)sc[0], dst.ptr<Npp32f>(), dst.step, sz) );\r
+\r
+    if (cudaStream == 0)\r
+        cudaSafeCall( cudaDeviceSynchronize() );\r
 }\r
 \r
 void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream& stream)\r
 {\r
-    typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream);\r
-    static const caller_t callers[] = {0, NppArithmScalar<1, nppiDivC_32f_C1R>::calc, NppArithmScalar<2, nppiDivC_32fc_C1R>::calc};\r
+    CV_Assert(src.type() == CV_32FC1);\r
 \r
-    CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);\r
+    dst.create(src.size(), src.type());\r
 \r
-    callers[src.channels()](src, sc, dst, StreamAccessor::getStream(stream));\r
+    NppiSize sz;\r
+    sz.width  = src.cols;\r
+    sz.height = src.rows;\r
+\r
+    cudaStream_t cudaStream = StreamAccessor::getStream(stream);\r
+\r
+    NppStreamHandler h(cudaStream);\r
+\r
+    nppSafeCall( nppiDivC_32f_C1R(src.ptr<Npp32f>(), src.step, (Npp32f)sc[0], dst.ptr<Npp32f>(), dst.step, sz) );\r
+\r
+    if (cudaStream == 0)\r
+        cudaSafeCall( cudaDeviceSynchronize() );\r
 }\r
 \r
 \r
index d8106ef..bdaa8fa 100644 (file)
 \r
 #include "NCVTest.hpp"\r
 \r
+enum OutputLevel\r
+{\r
+    OutputLevelNone,\r
+    OutputLevelCompact,\r
+    OutputLevelFull\r
+};\r
+\r
 class NCVAutoTestLister\r
 {\r
 public:\r
 \r
-    NCVAutoTestLister(std::string testSuiteName, NcvBool bStopOnFirstFail=false, NcvBool bCompactOutput=true)\r
+    NCVAutoTestLister(std::string testSuiteName, OutputLevel outputLevel = OutputLevelCompact, NcvBool bStopOnFirstFail=false)\r
         :\r
     testSuiteName(testSuiteName),\r
-    bStopOnFirstFail(bStopOnFirstFail),\r
-    bCompactOutput(bCompactOutput)\r
+    outputLevel(outputLevel),\r
+    bStopOnFirstFail(bStopOnFirstFail)\r
     {\r
     }\r
 \r
@@ -38,7 +45,7 @@ public:
         Ncv32u nFailed = 0;\r
         Ncv32u nFailedMem = 0;\r
 \r
-        if (bCompactOutput)\r
+        if (outputLevel == OutputLevelCompact)\r
         {\r
             printf("Test suite '%s' with %d tests\n", \r
                 testSuiteName.c_str(),\r
@@ -52,7 +59,7 @@ public:
             NCVTestReport curReport;\r
             bool res = curTest.executeTest(curReport);\r
 \r
-            if (!bCompactOutput)\r
+            if (outputLevel == OutputLevelFull)\r
             {\r
                 printf("Test %3i %16s; Consumed mem GPU = %8d, CPU = %8d; %s\n",\r
                     i,\r
@@ -65,7 +72,7 @@ public:
             if (res)\r
             {\r
                 nPassed++;\r
-                if (bCompactOutput)\r
+                if (outputLevel == OutputLevelCompact)\r
                 {\r
                     printf(".");\r
                 }\r
@@ -75,7 +82,7 @@ public:
                 if (!curReport.statsText["rcode"].compare("FAILED"))\r
                 {\r
                     nFailed++;\r
-                    if (bCompactOutput)\r
+                    if (outputLevel == OutputLevelCompact)\r
                     {\r
                         printf("x");\r
                     }\r
@@ -87,7 +94,7 @@ public:
                 else\r
                 {\r
                     nFailedMem++;\r
-                    if (bCompactOutput)\r
+                    if (outputLevel == OutputLevelCompact)\r
                     {\r
                         printf("m");\r
                     }\r
@@ -95,17 +102,20 @@ public:
             }\r
             fflush(stdout);\r
         }\r
-        if (bCompactOutput)\r
+        if (outputLevel == OutputLevelCompact)\r
         {\r
             printf("\n");\r
         }\r
 \r
-        printf("Test suite '%s' complete: %d total, %d passed, %d memory errors, %d failed\n\n", \r
-            testSuiteName.c_str(),\r
-            (int)(this->tests.size()),\r
-            nPassed,\r
-            nFailedMem,\r
-            nFailed);\r
+        if (outputLevel != OutputLevelNone)\r
+        {\r
+            printf("Test suite '%s' complete: %d total, %d passed, %d memory errors, %d failed\n\n", \r
+                testSuiteName.c_str(),\r
+                (int)(this->tests.size()),\r
+                nPassed,\r
+                nFailedMem,\r
+                nFailed);\r
+        }\r
 \r
         bool passed = nFailed == 0 && nFailedMem == 0;\r
         return passed;\r
@@ -121,9 +131,9 @@ public:
 \r
 private:\r
 \r
-    NcvBool bStopOnFirstFail;\r
-    NcvBool bCompactOutput;\r
     std::string testSuiteName;\r
+    OutputLevel outputLevel;\r
+    NcvBool bStopOnFirstFail;\r
     std::vector<INCVTest *> tests;\r
 };\r
 \r
index 31f0cb1..994737e 100644 (file)
@@ -288,70 +288,162 @@ static void devNullOutput(const char *msg)
 \r
 }\r
 \r
+bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
 \r
-bool main_nvidia(const std::string& test_data_path)\r
+    NCVAutoTestLister testListerII("NPPST Integral Image", outputLevel);\r
+    \r
+    NCVTestSourceProvider<Ncv8u> testSrcRandom_8u(2010, 0, 255, 4096, 4096);\r
+    NCVTestSourceProvider<Ncv32f> testSrcRandom_32f(2010, -1.0f, 1.0f, 4096, 4096);\r
+\r
+    generateIntegralTests<Ncv8u, Ncv32u>(testListerII, testSrcRandom_8u, 4096, 4096);\r
+    generateIntegralTests<Ncv32f, Ncv32f>(testListerII, testSrcRandom_32f, 4096, 4096);\r
+\r
+    return testListerII.invoke();\r
+}\r
+\r
+bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)\r
 {\r
        path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
 \r
-    printf("Testing NVIDIA Computer Vision SDK\n");\r
-    printf("==================================\n");\r
+    NCVAutoTestLister testListerSII("NPPST Squared Integral Image", outputLevel);\r
 \r
+    NCVTestSourceProvider<Ncv8u> testSrcRandom_8u(2010, 0, 255, 4096, 4096);\r
+\r
+    generateSquaredIntegralTests(testListerSII, testSrcRandom_8u, 4096, 4096);\r
+\r
+    return testListerSII.invoke();\r
+}\r
+\r
+bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
     ncvSetDebugOutputHandler(devNullOutput);\r
+    \r
+    NCVAutoTestLister testListerRStdDev("NPPST RectStdDev", outputLevel);\r
+    \r
+    NCVTestSourceProvider<Ncv8u> testSrcRandom_8u(2010, 0, 255, 4096, 4096);\r
 \r
-    NCVAutoTestLister testListerII("NPPST Integral Image"                   );//,,true, false);\r
-    NCVAutoTestLister testListerSII("NPPST Squared Integral Image"          );//,,true, false);\r
-    NCVAutoTestLister testListerRStdDev("NPPST RectStdDev"                  );//,,true, false);\r
-    NCVAutoTestLister testListerResize("NPPST Resize"                       );//,,true, false);\r
-    NCVAutoTestLister testListerNPPSTVectorOperations("NPPST Vector Operations"  );//,,true, false);\r
-    NCVAutoTestLister testListerTranspose("NPPST Transpose"                 );//,,true, false);\r
+    generateRectStdDevTests(testListerRStdDev, testSrcRandom_8u, 4096, 4096);\r
 \r
-    NCVAutoTestLister testListerVectorOperations("Vector Operations"        );//,,true, false);\r
-    NCVAutoTestLister testListerHaarLoader("Haar Cascade Loader"            );//,,true, false);\r
-    NCVAutoTestLister testListerHaarAppl("Haar Cascade Application"         );//,,true, false);\r
-    NCVAutoTestLister testListerHypFiltration("Hypotheses Filtration"       );//,,true, false);\r
-    NCVAutoTestLister testListerVisualize("Visualization"                   );//,,true, false);\r
+    return testListerRStdDev.invoke();\r
+}\r
+\r
+bool nvidia_NPPST_Resize(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+\r
+    NCVAutoTestLister testListerResize("NPPST Resize", outputLevel);\r
 \r
-    printf("Initializing data source providers\n");\r
     NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
-    NCVTestSourceProvider<Ncv8u> testSrcRandom_8u(2010, 0, 255, 4096, 4096);\r
     NCVTestSourceProvider<Ncv64u> testSrcRandom_64u(2010, 0, -1, 4096, 4096);\r
-    NCVTestSourceProvider<Ncv8u> testSrcFacesVGA_8u(path + "group_1_640x480_VGA.pgm");\r
-    NCVTestSourceProvider<Ncv32f> testSrcRandom_32f(2010, -1.0f, 1.0f, 4096, 4096);\r
 \r
-    printf("Generating NPPST test suites\n");\r
-    generateIntegralTests<Ncv8u, Ncv32u>(testListerII, testSrcRandom_8u, 4096, 4096);\r
-    generateIntegralTests<Ncv32f, Ncv32f>(testListerII, testSrcRandom_32f, 4096, 4096);\r
-    generateSquaredIntegralTests(testListerSII, testSrcRandom_8u, 4096, 4096);\r
-    generateRectStdDevTests(testListerRStdDev, testSrcRandom_8u, 4096, 4096);\r
     generateResizeTests(testListerResize, testSrcRandom_32u);\r
     generateResizeTests(testListerResize, testSrcRandom_64u);\r
+\r
+    return testListerResize.invoke();\r
+}\r
+\r
+bool nvidia_NPPST_Vector_Operations(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+    \r
+    NCVAutoTestLister testListerNPPSTVectorOperations("NPPST Vector Operations", outputLevel);\r
+    \r
+    NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
+\r
     generateNPPSTVectorTests(testListerNPPSTVectorOperations, testSrcRandom_32u, 4096*4096);\r
+\r
+    return testListerNPPSTVectorOperations.invoke();\r
+}\r
+\r
+bool nvidia_NPPST_Transpose(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+\r
+    NCVAutoTestLister testListerTranspose("NPPST Transpose", outputLevel);\r
+    \r
+    NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
+    NCVTestSourceProvider<Ncv64u> testSrcRandom_64u(2010, 0, -1, 4096, 4096);\r
+\r
     generateTransposeTests(testListerTranspose, testSrcRandom_32u);\r
     generateTransposeTests(testListerTranspose, testSrcRandom_64u);\r
 \r
-    printf("Generating NCV test suites\n");\r
-    generateDrawRectsTests(testListerVisualize, testSrcRandom_8u, testSrcRandom_32u, 4096, 4096);\r
-    generateDrawRectsTests(testListerVisualize, testSrcRandom_32u, testSrcRandom_32u, 4096, 4096);\r
+    return testListerTranspose.invoke();\r
+}\r
+\r
+bool nvidia_NCV_Vector_Operations(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+    \r
+    NCVAutoTestLister testListerVectorOperations("Vector Operations", outputLevel);\r
+\r
+    NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
+    \r
     generateVectorTests(testListerVectorOperations, testSrcRandom_32u, 4096*4096);\r
-    generateHypothesesFiltrationTests(testListerHypFiltration, testSrcRandom_32u, 1024);\r
+\r
+    return testListerVectorOperations.invoke();\r
+}\r
+\r
+bool nvidia_NCV_Haar_Cascade_Loader(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+\r
+    NCVAutoTestLister testListerHaarLoader("Haar Cascade Loader", outputLevel);\r
+    \r
     generateHaarLoaderTests(testListerHaarLoader);\r
+\r
+    return testListerHaarLoader.invoke();\r
+}\r
+\r
+bool nvidia_NCV_Haar_Cascade_Application(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+    \r
+    NCVAutoTestLister testListerHaarAppl("Haar Cascade Application", outputLevel);\r
+    \r
+    NCVTestSourceProvider<Ncv8u> testSrcFacesVGA_8u(path + "group_1_640x480_VGA.pgm");\r
+    \r
     generateHaarApplicationTests(testListerHaarAppl, testSrcFacesVGA_8u, 1280, 720);\r
 \r
-    // Indicate if at least one test failed\r
-    bool passed = true;\r
-\r
-    // Invoke all tests\r
-    passed &= testListerII.invoke();\r
-    passed &= testListerSII.invoke();\r
-    passed &= testListerRStdDev.invoke();\r
-    passed &= testListerResize.invoke();\r
-    passed &= testListerNPPSTVectorOperations.invoke();\r
-    passed &= testListerTranspose.invoke();\r
-    passed &= testListerVisualize.invoke();\r
-    passed &= testListerVectorOperations.invoke();\r
-    passed &= testListerHypFiltration.invoke();\r
-    passed &= testListerHaarLoader.invoke();\r
-    passed &= testListerHaarAppl.invoke();\r
-\r
-    return passed;\r
+    return testListerHaarAppl.invoke();\r
+}\r
+\r
+bool nvidia_NCV_Hypotheses_Filtration(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+    \r
+    NCVAutoTestLister testListerHypFiltration("Hypotheses Filtration", outputLevel);\r
+    \r
+    NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
+\r
+    generateHypothesesFiltrationTests(testListerHypFiltration, testSrcRandom_32u, 1024);\r
+\r
+    return testListerHypFiltration.invoke();\r
+}\r
+\r
+bool nvidia_NCV_Visualization(const std::string& test_data_path, OutputLevel outputLevel)\r
+{\r
+       path = test_data_path;\r
+    ncvSetDebugOutputHandler(devNullOutput);\r
+\r
+    NCVAutoTestLister testListerVisualize("Visualization", outputLevel);\r
+\r
+    NCVTestSourceProvider<Ncv8u> testSrcRandom_8u(2010, 0, 255, 4096, 4096);\r
+    NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
+    \r
+    generateDrawRectsTests(testListerVisualize, testSrcRandom_8u, testSrcRandom_32u, 4096, 4096);\r
+    generateDrawRectsTests(testListerVisualize, testSrcRandom_32u, testSrcRandom_32u, 4096, 4096);\r
+\r
+    return testListerVisualize.invoke();\r
 }\r
index 7e72b24..8ca0ced 100644 (file)
 //\r
 //M*/\r
 \r
-#include <iostream>\r
-#include <cmath>\r
-#include <limits>\r
 #include "test_precomp.hpp"\r
 \r
-using namespace cv;\r
-using namespace std;\r
-using namespace gpu;\r
+#ifdef HAVE_CUDA\r
 \r
-#define CHECK(pred, err) if (!(pred)) { \\r
-    ts->printf(cvtest::TS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \\r
-    ts->set_failed_test_info(err); \\r
-    return; }\r
-\r
-class CV_GpuArithmTest : public cvtest::BaseTest\r
+struct ArithmTest : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
 {\r
-public:\r
-    CV_GpuArithmTest(const char* /*test_name*/, const char* /*test_funcs*/){}\r
-    virtual ~CV_GpuArithmTest() {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
 \r
-protected:\r
-    void run(int);\r
+    cv::Size size;\r
+    cv::Mat mat1, mat2;\r
+        \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
 \r
-    int test(int type);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-    virtual int test(const Mat& mat1, const Mat& mat2) = 0;\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-    int CheckNorm(const Mat& m1, const Mat& m2, double eps = 1e-5);\r
-    int CheckNorm(const Scalar& s1, const Scalar& s2, double eps = 1e-5);\r
-    int CheckNorm(double d1, double d2, double eps = 1e-5);\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+        \r
+        mat1 = cvtest::randomMat(rng, size, type, 1, 16, false);\r
+        mat2 = cvtest::randomMat(rng, size, type, 1, 16, false);\r
+    }\r
 };\r
 \r
-int CV_GpuArithmTest::test(int type)\r
+////////////////////////////////////////////////////////////////////////////////\r
+// add\r
+\r
+struct AddArray : ArithmTest {};\r
+\r
+TEST_P(AddArray, Accuracy) \r
 {\r
-    cv::Size sz(200, 200);\r
-    cv::Mat mat1(sz, type), mat2(sz, type);\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
     \r
-    cv::RNG& rng = ts->get_rng();\r
+    cv::Mat dst_gold;\r
+    cv::add(mat1, mat2, dst_gold);\r
 \r
-    if (type != CV_32FC1)\r
-    {\r
-        rng.fill(mat1, cv::RNG::UNIFORM, cv::Scalar::all(1), cv::Scalar::all(20));\r
-        rng.fill(mat2, cv::RNG::UNIFORM, cv::Scalar::all(1), cv::Scalar::all(20));\r
-    }\r
-    else\r
-    {\r
-        rng.fill(mat1, cv::RNG::UNIFORM, cv::Scalar::all(0.1), cv::Scalar::all(1.0));\r
-        rng.fill(mat2, cv::RNG::UNIFORM, cv::Scalar::all(0.1), cv::Scalar::all(1.0));\r
-    }\r
+    cv::Mat dst;\r
 \r
-    return test(mat1, mat2);\r
-}\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-int CV_GpuArithmTest::CheckNorm(const Mat& m1, const Mat& m2, double eps)\r
-{\r
-    double ret = norm(m1, m2, NORM_INF);\r
+        cv::gpu::add(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes);\r
 \r
-    if (ret < eps)\r
-        return cvtest::TS::OK;\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-    ts->printf(cvtest::TS::LOG, "\nNorm: %f\n", ret);\r
-    return cvtest::TS::FAIL_GENERIC;\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
 }\r
 \r
-int CV_GpuArithmTest::CheckNorm(const Scalar& s1, const Scalar& s2, double eps)\r
-{\r
-    int ret0 = CheckNorm(s1[0], s2[0], eps), \r
-        ret1 = CheckNorm(s1[1], s2[1], eps), \r
-        ret2 = CheckNorm(s1[2], s2[2], eps), \r
-        ret3 = CheckNorm(s1[3], s2[3], eps);\r
+INSTANTIATE_TEST_CASE_P(Arithm, AddArray, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));\r
 \r
-    return (ret0 == cvtest::TS::OK && ret1 == cvtest::TS::OK && ret2 == cvtest::TS::OK && ret3 == cvtest::TS::OK) ? cvtest::TS::OK : cvtest::TS::FAIL_GENERIC;\r
-}\r
+struct AddScalar : ArithmTest {};\r
 \r
-int CV_GpuArithmTest::CheckNorm(double d1, double d2, double eps)\r
+TEST_P(AddScalar, Accuracy) \r
 {\r
-    double ret = ::fabs(d1 - d2);\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-    if (ret < eps)\r
-        return cvtest::TS::OK;\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-    ts->printf(cvtest::TS::LOG, "\nNorm: %f\n", ret);\r
-    return cvtest::TS::FAIL_GENERIC;\r
-}\r
+    cv::Scalar val(rng.uniform(0.1, 3.0), rng.uniform(0.1, 3.0));\r
 \r
-void CV_GpuArithmTest::run( int )\r
-{\r
-    int testResult = cvtest::TS::OK;\r
+    PRINT_PARAM(val);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::add(mat1, val, dst_gold);\r
 \r
-    const int types[] = {CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1};\r
-    const char* type_names[] = {"CV_8UC1 ", "CV_8UC3 ", "CV_8UC4 ", "CV_32FC1"};\r
-    const int type_count = sizeof(types)/sizeof(types[0]);\r
+    cv::Mat dst;\r
 \r
-    //run tests\r
-    for (int t = 0; t < type_count; ++t)\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "Start testing %s", type_names[t]);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-        if (cvtest::TS::OK == test(types[t]))\r
-            ts->printf(cvtest::TS::LOG, "SUCCESS\n");\r
-        else\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "FAIL\n");\r
-            testResult = cvtest::TS::FAIL_MISMATCH;\r
-        }\r
-    }\r
+        cv::gpu::add(cv::gpu::GpuMat(mat1), val, gpuRes);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-    ts->set_failed_test_info(testResult);\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
 }\r
 \r
+INSTANTIATE_TEST_CASE_P(Arithm, AddScalar, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_32FC1, CV_32FC2)));\r
+\r
 ////////////////////////////////////////////////////////////////////////////////\r
-// Add\r
+// subtract\r
+\r
+struct SubtractArray : ArithmTest {};\r
 \r
-struct CV_GpuNppImageAddTest : public CV_GpuArithmTest\r
+TEST_P(SubtractArray, Accuracy) \r
 {\r
-    CV_GpuNppImageAddTest() : CV_GpuArithmTest( "GPU-NppImageAdd", "add" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::subtract(mat1, mat2, dst_gold);\r
 \r
-        virtual int test(const Mat& mat1, const Mat& mat2)\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::Mat dst;\r
 \r
-        cv::Mat cpuRes;\r
-        cv::add(mat1, mat2, cpuRes);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuRes;\r
-        cv::gpu::add(gpu1, gpu2, gpuRes);\r
+        cv::gpu::subtract(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes);\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
-    }\r
-};\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Sub\r
-struct CV_GpuNppImageSubtractTest : public CV_GpuArithmTest\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, SubtractArray, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));\r
+\r
+struct SubtractScalar : ArithmTest {};\r
+\r
+TEST_P(SubtractScalar, Accuracy) \r
 {\r
-    CV_GpuNppImageSubtractTest() : CV_GpuArithmTest( "GPU-NppImageSubtract", "subtract" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        cv::Mat cpuRes;\r
-        cv::subtract(mat1, mat2, cpuRes);\r
+    cv::Scalar val(rng.uniform(0.1, 3.0), rng.uniform(0.1, 3.0));\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuRes;\r
-        cv::gpu::subtract(gpu1, gpu2, gpuRes);\r
+    PRINT_PARAM(val);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::subtract(mat1, val, dst_gold);\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
-    }\r
-};\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::subtract(cv::gpu::GpuMat(mat1), val, gpuRes);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    ASSERT_LE(checkNorm(dst_gold, dst), 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, SubtractScalar, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_32FC1, CV_32FC2)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
 // multiply\r
-struct CV_GpuNppImageMultiplyTest : public CV_GpuArithmTest\r
+\r
+struct MultiplyArray : ArithmTest {};\r
+\r
+TEST_P(MultiplyArray, Accuracy) \r
 {\r
-    CV_GpuNppImageMultiplyTest() : CV_GpuArithmTest( "GPU-NppImageMultiply", "multiply" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::multiply(mat1, mat2, dst_gold);\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::Mat dst;\r
 \r
-           cv::Mat cpuRes;\r
-           cv::multiply(mat1, mat2, cpuRes);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-           GpuMat gpu1(mat1);\r
-           GpuMat gpu2(mat2);\r
-           GpuMat gpuRes;\r
-           cv::gpu::multiply(gpu1, gpu2, gpuRes);\r
+        cv::gpu::multiply(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes);\r
 \r
-            return CheckNorm(cpuRes, gpuRes);\r
-    }\r
-};\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// divide\r
-struct CV_GpuNppImageDivideTest : public CV_GpuArithmTest\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, MultiplyArray, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));\r
+\r
+struct MultiplyScalar : ArithmTest {};\r
+\r
+TEST_P(MultiplyScalar, Accuracy) \r
 {\r
-    CV_GpuNppImageDivideTest() : CV_GpuArithmTest( "GPU-NppImageDivide", "divide" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-           cv::Mat cpuRes;\r
-           cv::divide(mat1, mat2, cpuRes);\r
+    cv::Scalar val(rng.uniform(0.1, 3.0), rng.uniform(0.1, 3.0));\r
 \r
-           GpuMat gpu1(mat1);\r
-           GpuMat gpu2(mat2);\r
-           GpuMat gpuRes;\r
-           cv::gpu::divide(gpu1, gpu2, gpuRes);\r
+    PRINT_PARAM(val);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::multiply(mat1, val, dst_gold);\r
 \r
-        return CheckNorm(cpuRes, gpuRes, 1.01f);\r
-    }\r
-};\r
+    cv::Mat dst;\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// transpose\r
-struct CV_GpuNppImageTransposeTest : public CV_GpuArithmTest\r
-{\r
-    CV_GpuNppImageTransposeTest() : CV_GpuArithmTest( "GPU-NppImageTranspose", "transpose" ) {}\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-    int test( const Mat& mat1, const Mat& )\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+        cv::gpu::multiply(cv::gpu::GpuMat(mat1), val, gpuRes);\r
 \r
-        cv::Mat cpuRes;\r
-        cv::transpose(mat1, cpuRes);\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpuRes;\r
-        cv::gpu::transpose(gpu1, gpuRes);\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
-    }\r
-};\r
+INSTANTIATE_TEST_CASE_P(Arithm, MultiplyScalar, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_32FC1)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// absdiff\r
-struct CV_GpuNppImageAbsdiffTest : public CV_GpuArithmTest\r
+// divide\r
+\r
+struct DivideArray : ArithmTest {};\r
+\r
+TEST_P(DivideArray, Accuracy) \r
 {\r
-    CV_GpuNppImageAbsdiffTest() : CV_GpuArithmTest( "GPU-NppImageAbsdiff", "absdiff" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::divide(mat1, mat2, dst_gold);\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::Mat dst;\r
 \r
-        cv::Mat cpuRes;\r
-        cv::absdiff(mat1, mat2, cpuRes);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuRes;\r
-        cv::gpu::absdiff(gpu1, gpu2, gpuRes);\r
+        cv::gpu::divide(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes);\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
-    }\r
-};\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// compare\r
-struct CV_GpuNppImageCompareTest : public CV_GpuArithmTest\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, DivideArray, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));\r
+\r
+struct DivideScalar : ArithmTest {};\r
+\r
+TEST_P(DivideScalar, Accuracy) \r
 {\r
-    CV_GpuNppImageCompareTest() : CV_GpuArithmTest( "GPU-NppImageCompare", "compare" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        int cmp_codes[] = {CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE};\r
-        const char* cmp_str[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};\r
-        int cmp_num = sizeof(cmp_codes) / sizeof(int);\r
+    cv::Scalar val(rng.uniform(0.1, 3.0), rng.uniform(0.1, 3.0));\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    PRINT_PARAM(val);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::divide(mat1, val, dst_gold);\r
 \r
-        for (int i = 0; i < cmp_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nCompare operation: %s\n", cmp_str[i]);\r
+    cv::Mat dst;\r
 \r
-            cv::Mat cpuRes;\r
-            cv::compare(mat1, mat2, cpuRes, cmp_codes[i]);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-            GpuMat gpu1(mat1);\r
-            GpuMat gpu2(mat2);\r
-            GpuMat gpuRes;\r
-            cv::gpu::compare(gpu1, gpu2, gpuRes, cmp_codes[i]);\r
+        cv::gpu::divide(cv::gpu::GpuMat(mat1), val, gpuRes);\r
 \r
-            if (CheckNorm(cpuRes, gpuRes) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-        return test_res;\r
-    }\r
-};\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, DivideScalar, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_32FC1)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// meanStdDev\r
-struct CV_GpuNppImageMeanStdDevTest : public CV_GpuArithmTest\r
-{\r
-    CV_GpuNppImageMeanStdDevTest() : CV_GpuArithmTest( "GPU-NppImageMeanStdDev", "meanStdDev" ) {}\r
+// transpose\r
 \r
-    int test( const Mat& mat1, const Mat& )\r
-    {\r
-        if (mat1.type() != CV_8UC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+struct Transpose : ArithmTest {};\r
 \r
-        Scalar cpumean;\r
-        Scalar cpustddev;\r
-        cv::meanStdDev(mat1, cpumean, cpustddev);\r
+TEST_P(Transpose, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-        GpuMat gpu1(mat1);\r
-        Scalar gpumean;\r
-        Scalar gpustddev;\r
-        cv::gpu::meanStdDev(gpu1, gpumean, gpustddev);\r
+    cv::Mat dst_gold;\r
+    cv::transpose(mat1, dst_gold);\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-        if (CheckNorm(cpumean, gpumean) != cvtest::TS::OK)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nMean FAILED\n");\r
-            test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+        cv::gpu::transpose(cv::gpu::GpuMat(mat1), gpuRes);\r
 \r
-        if (CheckNorm(cpustddev, gpustddev) != cvtest::TS::OK)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nStdDev FAILED\n");\r
-            test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-        return test_res;\r
-    }\r
-};\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Transpose, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_8SC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_32FC1, CV_32FC2, CV_64FC1)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// norm\r
-struct CV_GpuNppImageNormTest : public CV_GpuArithmTest\r
-{\r
-    CV_GpuNppImageNormTest() : CV_GpuArithmTest( "GPU-NppImageNorm", "norm" ) {}\r
+// absdiff\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_8UC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+struct AbsdiffArray : ArithmTest {};\r
 \r
-        int norms[] = {NORM_INF, NORM_L1, NORM_L2};\r
-        const char* norms_str[] = {"NORM_INF", "NORM_L1", "NORM_L2"};\r
-        int norms_num = sizeof(norms) / sizeof(int);\r
+TEST_P(AbsdiffArray, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::absdiff(mat1, mat2, dst_gold);\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    cv::Mat dst;\r
 \r
-        for (int i = 0; i < norms_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nNorm type: %s\n", norms_str[i]);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-            double cpu_norm = cv::norm(mat1, mat2, norms[i]);\r
+        cv::gpu::absdiff(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes);\r
 \r
-            GpuMat gpu1(mat1);\r
-            GpuMat gpu2(mat2);\r
-            double gpu_norm = cv::gpu::norm(gpu1, gpu2, norms[i]);\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-            if (CheckNorm(cpu_norm, gpu_norm) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
 \r
-        return test_res;\r
-    }\r
-};\r
+INSTANTIATE_TEST_CASE_P(Arithm, AbsdiffArray, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// flip\r
-struct CV_GpuNppImageFlipTest : public CV_GpuArithmTest\r
+struct AbsdiffScalar : ArithmTest {};\r
+\r
+TEST_P(AbsdiffScalar, Accuracy) \r
 {\r
-    CV_GpuNppImageFlipTest() : CV_GpuArithmTest( "GPU-NppImageFlip", "flip" ) {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-    int test( const Mat& mat1, const Mat& )\r
-    {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        int flip_codes[] = {0, 1, -1};\r
-        const char* flip_axis[] = {"X", "Y", "Both"};\r
-        int flip_codes_num = sizeof(flip_codes) / sizeof(int);\r
+    cv::Scalar val(rng.uniform(0.1, 3.0), rng.uniform(0.1, 3.0));\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    PRINT_PARAM(val);\r
+    \r
+    cv::Mat dst_gold;\r
+    cv::absdiff(mat1, val, dst_gold);\r
 \r
-        for (int i = 0; i < flip_codes_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nFlip Axis: %s\n", flip_axis[i]);\r
+    cv::Mat dst;\r
 \r
-            Mat cpu_res;\r
-            cv::flip(mat1, cpu_res, flip_codes[i]);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-            GpuMat gpu1(mat1);\r
-            GpuMat gpu_res;\r
-            cv::gpu::flip(gpu1, gpu_res, flip_codes[i]);\r
+        cv::gpu::absdiff(cv::gpu::GpuMat(mat1), val, gpuRes);\r
 \r
-            if (CheckNorm(cpu_res, gpu_res) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-        return test_res;\r
-    }\r
-};\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, AbsdiffScalar, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_32FC1)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// LUT\r
-struct CV_GpuNppImageLUTTest : public CV_GpuArithmTest\r
+// compare\r
+\r
+struct Compare : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> > \r
 {\r
-    CV_GpuNppImageLUTTest() : CV_GpuArithmTest( "GPU-NppImageLUT", "LUT" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int cmp_code;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1, mat2;\r
 \r
-    int test( const Mat& mat1, const Mat& )\r
+    cv::Mat dst_gold;\r
+        \r
+    virtual void SetUp()\r
     {\r
-        if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC3)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        cmp_code = std::tr1::get<1>(GetParam());\r
 \r
-        cv::Mat lut(1, 256, CV_8UC1);\r
-        cv::RNG& rng = ts->get_rng();\r
-        rng.fill(lut, cv::RNG::UNIFORM, cv::Scalar::all(100), cv::Scalar::all(200));\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        cv::Mat cpuRes;\r
-        cv::LUT(mat1, lut, cpuRes);\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        cv::gpu::GpuMat gpuRes;\r
-        cv::gpu::LUT(GpuMat(mat1), lut, gpuRes);\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+        \r
+        mat1 = cvtest::randomMat(rng, size, CV_32FC1, 1, 16, false);\r
+        mat2 = cvtest::randomMat(rng, size, CV_32FC1, 1, 16, false);\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
+        cv::compare(mat1, mat2, dst_gold, cmp_code);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// exp\r
-struct CV_GpuNppImageExpTest : public CV_GpuArithmTest\r
+TEST_P(Compare, Accuracy) \r
 {\r
-    CV_GpuNppImageExpTest() : CV_GpuArithmTest( "GPU-NppImageExp", "exp" ) {}\r
+    static const char* cmp_codes[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};\r
+    const char* cmpCodeStr = cmp_codes[cmp_code];\r
 \r
-    int test( const Mat& mat1, const Mat& )\r
-    {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(cmpCodeStr);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
 \r
-        cv::Mat cpuRes;\r
-        cv::exp(mat1, cpuRes);\r
+        cv::gpu::compare(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes, cmp_code);\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpuRes;\r
-        cv::gpu::exp(gpu1, gpuRes);\r
+        gpuRes.download(dst);\r
+    );\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
-    }\r
-};\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Compare, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// log\r
-struct CV_GpuNppImageLogTest : public CV_GpuArithmTest\r
+// meanStdDev\r
+\r
+struct MeanStdDev : testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-    CV_GpuNppImageLogTest() : CV_GpuArithmTest( "GPU-NppImageLog", "log" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
 \r
-    int test( const Mat& mat1, const Mat& )\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Scalar mean_gold;\r
+    cv::Scalar stddev_gold;\r
+\r
+    virtual void SetUp() \r
     {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+        devInfo = GetParam();\r
 \r
-        cv::Mat cpuRes;\r
-        cv::log(mat1, cpuRes);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpuRes;\r
-        cv::gpu::log(gpu1, gpuRes);\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+        \r
+        mat = cvtest::randomMat(rng, size, CV_8UC1, 1, 255, false);\r
+\r
+        cv::meanStdDev(mat, mean_gold, stddev_gold);\r
     }\r
 };\r
 \r
+TEST_P(MeanStdDev, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Scalar mean;\r
+    cv::Scalar stddev;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::meanStdDev(cv::gpu::GpuMat(mat), mean, stddev);\r
+    );\r
+\r
+    EXPECT_NEAR(mean_gold[0], mean[0], 1e-5);\r
+    EXPECT_NEAR(mean_gold[1], mean[1], 1e-5);\r
+    EXPECT_NEAR(mean_gold[2], mean[2], 1e-5);\r
+    EXPECT_NEAR(mean_gold[3], mean[3], 1e-5);\r
+\r
+    EXPECT_NEAR(stddev_gold[0], stddev[0], 1e-5);\r
+    EXPECT_NEAR(stddev_gold[1], stddev[1], 1e-5);\r
+    EXPECT_NEAR(stddev_gold[2], stddev[2], 1e-5);\r
+    EXPECT_NEAR(stddev_gold[3], stddev[3], 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, MeanStdDev, testing::ValuesIn(devices()));\r
+\r
 ////////////////////////////////////////////////////////////////////////////////\r
-// magnitude\r
-struct CV_GpuNppImageMagnitudeTest : public CV_GpuArithmTest\r
+// normDiff\r
+\r
+static const int norms[] = {cv::NORM_INF, cv::NORM_L1, cv::NORM_L2};\r
+static const char* norms_str[] = {"NORM_INF", "NORM_L1", "NORM_L2"};\r
+\r
+struct NormDiff : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
 {\r
-    CV_GpuNppImageMagnitudeTest() : CV_GpuArithmTest( "GPU-NppImageMagnitude", "magnitude" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int normIdx;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1, mat2;\r
+\r
+    double norm_gold;\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
+    virtual void SetUp() \r
     {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        normIdx = std::tr1::get<1>(GetParam());\r
 \r
-        cv::Mat cpuRes;\r
-        cv::magnitude(mat1, mat2, cpuRes);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuRes;\r
-        cv::gpu::magnitude(gpu1, gpu2, gpuRes);\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        return CheckNorm(cpuRes, gpuRes);\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+        \r
+        mat1 = cvtest::randomMat(rng, size, CV_8UC1, 1, 255, false);\r
+        mat2 = cvtest::randomMat(rng, size, CV_8UC1, 1, 255, false);\r
+\r
+        norm_gold = cv::norm(mat1, mat2, norms[normIdx]);\r
     }\r
 };\r
 \r
+TEST_P(NormDiff, Accuracy) \r
+{\r
+    const char* normStr = norms_str[normIdx];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(normStr);\r
+    \r
+    double norm;\r
+    \r
+    ASSERT_NO_THROW(\r
+        norm = cv::gpu::norm(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), norms[normIdx]);\r
+    );\r
+\r
+    EXPECT_NEAR(norm_gold, norm, 1e-6);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, NormDiff, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Range(0, 3)));\r
+\r
 ////////////////////////////////////////////////////////////////////////////////\r
-// phase\r
-struct CV_GpuNppImagePhaseTest : public CV_GpuArithmTest\r
+// flip\r
+\r
+struct Flip : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
 {\r
-    CV_GpuNppImagePhaseTest() : CV_GpuArithmTest( "GPU-NppImagePhase", "phase" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int flip_code;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Mat dst_gold;\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
+    virtual void SetUp() \r
     {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        flip_code = std::tr1::get<2>(GetParam());\r
 \r
-        cv::Mat cpuRes;\r
-        cv::phase(mat1, mat2, cpuRes, true);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuRes;\r
-        cv::gpu::phase(gpu1, gpu2, gpuRes, true);\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        return CheckNorm(cpuRes, gpuRes, 0.3f);\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+        \r
+        mat = cvtest::randomMat(rng, size, type, 1, 255, false);\r
+\r
+        cv::flip(mat, dst_gold, flip_code);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// cartToPolar\r
-struct CV_GpuNppImageCartToPolarTest : public CV_GpuArithmTest\r
+TEST_P(Flip, Accuracy) \r
 {\r
-    CV_GpuNppImageCartToPolarTest() : CV_GpuArithmTest( "GPU-NppImageCartToPolar", "cartToPolar" ) {}\r
+    static const char* flip_axis[] = {"Both", "X", "Y"};\r
+    const char* flipAxisStr = flip_axis[flip_code + 1];\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
-    {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(flipAxisStr);\r
+    \r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpu_res;\r
 \r
-        cv::Mat cpuMag, cpuAngle;\r
-        cv::cartToPolar(mat1, mat2, cpuMag, cpuAngle);\r
+        cv::gpu::flip(cv::gpu::GpuMat(mat), gpu_res, flip_code);\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuMag, gpuAngle;\r
-        cv::gpu::cartToPolar(gpu1, gpu2, gpuMag, gpuAngle);\r
+        gpu_res.download(dst);\r
+    );\r
 \r
-        int magRes = CheckNorm(cpuMag, gpuMag);\r
-        int angleRes = CheckNorm(cpuAngle, gpuAngle, 0.005f);\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
 \r
-        return magRes == cvtest::TS::OK && angleRes == cvtest::TS::OK ? cvtest::TS::OK : cvtest::TS::FAIL_GENERIC;\r
-    }\r
-};\r
+INSTANTIATE_TEST_CASE_P(Arithm, Flip, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC4),\r
+                        testing::Values(0, 1, -1)));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// polarToCart\r
-struct CV_GpuNppImagePolarToCartTest : public CV_GpuArithmTest\r
+// LUT\r
+\r
+struct LUT : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
 {\r
-    CV_GpuNppImagePolarToCartTest() : CV_GpuArithmTest( "GPU-NppImagePolarToCart", "polarToCart" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
 \r
-    int test( const Mat& mat1, const Mat& mat2 )\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+    cv::Mat lut;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
     {\r
-        if (mat1.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\tUnsupported type\t");\r
-            return cvtest::TS::OK;\r
-        }\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
 \r
-        cv::Mat cpuX, cpuY;\r
-        cv::polarToCart(mat1, mat2, cpuX, cpuY);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        GpuMat gpu1(mat1);\r
-        GpuMat gpu2(mat2);\r
-        GpuMat gpuX, gpuY;\r
-        cv::gpu::polarToCart(gpu1, gpu2, gpuX, gpuY);\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        int xRes = CheckNorm(cpuX, gpuX);\r
-        int yRes = CheckNorm(cpuY, gpuY);\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+        \r
+        mat = cvtest::randomMat(rng, size, type, 1, 255, false);\r
+        lut = cvtest::randomMat(rng, cv::Size(256, 1), CV_8UC1, 100, 200, false);\r
 \r
-        return xRes == cvtest::TS::OK && yRes == cvtest::TS::OK ? cvtest::TS::OK : cvtest::TS::FAIL_GENERIC;\r
+        cv::LUT(mat, lut, dst_gold);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Min max\r
-\r
-struct CV_GpuMinMaxTest: public cvtest::BaseTest\r
+TEST_P(LUT, Accuracy) \r
 {\r
-    CV_GpuMinMaxTest() {}\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
 \r
-    cv::gpu::GpuMat buf;\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpu_res;\r
 \r
-    void run(int)\r
-    {\r
-        bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&\r
-                         gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-        int depth_end = double_ok ? CV_64F : CV_32F;\r
+        cv::gpu::LUT(cv::gpu::GpuMat(mat), lut, gpu_res);\r
 \r
-        for (int depth = CV_8U; depth <= depth_end; ++depth)\r
-        {\r
-            for (int i = 0; i < 3; ++i)\r
-            {\r
-                int rows = 1 + rand() % 1000;\r
-                int cols = 1 + rand() % 1000;\r
-                test(rows, cols, 1, depth);\r
-                test_masked(rows, cols, 1, depth);\r
-            }\r
-        }\r
-    }\r
+        gpu_res.download(dst);\r
+    );\r
 \r
-    void test(int rows, int cols, int cn, int depth)\r
-    {\r
-        cv::Mat src(rows, cols, CV_MAKE_TYPE(depth, cn));\r
-        cv::RNG& rng = ts->get_rng();\r
-        rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(255));\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
 \r
-        double minVal, maxVal;\r
-        cv::Point minLoc, maxLoc;\r
+INSTANTIATE_TEST_CASE_P(Arithm, LUT, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8UC1, CV_8UC3)));\r
 \r
-        if (depth != CV_8S)\r
-        {\r
-            cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);\r
-        }\r
-        else \r
-        {\r
-            minVal = std::numeric_limits<double>::max();\r
-            maxVal = -std::numeric_limits<double>::max();\r
-            for (int i = 0; i < src.rows; ++i)\r
-                for (int j = 0; j < src.cols; ++j)\r
-                {\r
-                    signed char val = src.at<signed char>(i, j);\r
-                    if (val < minVal) minVal = val;\r
-                    if (val > maxVal) maxVal = val;\r
-                }\r
-        }\r
+////////////////////////////////////////////////////////////////////////////////\r
+// exp\r
 \r
-        double minVal_, maxVal_;\r
-        cv::gpu::minMax(cv::gpu::GpuMat(src), &minVal_, &maxVal_, cv::gpu::GpuMat(), buf);\r
-       \r
-        if (abs(minVal - minVal_) > 1e-3f)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nfail: minVal=%f minVal_=%f rows=%d cols=%d depth=%d cn=%d\n", minVal, minVal_, rows, cols, depth, cn);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        }\r
-        if (abs(maxVal - maxVal_) > 1e-3f)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nfail: maxVal=%f maxVal_=%f rows=%d cols=%d depth=%d cn=%d\n", maxVal, maxVal_, rows, cols, depth, cn);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        }\r
-    }  \r
+struct Exp : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
 \r
-    void test_masked(int rows, int cols, int cn, int depth)\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
     {\r
-        cv::Mat src(rows, cols, CV_MAKE_TYPE(depth, cn));\r
-        cv::RNG& rng = ts->get_rng();\r
-        rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(255));\r
+        devInfo = GetParam();\r
 \r
-        cv::Mat mask(src.size(), CV_8U);\r
-        rng.fill(mask, RNG::UNIFORM, Scalar(0), Scalar(2));\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        double minVal, maxVal;\r
-        cv::Point minLoc, maxLoc;\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        Mat src_ = src.reshape(1);\r
-        if (depth != CV_8S)\r
-        {\r
-            cv::minMaxLoc(src_, &minVal, &maxVal, &minLoc, &maxLoc, mask);\r
-        }\r
-        else \r
-        {\r
-            // OpenCV's minMaxLoc doesn't support CV_8S type \r
-            minVal = std::numeric_limits<double>::max();\r
-            maxVal = -std::numeric_limits<double>::max();\r
-            for (int i = 0; i < src_.rows; ++i)\r
-                for (int j = 0; j < src_.cols; ++j)\r
-                {\r
-                    char val = src_.at<char>(i, j);\r
-                    if (mask.at<unsigned char>(i, j)) { if (val < minVal) minVal = val; }\r
-                    if (mask.at<unsigned char>(i, j)) { if (val > maxVal) maxVal = val; }\r
-                }\r
-        }\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
 \r
-        double minVal_, maxVal_;\r
-        cv::Point minLoc_, maxLoc_;        \r
-        cv::gpu::minMax(cv::gpu::GpuMat(src), &minVal_, &maxVal_, cv::gpu::GpuMat(mask), buf);\r
-       \r
-        if (abs(minVal - minVal_) > 1e-3f)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nfail: minVal=%f minVal_=%f rows=%d cols=%d depth=%d cn=%d\n", minVal, minVal_, rows, cols, depth, cn);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        }\r
-        if (abs(maxVal - maxVal_) > 1e-3f)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nfail: maxVal=%f maxVal_=%f rows=%d cols=%d depth=%d cn=%d\n", maxVal, maxVal_, rows, cols, depth, cn);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        }\r
-    }  \r
+        mat = cvtest::randomMat(rng, size, CV_32FC1, -10.0, 2.0, false);        \r
+\r
+        cv::exp(mat, dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Exp, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpu_res;\r
+\r
+        cv::gpu::exp(cv::gpu::GpuMat(mat), gpu_res);\r
+\r
+        gpu_res.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Exp, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// log\r
+\r
+struct Log : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat = cvtest::randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);        \r
+\r
+        cv::log(mat, dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Log, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpu_res;\r
+\r
+        cv::gpu::log(cv::gpu::GpuMat(mat), gpu_res);\r
+\r
+        gpu_res.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Log, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// magnitude\r
+\r
+struct Magnitude : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1, mat2;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat1 = cvtest::randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);\r
+        mat2 = cvtest::randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);       \r
+\r
+        cv::magnitude(mat1, mat2, dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Magnitude, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpu_res;\r
+\r
+        cv::gpu::magnitude(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpu_res);\r
+\r
+        gpu_res.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-4);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Magnitude, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// phase\r
+\r
+struct Phase : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1, mat2;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat1 = cvtest::randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);\r
+        mat2 = cvtest::randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);       \r
+\r
+        cv::phase(mat1, mat2, dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Phase, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpu_res;\r
+\r
+        cv::gpu::phase(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpu_res);\r
+\r
+        gpu_res.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-3);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Phase, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// cartToPolar\r
+\r
+struct CartToPolar : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1, mat2;\r
+\r
+    cv::Mat mag_gold;\r
+    cv::Mat angle_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat1 = cvtest::randomMat(rng, size, CV_32FC1, -100.0, 100.0, false);\r
+        mat2 = cvtest::randomMat(rng, size, CV_32FC1, -100.0, 100.0, false);       \r
+\r
+        cv::cartToPolar(mat1, mat2, mag_gold, angle_gold);\r
+    }\r
+};\r
+\r
+TEST_P(CartToPolar, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat mag, angle;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuMag;\r
+        cv::gpu::GpuMat gpuAngle;\r
+\r
+        cv::gpu::cartToPolar(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuMag, gpuAngle);\r
+\r
+        gpuMag.download(mag);\r
+        gpuAngle.download(angle);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(mag_gold, mag, 1e-4);\r
+    EXPECT_MAT_NEAR(angle_gold, angle, 1e-3);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// polarToCart\r
+\r
+struct PolarToCart : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat mag;\r
+    cv::Mat angle;\r
+\r
+    cv::Mat x_gold;\r
+    cv::Mat y_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mag = cvtest::randomMat(rng, size, CV_32FC1, -100.0, 100.0, false);\r
+        angle = cvtest::randomMat(rng, size, CV_32FC1, 0.0, 2.0 * CV_PI, false);       \r
+\r
+        cv::polarToCart(mag, angle, x_gold, y_gold);\r
+    }\r
 };\r
 \r
+TEST_P(PolarToCart, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat x, y;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuX;\r
+        cv::gpu::GpuMat gpuY;\r
+\r
+        cv::gpu::polarToCart(cv::gpu::GpuMat(mag), cv::gpu::GpuMat(angle), gpuX, gpuY);\r
+\r
+        gpuX.download(x);\r
+        gpuY.download(y);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(x_gold, x, 1e-4);\r
+    EXPECT_MAT_NEAR(y_gold, y, 1e-4);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, testing::ValuesIn(devices()));\r
 \r
 ////////////////////////////////////////////////////////////////////////////////\r
-// Min max loc\r
+// minMax\r
 \r
-struct CV_GpuMinMaxLocTest: public cvtest::BaseTest\r
+struct MinMax : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
 {\r
-    CV_GpuMinMaxLocTest() {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+    cv::Mat mask;\r
 \r
-    GpuMat valbuf, locbuf;\r
+    double minVal_gold;\r
+    double maxVal_gold;\r
 \r
-    void run(int)\r
+    virtual void SetUp() \r
     {\r
-        bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&\r
-                         gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-        int depth_end = double_ok ? CV_64F : CV_32F;\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
 \r
-        for (int depth = CV_8U; depth <= depth_end; ++depth)\r
+        mat = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+        mask = cvtest::randomMat(rng, size, CV_8UC1, 0, 2, false);\r
+\r
+        if (type != CV_8S)\r
+        {\r
+            cv::minMaxLoc(mat, &minVal_gold, &maxVal_gold, 0, 0, mask);\r
+        }\r
+        else \r
         {\r
-            int rows = 1, cols = 3;\r
-            test(rows, cols, depth);\r
-            for (int i = 0; i < 4; ++i)\r
+            // OpenCV's minMaxLoc doesn't support CV_8S type \r
+            minVal_gold = std::numeric_limits<double>::max();\r
+            maxVal_gold = -std::numeric_limits<double>::max();\r
+            for (int i = 0; i < mat.rows; ++i)\r
             {\r
-                int rows = 1 + rand() % 1000;\r
-                int cols = 1 + rand() % 1000;\r
-                test(rows, cols, depth);\r
+                const signed char* mat_row = mat.ptr<signed char>(i);\r
+                const unsigned char* mask_row = mask.ptr<unsigned char>(i);\r
+                for (int j = 0; j < mat.cols; ++j)\r
+                {\r
+                    if (mask_row[j]) \r
+                    { \r
+                        signed char val = mat_row[j];\r
+                        if (val < minVal_gold) minVal_gold = val;\r
+                        if (val > maxVal_gold) maxVal_gold = val; \r
+                    }\r
+                }\r
             }\r
         }\r
     }\r
+};\r
+\r
+TEST_P(MinMax, Accuracy) \r
+{\r
+    if (type == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
 \r
-    void test(int rows, int cols, int depth)\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    double minVal, maxVal;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::minMax(cv::gpu::GpuMat(mat), &minVal, &maxVal, cv::gpu::GpuMat(mask));\r
+    );\r
+\r
+    EXPECT_DOUBLE_EQ(minVal_gold, minVal);\r
+    EXPECT_DOUBLE_EQ(maxVal_gold, maxVal);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, MinMax, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// minMaxLoc\r
+\r
+struct MinMaxLoc : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+    cv::Mat mask;\r
+\r
+    double minVal_gold;\r
+    double maxVal_gold;\r
+    cv::Point minLoc_gold;\r
+    cv::Point maxLoc_gold;\r
+\r
+    virtual void SetUp() \r
     {\r
-        cv::Mat src(rows, cols, depth);\r
-        cv::RNG& rng = ts->get_rng();\r
-        rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(255));\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
 \r
-        cv::Mat mask(src.size(), CV_8U);\r
-        rng.fill(mask, RNG::UNIFORM, Scalar(0), Scalar(2));\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        // At least one of the mask elements must be non zero as OpenCV returns 0\r
-        // in such case, when our implementation returns maximum or minimum value\r
-        mask.at<unsigned char>(0, 0) = 1;\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        double minVal, maxVal;\r
-        cv::Point minLoc, maxLoc;\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
 \r
-        if (depth != CV_8S)       \r
-            cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, mask);\r
+        mat = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+        mask = cvtest::randomMat(rng, size, CV_8UC1, 0, 2, false);\r
+\r
+        if (type != CV_8S)\r
+        {\r
+            cv::minMaxLoc(mat, &minVal_gold, &maxVal_gold, &minLoc_gold, &maxLoc_gold, mask);\r
+        }\r
         else \r
         {\r
             // OpenCV's minMaxLoc doesn't support CV_8S type \r
-            minVal = std::numeric_limits<double>::max();\r
-            maxVal = -std::numeric_limits<double>::max();\r
-            for (int i = 0; i < src.rows; ++i)\r
-                for (int j = 0; j < src.cols; ++j)\r
+            minVal_gold = std::numeric_limits<double>::max();\r
+            maxVal_gold = -std::numeric_limits<double>::max();\r
+            for (int i = 0; i < mat.rows; ++i)\r
+            {\r
+                const signed char* mat_row = mat.ptr<signed char>(i);\r
+                const unsigned char* mask_row = mask.ptr<unsigned char>(i);\r
+                for (int j = 0; j < mat.cols; ++j)\r
                 {\r
-                    char val = src.at<char>(i, j);\r
-                    if (mask.at<unsigned char>(i, j))\r
-                    {\r
-                        if (val < minVal) { minVal = val; minLoc = cv::Point(j, i); }\r
-                        if (val > maxVal) { maxVal = val; maxLoc = cv::Point(j, i); }\r
+                    if (mask_row[j]) \r
+                    { \r
+                        signed char val = mat_row[j];\r
+                        if (val < minVal_gold) { minVal_gold = val; minLoc_gold = cv::Point(j, i); }\r
+                        if (val > maxVal_gold) { maxVal_gold = val; maxLoc_gold = cv::Point(j, i); }\r
                     }\r
                 }\r
+            }\r
         }\r
-\r
-        double minVal_, maxVal_;\r
-        cv::Point minLoc_, maxLoc_;        \r
-        cv::gpu::minMaxLoc(cv::gpu::GpuMat(src), &minVal_, &maxVal_, &minLoc_, &maxLoc_, cv::gpu::GpuMat(mask), valbuf, locbuf);\r
-\r
-        CHECK(minVal == minVal_, cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(maxVal == maxVal_, cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(0 == memcmp(src.ptr(minLoc.y) + minLoc.x * src.elemSize(), src.ptr(minLoc_.y) + minLoc_.x * src.elemSize(), src.elemSize()),  \r
-              cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(0 == memcmp(src.ptr(maxLoc.y) + maxLoc.x * src.elemSize(), src.ptr(maxLoc_.y) + maxLoc_.x * src.elemSize(), src.elemSize()),  \r
-              cvtest::TS::FAIL_INVALID_OUTPUT);\r
-    }  \r
+    }\r
 };\r
 \r
+TEST_P(MinMaxLoc, Accuracy) \r
+{\r
+    if (type == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    double minVal, maxVal;\r
+    cv::Point minLoc, maxLoc;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::minMaxLoc(cv::gpu::GpuMat(mat), &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(mask));\r
+    );\r
+\r
+    EXPECT_DOUBLE_EQ(minVal_gold, minVal);\r
+    EXPECT_DOUBLE_EQ(maxVal_gold, maxVal);\r
+\r
+    int cmpMinVals = memcmp(mat.data + minLoc_gold.y * mat.step + minLoc_gold.x * mat.elemSize(), \r
+                            mat.data + minLoc.y * mat.step + minLoc.x * mat.elemSize(), \r
+                            mat.elemSize());\r
+    int cmpMaxVals = memcmp(mat.data + maxLoc_gold.y * mat.step + maxLoc_gold.x * mat.elemSize(), \r
+                            mat.data + maxLoc.y * mat.step + maxLoc.x * mat.elemSize(), \r
+                            mat.elemSize());\r
+\r
+    EXPECT_EQ(0, cmpMinVals);\r
+    EXPECT_EQ(0, cmpMaxVals);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, MinMaxLoc, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)));\r
+\r
 ////////////////////////////////////////////////////////////////////////////\r
-// Count non zero\r
-struct CV_GpuCountNonZeroTest: cvtest::BaseTest \r
+// countNonZero\r
+\r
+struct CountNonZero : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
 {\r
-    CV_GpuCountNonZeroTest(){}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    int n_gold;\r
 \r
-    void run(int\r
+    virtual void SetUp(\r
     {\r
-        int depth_end;\r
-        if (cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE))\r
-            depth_end = CV_64F;\r
-        else\r
-            depth_end = CV_32F;\r
-        for (int depth = CV_8U; depth <= CV_32F; ++depth)\r
-        {\r
-            for (int i = 0; i < 4; ++i)\r
-            {\r
-                int rows = 1 + rand() % 1000;\r
-                int cols = 1 + rand() % 1000;\r
-                test(rows, cols, depth);\r
-            }\r
-        }\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        cv::Mat matBase = cvtest::randomMat(rng, size, CV_8U, 0.0, 1.0, false);\r
+        matBase.convertTo(mat, type);\r
+\r
+        n_gold = cv::countNonZero(mat);\r
     }\r
+};\r
+\r
+TEST_P(CountNonZero, Accuracy) \r
+{\r
+    if (type == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    int n;\r
+    \r
+    ASSERT_NO_THROW(\r
+        n = cv::gpu::countNonZero(cv::gpu::GpuMat(mat));\r
+    );\r
+\r
+    ASSERT_EQ(n_gold, n);\r
+}\r
 \r
-    void test(int rows, int cols, int depth)\r
+INSTANTIATE_TEST_CASE_P(Arithm, CountNonZero, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)));\r
+\r
+//////////////////////////////////////////////////////////////////////////////\r
+// sum\r
+\r
+struct Sum : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Scalar sum_gold;\r
+\r
+    virtual void SetUp() \r
     {\r
-        cv::Mat src(rows, cols, depth);\r
-        cv::RNG rng;\r
-        if (depth == 5)\r
-            rng.fill(src, RNG::UNIFORM, Scalar(-1000.f), Scalar(1000.f));\r
-        else if (depth == 6)\r
-            rng.fill(src, RNG::UNIFORM, Scalar(-1000.), Scalar(1000.));\r
-        else\r
-            for (int i = 0; i < src.rows; ++i)\r
-            { \r
-                Mat row(1, src.cols * src.elemSize(), CV_8U, src.ptr(i));\r
-                rng.fill(row, RNG::UNIFORM, Scalar(0), Scalar(256));\r
-            }\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat = cvtest::randomMat(rng, size, CV_8U, 0.0, 10.0, false);\r
+\r
+        sum_gold = cv::sum(mat);\r
+    }\r
+};\r
+\r
+TEST_P(Sum, Accuracy) \r
+{\r
+    if (type == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Scalar sum;\r
+    \r
+    ASSERT_NO_THROW(\r
+        sum = cv::gpu::sum(cv::gpu::GpuMat(mat));\r
+    );\r
+\r
+    EXPECT_NEAR(sum[0], sum_gold[0], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[1], sum_gold[1], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[2], sum_gold[2], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[3], sum_gold[3], mat.size().area() * 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, Sum, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)));\r
+\r
+struct AbsSum : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Scalar sum_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat = cvtest::randomMat(rng, size, CV_8U, 0.0, 10.0, false);\r
+\r
+        sum_gold = cv::norm(mat, cv::NORM_L1);\r
+    }\r
+};\r
+\r
+TEST_P(AbsSum, Accuracy) \r
+{\r
+    if (type == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Scalar sum;\r
+    \r
+    ASSERT_NO_THROW(\r
+        sum = cv::gpu::absSum(cv::gpu::GpuMat(mat));\r
+    );\r
+\r
+    EXPECT_NEAR(sum[0], sum_gold[0], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[1], sum_gold[1], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[2], sum_gold[2], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[3], sum_gold[3], mat.size().area() * 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, AbsSum, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)));\r
+\r
+struct SqrSum : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Scalar sum_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat = cvtest::randomMat(rng, size, CV_8U, 0.0, 10.0, false);\r
\r
+        cv::Mat sqrmat;\r
+        cv::multiply(mat, mat, sqrmat);\r
+        sum_gold = cv::sum(sqrmat);\r
+    }\r
+};\r
+\r
+TEST_P(SqrSum, Accuracy) \r
+{\r
+    if (type == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Scalar sum;\r
+    \r
+    ASSERT_NO_THROW(\r
+        sum = cv::gpu::sqrSum(cv::gpu::GpuMat(mat));\r
+    );\r
+\r
+    EXPECT_NEAR(sum[0], sum_gold[0], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[1], sum_gold[1], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[2], sum_gold[2], mat.size().area() * 1e-5);\r
+    EXPECT_NEAR(sum[3], sum_gold[3], mat.size().area() * 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, SqrSum, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)));\r
+\r
+//////////////////////////////////////////////////////////////////////////////\r
+// bitwise\r
+\r
+struct BitwiseNot : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        int n_gold = cv::countNonZero(src);\r
-        int n = cv::gpu::countNonZero(cv::gpu::GpuMat(src));\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
 \r
-        if (n != n_gold)\r
+        mat.create(size, type);\r
+        \r
+        for (int i = 0; i < mat.rows; ++i)\r
         {\r
-            ts->printf(cvtest::TS::LOG, "%d %d %d %d %d\n", n, n_gold, depth, cols, rows);\r
-            n_gold = cv::countNonZero(src);\r
+            cv::Mat row(1, mat.cols * mat.elemSize(), CV_8U, (void*)mat.ptr(i));\r
+            rng.fill(row, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
         }\r
 \r
-        CHECK(n == n_gold, cvtest::TS::FAIL_INVALID_OUTPUT);\r
+        dst_gold = ~mat;\r
     }\r
 };\r
 \r
+TEST_P(BitwiseNot, Accuracy) \r
+{\r
+    if (mat.depth() == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
 \r
-//////////////////////////////////////////////////////////////////////////////\r
-// sum\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        cv::gpu::bitwise_not(cv::gpu::GpuMat(mat), dev_dst);\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
 \r
-struct CV_GpuSumTest: cvtest::BaseTest \r
+INSTANTIATE_TEST_CASE_P(Arithm, BitwiseNot, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::ValuesIn(all_types())));\r
+\r
+struct BitwiseOr : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
 {\r
-    CV_GpuSumTest() {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1;\r
+    cv::Mat mat2;\r
+\r
+    cv::Mat dst_gold;\r
 \r
-    void run(int\r
+    virtual void SetUp(\r
     {\r
-        Mat src;\r
-        Scalar a, b;\r
-        double max_err = 1e-5;\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
 \r
-        int typemax = CV_32F;\r
-        for (int type = CV_8U; type <= typemax; ++type)\r
+        mat1.create(size, type);\r
+        mat2.create(size, type);\r
+        \r
+        for (int i = 0; i < mat1.rows; ++i)\r
         {\r
-            //\r
-            // sum\r
-            //\r
-\r
-            gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 1), src);\r
-            a = sum(src);\r
-            b = sum(GpuMat(src));\r
-            if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "1 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[0], b[0]);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
+            cv::Mat row1(1, mat1.cols * mat1.elemSize(), CV_8U, (void*)mat1.ptr(i));\r
+            rng.fill(row1, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
 \r
-            gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 2), src);\r
-            a = sum(src);\r
-            b = sum(GpuMat(src));\r
-            if (abs(a[0] - b[0]) + abs(a[1] - b[1]) > src.size().area() * max_err)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "2 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[1], b[1]);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
+            cv::Mat row2(1, mat2.cols * mat2.elemSize(), CV_8U, (void*)mat2.ptr(i));\r
+            rng.fill(row2, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
+        }\r
 \r
-            gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 3), src);\r
-            a = sum(src);\r
-            b = sum(GpuMat(src));\r
-            if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2])> src.size().area() * max_err)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "3 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[2], b[2]);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
+        dst_gold = mat1 | mat2;\r
+    }\r
+};\r
 \r
-            gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 4), src);\r
-            a = sum(src);\r
-            b = sum(GpuMat(src));\r
-            if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2]) + abs(a[3] - b[3])> src.size().area() * max_err)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "4 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[3], b[3]);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
+TEST_P(BitwiseOr, Accuracy) \r
+{\r
+    if (mat1.depth() == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
 \r
-            gen(1 + rand() % 500, 1 + rand() % 500, type, src);\r
-            a = sum(src);\r
-            b = sum(GpuMat(src));\r
-            if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[0], b[0]);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
 \r
-            //\r
-            // absSum\r
-            //\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
 \r
-            gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 1), src);\r
-            b = absSum(GpuMat(src));\r
-            a = norm(src, NORM_L1);\r
-            if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
+        cv::gpu::bitwise_or(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), dev_dst);\r
 \r
-            //\r
-            // sqrSum\r
-            //\r
+        dev_dst.download(dst);\r
+    );\r
 \r
-            if (type != CV_8S)\r
-            {\r
-                gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 1), src);\r
-                b = sqrSum(GpuMat(src));\r
-                Mat sqrsrc;\r
-                multiply(src, src, sqrsrc);\r
-                a = sum(sqrsrc);\r
-                if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-                gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 2), src);\r
-                b = sqrSum(GpuMat(src));\r
-                multiply(src, src, sqrsrc);\r
-                a = sum(sqrsrc);\r
-                if (abs(a[0] - b[0]) + abs(a[1] - b[1])> src.size().area() * max_err * 2)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-                gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 3), src);\r
-                b = sqrSum(GpuMat(src));\r
-                multiply(src, src, sqrsrc);\r
-                a = sum(sqrsrc);\r
-                if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2])> src.size().area() * max_err * 3)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-                gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 4), src);\r
-                b = sqrSum(GpuMat(src));\r
-                multiply(src, src, sqrsrc);\r
-                a = sum(sqrsrc);\r
-                if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2]) + abs(a[3] - b[3])> src.size().area() * max_err * 4)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-            }\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, BitwiseOr, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::ValuesIn(all_types())));\r
+\r
+struct BitwiseAnd : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1;\r
+    cv::Mat mat2;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat1.create(size, type);\r
+        mat2.create(size, type);\r
+        \r
+        for (int i = 0; i < mat1.rows; ++i)\r
+        {\r
+            cv::Mat row1(1, mat1.cols * mat1.elemSize(), CV_8U, (void*)mat1.ptr(i));\r
+            rng.fill(row1, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
+\r
+            cv::Mat row2(1, mat2.cols * mat2.elemSize(), CV_8U, (void*)mat2.ptr(i));\r
+            rng.fill(row2, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
         }\r
+\r
+        dst_gold = mat1 & mat2;\r
     }\r
+};\r
+\r
+TEST_P(BitwiseAnd, Accuracy) \r
+{\r
+    if (mat1.depth() == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        cv::gpu::bitwise_and(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), dev_dst);\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, BitwiseAnd, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::ValuesIn(all_types())));\r
+\r
+struct BitwiseXor : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat1;\r
+    cv::Mat mat2;\r
+\r
+    cv::Mat dst_gold;\r
 \r
-    void gen(int cols, int rows, int type, Mat& m)\r
+    virtual void SetUp() \r
     {\r
-        m.create(rows, cols, type);\r
-        RNG rng;\r
-        rng.fill(m, RNG::UNIFORM, Scalar::all(0), Scalar::all(16));\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
 \r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
+\r
+        mat1.create(size, type);\r
+        mat2.create(size, type);\r
+        \r
+        for (int i = 0; i < mat1.rows; ++i)\r
+        {\r
+            cv::Mat row1(1, mat1.cols * mat1.elemSize(), CV_8U, (void*)mat1.ptr(i));\r
+            rng.fill(row1, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
+\r
+            cv::Mat row2(1, mat2.cols * mat2.elemSize(), CV_8U, (void*)mat2.ptr(i));\r
+            rng.fill(row2, cv::RNG::UNIFORM, cv::Scalar(0), cv::Scalar(255));\r
+        }\r
+\r
+        dst_gold = mat1 ^ mat2;\r
     }\r
 };\r
 \r
-TEST(add, accuracy) { CV_GpuNppImageAddTest test; test.safe_run(); }\r
-TEST(subtract, accuracy) { CV_GpuNppImageSubtractTest test; test.safe_run(); }\r
-TEST(multiply, accuracy) { CV_GpuNppImageMultiplyTest test; test.safe_run(); }\r
-TEST(divide, accuracy) { CV_GpuNppImageDivideTest test; test.safe_run(); }\r
-TEST(transpose, accuracy) { CV_GpuNppImageTransposeTest test; test.safe_run(); }\r
-TEST(absdiff, accuracy) { CV_GpuNppImageAbsdiffTest test; test.safe_run(); }\r
-TEST(compare, accuracy) { CV_GpuNppImageCompareTest test; test.safe_run(); }\r
-TEST(meanStdDev, accuracy) { CV_GpuNppImageMeanStdDevTest test; test.safe_run(); }\r
-TEST(normDiff, accuracy) { CV_GpuNppImageNormTest test; test.safe_run(); }\r
-TEST(flip, accuracy) { CV_GpuNppImageFlipTest test; test.safe_run(); }\r
-TEST(LUT, accuracy) { CV_GpuNppImageLUTTest test; test.safe_run(); }\r
-TEST(exp, accuracy) { CV_GpuNppImageExpTest test; test.safe_run(); }\r
-TEST(log, accuracy) { CV_GpuNppImageLogTest test; test.safe_run(); }\r
-TEST(magnitude, accuracy) { CV_GpuNppImageMagnitudeTest test; test.safe_run(); }\r
-TEST(phase, accuracy) { CV_GpuNppImagePhaseTest test; test.safe_run(); }\r
-TEST(cartToPolar, accuracy) { CV_GpuNppImageCartToPolarTest test; test.safe_run(); }\r
-TEST(polarToCart, accuracy) { CV_GpuNppImagePolarToCartTest test; test.safe_run(); }\r
-TEST(minMax, accuracy) { CV_GpuMinMaxTest test; test.safe_run(); }\r
-TEST(minMaxLoc, accuracy) { CV_GpuMinMaxLocTest test; test.safe_run(); }\r
-TEST(countNonZero, accuracy) { CV_GpuCountNonZeroTest test; test.safe_run(); }\r
-TEST(sum, accuracy) { CV_GpuSumTest test; test.safe_run(); }\r
+TEST_P(BitwiseXor, Accuracy) \r
+{\r
+    if (mat1.depth() == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type)\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        cv::gpu::bitwise_xor(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), dev_dst);\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Arithm, BitwiseXor, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::ValuesIn(all_types())));\r
+\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_bitwise_oper.cpp b/modules/gpu/test/test_bitwise_oper.cpp
deleted file mode 100644 (file)
index 6b05053..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <limits>\r
-#include "test_precomp.hpp"\r
-\r
-#define CHECK(pred, err) if (!(pred)) { \\r
-    ts->printf(cvtest::TS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \\r
-    ts->set_failed_test_info(err); \\r
-    return; }\r
-\r
-using namespace cv;\r
-using namespace std;\r
-\r
-struct CV_GpuBitwiseTest: public cvtest::BaseTest\r
-{\r
-    CV_GpuBitwiseTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        int rows, cols;\r
-\r
-        bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
-                         gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-        int depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
-        for (int depth = CV_8U; depth <= depth_end; ++depth)\r
-            for (int cn = 1; cn <= 4; ++cn)\r
-                for (int attempt = 0; attempt < 3; ++attempt)\r
-                {\r
-                    rows = 1 + rand() % 100;\r
-                    cols = 1 + rand() % 100;\r
-                    test_bitwise_not(rows, cols, CV_MAKETYPE(depth, cn));\r
-                    test_bitwise_or(rows, cols, CV_MAKETYPE(depth, cn));\r
-                    test_bitwise_and(rows, cols, CV_MAKETYPE(depth, cn));\r
-                    test_bitwise_xor(rows, cols, CV_MAKETYPE(depth, cn));\r
-                }\r
-    }\r
-\r
-    void test_bitwise_not(int rows, int cols, int type)\r
-    {\r
-        Mat src(rows, cols, type);\r
-\r
-        RNG rng;\r
-        for (int i = 0; i < src.rows; ++i)\r
-        {\r
-            Mat row(1, src.cols * src.elemSize(), CV_8U, src.ptr(i));\r
-            rng.fill(row, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-        }\r
-\r
-        Mat dst_gold = ~src;\r
-\r
-        gpu::GpuMat mask(src.size(), CV_8U);\r
-        mask.setTo(Scalar(1));\r
-\r
-        gpu::GpuMat dst;\r
-        gpu::bitwise_not(gpu::GpuMat(src), dst);\r
-\r
-        CHECK(dst_gold.size() == dst.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold.type() == dst.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-\r
-        Mat dsth(dst);\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT);\r
-\r
-        dst.setTo(Scalar::all(0));\r
-        gpu::bitwise_not(gpu::GpuMat(src), dst, mask);\r
-\r
-        CHECK(dst_gold.size() == dst.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold.type() == dst.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-\r
-        dsth = dst;\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-    }\r
-\r
-    void test_bitwise_or(int rows, int cols, int type)\r
-    {\r
-        Mat src1(rows, cols, type);\r
-        Mat src2(rows, cols, type);\r
-\r
-        RNG rng;\r
-        for (int i = 0; i < src1.rows; ++i)\r
-        {\r
-            Mat row1(1, src1.cols * src1.elemSize(), CV_8U, src1.ptr(i));\r
-            rng.fill(row1, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-            Mat row2(1, src2.cols * src2.elemSize(), CV_8U, src2.ptr(i));\r
-            rng.fill(row2, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-        }\r
-\r
-        Mat dst_gold = src1 | src2;\r
-        gpu::GpuMat dst = gpu::GpuMat(src1) | gpu::GpuMat(src2);\r
-\r
-        CHECK(dst_gold.size() == dst.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold.type() == dst.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-        Mat dsth(dst);\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-\r
-        Mat mask(src1.size(), CV_8U);\r
-        randu(mask, Scalar(0), Scalar(255));\r
-\r
-        Mat dst_gold2(dst_gold.size(), dst_gold.type()); dst_gold2.setTo(Scalar::all(0));\r
-        gpu::GpuMat dst2(dst.size(), dst.type()); dst2.setTo(Scalar::all(0));\r
-        bitwise_or(src1, src2, dst_gold2, mask);\r
-        gpu::bitwise_or(gpu::GpuMat(src1), gpu::GpuMat(src2), dst2, gpu::GpuMat(mask));\r
-\r
-        CHECK(dst_gold2.size() == dst2.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold2.type() == dst2.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-        dsth = dst2;\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold2.ptr(i), dsth.ptr(i), dst_gold2.cols * dst_gold2.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-    }\r
-\r
-    void test_bitwise_and(int rows, int cols, int type)\r
-    {\r
-        Mat src1(rows, cols, type);\r
-        Mat src2(rows, cols, type);\r
-\r
-        RNG rng;\r
-        for (int i = 0; i < src1.rows; ++i)\r
-        {\r
-            Mat row1(1, src1.cols * src1.elemSize(), CV_8U, src1.ptr(i));\r
-            rng.fill(row1, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-            Mat row2(1, src2.cols * src2.elemSize(), CV_8U, src2.ptr(i));\r
-            rng.fill(row2, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-        }\r
-\r
-        Mat dst_gold = src1 & src2;\r
-\r
-        gpu::GpuMat dst = gpu::GpuMat(src1) & gpu::GpuMat(src2);\r
-\r
-        CHECK(dst_gold.size() == dst.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold.type() == dst.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-        Mat dsth(dst);\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-\r
-\r
-        Mat mask(src1.size(), CV_8U);\r
-        randu(mask, Scalar(0), Scalar(255));\r
-\r
-        Mat dst_gold2(dst_gold.size(), dst_gold.type()); dst_gold2.setTo(Scalar::all(0));\r
-        gpu::GpuMat dst2(dst.size(), dst.type()); dst2.setTo(Scalar::all(0));\r
-        bitwise_and(src1, src2, dst_gold2, mask);\r
-        gpu::bitwise_and(gpu::GpuMat(src1), gpu::GpuMat(src2), dst2, gpu::GpuMat(mask));\r
-\r
-        CHECK(dst_gold2.size() == dst2.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold2.type() == dst2.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-        dsth = dst2;\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold2.ptr(i), dsth.ptr(i), dst_gold2.cols * dst_gold2.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-    }\r
-\r
-    void test_bitwise_xor(int rows, int cols, int type)\r
-    {\r
-        Mat src1(rows, cols, type);\r
-        Mat src2(rows, cols, type);\r
-\r
-        RNG rng;\r
-        for (int i = 0; i < src1.rows; ++i)\r
-        {\r
-            Mat row1(1, src1.cols * src1.elemSize(), CV_8U, src1.ptr(i));\r
-            rng.fill(row1, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-            Mat row2(1, src2.cols * src2.elemSize(), CV_8U, src2.ptr(i));\r
-            rng.fill(row2, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-        }\r
-\r
-        Mat dst_gold = src1 ^ src2;\r
-\r
-        gpu::GpuMat dst = gpu::GpuMat(src1) ^ gpu::GpuMat(src2);\r
-\r
-        CHECK(dst_gold.size() == dst.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold.type() == dst.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-        Mat dsth(dst);\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-\r
-\r
-        Mat mask(src1.size(), CV_8U);\r
-        randu(mask, Scalar(0), Scalar(255));\r
-\r
-        Mat dst_gold2(dst_gold.size(), dst_gold.type()); dst_gold2.setTo(Scalar::all(0));\r
-        gpu::GpuMat dst2(dst.size(), dst.type()); dst2.setTo(Scalar::all(0));\r
-        bitwise_xor(src1, src2, dst_gold2, mask);\r
-        gpu::bitwise_xor(gpu::GpuMat(src1), gpu::GpuMat(src2), dst2, gpu::GpuMat(mask));\r
-\r
-        CHECK(dst_gold2.size() == dst2.size(), cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(dst_gold2.type() == dst2.type(), cvtest::TS::FAIL_INVALID_OUTPUT);        \r
-        dsth = dst2;\r
-        for (int i = 0; i < dst_gold.rows; ++i)       \r
-            CHECK(memcmp(dst_gold2.ptr(i), dsth.ptr(i), dst_gold2.cols * dst_gold2.elemSize()) == 0, cvtest::TS::FAIL_INVALID_OUTPUT)\r
-    }\r
-};\r
-\r
-TEST(BitwiseOperations, accuracy) { CV_GpuBitwiseTest test; test.safe_run(); }\r
diff --git a/modules/gpu/test/test_blend.cpp b/modules/gpu/test/test_blend.cpp
deleted file mode 100644 (file)
index 9479695..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-\r
-using namespace std;\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-\r
-TEST(blendLinear, accuracy_on_8U)\r
-{\r
-    RNG& rng = cvtest::TS::ptr()->get_rng();\r
-    Size size(200 + cvtest::randInt(rng) % 1000,\r
-              200 + cvtest::randInt(rng) % 1000);\r
-    for (int cn = 1; cn <= 4; ++cn)\r
-    {\r
-        Mat img1 = cvtest::randomMat(rng, size, CV_MAKE_TYPE(CV_8U, cn), 0, 255, false);\r
-        Mat img2 = cvtest::randomMat(rng, size, CV_MAKE_TYPE(CV_8U, cn), 0, 255, false);\r
-        Mat weights1 = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
-        Mat weights2 = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
-        Mat result_gold(size, CV_MAKE_TYPE(CV_8U, cn));\r
-        for (int y = 0; y < size.height; ++y)\r
-            for (int x = 0; x < size.width * cn; ++x)\r
-            {\r
-                float w1 = weights1.at<float>(y, x / cn);\r
-                float w2 = weights2.at<float>(y, x / cn);\r
-                result_gold.at<uchar>(y, x) = static_cast<uchar>(\r
-                    (img1.at<uchar>(y, x) * w1 + img2.at<uchar>(y, x) * w2) / (w1 + w2 + 1e-5f));\r
-            }\r
-        GpuMat d_result;\r
-        blendLinear(GpuMat(img1), GpuMat(img2), GpuMat(weights1), GpuMat(weights2), d_result);\r
-        ASSERT_LE(cvtest::norm(result_gold, Mat(d_result), NORM_INF), 1) \r
-            << "rows=" << size.height << ", cols=" << size.width << ", cn=" << cn;\r
-    }\r
-}\r
-\r
-TEST(blendLinear, accuracy_on_32F)\r
-{\r
-    RNG& rng = cvtest::TS::ptr()->get_rng();\r
-    Size size(200 + cvtest::randInt(rng) % 1000,\r
-              200 + cvtest::randInt(rng) % 1000);\r
-    for (int cn = 1; cn <= 4; ++cn)\r
-    {\r
-        Mat img1 = cvtest::randomMat(rng, size, CV_MAKE_TYPE(CV_32F, cn), 0, 1, false);\r
-        Mat img2 = cvtest::randomMat(rng, size, CV_MAKE_TYPE(CV_32F, cn), 0, 1, false);\r
-        Mat weights1 = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
-        Mat weights2 = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
-        Mat result_gold(size, CV_MAKE_TYPE(CV_32F, cn));\r
-        for (int y = 0; y < size.height; ++y)\r
-            for (int x = 0; x < size.width * cn; ++x)\r
-            {\r
-                float w1 = weights1.at<float>(y, x / cn);\r
-                float w2 = weights2.at<float>(y, x / cn);\r
-                result_gold.at<float>(y, x) = \r
-                    (img1.at<float>(y, x) * w1 + img2.at<float>(y, x) * w2) / (w1 + w2 + 1e-5f);\r
-            }\r
-        GpuMat d_result;\r
-        blendLinear(GpuMat(img1), GpuMat(img2), GpuMat(weights1), GpuMat(weights2), d_result);\r
-        ASSERT_LE(cvtest::norm(result_gold, Mat(d_result), NORM_INF), 1e-3)\r
-            << "rows=" << size.height << ", cols=" << size.width << ", cn=" << cn;\r
-    }\r
-}\r
diff --git a/modules/gpu/test/test_brute_force_matcher.cpp b/modules/gpu/test/test_brute_force_matcher.cpp
deleted file mode 100644 (file)
index 59af9f0..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-#include <algorithm>\r
-#include <iterator>\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-class CV_GpuBruteForceMatcherTest : public cvtest::BaseTest\r
-{\r
-public:\r
-    CV_GpuBruteForceMatcherTest()\r
-    {\r
-    }\r
-\r
-protected:\r
-    virtual void run(int);\r
-    \r
-    void emptyDataTest();\r
-    void dataTest(int dim);\r
-    \r
-    void generateData(GpuMat& query, GpuMat& train, int dim);\r
-\r
-    void matchTest(const GpuMat& query, const GpuMat& train);\r
-    void knnMatchTest(const GpuMat& query, const GpuMat& train);\r
-    void radiusMatchTest(const GpuMat& query, const GpuMat& train);\r
-\r
-private:\r
-    BruteForceMatcher_GPU< L2<float> > dmatcher;\r
-\r
-    static const int queryDescCount = 300; // must be even number because we split train data in some cases in two\r
-    static const int countFactor = 4; // do not change it\r
-};\r
-\r
-void CV_GpuBruteForceMatcherTest::emptyDataTest()\r
-{\r
-    GpuMat queryDescriptors, trainDescriptors, mask;\r
-    vector<GpuMat> trainDescriptorCollection, masks;\r
-    vector<DMatch> matches;\r
-    vector< vector<DMatch> > vmatches;\r
-\r
-    try\r
-    {\r
-        dmatcher.match(queryDescriptors, trainDescriptors, matches, mask);\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "match() on empty descriptors must not generate exception (1).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-    try\r
-    {\r
-        dmatcher.knnMatch(queryDescriptors, trainDescriptors, vmatches, 2, mask);\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "knnMatch() on empty descriptors must not generate exception (1).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-    try\r
-    {\r
-        dmatcher.radiusMatch(queryDescriptors, trainDescriptors, vmatches, 10.f, mask);\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "radiusMatch() on empty descriptors must not generate exception (1).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-    try\r
-    {\r
-        dmatcher.add(trainDescriptorCollection);\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "add() on empty descriptors must not generate exception.\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-    try\r
-    {\r
-        dmatcher.match(queryDescriptors, matches, masks);\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "match() on empty descriptors must not generate exception (2).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-    try\r
-    {\r
-        dmatcher.knnMatch(queryDescriptors, vmatches, 2, masks);\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "knnMatch() on empty descriptors must not generate exception (2).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-    try\r
-    {\r
-        dmatcher.radiusMatch( queryDescriptors, vmatches, 10.f, masks );\r
-    }\r
-    catch(...)\r
-    {\r
-        ts->printf( cvtest::TS::LOG, "radiusMatch() on empty descriptors must not generate exception (2).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-    }\r
-\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::generateData( GpuMat& queryGPU, GpuMat& trainGPU, int dim )\r
-{\r
-    Mat query, train;\r
-    RNG& rng = ts->get_rng();\r
-\r
-    // Generate query descriptors randomly.\r
-    // Descriptor vector elements are integer values.\r
-    Mat buf( queryDescCount, dim, CV_32SC1 );\r
-    rng.fill( buf, RNG::UNIFORM, Scalar::all(0), Scalar(3) );\r
-    buf.convertTo( query, CV_32FC1 );\r
-\r
-    // Generate train decriptors as follows:\r
-    // copy each query descriptor to train set countFactor times\r
-    // and perturb some one element of the copied descriptors in\r
-    // in ascending order. General boundaries of the perturbation\r
-    // are (0.f, 1.f).\r
-    train.create( query.rows*countFactor, query.cols, CV_32FC1 );\r
-    float step = 1.f / countFactor;\r
-    for( int qIdx = 0; qIdx < query.rows; qIdx++ )\r
-    {\r
-        Mat queryDescriptor = query.row(qIdx);\r
-        for( int c = 0; c < countFactor; c++ )\r
-        {\r
-            int tIdx = qIdx * countFactor + c;\r
-            Mat trainDescriptor = train.row(tIdx);\r
-            queryDescriptor.copyTo( trainDescriptor );\r
-            int elem = rng(dim);\r
-            float diff = rng.uniform( step*c, step*(c+1) );\r
-            trainDescriptor.at<float>(0, elem) += diff;\r
-        }\r
-    }\r
-\r
-    queryGPU.upload(query);\r
-    trainGPU.upload(train);\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::matchTest( const GpuMat& query, const GpuMat& train )\r
-{\r
-    dmatcher.clear();\r
-\r
-    // test const version of match()\r
-    {\r
-        vector<DMatch> matches;\r
-        dmatcher.match( query, train, matches );\r
-\r
-        if( (int)matches.size() != queryDescCount )\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Incorrect matches count while test match() function (1).\n");\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        }\r
-        else\r
-        {\r
-            int badCount = 0;\r
-            for( size_t i = 0; i < matches.size(); i++ )\r
-            {\r
-                DMatch match = matches[i];\r
-                if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )\r
-                    badCount++;\r
-            }\r
-            if (badCount > 0)\r
-            {\r
-                ts->printf( cvtest::TS::LOG, "%f - too large bad matches part while test match() function (1).\n",\r
-                            (float)badCount/(float)queryDescCount );\r
-                ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-            }\r
-        }\r
-    }\r
-\r
-    // test version of match() with add()\r
-    {\r
-        vector<DMatch> matches;\r
-        // make add() twice to test such case\r
-        dmatcher.add( vector<GpuMat>(1,train.rowRange(0, train.rows/2)) );\r
-        dmatcher.add( vector<GpuMat>(1,train.rowRange(train.rows/2, train.rows)) );\r
-        // prepare masks (make first nearest match illegal)\r
-        vector<GpuMat> masks(2);\r
-        for(int mi = 0; mi < 2; mi++ )\r
-        {\r
-            masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
-            for( int di = 0; di < queryDescCount/2; di++ )\r
-                masks[mi].col(di*countFactor).setTo(Scalar::all(0));\r
-        }\r
-\r
-        dmatcher.match( query, matches, masks );\r
-\r
-        if( (int)matches.size() != queryDescCount )\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Incorrect matches count while test match() function (2).\n");\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        }\r
-        else\r
-        {\r
-            int badCount = 0;\r
-            for( size_t i = 0; i < matches.size(); i++ )\r
-            {\r
-                DMatch match = matches[i];\r
-                int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
-                {\r
-                    if( i < queryDescCount/2 )\r
-                    {\r
-                        if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor + shift) || (match.imgIdx != 0) )\r
-                            badCount++;\r
-                    }\r
-                    else\r
-                    {\r
-                        if( (match.queryIdx != (int)i) || (match.trainIdx != ((int)i-queryDescCount/2)*countFactor + shift) || (match.imgIdx != 1) )\r
-                            badCount++;\r
-                    }\r
-                }\r
-            }\r
-            if (badCount > 0)\r
-            {\r
-                ts->printf( cvtest::TS::LOG, "%f - too large bad matches part while test match() function (2).\n",\r
-                            (float)badCount/(float)queryDescCount );\r
-                ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );\r
-            }\r
-        }\r
-    }\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::knnMatchTest( const GpuMat& query, const GpuMat& train )\r
-{\r
-    dmatcher.clear();\r
-\r
-    // test const version of knnMatch()\r
-    {\r
-        const int knn = 3;\r
-\r
-        vector< vector<DMatch> > matches;\r
-        dmatcher.knnMatch( query, train, matches, knn );\r
-\r
-        if( (int)matches.size() != queryDescCount )\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Incorrect matches count while test knnMatch() function (1).\n");\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        }\r
-        else\r
-        {\r
-            int badCount = 0;\r
-            for( size_t i = 0; i < matches.size(); i++ )\r
-            {\r
-                if( (int)matches[i].size() != knn )\r
-                    badCount++;\r
-                else\r
-                {\r
-                    int localBadCount = 0;\r
-                    for( int k = 0; k < knn; k++ )\r
-                    {\r
-                        DMatch match = matches[i][k];\r
-                        if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor+k) || (match.imgIdx != 0) )\r
-                            localBadCount++;\r
-                    }\r
-                    badCount += localBadCount > 0 ? 1 : 0;\r
-                }\r
-            }\r
-            if (badCount > 0)\r
-            {\r
-                ts->printf( cvtest::TS::LOG, "%f - too large bad matches part while test knnMatch() function (1).\n",\r
-                            (float)badCount/(float)queryDescCount );\r
-                ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-            }\r
-        }\r
-    }\r
-\r
-    // test version of knnMatch() with add()\r
-    {\r
-        const int knn = 2;\r
-        vector<vector<DMatch> > matches;\r
-        // make add() twice to test such case\r
-        dmatcher.add( vector<GpuMat>(1,train.rowRange(0, train.rows/2)) );\r
-        dmatcher.add( vector<GpuMat>(1,train.rowRange(train.rows/2, train.rows)) );\r
-        // prepare masks (make first nearest match illegal)\r
-        vector<GpuMat> masks(2);\r
-        for(int mi = 0; mi < 2; mi++ )\r
-        {\r
-            masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
-            for( int di = 0; di < queryDescCount/2; di++ )\r
-                masks[mi].col(di*countFactor).setTo(Scalar::all(0));\r
-        }\r
-\r
-        dmatcher.knnMatch( query, matches, knn, masks );\r
-\r
-        if( (int)matches.size() != queryDescCount )\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Incorrect matches count while test knnMatch() function (2).\n");\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        }\r
-        else\r
-        {\r
-            int badCount = 0;\r
-            int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
-            for( size_t i = 0; i < matches.size(); i++ )\r
-            {\r
-                if( (int)matches[i].size() != knn )\r
-                    badCount++;\r
-                else\r
-                {\r
-                    int localBadCount = 0;\r
-                    for( int k = 0; k < knn; k++ )\r
-                    {\r
-                        DMatch match = matches[i][k];\r
-                        {\r
-                            if( i < queryDescCount/2 )\r
-                            {\r
-                                if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor + k + shift) ||\r
-                                    (match.imgIdx != 0) )\r
-                                    localBadCount++;\r
-                            }\r
-                            else\r
-                            {\r
-                                if( (match.queryIdx != (int)i) || (match.trainIdx != ((int)i-queryDescCount/2)*countFactor + k + shift) ||\r
-                                    (match.imgIdx != 1) )\r
-                                    localBadCount++;\r
-                            }\r
-                        }\r
-                    }\r
-                    badCount += localBadCount > 0 ? 1 : 0;\r
-                }\r
-            }\r
-            if (badCount > 0)\r
-            {\r
-                ts->printf( cvtest::TS::LOG, "%f - too large bad matches part while test knnMatch() function (2).\n",\r
-                            (float)badCount/(float)queryDescCount );\r
-                ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );\r
-            }\r
-        }\r
-    }\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::radiusMatchTest( const GpuMat& query, const GpuMat& train )\r
-{\r
-    bool atomics_ok = TargetArchs::builtWith(GLOBAL_ATOMICS) && DeviceInfo().supports(GLOBAL_ATOMICS);\r
-    if (!atomics_ok)\r
-    {\r
-        ts->printf(cvtest::TS::CONSOLE, "\nCode and device atomics support is required for radiusMatch (CC >= 1.1)");\r
-        ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-        return;\r
-    }\r
-\r
-    dmatcher.clear();\r
-    // test const version of match()\r
-    {\r
-        const float radius = 1.f/countFactor;\r
-        vector< vector<DMatch> > matches;\r
-        dmatcher.radiusMatch( query, train, matches, radius );\r
-\r
-        if( (int)matches.size() != queryDescCount )\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Incorrect matches count while test radiusMatch() function (1).\n");\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        }\r
-        else\r
-        {\r
-            int badCount = 0;\r
-            for( size_t i = 0; i < matches.size(); i++ )\r
-            {\r
-                if( (int)matches[i].size() != 1 )\r
-                    badCount++;\r
-                else\r
-                {\r
-                    DMatch match = matches[i][0];\r
-                    if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )\r
-                        badCount++;\r
-                }\r
-            }\r
-            if (badCount > 0)\r
-            {\r
-                ts->printf( cvtest::TS::LOG, "%f - too large bad matches part while test radiusMatch() function (1).\n",\r
-                            (float)badCount/(float)queryDescCount );\r
-                ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-            }\r
-        }\r
-    }\r
-\r
-    // test version of match() with add()\r
-    {\r
-        int n = 3;\r
-        const float radius = 1.f/countFactor * n;\r
-        vector< vector<DMatch> > matches;\r
-        // make add() twice to test such case\r
-        dmatcher.add( vector<GpuMat>(1,train.rowRange(0, train.rows/2)) );\r
-        dmatcher.add( vector<GpuMat>(1,train.rowRange(train.rows/2, train.rows)) );\r
-        // prepare masks (make first nearest match illegal)\r
-        vector<GpuMat> masks(2);\r
-        for(int mi = 0; mi < 2; mi++ )\r
-        {\r
-            masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
-            for( int di = 0; di < queryDescCount/2; di++ )\r
-                masks[mi].col(di*countFactor).setTo(Scalar::all(0));\r
-        }\r
-\r
-        dmatcher.radiusMatch( query, matches, radius, masks );\r
-\r
-        int curRes = cvtest::TS::OK;\r
-        if( (int)matches.size() != queryDescCount )\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Incorrect matches count while test radiusMatch() function (1).\n");\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        }\r
-\r
-        int badCount = 0;\r
-        int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
-        int needMatchCount = dmatcher.isMaskSupported() ? n-1 : n;\r
-        for( size_t i = 0; i < matches.size(); i++ )\r
-        {\r
-            if( (int)matches[i].size() != needMatchCount )\r
-                badCount++;\r
-            else\r
-            {\r
-                int localBadCount = 0;\r
-                for( int k = 0; k < needMatchCount; k++ )\r
-                {\r
-                    DMatch match = matches[i][k];\r
-                    {\r
-                        if( i < queryDescCount/2 )\r
-                        {\r
-                            if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor + k + shift) ||\r
-                                (match.imgIdx != 0) )\r
-                                localBadCount++;\r
-                        }\r
-                        else\r
-                        {\r
-                            if( (match.queryIdx != (int)i) || (match.trainIdx != ((int)i-queryDescCount/2)*countFactor + k + shift) ||\r
-                                (match.imgIdx != 1) )\r
-                                localBadCount++;\r
-                        }\r
-                    }\r
-                }\r
-                badCount += localBadCount > 0 ? 1 : 0;\r
-            }\r
-        }\r
-\r
-        if (badCount > 0)\r
-        {\r
-            curRes = cvtest::TS::FAIL_INVALID_OUTPUT;\r
-            ts->printf( cvtest::TS::LOG, "%f - too large bad matches part while test radiusMatch() function (2).\n",\r
-                        (float)badCount/(float)queryDescCount );\r
-            ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );\r
-        }\r
-    }\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::dataTest(int dim)\r
-{\r
-    GpuMat query, train;\r
-    generateData(query, train, dim);\r
-\r
-    matchTest(query, train);\r
-    knnMatchTest(query, train);\r
-    radiusMatchTest(query, train);\r
-\r
-    dmatcher.clear();\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::run(int)\r
-{\r
-    emptyDataTest();\r
-\r
-    dataTest(50);\r
-    dataTest(64);\r
-    dataTest(100);\r
-    dataTest(128);\r
-    dataTest(200);\r
-    dataTest(256);\r
-    dataTest(300);\r
-}\r
-\r
-TEST(BruteForceMatcher, accuracy) { CV_GpuBruteForceMatcherTest test; test.safe_run(); }\r
index 3fdcf47..45404b2 100644 (file)
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv;
-using namespace cv::gpu;
-using namespace cvtest;
-
-TEST(projectPoints, accuracy)
-{
-    RNG& rng = TS::ptr()->get_rng();
-    Mat src = randomMat(rng, Size(1000, 1), CV_32FC3, 0, 10, false);
-    Mat rvec = randomMat(rng, Size(3, 1), CV_32F, 0, 1, false);
-    Mat tvec = randomMat(rng, Size(3, 1), CV_32F, 0, 1, false);
-    Mat camera_mat = randomMat(rng, Size(3, 3), CV_32F, 0, 1, false);
-    camera_mat.at<float>(0, 1) = 0.f;
-    camera_mat.at<float>(1, 0) = 0.f;
-    camera_mat.at<float>(2, 0) = 0.f;
-    camera_mat.at<float>(2, 1) = 0.f;
-
-    vector<Point2f> dst;
-    projectPoints(src, rvec, tvec, camera_mat, Mat(1, 8, CV_32F, Scalar::all(0)), dst);
-
-    GpuMat d_dst;
-    projectPoints(GpuMat(src), rvec, tvec, camera_mat, Mat(), d_dst);
-
-    ASSERT_EQ(dst.size(), (size_t)d_dst.cols);
-    ASSERT_EQ(1, d_dst.rows);
-    ASSERT_EQ(CV_32FC2, d_dst.type());
-
-    Mat h_dst(d_dst);
-    for (size_t i = 0; i < dst.size(); ++i)
-    {
-        Point2f res_gold = dst[i];
-        Point2f res_actual = h_dst.at<Point2f>(0, i);
-        Point2f err = res_actual - res_gold;
-        ASSERT_LT(err.dot(err) / res_gold.dot(res_gold), 1e-3f);
-    }
-}
-
-
-TEST(transformPoints, accuracy)
-{
-    RNG& rng = TS::ptr()->get_rng();
-    Mat src = randomMat(rng, Size(1000, 1), CV_32FC3, 0, 10, false);
-    Mat rvec = randomMat(rng, Size(3, 1), CV_32F, 0, 1, false);
-    Mat tvec = randomMat(rng, Size(3, 1), CV_32F, 0, 1, false);
-
-    GpuMat d_dst;
-    transformPoints(GpuMat(src), rvec, tvec, d_dst);
-    ASSERT_TRUE(src.size() == d_dst.size());
-    ASSERT_EQ(src.type(), d_dst.type());
-
-    Mat h_dst(d_dst);
-    Mat rot;
-    Rodrigues(rvec, rot);
-    for (int i = 0; i < h_dst.cols; ++i)
-    {
-        Point3f p = src.at<Point3f>(0, i);
-        Point3f res_gold(
-                rot.at<float>(0, 0) * p.x + rot.at<float>(0, 1) * p.y + rot.at<float>(0, 2) * p.z + tvec.at<float>(0, 0),
-                rot.at<float>(1, 0) * p.x + rot.at<float>(1, 1) * p.y + rot.at<float>(1, 2) * p.z + tvec.at<float>(0, 1),
-                rot.at<float>(2, 0) * p.x + rot.at<float>(2, 1) * p.y + rot.at<float>(2, 2) * p.z + tvec.at<float>(0, 2));
-        Point3f res_actual = h_dst.at<Point3f>(0, i);
-        Point3f err = res_actual - res_gold;
-        ASSERT_LT(err.dot(err) / res_gold.dot(res_gold), 1e-3f);
-    }
-}
-
-
-TEST(solvePnPRansac, accuracy)
-{
-    RNG& rng = TS::ptr()->get_rng();
-
-    const int num_points = 5000;
-    Mat object = randomMat(rng, Size(num_points, 1), CV_32FC3, 0, 100, false);
-    Mat camera_mat = randomMat(rng, Size(3, 3), CV_32F, 0.5, 1, false);
-    camera_mat.at<float>(0, 1) = 0.f;
-    camera_mat.at<float>(1, 0) = 0.f;
-    camera_mat.at<float>(2, 0) = 0.f;
-    camera_mat.at<float>(2, 1) = 0.f;
-
-    Mat rvec_gold = randomMat(rng, Size(3, 1), CV_32F, 0, 1, false);
-    Mat tvec_gold = randomMat(rng, Size(3, 1), CV_32F, 0, 1, false);
-
-    vector<Point2f> image_vec;
-    projectPoints(object, rvec_gold, tvec_gold, camera_mat, Mat(1, 8, CV_32F, Scalar::all(0)), image_vec);
-    Mat image(1, image_vec.size(), CV_32FC2, &image_vec[0]);
-
-    Mat rvec, tvec;
-    vector<int> inliers;
-    gpu::solvePnPRansac(object, image, camera_mat, Mat(1, 8, CV_32F, Scalar::all(0)), rvec, tvec, false, 200, 2.f, 100, &inliers);
-
-    ASSERT_LE(norm(rvec - rvec_gold), 1e-3f);
-    ASSERT_LE(norm(tvec - tvec_gold), 1e-3f);
-}
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "test_precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+struct StereoTest : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    static cv::Mat img_l;\r
+    static cv::Mat img_r;\r
+    static cv::Mat img_template;\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        img_l.release();\r
+        img_r.release();\r
+        img_template.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    }\r
+};\r
+\r
+cv::Mat StereoTest::img_l;\r
+cv::Mat StereoTest::img_r;\r
+cv::Mat StereoTest::img_template;\r
+\r
+//////////////////////////////////////////////////////////////////////////\r
+// BlockMatching\r
+\r
+struct StereoBlockMatching : StereoTest\r
+{\r
+    static void SetUpTestCase() \r
+    {\r
+        img_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+        img_r = readImage("stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+        img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+    }\r
+};\r
+\r
+TEST_P(StereoBlockMatching, Regression) \r
+{\r
+    ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::gpu::GpuMat disp;\r
+    cv::gpu::StereoBM_GPU bm(0, 128, 19);\r
+\r
+    bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);\r
+\r
+    disp.convertTo(disp, img_template.type());\r
+\r
+    ASSERT_EQ(img_template.size(), disp.size());\r
+    double norm = cv::norm(img_template, (cv::Mat)disp, cv::NORM_INF);\r
+    ASSERT_EQ(0.0, norm);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, testing::ValuesIn(devices()));\r
+\r
+//////////////////////////////////////////////////////////////////////////\r
+// BeliefPropagation\r
+\r
+struct StereoBeliefPropagation : StereoTest\r
+{\r
+    static void SetUpTestCase() \r
+    {\r
+        img_l = readImage("stereobp/aloe-L.png");\r
+        img_r = readImage("stereobp/aloe-R.png");\r
+        img_template = readImage("stereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+    }\r
+};\r
+\r
+TEST_P(StereoBeliefPropagation, Regression) \r
+{\r
+    ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::gpu::GpuMat disp;\r
+    cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);\r
+\r
+    bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);\r
+\r
+    disp.convertTo(disp, img_template.type());\r
+\r
+    ASSERT_EQ(img_template.size(), disp.size());\r
+    double norm = cv::norm(img_template, (cv::Mat)disp, cv::NORM_INF);\r
+    ASSERT_EQ(0.0, norm);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, testing::ValuesIn(devices()));\r
+\r
+//////////////////////////////////////////////////////////////////////////\r
+// ConstantSpaceBP\r
+\r
+struct StereoConstantSpaceBP : StereoTest\r
+{\r
+    static void SetUpTestCase() \r
+    {\r
+        img_l = readImage("csstereobp/aloe-L.png");\r
+        img_r = readImage("csstereobp/aloe-R.png");\r
+    }\r
+\r
+    virtual void SetUp() \r
+    {\r
+        StereoTest::SetUp();\r
+\r
+        if (supportFeature(GetParam(), cv::gpu::FEATURE_SET_COMPUTE_20))\r
+            img_template = readImage("csstereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+        else\r
+            img_template = readImage("csstereobp/aloe-disp_CC1X.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+    }\r
+};\r
+\r
+TEST_P(StereoConstantSpaceBP, Regression) \r
+{\r
+    ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::gpu::GpuMat disp;\r
+    cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);\r
+\r
+    bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);\r
+\r
+    disp.convertTo(disp, img_template.type());\r
+\r
+    ASSERT_EQ(img_template.size(), disp.size());\r
+    double norm = cv::norm(img_template, (cv::Mat)disp, cv::NORM_INF);\r
+    ASSERT_EQ(0.0, norm);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, testing::ValuesIn(devices()));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// projectPoints\r
+\r
+struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    \r
+    cv::Mat src;\r
+    cv::Mat rvec;\r
+    cv::Mat tvec;\r
+    cv::Mat camera_mat;\r
+    \r
+    std::vector<cv::Point2f> dst_gold;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        src = cvtest::randomMat(rng, cv::Size(1000, 1), CV_32FC3, 0, 10, false);\r
+        rvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);\r
+        tvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);\r
+        camera_mat = cvtest::randomMat(rng, cv::Size(3, 3), CV_32F, 0, 1, false);\r
+        camera_mat.at<float>(0, 1) = 0.f;\r
+        camera_mat.at<float>(1, 0) = 0.f;\r
+        camera_mat.at<float>(2, 0) = 0.f;\r
+        camera_mat.at<float>(2, 1) = 0.f;\r
+\r
+        cv::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(ProjectPoints, Accuracy) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(   \r
+        cv::gpu::GpuMat d_dst;\r
+\r
+        cv::gpu::projectPoints(cv::gpu::GpuMat(src), rvec, tvec, camera_mat, cv::Mat(), d_dst);\r
+\r
+        d_dst.download(dst);\r
+    );\r
+\r
+    ASSERT_EQ(dst_gold.size(), dst.cols);\r
+    ASSERT_EQ(1, dst.rows);\r
+    ASSERT_EQ(CV_32FC2, dst.type());\r
+\r
+    for (size_t i = 0; i < dst_gold.size(); ++i)\r
+    {\r
+        cv::Point2f res_gold = dst_gold[i];\r
+        cv::Point2f res_actual = dst.at<cv::Point2f>(0, i);\r
+        cv::Point2f err = res_actual - res_gold;\r
+\r
+        ASSERT_LE(err.dot(err) / res_gold.dot(res_gold), 1e-3f);\r
+    }\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::ValuesIn(devices()));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// transformPoints\r
+\r
+struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Mat src;\r
+    cv::Mat rvec;\r
+    cv::Mat tvec;\r
+    cv::Mat rot;\r
+        \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        src = cvtest::randomMat(rng, cv::Size(1000, 1), CV_32FC3, 0, 10, false);\r
+        rvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);\r
+        tvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);\r
+\r
+        cv::Rodrigues(rvec, rot);\r
+    }\r
+};\r
+\r
+TEST_P(TransformPoints, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat d_dst;\r
+\r
+        cv::gpu::transformPoints(cv::gpu::GpuMat(src), rvec, tvec, d_dst);\r
+\r
+        d_dst.download(dst);\r
+    );\r
+    \r
+    ASSERT_EQ(src.size(), dst.size());\r
+    ASSERT_EQ(src.type(), dst.type());\r
+\r
+    for (int i = 0; i < dst.cols; ++i)\r
+    {\r
+        cv::Point3f p = src.at<cv::Point3f>(0, i);\r
+        cv::Point3f res_gold(\r
+                rot.at<float>(0, 0) * p.x + rot.at<float>(0, 1) * p.y + rot.at<float>(0, 2) * p.z + tvec.at<float>(0, 0),\r
+                rot.at<float>(1, 0) * p.x + rot.at<float>(1, 1) * p.y + rot.at<float>(1, 2) * p.z + tvec.at<float>(0, 1),\r
+                rot.at<float>(2, 0) * p.x + rot.at<float>(2, 1) * p.y + rot.at<float>(2, 2) * p.z + tvec.at<float>(0, 2));\r
+        cv::Point3f res_actual = dst.at<cv::Point3f>(0, i);\r
+        cv::Point3f err = res_actual - res_gold;\r
+\r
+        ASSERT_LE(err.dot(err) / res_gold.dot(res_gold), 1e-3f);\r
+    }\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, testing::ValuesIn(devices()));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// solvePnPRansac\r
+\r
+struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    static const int num_points = 5000;\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Mat object;\r
+    cv::Mat camera_mat;\r
+    std::vector<cv::Point2f> image_vec;\r
+\r
+    cv::Mat rvec_gold;\r
+    cv::Mat tvec_gold;\r
+        \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        object = cvtest::randomMat(rng, cv::Size(num_points, 1), CV_32FC3, 0, 100, false);\r
+        camera_mat = cvtest::randomMat(rng, cv::Size(3, 3), CV_32F, 0.5, 1, false);\r
+        camera_mat.at<float>(0, 1) = 0.f;\r
+        camera_mat.at<float>(1, 0) = 0.f;\r
+        camera_mat.at<float>(2, 0) = 0.f;\r
+        camera_mat.at<float>(2, 1) = 0.f;\r
+\r
+        rvec_gold = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);\r
+        tvec_gold = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);\r
+\r
+        cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), image_vec);\r
+    }\r
+};\r
+\r
+TEST_P(SolvePnPRansac, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat rvec, tvec;\r
+    std::vector<int> inliers;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::solvePnPRansac(object, cv::Mat(1, image_vec.size(), CV_32FC2, &image_vec[0]), camera_mat, \r
+                                cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec, false, 200, 2.f, 100, &inliers);\r
+    );\r
+\r
+    ASSERT_LE(cv::norm(rvec - rvec_gold), 1e-3f);\r
+    ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3f);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::ValuesIn(devices()));\r
+\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_dft_routines.cpp b/modules/gpu/test/test_dft_routines.cpp
deleted file mode 100644 (file)
index f346bef..0000000
+++ /dev/null
@@ -1,399 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-struct CV_GpuMulSpectrumsTest: cvtest::BaseTest\r
-{\r
-    CV_GpuMulSpectrumsTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        test(0);\r
-        testConj(0);\r
-        testScaled(0);\r
-        testScaledConj(0);\r
-        test(DFT_ROWS);\r
-        testConj(DFT_ROWS);\r
-        testScaled(DFT_ROWS);\r
-        testScaledConj(DFT_ROWS);\r
-    }\r
-\r
-    void gen(int cols, int rows, Mat& mat)\r
-    {\r
-        RNG rng;\r
-        mat.create(rows, cols, CV_32FC2);\r
-        rng.fill(mat, RNG::UNIFORM, Scalar::all(0.f), Scalar::all(10.f));\r
-    }\r
-\r
-    bool cmp(const Mat& gold, const Mat& mine, float max_err=1e-3f)\r
-    {\r
-        if (gold.size() != mine.size())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad sizes: gold: %d d%, mine: %d %d\n", gold.cols, gold.rows, mine.cols, mine.rows);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        if (gold.type() != mine.type())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad types: gold=%d, mine=%d\n", gold.type(), mine.type());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        for (int i = 0; i < gold.rows; ++i)\r
-        {\r
-            for (int j = 0; j < gold.cols * 2; ++j)\r
-            {\r
-                float gold_ = gold.at<float>(i, j);\r
-                float mine_ = mine.at<float>(i, j);\r
-                if (fabs(gold_ - mine_) > max_err)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "bad values at %d %d: gold=%f, mine=%f\n", j, i, gold_, mine_);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    bool cmpScaled(const Mat& gold, const Mat& mine, float scale, float max_err=1e-3f)\r
-    {\r
-        if (gold.size() != mine.size())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad sizes: gold: %d d%, mine: %d %d\n", gold.cols, gold.rows, mine.cols, mine.rows);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        if (gold.type() != mine.type())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad types: gold=%d, mine=%d\n", gold.type(), mine.type());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        for (int i = 0; i < gold.rows; ++i)\r
-        {\r
-            for (int j = 0; j < gold.cols * 2; ++j)\r
-            {\r
-                float gold_ = gold.at<float>(i, j) * scale;\r
-                float mine_ = mine.at<float>(i, j);\r
-                if (fabs(gold_ - mine_) > max_err)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "bad values at %d %d: gold=%f, mine=%f\n", j, i, gold_, mine_);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    void test(int flags)\r
-    {\r
-        int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
-        Mat a, b;\r
-        gen(cols, rows, a);\r
-        gen(cols, rows, b);\r
-\r
-        Mat c_gold;\r
-        mulSpectrums(a, b, c_gold, flags, false);\r
-\r
-        GpuMat d_c;\r
-        mulSpectrums(GpuMat(a), GpuMat(b), d_c, flags, false);\r
-\r
-        if (!cmp(c_gold, Mat(d_c)))\r
-            ts->printf(cvtest::TS::CONSOLE, "test failed: cols=%d, rows=%d, flags=%d\n", cols, rows, flags);\r
-    }\r
-\r
-    void testConj(int flags)\r
-    {\r
-        int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
-        Mat a, b;\r
-        gen(cols, rows, a);\r
-        gen(cols, rows, b);\r
-\r
-        Mat c_gold;\r
-        mulSpectrums(a, b, c_gold, flags, true);\r
-\r
-        GpuMat d_c;\r
-        mulSpectrums(GpuMat(a), GpuMat(b), d_c, flags, true);\r
-\r
-        if (!cmp(c_gold, Mat(d_c)))\r
-            ts->printf(cvtest::TS::CONSOLE, "testConj failed: cols=%d, rows=%d, flags=%d\n", cols, rows, flags);\r
-    }\r
-\r
-    void testScaled(int flags)\r
-    {\r
-        int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
-        Mat a, b;\r
-        gen(cols, rows, a);\r
-        gen(cols, rows, b);\r
-        float scale = 1.f / a.size().area();\r
-\r
-        Mat c_gold;\r
-        mulSpectrums(a, b, c_gold, flags, false);\r
-\r
-        GpuMat d_c;\r
-        mulAndScaleSpectrums(GpuMat(a), GpuMat(b), d_c, flags, scale, false);\r
-\r
-        if (!cmpScaled(c_gold, Mat(d_c), scale))\r
-            ts->printf(cvtest::TS::CONSOLE, "testScaled failed: cols=%d, rows=%d, flags=%d\n", cols, rows, flags);\r
-    }\r
-\r
-    void testScaledConj(int flags)\r
-    {\r
-        int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
-        Mat a, b;\r
-        gen(cols, rows, a);\r
-        gen(cols, rows, b);\r
-        float scale = 1.f / a.size().area();\r
-\r
-        Mat c_gold;\r
-        mulSpectrums(a, b, c_gold, flags, true);\r
-\r
-        GpuMat d_c;\r
-        mulAndScaleSpectrums(GpuMat(a), GpuMat(b), d_c, flags, scale, true);\r
-\r
-        if (!cmpScaled(c_gold, Mat(d_c), scale))\r
-            ts->printf(cvtest::TS::CONSOLE, "testScaledConj failed: cols=%d, rows=%d, flags=%D\n", cols, rows, flags);\r
-    }\r
-} CV_GpuMulSpectrumsTest_inst;\r
-\r
-\r
-struct CV_GpuDftTest: cvtest::BaseTest\r
-{\r
-    CV_GpuDftTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        srand(0);\r
-        int cols = 2 + rand() % 100, rows = 2 + rand() % 100;\r
-\r
-        for (int i = 0; i < 2; ++i)\r
-        {\r
-            bool inplace = i != 0;\r
-            testC2C("no flags", cols, rows, 0, inplace);\r
-            testC2C("no flags 0 1", cols, rows + 1, 0, inplace);\r
-            testC2C("no flags 1 0", cols, rows + 1, 0, inplace);\r
-            testC2C("no flags 1 1", cols + 1, rows, 0, inplace);\r
-            testC2C("DFT_INVERSE", cols, rows, DFT_INVERSE, inplace);\r
-            testC2C("DFT_ROWS", cols, rows, DFT_ROWS, inplace);\r
-            testC2C("single col", 1, rows, 0, inplace);\r
-            testC2C("single row", cols, 1, 0, inplace);\r
-            testC2C("single col inversed", 1, rows, DFT_INVERSE, inplace);\r
-            testC2C("single row inversed", cols, 1, DFT_INVERSE, inplace);\r
-            testC2C("single row DFT_ROWS", cols, 1, DFT_ROWS, inplace);\r
-            testC2C("size 1 2", 1, 2, 0, inplace);\r
-            testC2C("size 2 1", 2, 1, 0, inplace);\r
-        }\r
-\r
-        testR2CThenC2R("sanity", cols, rows);\r
-        testR2CThenC2R("sanity 0 1", cols, rows + 1);\r
-        testR2CThenC2R("sanity 1 0", cols + 1, rows);\r
-        testR2CThenC2R("sanity 1 1", cols + 1, rows + 1);\r
-        testR2CThenC2R("single col", 1, rows);\r
-        testR2CThenC2R("single col 1", 1, rows + 1);\r
-        testR2CThenC2R("single row", cols, 1);\r
-        testR2CThenC2R("single row 1", cols + 1, 1);\r
-\r
-        testR2CThenC2R("sanity", cols, rows, true);\r
-        testR2CThenC2R("sanity 0 1", cols, rows + 1, true);\r
-        testR2CThenC2R("sanity 1 0", cols + 1, rows, true);\r
-        testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);\r
-        testR2CThenC2R("single row", cols, 1, true);\r
-        testR2CThenC2R("single row 1", cols + 1, 1, true);\r
-}\r
-\r
-    void gen(int cols, int rows, int cn, Mat& mat)\r
-    {\r
-        RNG rng(1);\r
-        mat.create(rows, cols, CV_MAKETYPE(CV_32F, cn));\r
-        rng.fill(mat, RNG::UNIFORM, Scalar::all(0.f), Scalar::all(10.f));\r
-    }\r
-\r
-    bool cmp(const Mat& gold, const Mat& mine, float max_err=1e-3f)\r
-    {\r
-        if (gold.size() != mine.size())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad sizes: gold: %d %d, mine: %d %d\n", gold.cols, gold.rows, mine.cols, mine.rows);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        if (gold.depth() != mine.depth())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad depth: gold=%d, mine=%d\n", gold.depth(), mine.depth());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        if (gold.channels() != mine.channels())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad channel count: gold=%d, mine=%d\n", gold.channels(), mine.channels());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-        for (int i = 0; i < gold.rows; ++i)\r
-        {\r
-            for (int j = 0; j < gold.cols * gold.channels(); ++j)\r
-            {\r
-                float gold_ = gold.at<float>(i, j);\r
-                float mine_ = mine.at<float>(i, j);\r
-                if (fabs(gold_ - mine_) > max_err)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "bad values at %d %d: gold=%f, mine=%f\n", j / gold.channels(), i, gold_, mine_);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace=false)\r
-    {\r
-        Mat a;\r
-        gen(cols, rows, 2, a);\r
-\r
-        Mat b_gold;\r
-        dft(a, b_gold, flags);\r
-\r
-        GpuMat d_b;\r
-        GpuMat d_b_data;\r
-        if (inplace)\r
-        {\r
-            d_b_data.create(1, a.size().area(), CV_32FC2);\r
-            d_b = GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
-        }\r
-\r
-        dft(GpuMat(a), d_b, Size(cols, rows), flags);\r
-\r
-        bool ok = true;\r
-        if (ok && inplace && d_b.ptr() != d_b_data.ptr())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "unnecessary reallocation was done\n");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok && d_b.depth() != CV_32F)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad depth: %d\n", d_b.depth());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok && d_b.channels() != 2)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad channel count: %d\n", d_b.channels());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok) ok = cmp(b_gold, Mat(d_b), rows * cols * 1e-4f);\r
-        if (!ok) \r
-            ts->printf(cvtest::TS::CONSOLE, "testC2C failed: hint=%s, cols=%d, rows=%d, flags=%d, inplace=%d\n", \r
-                       hint.c_str(), cols, rows, flags, inplace);\r
-    }\r
-\r
-    void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace=false)\r
-    {\r
-        Mat a;\r
-        gen(cols, rows, 1, a);\r
-\r
-        bool ok = true;\r
-\r
-        GpuMat d_b, d_c;\r
-        GpuMat d_b_data, d_c_data;\r
-        if (inplace)\r
-        {\r
-            if (a.cols == 1)\r
-            {\r
-                d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);\r
-                d_b = GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
-            }\r
-            else\r
-            {\r
-                d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);\r
-                d_b = GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());\r
-            }\r
-            d_c_data.create(1, a.size().area(), CV_32F);\r
-            d_c = GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());\r
-        }\r
-\r
-        dft(GpuMat(a), d_b, Size(cols, rows), 0);\r
-        dft(d_b, d_c, Size(cols, rows), DFT_REAL_OUTPUT | DFT_SCALE);\r
-\r
-        if (ok && inplace && d_b.ptr() != d_b_data.ptr())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "unnecessary reallocation was done for b\n");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok && inplace && d_c.ptr() != d_c_data.ptr())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "unnecessary reallocation was done for c\n");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok && d_c.depth() != CV_32F)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad depth: %d\n", d_c.depth());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok && d_c.channels() != 1)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad channel count: %d\n", d_c.channels());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            ok = false;\r
-        }\r
-        if (ok) ok = cmp(a, Mat(d_c), rows * cols * 1e-5f);\r
-        if (!ok) \r
-            ts->printf(cvtest::TS::CONSOLE, "testR2CThenC2R failed: hint=%s, cols=%d, rows=%d, inplace=%d\n", \r
-                       hint.c_str(), cols, rows, inplace);\r
-    }\r
-};\r
-\r
-TEST(dft, accuracy) { CV_GpuDftTest test; test.safe_run(); }\r
index 12f7196..4b0c699 100644 (file)
 //M*/\r
 \r
 #include "test_precomp.hpp"\r
-#include <string>\r
 \r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
+#ifdef HAVE_CUDA\r
 \r
-const string FEATURES2D_DIR = "features2d";\r
-const string IMAGE_FILENAME = "aloe.png";\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// SURF\r
 \r
-class CV_GPU_SURFTest : public cvtest::BaseTest\r
+struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-public:\r
-    CV_GPU_SURFTest()\r
+    static cv::Mat image;\r
+    static cv::Mat mask;\r
+    static std::vector<cv::KeyPoint> keypoints_gold;\r
+    static std::vector<float> descriptors_gold;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);        \r
+        \r
+        mask = cv::Mat(image.size(), CV_8UC1, cv::Scalar::all(1));\r
+        mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));\r
+                \r
+        cv::SURF fdetector_gold; fdetector_gold.extended = false;\r
+        fdetector_gold(image, mask, keypoints_gold, descriptors_gold);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
     {\r
+        image.release();\r
+        mask.release();\r
+        keypoints_gold.clear();\r
+        descriptors_gold.clear();\r
     }\r
 \r
-protected:\r
-    bool isSimilarKeypoints(const KeyPoint& p1, const KeyPoint& p2);\r
-    int getValidCount(const vector<KeyPoint>& keypoints1, const vector<KeyPoint>& keypoints2, const vector<DMatch>& matches);\r
-    void compareKeypointSets(const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints,\r
-                             const Mat& validDescriptors, const Mat& calcDescriptors);\r
+    cv::gpu::DeviceInfo devInfo;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    }\r
 \r
-    void emptyDataTest();\r
-    void accuracyTest();\r
+    bool isSimilarKeypoints(const cv::KeyPoint& p1, const cv::KeyPoint& p2)\r
+    {\r
+        const float maxPtDif = 1.f;\r
+        const float maxSizeDif = 1.f;\r
+        const float maxAngleDif = 2.f;\r
+        const float maxResponseDif = 0.1f;\r
 \r
-    virtual void run(int);\r
+        float dist = (float)cv::norm(p1.pt - p2.pt);\r
+        return (dist < maxPtDif &&\r
+                fabs(p1.size - p2.size) < maxSizeDif &&\r
+                abs(p1.angle - p2.angle) < maxAngleDif &&\r
+                abs(p1.response - p2.response) < maxResponseDif &&\r
+                p1.octave == p2.octave &&\r
+                p1.class_id == p2.class_id );\r
+    }\r
 };\r
 \r
-void CV_GPU_SURFTest::emptyDataTest()\r
+cv::Mat SURF::image;\r
+cv::Mat SURF::mask;\r
+std::vector<cv::KeyPoint> SURF::keypoints_gold;\r
+std::vector<float> SURF::descriptors_gold;\r
+\r
+TEST_P(SURF, EmptyDataTest)\r
 {\r
-    SURF_GPU fdetector;\r
+    PRINT_PARAM(devInfo);\r
 \r
-    GpuMat image;\r
-    vector<KeyPoint> keypoints;\r
-    vector<float> descriptors;\r
-    try\r
-    {\r
-        fdetector(image, GpuMat(), keypoints, descriptors);\r
-    }\r
-    catch(...)\r
+    cv::gpu::SURF_GPU fdetector;\r
+\r
+    cv::gpu::GpuMat image;\r
+    std::vector<cv::KeyPoint> keypoints;\r
+    std::vector<float> descriptors;\r
+\r
+    ASSERT_NO_THROW(\r
+        fdetector(image, cv::gpu::GpuMat(), keypoints, descriptors);\r
+    );\r
+\r
+    EXPECT_TRUE(keypoints.empty());\r
+    EXPECT_TRUE(descriptors.empty());\r
+}\r
+\r
+TEST_P(SURF, Accuracy)\r
+{\r
+    ASSERT_TRUE(!image.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    // Compute keypoints.\r
+    std::vector<cv::KeyPoint> keypoints;\r
+    cv::Mat descriptors;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_descriptors;\r
+        cv::gpu::SURF_GPU fdetector; fdetector.extended = false;\r
+\r
+        fdetector(cv::gpu::GpuMat(image), cv::gpu::GpuMat(mask), keypoints, dev_descriptors);\r
+\r
+        dev_descriptors.download(descriptors);\r
+    );\r
+\r
+    cv::BruteForceMatcher< cv::L2<float> > matcher;\r
+    std::vector<cv::DMatch> matches;\r
+\r
+    matcher.match(cv::Mat(keypoints_gold.size(), 64, CV_32FC1, &descriptors_gold[0]), descriptors, matches);\r
+\r
+    int validCount = 0;\r
+    \r
+    for (size_t i = 0; i < matches.size(); ++i)\r
     {\r
-        ts->printf( cvtest::TS::LOG, "detect() on empty image must not generate exception (1).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
+        const cv::DMatch& m = matches[i];\r
+\r
+        const cv::KeyPoint& p1 = keypoints_gold[m.queryIdx];\r
+        const cv::KeyPoint& p2 = keypoints[m.trainIdx];\r
+\r
+        const float maxPtDif = 1.f;\r
+        const float maxSizeDif = 1.f;\r
+        const float maxAngleDif = 2.f;\r
+        const float maxResponseDif = 0.1f;\r
+\r
+        float dist = (float)cv::norm(p1.pt - p2.pt);\r
+        if (dist < maxPtDif &&\r
+                fabs(p1.size - p2.size) < maxSizeDif &&\r
+                abs(p1.angle - p2.angle) < maxAngleDif &&\r
+                abs(p1.response - p2.response) < maxResponseDif &&\r
+                p1.octave == p2.octave &&\r
+                p1.class_id == p2.class_id )\r
+        {\r
+            ++validCount;\r
+        }\r
     }\r
 \r
-    if( !keypoints.empty() )\r
+    double validRatio = (double)validCount / matches.size();\r
+\r
+    EXPECT_GT(validRatio, 0.5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Features2D, SURF, testing::ValuesIn(devices(cv::gpu::GLOBAL_ATOMICS)));\r
+\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// BruteForceMatcher\r
+\r
+static const char* dists[] = {"L1Dist", "L2Dist", "HammingDist"};\r
+\r
+struct BruteForceMatcher : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, cv::gpu::BruteForceMatcher_GPU_base::DistType, int> >\r
+{\r
+    static const int queryDescCount = 300; // must be even number because we split train data in some cases in two\r
+    static const int countFactor = 4; // do not change it\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    cv::gpu::BruteForceMatcher_GPU_base::DistType distType;\r
+    int dim;\r
+    \r
+    cv::Mat query, train;\r
+\r
+    virtual void SetUp() \r
     {\r
-        ts->printf( cvtest::TS::LOG, "detect() on empty image must return empty keypoints vector (1).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        return;\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        distType = std::tr1::get<1>(GetParam());\r
+        dim = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        cv::Mat queryBuf, trainBuf;\r
+\r
+        // Generate query descriptors randomly.\r
+        // Descriptor vector elements are integer values.\r
+        queryBuf.create(queryDescCount, dim, CV_32SC1);\r
+        rng.fill(queryBuf, cv::RNG::UNIFORM, cv::Scalar::all(0), cv::Scalar::all(3));\r
+        queryBuf.convertTo(queryBuf, CV_32FC1);\r
+\r
+        // Generate train decriptors as follows:\r
+        // copy each query descriptor to train set countFactor times\r
+        // and perturb some one element of the copied descriptors in\r
+        // in ascending order. General boundaries of the perturbation\r
+        // are (0.f, 1.f).\r
+        trainBuf.create(queryDescCount * countFactor, dim, CV_32FC1);\r
+        float step = 1.f / countFactor;\r
+        for (int qIdx = 0; qIdx < queryDescCount; qIdx++)\r
+        {\r
+            cv::Mat queryDescriptor = queryBuf.row(qIdx);\r
+            for (int c = 0; c < countFactor; c++)\r
+            {\r
+                int tIdx = qIdx * countFactor + c;\r
+                cv::Mat trainDescriptor = trainBuf.row(tIdx);\r
+                queryDescriptor.copyTo(trainDescriptor);\r
+                int elem = rng(dim);\r
+                float diff = rng.uniform(step * c, step * (c + 1));\r
+                trainDescriptor.at<float>(0, elem) += diff;\r
+            }\r
+        }\r
+\r
+        queryBuf.convertTo(query, CV_32F);\r
+        trainBuf.convertTo(train, CV_32F);\r
     }\r
+};\r
+\r
+TEST_P(BruteForceMatcher, Match)\r
+{\r
+    const char* distStr = dists[distType];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(distStr);\r
+    PRINT_PARAM(dim);\r
 \r
-    if( !descriptors.empty() )\r
+    std::vector<cv::DMatch> matches;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::BruteForceMatcher_GPU_base matcher(distType);\r
+\r
+        matcher.match(cv::gpu::GpuMat(query), cv::gpu::GpuMat(train), matches);\r
+    );\r
+\r
+    ASSERT_EQ(queryDescCount, matches.size());\r
+\r
+    int badCount = 0;\r
+    for (size_t i = 0; i < matches.size(); i++)\r
     {\r
-        ts->printf( cvtest::TS::LOG, "detect() on empty image must return empty descriptors vector (1).\n" );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );\r
-        return;\r
+        cv::DMatch match = matches[i];\r
+        if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor) || (match.imgIdx != 0))\r
+            badCount++;\r
     }\r
+\r
+    ASSERT_EQ(0, badCount);\r
 }\r
 \r
-bool CV_GPU_SURFTest::isSimilarKeypoints(const KeyPoint& p1, const KeyPoint& p2)\r
+TEST_P(BruteForceMatcher, MatchAdd)\r
 {\r
-    const float maxPtDif = 1.f;\r
-    const float maxSizeDif = 1.f;\r
-    const float maxAngleDif = 2.f;\r
-    const float maxResponseDif = 0.1f;\r
-\r
-    float dist = (float)norm( p1.pt - p2.pt );\r
-    return (dist < maxPtDif &&\r
-            fabs(p1.size - p2.size) < maxSizeDif &&\r
-            abs(p1.angle - p2.angle) < maxAngleDif &&\r
-            abs(p1.response - p2.response) < maxResponseDif &&\r
-            p1.octave == p2.octave &&\r
-            p1.class_id == p2.class_id );\r
+    const char* distStr = dists[distType];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(distStr);\r
+    PRINT_PARAM(dim);\r
+\r
+    std::vector<cv::DMatch> matches;\r
+\r
+    bool isMaskSupported;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::BruteForceMatcher_GPU_base matcher(distType);\r
+\r
+        cv::gpu::GpuMat d_train(train);\r
+\r
+        // make add() twice to test such case\r
+        matcher.add(std::vector<cv::gpu::GpuMat>(1, d_train.rowRange(0, train.rows/2)));\r
+        matcher.add(std::vector<cv::gpu::GpuMat>(1, d_train.rowRange(train.rows/2, train.rows)));\r
+\r
+        // prepare masks (make first nearest match illegal)\r
+        std::vector<cv::gpu::GpuMat> masks(2);\r
+        for (int mi = 0; mi < 2; mi++)\r
+        {\r
+            masks[mi] = cv::gpu::GpuMat(query.rows, train.rows/2, CV_8UC1, cv::Scalar::all(1));\r
+            for (int di = 0; di < queryDescCount/2; di++)\r
+                masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));\r
+        }\r
+\r
+        matcher.match(cv::gpu::GpuMat(query), matches, masks);\r
+\r
+        isMaskSupported = matcher.isMaskSupported();\r
+    );\r
+\r
+    ASSERT_EQ(queryDescCount, matches.size());\r
+\r
+    int badCount = 0;\r
+    for (size_t i = 0; i < matches.size(); i++)\r
+    {\r
+        cv::DMatch match = matches[i];\r
+        int shift = isMaskSupported ? 1 : 0;\r
+        {\r
+            if (i < queryDescCount / 2)\r
+            {\r
+                if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + shift) || (match.imgIdx != 0))\r
+                    badCount++;\r
+            }\r
+            else\r
+            {\r
+                if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + shift) || (match.imgIdx != 1))\r
+                    badCount++;\r
+            }\r
+        }\r
+    }\r
+\r
+    ASSERT_EQ(0, badCount);\r
 }\r
 \r
-int CV_GPU_SURFTest::getValidCount(const vector<KeyPoint>& keypoints1, const vector<KeyPoint>& keypoints2,\r
-                     const vector<DMatch>& matches)\r
+TEST_P(BruteForceMatcher, KnnMatch)\r
 {\r
-    int count = 0;\r
+    const char* distStr = dists[distType];\r
 \r
-    for (size_t i = 0; i < matches.size(); ++i)\r
-    {\r
-        const DMatch& m = matches[i];\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(distStr);\r
+    PRINT_PARAM(dim);\r
+\r
+    const int knn = 3;\r
+\r
+    std::vector< std::vector<cv::DMatch> > matches;\r
 \r
-        const KeyPoint& kp1 = keypoints1[m.queryIdx];\r
-        const KeyPoint& kp2 = keypoints2[m.trainIdx];\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::BruteForceMatcher_GPU_base matcher(distType);\r
+        matcher.knnMatch(cv::gpu::GpuMat(query), cv::gpu::GpuMat(train), matches, knn);\r
+    );\r
 \r
-        if (isSimilarKeypoints(kp1, kp2))\r
-            ++count;\r
+    ASSERT_EQ(queryDescCount, matches.size());\r
+\r
+    int badCount = 0;\r
+    for (size_t i = 0; i < matches.size(); i++)\r
+    {\r
+        if ((int)matches[i].size() != knn)\r
+            badCount++;\r
+        else\r
+        {\r
+            int localBadCount = 0;\r
+            for (int k = 0; k < knn; k++)\r
+            {\r
+                cv::DMatch match = matches[i][k];\r
+                if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k) || (match.imgIdx != 0))\r
+                    localBadCount++;\r
+            }\r
+            badCount += localBadCount > 0 ? 1 : 0;\r
+        }\r
     }\r
 \r
-    return count;\r
+    ASSERT_EQ(0, badCount);\r
 }\r
 \r
-void CV_GPU_SURFTest::compareKeypointSets(const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints, \r
-                                          const Mat& validDescriptors, const Mat& calcDescriptors)\r
+TEST_P(BruteForceMatcher, KnnMatchAdd)\r
 {\r
-    BruteForceMatcher< L2<float> > matcher;\r
-    vector<DMatch> matches;\r
+    const char* distStr = dists[distType];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(distStr);\r
+    PRINT_PARAM(dim);\r
 \r
-    matcher.match(validDescriptors, calcDescriptors, matches);\r
+    const int knn = 2;\r
+    std::vector< std::vector<cv::DMatch> > matches;\r
 \r
-    int validCount = getValidCount(validKeypoints, calcKeypoints, matches);\r
-    float validRatio = (float)validCount / matches.size();\r
+    bool isMaskSupported;\r
 \r
-    if (validRatio < 0.5f)\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::BruteForceMatcher_GPU_base matcher(distType);\r
+\r
+        cv::gpu::GpuMat d_train(train);\r
+\r
+        // make add() twice to test such case\r
+        matcher.add(std::vector<cv::gpu::GpuMat>(1, d_train.rowRange(0, train.rows / 2)));\r
+        matcher.add(std::vector<cv::gpu::GpuMat>(1, d_train.rowRange(train.rows / 2, train.rows)));\r
+\r
+        // prepare masks (make first nearest match illegal)\r
+        std::vector<cv::gpu::GpuMat> masks(2);\r
+        for (int mi = 0; mi < 2; mi++ )\r
+        {\r
+            masks[mi] = cv::gpu::GpuMat(query.rows, train.rows / 2, CV_8UC1, cv::Scalar::all(1));\r
+            for (int di = 0; di < queryDescCount / 2; di++)\r
+                masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));\r
+        }\r
+\r
+        matcher.knnMatch(cv::gpu::GpuMat(query), matches, knn, masks);\r
+\r
+        isMaskSupported = matcher.isMaskSupported();\r
+    );\r
+\r
+    ASSERT_EQ(queryDescCount, matches.size());\r
+\r
+    int badCount = 0;\r
+    int shift = isMaskSupported ? 1 : 0;\r
+    for (size_t i = 0; i < matches.size(); i++)\r
     {\r
-        ts->printf(cvtest::TS::LOG, "Bad accuracy - %f.\n", validRatio);\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );\r
-        return;\r
+        if ((int)matches[i].size() != knn)\r
+            badCount++;\r
+        else\r
+        {\r
+            int localBadCount = 0;\r
+            for (int k = 0; k < knn; k++)\r
+            {\r
+                cv::DMatch match = matches[i][k];\r
+                {\r
+                    if (i < queryDescCount / 2)\r
+                    {\r
+                        if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k + shift) || (match.imgIdx != 0) )\r
+                            localBadCount++;\r
+                    }\r
+                    else\r
+                    {\r
+                        if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + k + shift) || (match.imgIdx != 1) )\r
+                            localBadCount++;\r
+                    }\r
+                }\r
+            }\r
+            badCount += localBadCount > 0 ? 1 : 0;\r
+        }\r
     }\r
+\r
+    ASSERT_EQ(0, badCount);\r
 }\r
 \r
-void CV_GPU_SURFTest::accuracyTest()\r
+TEST_P(BruteForceMatcher, RadiusMatch)\r
 {\r
-    string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME;\r
+    if (!supportFeature(devInfo, cv::gpu::GLOBAL_ATOMICS))\r
+        return;\r
+\r
+    const char* distStr = dists[distType];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(distStr);\r
+    PRINT_PARAM(dim);\r
+\r
+    const float radius = 1.f / countFactor;\r
+\r
+    std::vector< std::vector<cv::DMatch> > matches;\r
 \r
-    // Read the test image.\r
-    Mat image = imread(imgFilename, 0);\r
-    if (image.empty())\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::BruteForceMatcher_GPU_base matcher(distType);\r
+\r
+        matcher.radiusMatch(cv::gpu::GpuMat(query), cv::gpu::GpuMat(train), matches, radius);\r
+    );\r
+\r
+    ASSERT_EQ(queryDescCount, matches.size());\r
+\r
+    int badCount = 0;\r
+    for (size_t i = 0; i < matches.size(); i++)\r
     {\r
-        ts->printf( cvtest::TS::LOG, "Image %s can not be read.\n", imgFilename.c_str() );\r
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );\r
-        return;\r
+        if ((int)matches[i].size() != 1)\r
+            badCount++;\r
+        else\r
+        {\r
+            cv::DMatch match = matches[i][0];\r
+            if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0))\r
+                badCount++;\r
+        }\r
     }\r
-    \r
-    Mat mask(image.size(), CV_8UC1, Scalar::all(1));\r
-    mask(Range(0, image.rows / 2), Range(0, image.cols / 2)).setTo(Scalar::all(0));\r
 \r
-    // Compute keypoints.\r
-    vector<KeyPoint> calcKeypoints;\r
-    GpuMat calcDescriptors;\r
-    SURF_GPU fdetector; fdetector.extended = false;\r
-    fdetector(GpuMat(image), GpuMat(mask), calcKeypoints, calcDescriptors);\r
-\r
-    // Calc validation keypoints set.\r
-    vector<KeyPoint> validKeypoints;\r
-    vector<float> validDescriptors;\r
-    SURF fdetector_gold; fdetector_gold.extended = false;\r
-    fdetector_gold(image, mask, validKeypoints, validDescriptors);\r
-\r
-    compareKeypointSets(validKeypoints, calcKeypoints, \r
-        Mat(validKeypoints.size(), fdetector_gold.descriptorSize(), CV_32F, &validDescriptors[0]), calcDescriptors);\r
+    ASSERT_EQ(0, badCount);\r
 }\r
 \r
-void CV_GPU_SURFTest::run( int /*start_from*/ )\r
+TEST_P(BruteForceMatcher, RadiusMatchAdd)\r
 {\r
-    emptyDataTest();\r
-    accuracyTest();\r
+    if (!supportFeature(devInfo, cv::gpu::GLOBAL_ATOMICS))\r
+        return;\r
+\r
+    const char* distStr = dists[distType];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(distStr);\r
+    PRINT_PARAM(dim);\r
+\r
+    int n = 3;\r
+    const float radius = 1.f / countFactor * n;\r
+\r
+    std::vector< std::vector<cv::DMatch> > matches;\r
+\r
+    bool isMaskSupported;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::BruteForceMatcher_GPU_base matcher(distType);\r
+\r
+        cv::gpu::GpuMat d_train(train);\r
+\r
+        // make add() twice to test such case\r
+        matcher.add(std::vector<cv::gpu::GpuMat>(1, d_train.rowRange(0, train.rows / 2)));\r
+        matcher.add(std::vector<cv::gpu::GpuMat>(1, d_train.rowRange(train.rows / 2, train.rows)));\r
+\r
+        // prepare masks (make first nearest match illegal)\r
+        std::vector<cv::gpu::GpuMat> masks(2);\r
+        for (int mi = 0; mi < 2; mi++)\r
+        {\r
+            masks[mi] = cv::gpu::GpuMat(query.rows, train.rows / 2, CV_8UC1, cv::Scalar::all(1));\r
+            for (int di = 0; di < queryDescCount / 2; di++)\r
+                masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));\r
+        }\r
+\r
+        matcher.radiusMatch(cv::gpu::GpuMat(query), matches, radius, masks);\r
+\r
+        isMaskSupported = matcher.isMaskSupported();\r
+    );\r
+\r
+    ASSERT_EQ(queryDescCount, matches.size());\r
+\r
+    int badCount = 0;\r
+    int shift = isMaskSupported ? 1 : 0;\r
+    int needMatchCount = isMaskSupported ? n-1 : n;\r
+    for (size_t i = 0; i < matches.size(); i++)\r
+    {\r
+        if ((int)matches[i].size() != needMatchCount)\r
+            badCount++;\r
+        else\r
+        {\r
+            int localBadCount = 0;\r
+            for (int k = 0; k < needMatchCount; k++)\r
+            {\r
+                cv::DMatch match = matches[i][k];\r
+                {\r
+                    if (i < queryDescCount / 2)\r
+                    {\r
+                        if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k + shift) || (match.imgIdx != 0) )\r
+                            localBadCount++;\r
+                    }\r
+                    else\r
+                    {\r
+                        if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + k + shift) || (match.imgIdx != 1) )\r
+                            localBadCount++;\r
+                    }\r
+                }\r
+            }\r
+            badCount += localBadCount > 0 ? 1 : 0;\r
+        }\r
+    }\r
+\r
+    ASSERT_EQ(0, badCount);\r
 }\r
 \r
-TEST(SURF, empty_data_and_accuracy) { CV_GPU_SURFTest test; test.safe_run(); }\r
+INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(cv::gpu::BruteForceMatcher_GPU_base::L1Dist, cv::gpu::BruteForceMatcher_GPU_base::L2Dist),\r
+                        testing::Values(57, 64, 83, 128, 179, 256, 304)));\r
+\r
+#endif // HAVE_CUDA\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+//struct CV_GpuBFMTest : CV_GpuTestBase\r
+//{\r
+//    void run_gpu_test();\r
+//       \r
+//    void generateData(GpuMat& query, GpuMat& train, int dim, int depth);\r
+//\r
+//    virtual void test(const GpuMat& query, const GpuMat& train, BruteForceMatcher_GPU_base& matcher) = 0;\r
+//\r
+//    static const int queryDescCount = 300; // must be even number because we split train data in some cases in two\r
+//    static const int countFactor = 4; // do not change it\r
+//};\r
+//\r
+//void CV_GpuBFMTest::run_gpu_test()\r
+//{\r
+//    BruteForceMatcher_GPU_base::DistType dists[] = {BruteForceMatcher_GPU_base::L1Dist, BruteForceMatcher_GPU_base::L2Dist, BruteForceMatcher_GPU_base::HammingDist};\r
+//    const char* dists_str[] = {"L1Dist", "L2Dist", "HammingDist"};\r
+//    int dists_count = sizeof(dists) / sizeof(dists[0]);\r
+//\r
+//    RNG rng = ts->get_rng();\r
+//\r
+//    int dims[] = {rng.uniform(30, 60), 64, rng.uniform(70, 110), 128, rng.uniform(130, 250), 256, rng.uniform(260, 350)};\r
+//    int dims_count = sizeof(dims) / sizeof(dims[0]);\r
+//\r
+//    for (int dist = 0; dist < dists_count; ++dist)\r
+//    {\r
+//        int depth_end = dists[dist] == BruteForceMatcher_GPU_base::HammingDist ? CV_32S : CV_32F;\r
+//\r
+//        for (int depth = CV_8U; depth <= depth_end; ++depth)\r
+//        {\r
+//            for (int dim = 0; dim < dims_count; ++dim)\r
+//            {\r
+//                PRINT_ARGS("dist=%s depth=%s dim=%d", dists_str[dist], getTypeName(depth), dims[dim]);\r
+//                \r
+//                BruteForceMatcher_GPU_base matcher(dists[dist]);\r
+//\r
+//                GpuMat query, train;\r
+//                generateData(query, train, dim, depth);\r
+//\r
+//                test(query, train, matcher);\r
+//            }\r
+//        }\r
+//    }\r
+//}\r
+//\r
+//void CV_GpuBFMTest::generateData(GpuMat& queryGPU, GpuMat& trainGPU, int dim, int depth)\r
+//{\r
+//    RNG& rng = ts->get_rng();\r
+//\r
+//    Mat queryBuf, trainBuf;\r
+//\r
+//    // Generate query descriptors randomly.\r
+//    // Descriptor vector elements are integer values.\r
+//    queryBuf.create(queryDescCount, dim, CV_32SC1);\r
+//    rng.fill(queryBuf, RNG::UNIFORM, Scalar::all(0), Scalar(3));\r
+//    queryBuf.convertTo(queryBuf, CV_32FC1);\r
+//\r
+//    // Generate train decriptors as follows:\r
+//    // copy each query descriptor to train set countFactor times\r
+//    // and perturb some one element of the copied descriptors in\r
+//    // in ascending order. General boundaries of the perturbation\r
+//    // are (0.f, 1.f).\r
+//    trainBuf.create(queryDescCount * countFactor, dim, CV_32FC1);\r
+//    float step = 1.f / countFactor;\r
+//    for (int qIdx = 0; qIdx < queryDescCount; qIdx++)\r
+//    {\r
+//        Mat queryDescriptor = queryBuf.row(qIdx);\r
+//        for (int c = 0; c < countFactor; c++)\r
+//        {\r
+//            int tIdx = qIdx * countFactor + c;\r
+//            Mat trainDescriptor = trainBuf.row(tIdx);\r
+//            queryDescriptor.copyTo(trainDescriptor);\r
+//            int elem = rng(dim);\r
+//            float diff = rng.uniform(step * c, step * (c + 1));\r
+//            trainDescriptor.at<float>(0, elem) += diff;\r
+//        }\r
+//    }\r
+//\r
+//    Mat query, train;\r
+//    queryBuf.convertTo(query, depth);\r
+//    trainBuf.convertTo(train, depth);\r
+//\r
+//    queryGPU.upload(query);\r
+//    trainGPU.upload(train);\r
+//}\r
+//\r
+//#define GPU_BFM_TEST(test_name) \\r
+//    struct CV_GpuBFM_ ##test_name ## _Test : CV_GpuBFMTest \\r
+//    { \\r
+//        void test(const GpuMat& query, const GpuMat& train, BruteForceMatcher_GPU_base& matcher); \\r
+//    }; \\r
+//    TEST(BruteForceMatcher, test_name) { CV_GpuBFM_ ##test_name ## _Test test; test.safe_run(); } \\r
+//    void CV_GpuBFM_ ##test_name ## _Test::test(const GpuMat& query, const GpuMat& train, BruteForceMatcher_GPU_base& matcher)\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////////////\r
+//// match\r
+//\r
+//GPU_BFM_TEST(match)\r
+//{\r
+//    vector<DMatch> matches;\r
+//\r
+//    matcher.match(query, train, matches);\r
+//\r
+//    CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+//\r
+//    int badCount = 0;\r
+//    for (size_t i = 0; i < matches.size(); i++)\r
+//    {\r
+//        DMatch match = matches[i];\r
+//        if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor) || (match.imgIdx != 0))\r
+//            badCount++;\r
+//    }\r
+//\r
+//    CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+//}\r
+//\r
+//GPU_BFM_TEST(match_add)\r
+//{\r
+//    vector<DMatch> matches;\r
+//\r
+//    // make add() twice to test such case\r
+//    matcher.add(vector<GpuMat>(1, train.rowRange(0, train.rows/2)));\r
+//    matcher.add(vector<GpuMat>(1, train.rowRange(train.rows/2, train.rows)));\r
+//\r
+//    // prepare masks (make first nearest match illegal)\r
+//    vector<GpuMat> masks(2);\r
+//    for (int mi = 0; mi < 2; mi++)\r
+//    {\r
+//        masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
+//        for (int di = 0; di < queryDescCount/2; di++)\r
+//            masks[mi].col(di * countFactor).setTo(Scalar::all(0));\r
+//    }\r
+//\r
+//    matcher.match(query, matches, masks);\r
+//\r
+//    CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+//\r
+//    int badCount = 0;\r
+//    for (size_t i = 0; i < matches.size(); i++)\r
+//    {\r
+//        DMatch match = matches[i];\r
+//        int shift = matcher.isMaskSupported() ? 1 : 0;\r
+//        {\r
+//            if (i < queryDescCount / 2)\r
+//            {\r
+//                if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + shift) || (match.imgIdx != 0))\r
+//                    badCount++;\r
+//            }\r
+//            else\r
+//            {\r
+//                if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + shift) || (match.imgIdx != 1))\r
+//                    badCount++;\r
+//            }\r
+//        }\r
+//    }\r
+//\r
+//    CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+//}\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////////////\r
+//// knnMatch\r
+//\r
+//GPU_BFM_TEST(knnMatch)\r
+//{\r
+//    const int knn = 3;\r
+//\r
+//    vector< vector<DMatch> > matches;\r
+//\r
+//    matcher.knnMatch(query, train, matches, knn);\r
+//\r
+//    CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+//\r
+//    int badCount = 0;\r
+//    for (size_t i = 0; i < matches.size(); i++)\r
+//    {\r
+//        if ((int)matches[i].size() != knn)\r
+//            badCount++;\r
+//        else\r
+//        {\r
+//            int localBadCount = 0;\r
+//            for (int k = 0; k < knn; k++)\r
+//            {\r
+//                DMatch match = matches[i][k];\r
+//                if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k) || (match.imgIdx != 0))\r
+//                    localBadCount++;\r
+//            }\r
+//            badCount += localBadCount > 0 ? 1 : 0;\r
+//        }\r
+//    }\r
+//\r
+//    CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+//}\r
+//\r
+//GPU_BFM_TEST(knnMatch_add)\r
+//{\r
+//    const int knn = 2;\r
+//    vector<vector<DMatch> > matches;\r
+//\r
+//    // make add() twice to test such case\r
+//    matcher.add(vector<GpuMat>(1,train.rowRange(0, train.rows / 2)));\r
+//    matcher.add(vector<GpuMat>(1,train.rowRange(train.rows / 2, train.rows)));\r
+//\r
+//    // prepare masks (make first nearest match illegal)\r
+//    vector<GpuMat> masks(2);\r
+//    for (int mi = 0; mi < 2; mi++ )\r
+//    {\r
+//        masks[mi] = GpuMat(query.rows, train.rows / 2, CV_8UC1, Scalar::all(1));\r
+//        for (int di = 0; di < queryDescCount / 2; di++)\r
+//            masks[mi].col(di * countFactor).setTo(Scalar::all(0));\r
+//    }\r
+//\r
+//    matcher.knnMatch(query, matches, knn, masks);\r
+//\r
+//    CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+//\r
+//    int badCount = 0;\r
+//    int shift = matcher.isMaskSupported() ? 1 : 0;\r
+//    for (size_t i = 0; i < matches.size(); i++)\r
+//    {\r
+//        if ((int)matches[i].size() != knn)\r
+//            badCount++;\r
+//        else\r
+//        {\r
+//            int localBadCount = 0;\r
+//            for (int k = 0; k < knn; k++)\r
+//            {\r
+//                DMatch match = matches[i][k];\r
+//                {\r
+//                    if (i < queryDescCount / 2)\r
+//                    {\r
+//                        if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k + shift) || (match.imgIdx != 0) )\r
+//                            localBadCount++;\r
+//                    }\r
+//                    else\r
+//                    {\r
+//                        if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + k + shift) || (match.imgIdx != 1) )\r
+//                            localBadCount++;\r
+//                    }\r
+//                }\r
+//            }\r
+//            badCount += localBadCount > 0 ? 1 : 0;\r
+//        }\r
+//    }\r
+//\r
+//    CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+//}\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////////////\r
+//// radiusMatch\r
+//\r
+//GPU_BFM_TEST(radiusMatch)\r
+//{\r
+//    CHECK_RETURN(support(GLOBAL_ATOMICS), TS::SKIPPED);\r
+//\r
+//    const float radius = 1.f / countFactor;\r
+//\r
+//    vector< vector<DMatch> > matches;\r
+//\r
+//    matcher.radiusMatch(query, train, matches, radius);\r
+//\r
+//    CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+//\r
+//    int badCount = 0;\r
+//    for (size_t i = 0; i < matches.size(); i++)\r
+//    {\r
+//        if ((int)matches[i].size() != 1)\r
+//            badCount++;\r
+//        else\r
+//        {\r
+//            DMatch match = matches[i][0];\r
+//            if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0))\r
+//                badCount++;\r
+//        }\r
+//    }\r
+//\r
+//    CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+//}\r
+//\r
+//GPU_BFM_TEST(radiusMatch_add)\r
+//{\r
+//    CHECK_RETURN(support(GLOBAL_ATOMICS), TS::SKIPPED);\r
+//\r
+//    int n = 3;\r
+//    const float radius = 1.f / countFactor * n;\r
+//    vector< vector<DMatch> > matches;\r
+//\r
+//    // make add() twice to test such case\r
+//    matcher.add(vector<GpuMat>(1,train.rowRange(0, train.rows / 2)));\r
+//    matcher.add(vector<GpuMat>(1,train.rowRange(train.rows / 2, train.rows)));\r
+//\r
+//    // prepare masks (make first nearest match illegal)\r
+//    vector<GpuMat> masks(2);\r
+//    for (int mi = 0; mi < 2; mi++)\r
+//    {\r
+//        masks[mi] = GpuMat(query.rows, train.rows / 2, CV_8UC1, Scalar::all(1));\r
+//        for (int di = 0; di < queryDescCount / 2; di++)\r
+//            masks[mi].col(di * countFactor).setTo(Scalar::all(0));\r
+//    }\r
+//\r
+//    matcher.radiusMatch(query, matches, radius, masks);\r
+//\r
+//    CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+//\r
+//    int badCount = 0;\r
+//    int shift = matcher.isMaskSupported() ? 1 : 0;\r
+//    int needMatchCount = matcher.isMaskSupported() ? n-1 : n;\r
+//    for (size_t i = 0; i < matches.size(); i++)\r
+//    {\r
+//        if ((int)matches[i].size() != needMatchCount)\r
+//            badCount++;\r
+//        else\r
+//        {\r
+//            int localBadCount = 0;\r
+//            for (int k = 0; k < needMatchCount; k++)\r
+//            {\r
+//                DMatch match = matches[i][k];\r
+//                {\r
+//                    if (i < queryDescCount / 2)\r
+//                    {\r
+//                        if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k + shift) || (match.imgIdx != 0) )\r
+//                            localBadCount++;\r
+//                    }\r
+//                    else\r
+//                    {\r
+//                        if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + k + shift) || (match.imgIdx != 1) )\r
+//                            localBadCount++;\r
+//                    }\r
+//                }\r
+//            }\r
+//            badCount += localBadCount > 0 ? 1 : 0;\r
+//        }\r
+//    }\r
+//\r
+//    CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+//}\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+//\r
+////struct CV_GpuBruteForceMatcherTest : CV_GpuTestBase\r
+////{\r
+////    void run_gpu_test();\r
+////    \r
+////    void emptyDataTest();\r
+////    void dataTest(int dim);\r
+////    \r
+////    void generateData(GpuMat& query, GpuMat& train, int dim);\r
+////\r
+////    void matchTest(const GpuMat& query, const GpuMat& train);\r
+////    void knnMatchTest(const GpuMat& query, const GpuMat& train);\r
+////    void radiusMatchTest(const GpuMat& query, const GpuMat& train);\r
+////\r
+////    BruteForceMatcher_GPU< L2<float> > dmatcher;\r
+////\r
+////    static const int queryDescCount = 300; // must be even number because we split train data in some cases in two\r
+////    static const int countFactor = 4; // do not change it\r
+////};\r
+////\r
+////void CV_GpuBruteForceMatcherTest::emptyDataTest()\r
+////{\r
+////    GpuMat queryDescriptors, trainDescriptors, mask;\r
+////    vector<GpuMat> trainDescriptorCollection, masks;\r
+////    vector<DMatch> matches;\r
+////    vector< vector<DMatch> > vmatches;\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.match(queryDescriptors, trainDescriptors, matches, mask);\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("match() on empty descriptors must not generate exception (1)");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.knnMatch(queryDescriptors, trainDescriptors, vmatches, 2, mask);\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("knnMatch() on empty descriptors must not generate exception (1)");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.radiusMatch(queryDescriptors, trainDescriptors, vmatches, 10.f, mask);\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("radiusMatch() on empty descriptors must not generate exception (1)");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.add(trainDescriptorCollection);\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("add() on empty descriptors must not generate exception");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.match(queryDescriptors, matches, masks);\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("match() on empty descriptors must not generate exception (2)");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.knnMatch(queryDescriptors, vmatches, 2, masks);\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("knnMatch() on empty descriptors must not generate exception (2)");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////    try\r
+////    {\r
+////        dmatcher.radiusMatch( queryDescriptors, vmatches, 10.f, masks );\r
+////    }\r
+////    catch(...)\r
+////    {\r
+////        PRINTLN("radiusMatch() on empty descriptors must not generate exception (2)");\r
+////        ts->set_failed_test_info(TS::FAIL_EXCEPTION);\r
+////    }\r
+////\r
+////}\r
+////\r
+////void CV_GpuBruteForceMatcherTest::generateData(GpuMat& queryGPU, GpuMat& trainGPU, int dim)\r
+////{\r
+////    Mat query, train;\r
+////    RNG& rng = ts->get_rng();\r
+////\r
+////    // Generate query descriptors randomly.\r
+////    // Descriptor vector elements are integer values.\r
+////    Mat buf(queryDescCount, dim, CV_32SC1);\r
+////    rng.fill(buf, RNG::UNIFORM, Scalar::all(0), Scalar(3));\r
+////    buf.convertTo(query, CV_32FC1);\r
+////\r
+////    // Generate train decriptors as follows:\r
+////    // copy each query descriptor to train set countFactor times\r
+////    // and perturb some one element of the copied descriptors in\r
+////    // in ascending order. General boundaries of the perturbation\r
+////    // are (0.f, 1.f).\r
+////    train.create( query.rows*countFactor, query.cols, CV_32FC1 );\r
+////    float step = 1.f / countFactor;\r
+////    for (int qIdx = 0; qIdx < query.rows; qIdx++)\r
+////    {\r
+////        Mat queryDescriptor = query.row(qIdx);\r
+////        for (int c = 0; c < countFactor; c++)\r
+////        {\r
+////            int tIdx = qIdx * countFactor + c;\r
+////            Mat trainDescriptor = train.row(tIdx);\r
+////            queryDescriptor.copyTo(trainDescriptor);\r
+////            int elem = rng(dim);\r
+////            float diff = rng.uniform(step * c, step * (c + 1));\r
+////            trainDescriptor.at<float>(0, elem) += diff;\r
+////        }\r
+////    }\r
+////\r
+////    queryGPU.upload(query);\r
+////    trainGPU.upload(train);\r
+////}\r
+////\r
+////void CV_GpuBruteForceMatcherTest::matchTest(const GpuMat& query, const GpuMat& train)\r
+////{\r
+////    dmatcher.clear();\r
+////\r
+////    // test const version of match()\r
+////    {\r
+////        vector<DMatch> matches;\r
+////        dmatcher.match(query, train, matches);\r
+////\r
+////        CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+////\r
+////        int badCount = 0;\r
+////        for (size_t i = 0; i < matches.size(); i++)\r
+////        {\r
+////            DMatch match = matches[i];\r
+////            if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor) || (match.imgIdx != 0))\r
+////                badCount++;\r
+////        }\r
+////\r
+////        CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+////    }\r
+////\r
+////    // test version of match() with add()\r
+////    {\r
+////        vector<DMatch> matches;\r
+////\r
+////        // make add() twice to test such case\r
+////        dmatcher.add(vector<GpuMat>(1, train.rowRange(0, train.rows/2)));\r
+////        dmatcher.add(vector<GpuMat>(1, train.rowRange(train.rows/2, train.rows)));\r
+////\r
+////        // prepare masks (make first nearest match illegal)\r
+////        vector<GpuMat> masks(2);\r
+////        for (int mi = 0; mi < 2; mi++)\r
+////        {\r
+////            masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
+////            for (int di = 0; di < queryDescCount/2; di++)\r
+////                masks[mi].col(di * countFactor).setTo(Scalar::all(0));\r
+////        }\r
+////\r
+////        dmatcher.match(query, matches, masks);\r
+////\r
+////        CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+////\r
+////        int badCount = 0;\r
+////        for (size_t i = 0; i < matches.size(); i++)\r
+////        {\r
+////            DMatch match = matches[i];\r
+////            int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
+////            {\r
+////                if (i < queryDescCount / 2)\r
+////                {\r
+////                    if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + shift) || (match.imgIdx != 0))\r
+////                        badCount++;\r
+////                }\r
+////                else\r
+////                {\r
+////                    if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + shift) || (match.imgIdx != 1))\r
+////                        badCount++;\r
+////                }\r
+////            }\r
+////        }\r
+////\r
+////        CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+////    }\r
+////}\r
+////\r
+////void CV_GpuBruteForceMatcherTest::knnMatchTest(const GpuMat& query, const GpuMat& train)\r
+////{\r
+////    dmatcher.clear();\r
+////\r
+////    // test const version of knnMatch()\r
+////    {\r
+////        const int knn = 3;\r
+////\r
+////        vector< vector<DMatch> > matches;\r
+////        dmatcher.knnMatch(query, train, matches, knn);\r
+////\r
+////        CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+////\r
+////        int badCount = 0;\r
+////        for (size_t i = 0; i < matches.size(); i++)\r
+////        {\r
+////            if ((int)matches[i].size() != knn)\r
+////                badCount++;\r
+////            else\r
+////            {\r
+////                int localBadCount = 0;\r
+////                for (int k = 0; k < knn; k++)\r
+////                {\r
+////                    DMatch match = matches[i][k];\r
+////                    if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k) || (match.imgIdx != 0))\r
+////                        localBadCount++;\r
+////                }\r
+////                badCount += localBadCount > 0 ? 1 : 0;\r
+////            }\r
+////        }\r
+////\r
+////        CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+////    }\r
+////\r
+////    // test version of knnMatch() with add()\r
+////    {\r
+////        const int knn = 2;\r
+////        vector<vector<DMatch> > matches;\r
+////\r
+////        // make add() twice to test such case\r
+////        dmatcher.add(vector<GpuMat>(1,train.rowRange(0, train.rows / 2)));\r
+////        dmatcher.add(vector<GpuMat>(1,train.rowRange(train.rows / 2, train.rows)));\r
+////\r
+////        // prepare masks (make first nearest match illegal)\r
+////        vector<GpuMat> masks(2);\r
+////        for (int mi = 0; mi < 2; mi++ )\r
+////        {\r
+////            masks[mi] = GpuMat(query.rows, train.rows / 2, CV_8UC1, Scalar::all(1));\r
+////            for (int di = 0; di < queryDescCount / 2; di++)\r
+////                masks[mi].col(di * countFactor).setTo(Scalar::all(0));\r
+////        }\r
+////\r
+////        dmatcher.knnMatch(query, matches, knn, masks);\r
+////\r
+////        CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+////\r
+////        int badCount = 0;\r
+////        int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
+////        for (size_t i = 0; i < matches.size(); i++)\r
+////        {\r
+////            if ((int)matches[i].size() != knn)\r
+////                badCount++;\r
+////            else\r
+////            {\r
+////                int localBadCount = 0;\r
+////                for (int k = 0; k < knn; k++)\r
+////                {\r
+////                    DMatch match = matches[i][k];\r
+////                    {\r
+////                        if (i < queryDescCount / 2)\r
+////                        {\r
+////                            if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k + shift) || (match.imgIdx != 0) )\r
+////                                localBadCount++;\r
+////                        }\r
+////                        else\r
+////                        {\r
+////                            if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + k + shift) || (match.imgIdx != 1) )\r
+////                                localBadCount++;\r
+////                        }\r
+////                    }\r
+////                }\r
+////                badCount += localBadCount > 0 ? 1 : 0;\r
+////            }\r
+////        }\r
+////\r
+////        CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+////    }\r
+////}\r
+////\r
+////void CV_GpuBruteForceMatcherTest::radiusMatchTest(const GpuMat& query, const GpuMat& train)\r
+////{\r
+////    CHECK_RETURN(support(GLOBAL_ATOMICS), TS::SKIPPED);\r
+////\r
+////    dmatcher.clear();\r
+////\r
+////    // test const version of match()\r
+////    {\r
+////        const float radius = 1.f / countFactor;\r
+////\r
+////        vector< vector<DMatch> > matches;\r
+////        dmatcher.radiusMatch(query, train, matches, radius);\r
+////\r
+////        CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+////\r
+////        int badCount = 0;\r
+////        for (size_t i = 0; i < matches.size(); i++)\r
+////        {\r
+////            if ((int)matches[i].size() != 1)\r
+////                badCount++;\r
+////            else\r
+////            {\r
+////                DMatch match = matches[i][0];\r
+////                if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0))\r
+////                    badCount++;\r
+////            }\r
+////        }\r
+////\r
+////        CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+////    }\r
+////\r
+////    // test version of match() with add()\r
+////    {\r
+////        int n = 3;\r
+////        const float radius = 1.f / countFactor * n;\r
+////        vector< vector<DMatch> > matches;\r
+////\r
+////        // make add() twice to test such case\r
+////        dmatcher.add(vector<GpuMat>(1,train.rowRange(0, train.rows / 2)));\r
+////        dmatcher.add(vector<GpuMat>(1,train.rowRange(train.rows / 2, train.rows)));\r
+////\r
+////        // prepare masks (make first nearest match illegal)\r
+////        vector<GpuMat> masks(2);\r
+////        for (int mi = 0; mi < 2; mi++)\r
+////        {\r
+////            masks[mi] = GpuMat(query.rows, train.rows / 2, CV_8UC1, Scalar::all(1));\r
+////            for (int di = 0; di < queryDescCount / 2; di++)\r
+////                masks[mi].col(di * countFactor).setTo(Scalar::all(0));\r
+////        }\r
+////\r
+////        dmatcher.radiusMatch(query, matches, radius, masks);\r
+////\r
+////        CHECK((int)matches.size() == queryDescCount, TS::FAIL_INVALID_OUTPUT);\r
+////\r
+////        int badCount = 0;\r
+////        int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
+////        int needMatchCount = dmatcher.isMaskSupported() ? n-1 : n;\r
+////        for (size_t i = 0; i < matches.size(); i++)\r
+////        {\r
+////            if ((int)matches[i].size() != needMatchCount)\r
+////                badCount++;\r
+////            else\r
+////            {\r
+////                int localBadCount = 0;\r
+////                for (int k = 0; k < needMatchCount; k++)\r
+////                {\r
+////                    DMatch match = matches[i][k];\r
+////                    {\r
+////                        if (i < queryDescCount / 2)\r
+////                        {\r
+////                            if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + k + shift) || (match.imgIdx != 0) )\r
+////                                localBadCount++;\r
+////                        }\r
+////                        else\r
+////                        {\r
+////                            if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + k + shift) || (match.imgIdx != 1) )\r
+////                                localBadCount++;\r
+////                        }\r
+////                    }\r
+////                }\r
+////                badCount += localBadCount > 0 ? 1 : 0;\r
+////            }\r
+////        }\r
+////\r
+////        CHECK(badCount == 0, TS::FAIL_INVALID_OUTPUT);\r
+////    }\r
+////}\r
+////\r
+////void CV_GpuBruteForceMatcherTest::dataTest(int dim)\r
+////{\r
+////    GpuMat query, train;\r
+////    generateData(query, train, dim);\r
+////\r
+////    matchTest(query, train);\r
+////    knnMatchTest(query, train);\r
+////    radiusMatchTest(query, train);\r
+////\r
+////    dmatcher.clear();\r
+////}\r
+////\r
+////void CV_GpuBruteForceMatcherTest::run_gpu_test()\r
+////{\r
+////    emptyDataTest();\r
+////\r
+////    dataTest(50);\r
+////    dataTest(64);\r
+////    dataTest(100);\r
+////    dataTest(128);\r
+////    dataTest(200);\r
+////    dataTest(256);\r
+////    dataTest(300);\r
+////}\r
+////\r
+////TEST(BruteForceMatcher, accuracy) { CV_GpuBruteForceMatcherTest test; test.safe_run(); }\r
index 91d1f14..77846dd 100644 (file)
 //\r
 //M*/\r
 \r
-#include <iostream>\r
-#include <cmath>\r
-#include <limits>\r
 #include "test_precomp.hpp"\r
 \r
-using namespace cv;\r
-using namespace std;\r
-using namespace gpu;\r
+#ifdef HAVE_CUDA\r
 \r
-class CV_GpuNppFilterTest : public cvtest::BaseTest\r
+struct FilterTest\r
 {\r
-public:\r
-    CV_GpuNppFilterTest(const char* /*test_name*/, const char* /*test_funcs*/) {}\r
-    virtual ~CV_GpuNppFilterTest() {}\r
+    static cv::Mat img_rgba;\r
+    static cv::Mat img_gray;\r
 \r
-protected:\r
-    void run(int);\r
-    virtual int test(const Mat& img) = 0;\r
-    \r
-    int test8UC1(const Mat& img)\r
+    static void SetUpTestCase() \r
     {\r
-        cv::Mat img_C1;\r
-        cvtColor(img, img_C1, CV_BGR2GRAY);\r
-        return test(img_C1);\r
+        cv::Mat img = readImage("stereobp/aloe-L.png");\r
+        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+        cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
     }\r
 \r
-    int test8UC4(const Mat& img)\r
+    static void TearDownTestCase() \r
     {\r
-        cv::Mat img_C4;\r
-        cvtColor(img, img_C4, CV_BGR2BGRA);\r
-        return test(img_C4);\r
+        img_rgba.release();\r
+        img_gray.release();\r
     }\r
-        \r
-    int CheckNorm(const Mat& m1, const Mat& m2, const Size& ksize)\r
-    {\r
-        Rect roi = Rect(ksize.width, ksize.height, m1.cols - 2 * ksize.width, m1.rows - 2 * ksize.height);\r
-        Mat m1ROI = m1(roi);\r
-        Mat m2ROI = m2(roi);\r
+};\r
 \r
-        double res = norm(m1ROI, m2ROI, NORM_INF);\r
+cv::Mat FilterTest::img_rgba;\r
+cv::Mat FilterTest::img_gray;\r
 \r
-        // Max difference (2.0) in GaussianBlur\r
-        if (res <= 2)\r
-            return cvtest::TS::OK;\r
-        \r
-        ts->printf(cvtest::TS::LOG, "Norm: %f\n", res);\r
-        return cvtest::TS::FAIL_GENERIC;\r
+static double checkNorm(const cv::Mat& m1, const cv::Mat& m2, const cv::Size& ksize)\r
+{\r
+    cv::Rect roi(ksize.width, ksize.height, m1.cols - 2 * ksize.width, m1.rows - 2 * ksize.height);\r
+    cv::Mat m1ROI = m1(roi);\r
+    cv::Mat m2ROI = m2(roi);\r
+    return checkNorm(m1ROI, m2ROI);\r
+}\r
+\r
+static double checkNorm(const cv::Mat& m1, const cv::Mat& m2, int ksize)\r
+{\r
+    return checkNorm(m1, m2, cv::Size(ksize, ksize));\r
+}\r
+\r
+#define EXPECT_MAT_NEAR_KSIZE(mat1, mat2, ksize, eps) \\r
+    { \\r
+        ASSERT_EQ(mat1.type(), mat2.type()); \\r
+        ASSERT_EQ(mat1.size(), mat2.size()); \\r
+        EXPECT_LE(checkNorm(mat1, mat2, ksize), eps); \\r
     }\r
-};\r
 \r
-void CV_GpuNppFilterTest::run( int )\r
-{    \r
-    cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// blur\r
+\r
+struct Blur : FilterTest, testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    cv::Size ksize;\r
+\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
     \r
-    if (img.empty())\r
+    virtual void SetUp()\r
     {\r
-        ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-        return;\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        ksize = cv::Size(std::tr1::get<1>(GetParam()), std::tr1::get<2>(GetParam()));\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::blur(img_rgba, dst_gold_rgba, ksize);\r
+        cv::blur(img_gray, dst_gold_gray, ksize);\r
     }\r
+};\r
+\r
+TEST_P(Blur, Accuracy)\r
+{\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(ksize);\r
 \r
-    //run tests\r
-    int testResult = cvtest::TS::OK;\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
 \r
-    if (test8UC1(img) != cvtest::TS::OK)\r
-        testResult = cvtest::TS::FAIL_GENERIC;\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
 \r
-    if (test8UC4(img) != cvtest::TS::OK)\r
-        testResult = cvtest::TS::FAIL_GENERIC;\r
+        cv::gpu::blur(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, ksize);\r
+        cv::gpu::blur(cv::gpu::GpuMat(img_gray), dev_dst_gray, ksize);\r
 \r
-    ts->set_failed_test_info(testResult);\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
 \r
-    ts->set_failed_test_info(cvtest::TS::OK);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, ksize, 1.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, ksize, 1.0);\r
 }\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// blur\r
-struct CV_GpuNppImageBlurTest : public CV_GpuNppFilterTest\r
+INSTANTIATE_TEST_CASE_P(Filter, Blur, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(3, 5, 7), \r
+                        testing::Values(3, 5, 7)));\r
+\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// sobel\r
+\r
+struct Sobel : FilterTest, testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, std::pair<int, int> > >\r
 {\r
-    CV_GpuNppImageBlurTest() : CV_GpuNppFilterTest( "GPU-NppImageBlur", "blur" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int ksize;\r
+    int dx, dy;\r
+\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
 \r
-    int test(const Mat& img)\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
     {\r
-        int ksizes[] = {3, 5, 7};\r
-        int ksizes_num = sizeof(ksizes) / sizeof(int);\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        ksize = std::tr1::get<1>(GetParam());\r
+        std::pair<int, int> d = std::tr1::get<2>(GetParam());\r
+        dx = d.first; dy = d.second;\r
 \r
-        int test_res = cvtest::TS::OK;\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::Sobel(img_rgba, dst_gold_rgba, -1, dx, dy, ksize);\r
+        cv::Sobel(img_gray, dst_gold_gray, -1, dx, dy, ksize);\r
+    }\r
+};\r
+\r
+TEST_P(Sobel, Accuracy)\r
+{\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(ksize);\r
+    PRINT_PARAM(dx);\r
+    PRINT_PARAM(dy);\r
+\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
 \r
-        for (int i = 0; i < ksizes_num; ++i)\r
-        {\r
-            for (int j = 0; j < ksizes_num; ++j)\r
-            {\r
-                Size ksize(ksizes[i], ksizes[j]);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
 \r
-                ts->printf(cvtest::TS::LOG, "\nksize = (%dx%d)\n", ksizes[i], ksizes[j]);\r
+        cv::gpu::Sobel(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, -1, dx, dy, ksize);\r
+        cv::gpu::Sobel(cv::gpu::GpuMat(img_gray), dev_dst_gray, -1, dx, dy, ksize);\r
 \r
-                Mat cpudst;\r
-                cv::blur(img, cpudst, ksize);\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
 \r
-                GpuMat gpu1(img);\r
-                GpuMat gpudst;\r
-                cv::gpu::blur(gpu1, gpudst, ksize);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, ksize, 0.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, ksize, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Filter, Sobel, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(3, 5, 7), \r
+                        testing::Values(std::make_pair(1, 0), std::make_pair(0, 1), std::make_pair(1, 1), std::make_pair(2, 0), std::make_pair(2, 1), std::make_pair(0, 2), std::make_pair(1, 2), std::make_pair(2, 2))));\r
 \r
-                if (CheckNorm(cpudst, gpudst, ksize) != cvtest::TS::OK)\r
-                    test_res = cvtest::TS::FAIL_GENERIC;\r
-            }\r
-        }\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// scharr\r
+\r
+struct Scharr : FilterTest, testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, std::pair<int, int> > >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int dx, dy;\r
 \r
-        return test_res;\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        std::pair<int, int> d = std::tr1::get<1>(GetParam());\r
+        dx = d.first; dy = d.second;\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::Scharr(img_rgba, dst_gold_rgba, -1, dx, dy);\r
+        cv::Scharr(img_gray, dst_gold_gray, -1, dx, dy);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Sobel\r
-struct CV_GpuNppImageSobelTest : public CV_GpuNppFilterTest\r
+TEST_P(Scharr, Accuracy)\r
 {\r
-    CV_GpuNppImageSobelTest() : CV_GpuNppFilterTest( "GPU-NppImageSobel", "Sobel" ) {}\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
 \r
-    int test(const Mat& img)\r
-    {\r
-        int ksizes[] = {3, 5, 7};\r
-        int ksizes_num = sizeof(ksizes) / sizeof(int);\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(dx);\r
+    PRINT_PARAM(dy);\r
 \r
-        int dx = 1, dy = 0;\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
 \r
-        for (int i = 0; i < ksizes_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nksize = %d\n", ksizes[i]);\r
+        cv::gpu::Scharr(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, -1, dx, dy);\r
+        cv::gpu::Scharr(cv::gpu::GpuMat(img_gray), dev_dst_gray, -1, dx, dy);\r
 \r
-            Mat cpudst;\r
-            cv::Sobel(img, cpudst, -1, dx, dy, ksizes[i]);\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
 \r
-            GpuMat gpu1(img);\r
-            GpuMat gpudst;\r
-            cv::gpu::Sobel(gpu1, gpudst, -1, dx, dy, ksizes[i]);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);\r
+}\r
 \r
-            if (CheckNorm(cpudst, gpudst, Size(ksizes[i], ksizes[i])) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+INSTANTIATE_TEST_CASE_P(Filter, Scharr, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(std::make_pair(1, 0), std::make_pair(0, 1))));\r
 \r
-        return test_res;\r
-    }\r
-};\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// gaussianBlur\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Scharr\r
-struct CV_GpuNppImageScharrTest : public CV_GpuNppFilterTest\r
+struct GaussianBlur : FilterTest, testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
 {\r
-    CV_GpuNppImageScharrTest() : CV_GpuNppFilterTest( "GPU-NppImageScharr", "Scharr" ) {}\r
+    cv::gpu::DeviceInfo devInfo;\r
+    cv::Size ksize;\r
+\r
+    double sigma1, sigma2;\r
 \r
-    int test(const Mat& img)\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
     {\r
-        int dx = 1, dy = 0;\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        ksize = cv::Size(std::tr1::get<1>(GetParam()), std::tr1::get<2>(GetParam()));\r
 \r
-        Mat cpudst;\r
-        cv::Scharr(img, cpudst, -1, dx, dy);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
 \r
-        GpuMat gpu1(img);\r
-        GpuMat gpudst;\r
-        cv::gpu::Scharr(gpu1, gpudst, -1, dx, dy);\r
-                \r
-        return CheckNorm(cpudst, gpudst, Size(3, 3));\r
+        sigma1 = rng.uniform(0.1, 1.0); \r
+        sigma2 = rng.uniform(0.1, 1.0);\r
+        \r
+        cv::GaussianBlur(img_rgba, dst_gold_rgba, ksize, sigma1, sigma2);\r
+        cv::GaussianBlur(img_gray, dst_gold_gray, ksize, sigma1, sigma2);\r
     }\r
 };\r
 \r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// GaussianBlur\r
-struct CV_GpuNppImageGaussianBlurTest : public CV_GpuNppFilterTest\r
+TEST_P(GaussianBlur, Accuracy)\r
 {\r
-    CV_GpuNppImageGaussianBlurTest() : CV_GpuNppFilterTest( "GPU-NppImageGaussianBlur", "GaussianBlur" ) {}\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
 \r
-    int test(const Mat& img)\r
-    {\r
-        int ksizes[] = {3, 5, 7};\r
-        int ksizes_num = sizeof(ksizes) / sizeof(int);\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(ksize);\r
+    PRINT_PARAM(sigma1);\r
+    PRINT_PARAM(sigma2);\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
 \r
-        const double sigma1 = 3.0;\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
 \r
-        for (int i = 0; i < ksizes_num; ++i)\r
-        {\r
-            for (int j = 0; j < ksizes_num; ++j)\r
-            {\r
-                cv::Size ksize(ksizes[i], ksizes[j]);\r
+        cv::gpu::GaussianBlur(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, ksize, sigma1, sigma2);\r
+        cv::gpu::GaussianBlur(cv::gpu::GpuMat(img_gray), dev_dst_gray, ksize, sigma1, sigma2);\r
 \r
-                ts->printf(cvtest::TS::LOG, "ksize = (%dx%d)\t\n", ksizes[i], ksizes[j]);\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
 \r
-                Mat cpudst;\r
-                cv::GaussianBlur(img, cpudst, ksize, sigma1);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, ksize, 3.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, ksize, 3.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Filter, GaussianBlur, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(3, 5, 7), \r
+                        testing::Values(3, 5, 7)));\r
 \r
-                GpuMat gpu1(img);\r
-                GpuMat gpudst;\r
-                cv::gpu::GaussianBlur(gpu1, gpudst, ksize, sigma1);\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// laplacian\r
+\r
+struct Laplacian : FilterTest, testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int ksize;\r
+\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        ksize = std::tr1::get<1>(GetParam());\r
 \r
-                if (CheckNorm(cpudst, gpudst, ksize) != cvtest::TS::OK)\r
-                    test_res = cvtest::TS::FAIL_GENERIC;\r
-            }\r
-        }\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-        return test_res;\r
+        cv::Laplacian(img_rgba, dst_gold_rgba, -1, ksize);\r
+        cv::Laplacian(img_gray, dst_gold_gray, -1, ksize);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Laplacian\r
-struct CV_GpuNppImageLaplacianTest : public CV_GpuNppFilterTest\r
+TEST_P(Laplacian, Accuracy)\r
 {\r
-    CV_GpuNppImageLaplacianTest() : CV_GpuNppFilterTest( "GPU-NppImageLaplacian", "Laplacian" ) {}\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
 \r
-    int test(const Mat& img)\r
-    {\r
-        int ksizes[] = {1, 3};\r
-        int ksizes_num = sizeof(ksizes) / sizeof(int);\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(ksize);\r
 \r
-        int test_res = cvtest::TS::OK;\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
 \r
-        for (int i = 0; i < ksizes_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nksize = %d\n", ksizes[i]);\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
 \r
-            Mat cpudst;\r
-            cv::Laplacian(img, cpudst, -1, ksizes[i]);\r
+        cv::gpu::Laplacian(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, -1, ksize);\r
+        cv::gpu::Laplacian(cv::gpu::GpuMat(img_gray), dev_dst_gray, -1, ksize);\r
 \r
-            GpuMat gpu1(img);\r
-            GpuMat gpudst;\r
-            cv::gpu::Laplacian(gpu1, gpudst, -1, ksizes[i]);\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
 \r
-            if (CheckNorm(cpudst, gpudst, Size(3, 3)) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);\r
+}\r
 \r
-        return test_res;\r
-    }\r
-};\r
+INSTANTIATE_TEST_CASE_P(Filter, Laplacian, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(1, 3)));\r
+\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// erode\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Erode\r
-class CV_GpuErodeTest : public CV_GpuNppFilterTest\r
+struct Erode : FilterTest, testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-public:\r
-    CV_GpuErodeTest() : CV_GpuNppFilterTest( "GPU-NppErode", "erode" ) {} \r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Mat kernel;\r
 \r
-protected:\r
-       virtual int test(const Mat& img)\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
     {\r
-        Mat kernel(Mat::ones(3, 3, CV_8U));\r
+        devInfo = GetParam();\r
 \r
-           cv::Mat cpuRes;\r
-        cv::erode(img, cpuRes, kernel);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-           GpuMat gpuRes;\r
-        cv::gpu::erode(GpuMat(img), gpuRes, kernel);\r
+        kernel = cv::Mat::ones(3, 3, CV_8U);\r
 \r
-           return CheckNorm(cpuRes, gpuRes, Size(3, 3));\r
+        cv::erode(img_rgba, dst_gold_rgba, kernel);\r
+        cv::erode(img_gray, dst_gold_gray, kernel);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// Dilate\r
-class CV_GpuDilateTest : public CV_GpuNppFilterTest\r
+TEST_P(Erode, Accuracy)\r
+{\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
+\r
+        cv::gpu::erode(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, kernel);\r
+        cv::gpu::erode(cv::gpu::GpuMat(img_gray), dev_dst_gray, kernel);\r
+\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Filter, Erode, testing::ValuesIn(devices()));\r
+\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// dilate\r
+\r
+struct Dilate : FilterTest, testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-public:\r
-    CV_GpuDilateTest() : CV_GpuNppFilterTest( "GPU-NppDilate", "dilate" ) {} \r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Mat kernel;\r
 \r
-protected:\r
-       virtual int test(const Mat& img)\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
     {\r
-        Mat kernel(Mat::ones(3, 3, CV_8U));\r
+        devInfo = GetParam();\r
 \r
-           cv::Mat cpuRes;\r
-        cv::dilate(img, cpuRes, kernel);\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
 \r
-           GpuMat gpuRes;\r
-        cv::gpu::dilate(GpuMat(img), gpuRes, kernel);\r
-       \r
-           return CheckNorm(cpuRes, gpuRes, Size(3, 3));\r
+        kernel = cv::Mat::ones(3, 3, CV_8U);\r
+\r
+        cv::dilate(img_rgba, dst_gold_rgba, kernel);\r
+        cv::dilate(img_gray, dst_gold_gray, kernel);\r
     }\r
 };\r
 \r
-////////////////////////////////////////////////////////////////////////////////\r
-// MorphologyEx\r
-class CV_GpuMorphExTest : public CV_GpuNppFilterTest\r
+TEST_P(Dilate, Accuracy)\r
 {\r
-public:\r
-    CV_GpuMorphExTest() : CV_GpuNppFilterTest( "GPU-NppMorphologyEx", "morphologyEx" ) {} \r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
 \r
-protected:\r
-       virtual int test(const Mat& img)\r
-    {\r
-        static int ops[] = { MORPH_OPEN, CV_MOP_CLOSE, CV_MOP_GRADIENT, CV_MOP_TOPHAT, CV_MOP_BLACKHAT};\r
-        const char *names[] = { "MORPH_OPEN", "CV_MOP_CLOSE", "CV_MOP_GRADIENT", "CV_MOP_TOPHAT", "CV_MOP_BLACKHAT"};\r
-        int num = sizeof(ops)/sizeof(ops[0]);\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
+\r
+        cv::gpu::dilate(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, kernel);\r
+        cv::gpu::dilate(cv::gpu::GpuMat(img_gray), dev_dst_gray, kernel);\r
 \r
-        GpuMat kernel(Mat::ones(3, 3, CV_8U));\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
 \r
-        int res = cvtest::TS::OK;\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Filter, Dilate, testing::ValuesIn(devices()));\r
 \r
-        for(int i = 0; i < num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Tesing %s\n", names[i]);\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// morphEx\r
 \r
-               cv::Mat cpuRes;\r
-            cv::morphologyEx(img, cpuRes, ops[i], (Mat)kernel);\r
+static const int morphOps[] = {cv::MORPH_OPEN, CV_MOP_CLOSE, CV_MOP_GRADIENT, CV_MOP_TOPHAT, CV_MOP_BLACKHAT};\r
+static const char* morphOps_str[] = {"MORPH_OPEN", "MOP_CLOSE", "MOP_GRADIENT", "MOP_TOPHAT", "MOP_BLACKHAT"};\r
+\r
+struct MorphEx : FilterTest, testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int morphOpsIdx;\r
 \r
-               GpuMat gpuRes;\r
-            cv::gpu::morphologyEx(GpuMat(img), gpuRes, ops[i], kernel);\r
+    cv::Mat kernel;\r
 \r
-            if (cvtest::TS::OK != CheckNorm(cpuRes, gpuRes, Size(4, 4)))\r
-                res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
-        return res;\r
+    cv::Mat dst_gold_rgba;\r
+    cv::Mat dst_gold_gray;\r
+\r
+    using FilterTest::SetUpTestCase;\r
+    using FilterTest::TearDownTestCase;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        morphOpsIdx = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        kernel = cv::Mat::ones(3, 3, CV_8U);\r
+\r
+        cv::morphologyEx(img_rgba, dst_gold_rgba, morphOps[morphOpsIdx], kernel);\r
+        cv::morphologyEx(img_gray, dst_gold_gray, morphOps[morphOpsIdx], kernel);\r
     }\r
 };\r
 \r
+TEST_P(MorphEx, Accuracy)\r
+{\r
+    ASSERT_TRUE(!img_rgba.empty() && !img_gray.empty());\r
+\r
+    const char* morphOpStr = morphOps_str[morphOpsIdx];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(morphOpStr);\r
+\r
+    cv::Mat dst_rgba;\r
+    cv::Mat dst_gray;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst_rgba;\r
+        cv::gpu::GpuMat dev_dst_gray;\r
+\r
+        cv::gpu::morphologyEx(cv::gpu::GpuMat(img_rgba), dev_dst_rgba, morphOps[morphOpsIdx], cv::gpu::GpuMat(kernel));\r
+        cv::gpu::morphologyEx(cv::gpu::GpuMat(img_gray), dev_dst_gray, morphOps[morphOpsIdx], cv::gpu::GpuMat(kernel));\r
+\r
+        dev_dst_rgba.download(dst_rgba);\r
+        dev_dst_gray.download(dst_gray);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 4, 0.0);\r
+    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 4, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(Filter, MorphEx, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Range(0, 5)));\r
 \r
-TEST(blur, accuracy) { CV_GpuNppImageBlurTest test; test.safe_run(); }\r
-TEST(sobel, accuracy) { CV_GpuNppImageSobelTest test; test.safe_run(); }\r
-TEST(scharr, accuracy) { CV_GpuNppImageScharrTest test; test.safe_run(); }\r
-TEST(gaussianBlur, accuracy) { CV_GpuNppImageGaussianBlurTest test; test.safe_run(); }\r
-TEST(laplcaian, accuracy) { CV_GpuNppImageLaplacianTest test; test.safe_run(); }\r
-TEST(erode, accuracy) { CV_GpuErodeTest test; test.safe_run(); }\r
-TEST(dilate, accuracy) { CV_GpuDilateTest test; test.safe_run(); }\r
-TEST(morphEx, accuracy) { CV_GpuMorphExTest test;  test.safe_run(); }\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_gpu_base.cpp b/modules/gpu/test/test_gpu_base.cpp
new file mode 100644 (file)
index 0000000..f035d7a
--- /dev/null
@@ -0,0 +1,154 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "test_precomp.hpp"\r
+\r
+bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature)\r
+{\r
+    return cv::gpu::TargetArchs::builtWith(feature) && info.supports(feature);\r
+}\r
+\r
+const std::vector<cv::gpu::DeviceInfo>& devices()\r
+{\r
+    static std::vector<cv::gpu::DeviceInfo> devs;\r
+    static bool first = true;\r
+\r
+    if (first)\r
+    {\r
+        int deviceCount = cv::gpu::getCudaEnabledDeviceCount();\r
+\r
+        devs.reserve(deviceCount);\r
+\r
+        for (int i = 0; i < deviceCount; ++i)\r
+        {\r
+            cv::gpu::DeviceInfo info(i);\r
+            if (info.isCompatible())\r
+                devs.push_back(info);\r
+        }\r
+\r
+        first = false;\r
+    }\r
+\r
+    return devs;\r
+}\r
+\r
+std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature)\r
+{\r
+    const std::vector<cv::gpu::DeviceInfo>& d = devices();\r
+    \r
+    std::vector<cv::gpu::DeviceInfo> devs_filtered;\r
+\r
+    if (cv::gpu::TargetArchs::builtWith(feature))\r
+    {\r
+        devs_filtered.reserve(d.size());\r
+\r
+        for (size_t i = 0, size = d.size(); i < size; ++i)\r
+        {\r
+            const cv::gpu::DeviceInfo& info = d[i];\r
+\r
+            if (info.supports(feature))\r
+                devs_filtered.push_back(info);\r
+        }\r
+    }\r
+\r
+    return devs_filtered;\r
+}\r
+\r
+std::vector<int> types(int depth_start, int depth_end, int cn_start, int cn_end)\r
+{\r
+    std::vector<int> v;\r
+\r
+    v.reserve((depth_end - depth_start + 1) * (cn_end - cn_start + 1));\r
+\r
+    for (int depth = depth_start; depth <= depth_end; ++depth)\r
+    {\r
+        for (int cn = cn_start; cn <= cn_end; ++cn)\r
+        {\r
+            v.push_back(CV_MAKETYPE(depth, cn));\r
+        }\r
+    }\r
+\r
+    return v;\r
+}\r
+\r
+const std::vector<int>& all_types()\r
+{\r
+    static std::vector<int> v = types(CV_8U, CV_64F, 1, 4);\r
+    return v;\r
+}\r
+\r
+cv::Mat readImage(const std::string& fileName, int flags)\r
+{\r
+    return cv::imread(std::string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);\r
+}\r
+\r
+double checkNorm(const cv::Mat& m1, const cv::Mat& m2)\r
+{\r
+    return cv::norm(m1, m2, cv::NORM_INF);\r
+}\r
+\r
+double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2)\r
+{\r
+    cv::Mat diff;\r
+    cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
+    return std::abs(diff.at<float>(0, 0) - 1.f);\r
+}\r
+\r
+namespace cv\r
+{\r
+    std::ostream& operator << (std::ostream& os, const Size& sz)\r
+    {\r
+        return os << sz.width << "x" << sz.height;\r
+    }\r
+\r
+    std::ostream& operator << (std::ostream& os, const Scalar& s)\r
+    {\r
+        return os << "[" << s[0] << ", " << s[1] << ", " << s[2] << ", " << s[3] << "]";\r
+    }\r
+\r
+    namespace gpu\r
+    {\r
+        std::ostream& operator << (std::ostream& os, const DeviceInfo& info)\r
+        {\r
+            return os << info.name();\r
+        }\r
+    }\r
+}\r
diff --git a/modules/gpu/test/test_gpu_base.hpp b/modules/gpu/test/test_gpu_base.hpp
new file mode 100644 (file)
index 0000000..25bf163
--- /dev/null
@@ -0,0 +1,103 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#ifndef __OPENCV_TEST_GPU_BASE_HPP__\r
+#define __OPENCV_TEST_GPU_BASE_HPP__\r
+\r
+//! return true if device supports specified feature and gpu module was built with support the feature.\r
+bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);\r
+\r
+//! return all devices compatible with current gpu module build.\r
+const std::vector<cv::gpu::DeviceInfo>& devices();\r
+//! return all devices compatible with current gpu module build which support specified feature.\r
+std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature);\r
+\r
+//! return vector with types from specified range.\r
+std::vector<int> types(int depth_start, int depth_end, int cn_start, int cn_end);\r
+\r
+//! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).\r
+const std::vector<int>& all_types();\r
+\r
+//! read image from testdata folder.\r
+cv::Mat readImage(const std::string& fileName, int flags = CV_LOAD_IMAGE_COLOR);\r
+\r
+double checkNorm(const cv::Mat& m1, const cv::Mat& m2);\r
+double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2);\r
+\r
+#define OSTR_NAME(suf) ostr_ ## suf\r
+\r
+#define PRINT_PARAM(name) \\r
+        std::ostringstream OSTR_NAME(name); \\r
+        OSTR_NAME(name) << # name << ": " << name; \\r
+        SCOPED_TRACE(OSTR_NAME(name).str());\r
+\r
+#define PRINT_TYPE(type) \\r
+        std::ostringstream OSTR_NAME(type); \\r
+        OSTR_NAME(type) << # type << ": " << cvtest::getTypeName(type) << "c" << CV_MAT_CN(type); \\r
+        SCOPED_TRACE(OSTR_NAME(type).str());\r
+\r
+#define EXPECT_MAT_NEAR(mat1, mat2, eps) \\r
+    { \\r
+        ASSERT_EQ(mat1.type(), mat2.type()); \\r
+        ASSERT_EQ(mat1.size(), mat2.size()); \\r
+        EXPECT_LE(checkNorm(mat1, mat2), eps); \\r
+    }\r
+\r
+#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \\r
+    { \\r
+        ASSERT_EQ(mat1.type(), mat2.type()); \\r
+        ASSERT_EQ(mat1.size(), mat2.size()); \\r
+        EXPECT_LE(checkSimilarity(mat1, mat2), eps); \\r
+    }\r
+\r
+\r
+//! for gtest ASSERT\r
+namespace cv\r
+{\r
+    std::ostream& operator << (std::ostream& os, const Size& sz);\r
+    std::ostream& operator << (std::ostream& os, const Scalar& s);\r
+    namespace gpu\r
+    {\r
+        std::ostream& operator << (std::ostream& os, const DeviceInfo& info);\r
+    }\r
+}\r
+\r
+#endif // __OPENCV_TEST_GPU_BASE_HPP__\r
index c6089b0..2fd061c 100644 (file)
 //M*/\r
 \r
 #include "test_precomp.hpp"\r
-#include <fstream>\r
 \r
-using namespace std;\r
+#ifdef HAVE_CUDA\r
 \r
 //#define DUMP\r
 \r
-#define CHECK(pred, err) if (!(pred)) { \\r
-    ts->printf(cvtest::TS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \\r
-    ts->set_failed_test_info(err); \\r
-    return; }\r
-\r
-struct CV_GpuHogDetectTestRunner: cv::gpu::HOGDescriptor\r
+struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor\r
 {\r
-    CV_GpuHogDetectTestRunner(cvtest::TS* ts_): ts(ts_) {}\r
-\r
-    void run(int) \r
+    void run() \r
     {       \r
-        cv::Mat img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/road.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        cv::Mat img_rgb = readImage("hog/road.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
 \r
 #ifdef DUMP\r
-        f.open((std::string(ts->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);\r
-        CHECK(f.is_open(), cvtest::TS::FAIL_GENERIC);\r
+        f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);\r
+        ASSERT_TRUE(f.is_open());\r
 #else\r
-        f.open((std::string(ts->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);\r
-        CHECK(f.is_open(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);\r
+        ASSERT_TRUE(f.is_open());\r
 #endif\r
 \r
         // Test on color image\r
@@ -78,7 +70,6 @@ struct CV_GpuHogDetectTestRunner: cv::gpu::HOGDescriptor
         test(img);\r
 \r
         f.close();\r
-\r
     }\r
 \r
 #ifdef DUMP\r
@@ -107,24 +98,24 @@ struct CV_GpuHogDetectTestRunner: cv::gpu::HOGDescriptor
 \r
         f.read((char*)&rows, sizeof(rows));\r
         f.read((char*)&cols, sizeof(cols));\r
-        CHECK(rows == block_hists.rows, cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        CHECK(cols == block_hists.cols, cvtest::TS::FAIL_INVALID_OUTPUT);\r
+        ASSERT_EQ(rows, block_hists.rows);\r
+        ASSERT_EQ(cols, block_hists.cols);\r
         for (int i = 0; i < block_hists.rows; ++i)\r
         {\r
             for (int j = 0; j < block_hists.cols; ++j)\r
             {\r
                 float val;\r
                 f.read((char*)&val, sizeof(val));\r
-                CHECK(fabs(val - block_hists.at<float>(i, j)) < 1e-3f, cvtest::TS::FAIL_INVALID_OUTPUT);\r
+                ASSERT_NEAR(val, block_hists.at<float>(i, j), 1e-3);\r
             }\r
         }\r
         f.read((char*)&nlocations, sizeof(nlocations));\r
-        CHECK(nlocations == static_cast<int>(locations.size()), cvtest::TS::FAIL_INVALID_OUTPUT);\r
+        ASSERT_EQ(nlocations, static_cast<int>(locations.size()));\r
         for (int i = 0; i < nlocations; ++i)\r
         {\r
             cv::Point location;\r
             f.read((char*)&location, sizeof(location));\r
-            CHECK(location == locations[i], cvtest::TS::FAIL_INVALID_OUTPUT);\r
+            ASSERT_EQ(location, locations[i]);\r
         }\r
     }\r
 #endif\r
@@ -176,39 +167,47 @@ struct CV_GpuHogDetectTestRunner: cv::gpu::HOGDescriptor
 #else\r
     std::ifstream f;\r
 #endif\r
-\r
-    cvtest::TS* ts;\r
 };\r
 \r
-\r
-struct CV_GpuHogDetectTest: cvtest::BaseTest \r
+struct HogDetect : testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-    CV_GpuHogDetectTest() {}\r
-\r
-    void run(int i)\r
+    cv::gpu::DeviceInfo devInfo;\r
+    \r
+    virtual void SetUp()\r
     {\r
-        CV_GpuHogDetectTestRunner runner(ts);\r
-        runner.run(i);\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
     }\r
 };\r
 \r
-TEST(HOG, detect_accuracy) { CV_GpuHogDetectTest test; test.safe_run(); }\r
+TEST_P(HogDetect, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    ASSERT_NO_THROW(\r
+        CV_GpuHogDetectTestRunner runner;\r
+        runner.run();\r
+    );\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(HOG, HogDetect, testing::ValuesIn(devices()));\r
 \r
-struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor\r
+struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor\r
 {\r
-    CV_GpuHogGetDescriptorsTestRunner(cvtest::TS* ts_): HOGDescriptor(cv::Size(64, 128)), ts(ts_) {}\r
+    CV_GpuHogGetDescriptorsTestRunner(): cv::gpu::HOGDescriptor(cv::Size(64, 128)) {}\r
 \r
-    void run(int)\r
+    void run()\r
     {\r
         // Load image (e.g. train data, composed from windows)\r
-        cv::Mat img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/train_data.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        cv::Mat img_rgb = readImage("hog/train_data.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
 \r
         // Convert to C4\r
         cv::Mat img;\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
-        cv::gpu::GpuMat d_img(img);\r
 \r
+        cv::gpu::GpuMat d_img(img);\r
 \r
         // Convert train images into feature vectors (train table)\r
         cv::gpu::GpuMat descriptors, descriptors_by_cols;\r
@@ -223,7 +222,7 @@ struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor
         block_hist_size = 36;\r
         cv::Size descr_size_expected = cv::Size(blocks_per_win_x * blocks_per_win_y * block_hist_size,\r
                                                 wins_per_img_x * wins_per_img_y);\r
-        CHECK(descriptors.size() == descr_size_expected, cvtest::TS::FAIL_INVALID_OUTPUT);\r
+        ASSERT_EQ(descr_size_expected, descriptors.size());\r
 \r
         // Check both formats of output descriptors are handled correctly\r
         cv::Mat dr(descriptors);\r
@@ -235,8 +234,8 @@ struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor
             for (int y = 0; y < blocks_per_win_y; ++y)\r
                 for (int x = 0; x < blocks_per_win_x; ++x)\r
                     for (int k = 0; k < block_hist_size; ++k)\r
-                        CHECK(l[(y * blocks_per_win_x + x) * block_hist_size + k] ==\r
-                              r[(x * blocks_per_win_y + y) * block_hist_size + k], cvtest::TS::FAIL_INVALID_OUTPUT);\r
+                        ASSERT_EQ(l[(y * blocks_per_win_x + x) * block_hist_size + k],\r
+                                  r[(x * blocks_per_win_y + y) * block_hist_size + k]);\r
         }\r
 \r
         /* Now we want to extract the same feature vectors, but from single images. NOTE: results will\r
@@ -244,39 +243,39 @@ struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor
         wont't call getDescriptors and will use computeBlockHistograms instead of. computeBlockHistograms\r
         works good, it can be checked in the gpu_hog sample */\r
 \r
-        img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/positive1.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        img_rgb = readImage("hog/positive1.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
         computeBlockHistograms(cv::gpu::GpuMat(img));\r
         // Everything is fine with interpolation for left top subimage\r
-        CHECK(cv::norm((cv::Mat)block_hists, (cv::Mat)descriptors.rowRange(0, 1)) == 0.f, cvtest::TS::FAIL_INVALID_OUTPUT);\r
+        ASSERT_EQ(0.0, cv::norm((cv::Mat)block_hists, (cv::Mat)descriptors.rowRange(0, 1)));\r
 \r
-        img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/positive2.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        img_rgb = readImage("hog/positive2.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
         computeBlockHistograms(cv::gpu::GpuMat(img));\r
         compare_inner_parts(block_hists, descriptors.rowRange(1, 2));\r
 \r
-        img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/negative1.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        img_rgb = readImage("hog/negative1.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
         computeBlockHistograms(cv::gpu::GpuMat(img));\r
         compare_inner_parts(block_hists, descriptors.rowRange(2, 3));\r
 \r
-        img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/negative2.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        img_rgb = readImage("hog/negative2.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
         computeBlockHistograms(cv::gpu::GpuMat(img));\r
         compare_inner_parts(block_hists, descriptors.rowRange(3, 4));\r
 \r
-        img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/positive3.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        img_rgb = readImage("hog/positive3.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
         computeBlockHistograms(cv::gpu::GpuMat(img));\r
         compare_inner_parts(block_hists, descriptors.rowRange(4, 5));\r
 \r
-        img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/negative3.png");\r
-        CHECK(!img_rgb.empty(), cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+        img_rgb = readImage("hog/negative3.png");\r
+        ASSERT_TRUE(!img_rgb.empty());\r
         cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
         computeBlockHistograms(cv::gpu::GpuMat(img));\r
         compare_inner_parts(block_hists, descriptors.rowRange(5, 6));\r
@@ -291,7 +290,7 @@ struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor
                 {\r
                     float a = d1.at<float>(0, (i * blocks_per_win_x + j) * block_hist_size);\r
                     float b = d2.at<float>(0, (i * blocks_per_win_x + j) * block_hist_size);\r
-                    CHECK(a == b, cvtest::TS::FAIL_INVALID_OUTPUT)\r
+                    ASSERT_FLOAT_EQ(a, b);\r
                 }\r
     }\r
 \r
@@ -300,20 +299,30 @@ struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor
     int blocks_per_win_x;\r
     int blocks_per_win_y;\r
     int block_hist_size;\r
-\r
-    cvtest::TS* ts;\r
 };\r
 \r
-\r
-struct CV_GpuHogGetDescriptorsTest: cvtest::BaseTest \r
+struct HogGetDescriptors : testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-    CV_GpuHogGetDescriptorsTest() {}\r
-\r
-    void run(int i)\r
+    cv::gpu::DeviceInfo devInfo;\r
+    \r
+    virtual void SetUp()\r
     {\r
-        CV_GpuHogGetDescriptorsTestRunner runner(ts);\r
-        runner.run(i);\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
     }\r
 };\r
 \r
-TEST(HOG, descriptors_accuracy) { CV_GpuHogGetDescriptorsTest test; test.safe_run(); }\r
+TEST_P(HogGetDescriptors, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    ASSERT_NO_THROW(\r
+        CV_GpuHogGetDescriptorsTestRunner runner;\r
+        runner.run();\r
+    );\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(HOG, HogGetDescriptors, testing::ValuesIn(devices()));\r
+\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_imgproc.cpp b/modules/gpu/test/test_imgproc.cpp
new file mode 100644 (file)
index 0000000..219b73e
--- /dev/null
@@ -0,0 +1,2137 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "test_precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// threshold\r
+\r
+struct Threshold : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int threshOp;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+    double maxVal;\r
+    double thresh;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        threshOp = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+\r
+        maxVal = rng.uniform(20.0, 127.0);\r
+        thresh = rng.uniform(0.0, maxVal);\r
+\r
+        cv::threshold(src, dst_gold, thresh, maxVal, threshOp);\r
+    }\r
+};\r
+\r
+TEST_P(Threshold, Accuracy)\r
+{\r
+    static const char* ops[] = {"THRESH_BINARY", "THRESH_BINARY_INV", "THRESH_TRUNC", "THRESH_TOZERO", "THRESH_TOZERO_INV"};\r
+    const char* threshOpStr = ops[threshOp];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(threshOpStr);\r
+    PRINT_PARAM(maxVal);\r
+    PRINT_PARAM(thresh);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::threshold(cv::gpu::GpuMat(src), gpuRes, thresh, maxVal, threshOp);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8U, CV_32F), \r
+                        testing::Values((int)cv::THRESH_BINARY, (int)cv::THRESH_BINARY_INV, (int)cv::THRESH_TRUNC, (int)cv::THRESH_TOZERO, (int)cv::THRESH_TOZERO_INV)));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// resize\r
+\r
+struct Resize : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int interpolation;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    cv::Mat dst_gold1;\r
+    cv::Mat dst_gold2;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        interpolation = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+\r
+        cv::resize(src, dst_gold1, cv::Size(), 2.0, 2.0, interpolation);\r
+        cv::resize(src, dst_gold2, cv::Size(), 0.5, 0.5, interpolation);\r
+    }\r
+};\r
+\r
+TEST_P(Resize, Accuracy)\r
+{\r
+    static const char* interpolations[] = {"INTER_NEAREST", "INTER_LINEAR"};\r
+    const char* interpolationStr = interpolations[interpolation];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(interpolationStr);\r
+\r
+    cv::Mat dst1;\r
+    cv::Mat dst2;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_src(src);\r
+        cv::gpu::GpuMat gpuRes1;\r
+        cv::gpu::GpuMat gpuRes2;\r
+\r
+        cv::gpu::resize(dev_src, gpuRes1, cv::Size(), 2.0, 2.0, interpolation);\r
+        cv::gpu::resize(dev_src, gpuRes2, cv::Size(), 0.5, 0.5, interpolation);\r
+\r
+        gpuRes1.download(dst1);\r
+        gpuRes2.download(dst2);\r
+    );\r
+\r
+    EXPECT_MAT_SIMILAR(dst_gold1, dst1, 0.5);\r
+    EXPECT_MAT_SIMILAR(dst_gold2, dst2, 0.5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8UC1, CV_8UC4), \r
+                        testing::Values((int)cv::INTER_NEAREST, (int)cv::INTER_LINEAR)));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// copyMakeBorder\r
+\r
+struct CopyMakeBorder : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+    int top;\r
+    int botton;\r
+    int left;\r
+    int right;\r
+    cv::Scalar val;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+        \r
+        top = rng.uniform(1, 10);\r
+        botton = rng.uniform(1, 10);\r
+        left = rng.uniform(1, 10);\r
+        right = rng.uniform(1, 10);\r
+        val = cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));\r
+\r
+        cv::copyMakeBorder(src, dst_gold, top, botton, left, right, cv::BORDER_CONSTANT, val);\r
+    }\r
+};\r
+\r
+TEST_P(CopyMakeBorder, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(top);\r
+    PRINT_PARAM(botton);\r
+    PRINT_PARAM(left);\r
+    PRINT_PARAM(right);\r
+    PRINT_PARAM(val);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::copyMakeBorder(cv::gpu::GpuMat(src), gpuRes, top, botton, left, right, val);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8UC1, CV_8UC4, CV_32SC1)));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// warpAffine & warpPerspective\r
+\r
+static const int warpFlags[] = {cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_NEAREST | cv::WARP_INVERSE_MAP, cv::INTER_LINEAR | cv::WARP_INVERSE_MAP, cv::INTER_CUBIC | cv::WARP_INVERSE_MAP};\r
+static const char* warpFlags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};\r
+\r
+struct WarpAffine : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int flagIdx;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+    cv::Mat M;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        flagIdx = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+\r
+        static double reflect[2][3] = { {-1,  0, 0},\r
+                                        { 0, -1, 0}};\r
+        reflect[0][2] = size.width;\r
+        reflect[1][2] = size.height;\r
+        M = cv::Mat(2, 3, CV_64F, (void*)reflect); \r
+\r
+        cv::warpAffine(src, dst_gold, M, src.size(), warpFlags[flagIdx]);       \r
+    }\r
+};\r
+\r
+TEST_P(WarpAffine, Accuracy)\r
+{\r
+    const char* warpFlagStr = warpFlags_str[flagIdx];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(warpFlagStr);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::warpAffine(cv::gpu::GpuMat(src), gpuRes, M, src.size(), warpFlags[flagIdx]);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    // Check inner parts (ignoring 1 pixel width border)\r
+    cv::Mat dst_gold_roi = dst_gold.rowRange(1, dst_gold.rows - 1).colRange(1, dst_gold.cols - 1);\r
+    cv::Mat dst_roi = dst.rowRange(1, dst.rows - 1).colRange(1, dst.cols - 1);\r
+\r
+    EXPECT_MAT_NEAR(dst_gold_roi, dst_roi, 1e-3);\r
+}\r
+\r
+struct WarpPerspective : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int flagIdx;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+    cv::Mat M;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        flagIdx = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+\r
+        static double reflect[3][3] = { { -1, 0, 0},\r
+                                        { 0, -1, 0},\r
+                                        { 0,  0, 1}};\r
+        reflect[0][2] = size.width;\r
+        reflect[1][2] = size.height;\r
+        M = cv::Mat(3, 3, CV_64F, (void*)reflect);\r
+\r
+        cv::warpPerspective(src, dst_gold, M, src.size(), warpFlags[flagIdx]);       \r
+    }\r
+};\r
+\r
+TEST_P(WarpPerspective, Accuracy)\r
+{\r
+    const char* warpFlagStr = warpFlags_str[flagIdx];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(warpFlagStr);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::warpPerspective(cv::gpu::GpuMat(src), gpuRes, M, src.size(), warpFlags[flagIdx]);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    // Check inner parts (ignoring 1 pixel width border)\r
+    cv::Mat dst_gold_roi = dst_gold.rowRange(1, dst_gold.rows - 1).colRange(1, dst_gold.cols - 1);\r
+    cv::Mat dst_roi = dst.rowRange(1, dst.rows - 1).colRange(1, dst.cols - 1);\r
+\r
+    EXPECT_MAT_NEAR(dst_gold_roi, dst_roi, 1e-3);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
+                        testing::Range(0, 6)));\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
+                        testing::Range(0, 6)));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// integral\r
+\r
+struct Integral : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, CV_8UC1, 0.0, 255.0, false); \r
+\r
+        cv::integral(src, dst_gold, CV_32S);     \r
+    }\r
+};\r
+\r
+TEST_P(Integral, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::integral(cv::gpu::GpuMat(src), gpuRes);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::ValuesIn(devices()));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// cvtColor\r
+\r
+struct CvtColor : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    static cv::Mat imgBase;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        imgBase = readImage("stereobm/aloe-L.png"); \r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        imgBase.release();\r
+    } \r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Mat img;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());   \r
+\r
+        imgBase.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
+    }\r
+};\r
+\r
+cv::Mat CvtColor::imgBase;\r
+\r
+TEST_P(CvtColor, BGR2RGB)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2RGB);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2RGB);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2RGBA)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2RGBA);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2RGBA);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+TEST_P(CvtColor, BGRA2RGB)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2BGRA);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGRA2RGB);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGRA2RGB);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2YCrCb)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2YCrCb);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2YCrCb);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, YCrCb2RGB)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2YCrCb);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_YCrCb2RGB);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_YCrCb2RGB);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2YUV)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2YUV);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2YUV);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, YUV2BGR)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2YUV);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_YUV2BGR);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_YUV2BGR);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2XYZ)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2XYZ);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2XYZ);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, XYZ2BGR)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2XYZ);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_XYZ2BGR);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_XYZ2BGR);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2HSV)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2HSV);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2HSV);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, HSV2BGR)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2HSV);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_HSV2BGR);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HSV2BGR);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2HSV_FULL)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2HSV_FULL);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2HSV_FULL);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, HSV2BGR_FULL)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2HSV_FULL);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_HSV2BGR_FULL);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HSV2BGR_FULL);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2HLS)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2HLS);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2HLS);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, HLS2BGR)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2HLS);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_HLS2BGR);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HLS2BGR);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2HLS_FULL)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2HLS_FULL);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2HLS_FULL);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, HLS2BGR_FULL)\r
+{\r
+    if (type == CV_16U)\r
+        return;\r
+\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2HLS_FULL);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_HLS2BGR_FULL);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HLS2BGR_FULL);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
+}\r
+\r
+TEST_P(CvtColor, BGR2GRAY)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src = img;\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_BGR2GRAY);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2GRAY);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
+}\r
+\r
+TEST_P(CvtColor, GRAY2RGB)\r
+{\r
+    ASSERT_TRUE(!img.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+\r
+    cv::Mat src;\r
+    cv::cvtColor(img, src, CV_BGR2GRAY);\r
+    cv::Mat dst_gold;\r
+    cv::cvtColor(src, dst_gold, CV_GRAY2RGB);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpuRes;\r
+\r
+        cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_GRAY2RGB);\r
+\r
+        gpuRes.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8U, CV_16U, CV_32F)));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// histograms\r
+\r
+struct Histograms : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    static cv::Mat hsv;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        cv::Mat img = readImage("stereobm/aloe-L.png");\r
+        cv::cvtColor(img, hsv, CV_BGR2HSV);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        hsv.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    \r
+    int hbins;\r
+    float hranges[2];\r
+\r
+    cv::Mat hist_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        hbins = 30;\r
+\r
+        hranges[0] = 0;\r
+        hranges[1] = 180;\r
+\r
+        int histSize[] = {hbins};\r
+        const float* ranges[] = {hranges};\r
+\r
+        cv::MatND histnd;\r
+\r
+        int channels[] = {0};\r
+        cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);\r
+\r
+        hist_gold = histnd;\r
+        hist_gold = hist_gold.t();\r
+        hist_gold.convertTo(hist_gold, CV_32S);\r
+    }\r
+};\r
+\r
+cv::Mat Histograms::hsv;\r
+\r
+TEST_P(Histograms, Accuracy)\r
+{\r
+    ASSERT_TRUE(!hsv.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat hist;\r
+    \r
+    ASSERT_NO_THROW(\r
+        std::vector<cv::gpu::GpuMat> srcs;\r
+        cv::gpu::split(cv::gpu::GpuMat(hsv), srcs);\r
+\r
+        cv::gpu::GpuMat gpuHist;\r
+\r
+        cv::gpu::histEven(srcs[0], gpuHist, hbins, (int)hranges[0], (int)hranges[1]);\r
+\r
+        gpuHist.download(hist);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(hist_gold, hist, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Histograms, testing::ValuesIn(devices()));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// cornerHarris\r
+\r
+static const int borderTypes[] = {cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP, cv::BORDER_REFLECT101, cv::BORDER_TRANSPARENT};\r
+static const char* borderTypes_str[] = {"BORDER_REPLICATE", "BORDER_CONSTANT", "BORDER_REFLECT", "BORDER_WRAP", "BORDER_REFLECT101", "BORDER_TRANSPARENT"};\r
+\r
+struct CornerHarris : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    static cv::Mat img;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        img.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int borderTypeIdx;\r
+\r
+    cv::Mat src;\r
+    int blockSize;\r
+    int apertureSize;        \r
+    double k;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        borderTypeIdx = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+        \r
+        img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
+        \r
+        blockSize = 1 + rng.next() % 5;\r
+        apertureSize = 1 + 2 * (rng.next() % 4);        \r
+        k = rng.uniform(0.1, 0.9);\r
+\r
+        cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderTypes[borderTypeIdx]);\r
+    }\r
+};\r
+\r
+cv::Mat CornerHarris::img;\r
+\r
+TEST_P(CornerHarris, Accuracy)\r
+{\r
+    const char* borderTypeStr = borderTypes_str[borderTypeIdx];\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(borderTypeStr);\r
+    PRINT_PARAM(blockSize);\r
+    PRINT_PARAM(apertureSize);\r
+    PRINT_PARAM(k);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dev_dst, blockSize, apertureSize, k, borderTypes[borderTypeIdx]);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-3);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8UC1, CV_32FC1), \r
+                        testing::Values(0, 4)));\r
+\r
+///////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// cornerMinEigen\r
+\r
+struct CornerMinEigen : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    static cv::Mat img;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        img.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int borderTypeIdx;\r
+\r
+    cv::Mat src;\r
+    int blockSize;\r
+    int apertureSize;\r
+\r
+    cv::Mat dst_gold;\r
+    \r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        borderTypeIdx = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
+        \r
+        blockSize = 1 + rng.next() % 5;\r
+        apertureSize = 1 + 2 * (rng.next() % 4);\r
+\r
+        cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderTypes[borderTypeIdx]);\r
+    }\r
+};\r
+\r
+cv::Mat CornerMinEigen::img;\r
+\r
+TEST_P(CornerMinEigen, Accuracy)\r
+{\r
+    const char* borderTypeStr = borderTypes_str[borderTypeIdx];\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(borderTypeStr);\r
+    PRINT_PARAM(blockSize);\r
+    PRINT_PARAM(apertureSize);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dev_dst, blockSize, apertureSize, borderTypes[borderTypeIdx]);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 1e-2);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigen, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(CV_8UC1, CV_32FC1), \r
+                        testing::Values(0, 4)));\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+// ColumnSum\r
+\r
+struct ColumnSum : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));\r
+\r
+        src = cvtest::randomMat(rng, size, CV_32F, 0.0, 1.0, false);\r
+    }\r
+};\r
+\r
+TEST_P(ColumnSum, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::columnSum(cv::gpu::GpuMat(src), dev_dst);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    for (int j = 0; j < src.cols; ++j)\r
+    {\r
+        float gold = src.at<float>(0, j);\r
+        float res = dst.at<float>(0, j);\r
+        ASSERT_NEAR(res, gold, 0.5);\r
+    }\r
+\r
+    for (int i = 1; i < src.rows; ++i)\r
+    {\r
+        for (int j = 0; j < src.cols; ++j)\r
+        {\r
+            float gold = src.at<float>(i, j) += src.at<float>(i - 1, j);\r
+            float res = dst.at<float>(i, j);\r
+            ASSERT_NEAR(res, gold, 0.5);\r
+        }\r
+    }\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+// Norm\r
+\r
+static const int normTypes[] = {cv::NORM_INF, cv::NORM_L1, cv::NORM_L2};\r
+static const char* normTypes_str[] = {"NORM_INF", "NORM_L1", "NORM_L2"};\r
+\r
+struct Norm : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+    int normTypeIdx;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    double gold;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+        normTypeIdx = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 10.0, false);\r
+\r
+        gold = cv::norm(src, normTypes[normTypeIdx]);\r
+    }\r
+};\r
+\r
+TEST_P(Norm, Accuracy)\r
+{\r
+    const char* normTypeStr = normTypes_str[normTypeIdx];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(normTypeStr);\r
+\r
+    double res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = cv::gpu::norm(cv::gpu::GpuMat(src), normTypes[normTypeIdx]);\r
+    );\r
+\r
+    ASSERT_NEAR(res, gold, 0.5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Norm, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(types(CV_8U, CV_32F, 1, 1)),\r
+                        testing::Range(0, 3)));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// reprojectImageTo3D\r
+\r
+struct ReprojectImageTo3D : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::Size size;\r
+    cv::Mat disp;\r
+    cv::Mat Q;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(100, 500), rng.uniform(100, 500));\r
+\r
+        disp = cvtest::randomMat(rng, size, CV_8UC1, 5.0, 30.0, false);\r
+\r
+        Q = cvtest::randomMat(rng, cv::Size(4, 4), CV_32FC1, 0.1, 1.0, false);\r
+\r
+        cv::reprojectImageTo3D(disp, dst_gold, Q, false);\r
+    }\r
+};\r
+\r
+TEST_P(ReprojectImageTo3D, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpures;\r
+        cv::gpu::reprojectImageTo3D(cv::gpu::GpuMat(disp), gpures, Q);\r
+        gpures.download(dst);\r
+    );\r
+\r
+    ASSERT_EQ(dst_gold.size(), dst.size());\r
+\r
+    for (int y = 0; y < dst_gold.rows; ++y)\r
+    {\r
+        const cv::Vec3f* cpu_row = dst_gold.ptr<cv::Vec3f>(y);\r
+        const cv::Vec4f* gpu_row = dst.ptr<cv::Vec4f>(y);\r
+\r
+        for (int x = 0; x < dst_gold.cols; ++x)\r
+        {\r
+            cv::Vec3f gold = cpu_row[x];\r
+            cv::Vec4f res = gpu_row[x];\r
+\r
+            ASSERT_NEAR(res[0], gold[0], 1e-5);\r
+            ASSERT_NEAR(res[1], gold[1], 1e-5);\r
+            ASSERT_NEAR(res[2], gold[2], 1e-5);\r
+        }\r
+    }\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// Downsample\r
+\r
+struct Downsample : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int k;\r
+\r
+    cv::Size size;\r
+\r
+    cv::Size dst_gold_size;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        k = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(200 + cvtest::randInt(rng) % 1000, 200 + cvtest::randInt(rng) % 1000);\r
+\r
+        dst_gold_size = cv::Size((size.width + k - 1) / k, (size.height + k - 1) / k);\r
+    }\r
+};\r
+\r
+TEST_P(Downsample, Accuracy8U)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(k);\r
+\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    cv::Mat src = cvtest::randomMat(rng, size, CV_8U, 0, 255, false);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpures;\r
+        cv::gpu::downsample(cv::gpu::GpuMat(src), gpures, k);\r
+        gpures.download(dst);\r
+    );\r
+\r
+    ASSERT_EQ(dst_gold_size, dst.size());\r
+\r
+    for (int y = 0; y < dst.rows; ++y)\r
+    {\r
+        for (int x = 0; x < dst.cols; ++x)\r
+        {\r
+            int gold = src.at<uchar>(y * k, x * k);\r
+            int res = dst.at<uchar>(y, x);\r
+            ASSERT_EQ(gold, res);\r
+        }\r
+    }\r
+}\r
+\r
+TEST_P(Downsample, Accuracy32F)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(size);\r
+    PRINT_PARAM(k);\r
+\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    cv::Mat src = cvtest::randomMat(rng, size, CV_32F, 0, 1.0, false);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat gpures;\r
+        cv::gpu::downsample(cv::gpu::GpuMat(src), gpures, k);\r
+        gpures.download(dst);\r
+    );\r
+\r
+    ASSERT_EQ(dst_gold_size, dst.size());\r
+\r
+    for (int y = 0; y < dst.rows; ++y)\r
+    {\r
+        for (int x = 0; x < dst.cols; ++x)\r
+        {\r
+            float gold = src.at<float>(y * k, x * k);\r
+            float res = dst.at<float>(y, x);\r
+            ASSERT_FLOAT_EQ(gold, res);\r
+        }\r
+    }\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Downsample, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Range(2, 6)));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// meanShift\r
+\r
+struct MeanShift : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    static cv::Mat rgba;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        cv::Mat img = readImage("meanshift/cones.png");\r
+        cv::cvtColor(img, rgba, CV_BGR2BGRA);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        rgba.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    int spatialRad;\r
+    int colorRad;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        spatialRad = 30;\r
+        colorRad = 30;\r
+    }\r
+};\r
+\r
+cv::Mat MeanShift::rgba;\r
+\r
+TEST_P(MeanShift, Filtering)\r
+{\r
+    cv::Mat img_template;\r
+    \r
+    if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))\r
+        img_template = readImage("meanshift/con_result.png");\r
+    else\r
+        img_template = readImage("meanshift/con_result_CC1X.png");\r
+\r
+    ASSERT_TRUE(!rgba.empty() && !img_template.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::meanShiftFiltering(cv::gpu::GpuMat(rgba), dev_dst, spatialRad, colorRad);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    ASSERT_EQ(CV_8UC4, dst.type());\r
+\r
+    cv::Mat result;\r
+    cv::cvtColor(dst, result, CV_BGRA2BGR);\r
+\r
+    EXPECT_MAT_NEAR(img_template, result, 0.0);\r
+}\r
+\r
+TEST_P(MeanShift, Proc)\r
+{\r
+    cv::Mat spmap_template;\r
+    cv::FileStorage fs;\r
+\r
+    if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))\r
+        fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);\r
+    else\r
+        fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);\r
+\r
+    ASSERT_TRUE(fs.isOpened());\r
+\r
+    fs["spmap"] >> spmap_template;\r
+\r
+    ASSERT_TRUE(!rgba.empty() && !spmap_template.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat rmap_filtered;\r
+    cv::Mat rmap;\r
+    cv::Mat spmap;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat d_rmap_filtered;\r
+        cv::gpu::meanShiftFiltering(cv::gpu::GpuMat(rgba), d_rmap_filtered, spatialRad, colorRad);\r
+\r
+        cv::gpu::GpuMat d_rmap;\r
+        cv::gpu::GpuMat d_spmap;\r
+        cv::gpu::meanShiftProc(cv::gpu::GpuMat(rgba), d_rmap, d_spmap, spatialRad, colorRad);\r
+\r
+        d_rmap_filtered.download(rmap_filtered);\r
+        d_rmap.download(rmap);\r
+        d_spmap.download(spmap);\r
+    );\r
+\r
+    ASSERT_EQ(CV_8UC4, rmap.type());\r
+    \r
+    EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);    \r
+    EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, MeanShift, testing::ValuesIn(devices(cv::gpu::FEATURE_SET_COMPUTE_12)));\r
+\r
+struct MeanShiftSegmentation : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    static cv::Mat rgba;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        cv::Mat img = readImage("meanshift/cones.png");\r
+        cv::cvtColor(img, rgba, CV_BGR2BGRA);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        rgba.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int minsize;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        minsize = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        std::ostringstream path;\r
+        path << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;\r
+        if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))\r
+            path << ".png";\r
+        else\r
+            path << "_CC1X.png";\r
+\r
+        dst_gold = readImage(path.str());\r
+    }\r
+};\r
+\r
+cv::Mat MeanShiftSegmentation::rgba;\r
+\r
+TEST_P(MeanShiftSegmentation, Regression)\r
+{\r
+    ASSERT_TRUE(!rgba.empty() && !dst_gold.empty());\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(minsize);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::meanShiftSegmentation(cv::gpu::GpuMat(rgba), dst, 10, 10, minsize);\r
+    );\r
+\r
+    cv::Mat dst_rgb;\r
+    cv::cvtColor(dst, dst_rgb, CV_BGRA2BGR);\r
+\r
+    EXPECT_MAT_SIMILAR(dst_gold, dst_rgb, 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, testing::Combine(\r
+                        testing::ValuesIn(devices(cv::gpu::FEATURE_SET_COMPUTE_12)), \r
+                        testing::Values(0, 4, 20, 84, 340, 1364)));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// matchTemplate\r
+\r
+static const char* matchTemplateMethods[] = {"SQDIFF", "SQDIFF_NORMED", "CCORR", "CCORR_NORMED", "CCOEFF", "CCOEFF_NORMED"};\r
+\r
+struct MatchTemplate8U : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int cn;\r
+    int method;\r
+\r
+    int n, m, h, w;\r
+    cv::Mat image, templ;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        cn = std::tr1::get<1>(GetParam());\r
+        method = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        n = rng.uniform(30, 100);\r
+        m = rng.uniform(30, 100);\r
+        h = rng.uniform(5, n - 1);\r
+        w = rng.uniform(5, m - 1);\r
+\r
+        image = cvtest::randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);\r
+        templ = cvtest::randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);\r
+\r
+        cv::matchTemplate(image, templ, dst_gold, method);\r
+    }\r
+};\r
+\r
+TEST_P(MatchTemplate8U, Regression)\r
+{\r
+    const char* matchTemplateMethodStr = matchTemplateMethods[method];\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(cn);\r
+    PRINT_PARAM(matchTemplateMethodStr);\r
+    PRINT_PARAM(n);\r
+    PRINT_PARAM(m);\r
+    PRINT_PARAM(h);\r
+    PRINT_PARAM(w);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::matchTemplate(cv::gpu::GpuMat(image), cv::gpu::GpuMat(templ), dev_dst, method);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 5 * h * w * 1e-4);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate8U, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Range(1, 5), \r
+                        testing::Values((int)CV_TM_SQDIFF, (int)CV_TM_SQDIFF_NORMED, (int)CV_TM_CCORR, (int)CV_TM_CCORR_NORMED, (int)CV_TM_CCOEFF, (int)CV_TM_CCOEFF_NORMED)));\r
+\r
+struct MatchTemplate32F : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int cn;\r
+    int method;\r
+\r
+    int n, m, h, w;\r
+    cv::Mat image, templ;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        cn = std::tr1::get<1>(GetParam());\r
+        method = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        n = rng.uniform(30, 100);\r
+        m = rng.uniform(30, 100);\r
+        h = rng.uniform(5, n - 1);\r
+        w = rng.uniform(5, m - 1);\r
+\r
+        image = cvtest::randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);\r
+        templ = cvtest::randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);\r
+\r
+        cv::matchTemplate(image, templ, dst_gold, method);\r
+    }\r
+};\r
+\r
+TEST_P(MatchTemplate32F, Regression)\r
+{\r
+    const char* matchTemplateMethodStr = matchTemplateMethods[method];\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(cn);\r
+    PRINT_PARAM(matchTemplateMethodStr);\r
+    PRINT_PARAM(n);\r
+    PRINT_PARAM(m);\r
+    PRINT_PARAM(h);\r
+    PRINT_PARAM(w);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::matchTemplate(cv::gpu::GpuMat(image), cv::gpu::GpuMat(templ), dev_dst, method);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.25 * h * w * 1e-4);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate32F, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Range(1, 5), \r
+                        testing::Values((int)CV_TM_SQDIFF, (int)CV_TM_CCORR)));\r
+\r
+struct MatchTemplate : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    static cv::Mat image;\r
+    static cv::Mat pattern;\r
+\r
+    static cv::Point maxLocGold;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        image = readImage("matchtemplate/black.png");\r
+        pattern = readImage("matchtemplate/cat.png");\r
+\r
+        maxLocGold = cv::Point(284, 12);\r
+    }\r
+\r
+    static void TearDownTestCase() \r
+    {\r
+        image.release();\r
+        pattern.release();\r
+    }\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int method;\r
+\r
+    virtual void SetUp()\r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        method = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    }\r
+};\r
+\r
+cv::Mat MatchTemplate::image;\r
+cv::Mat MatchTemplate::pattern;\r
+cv::Point MatchTemplate::maxLocGold;\r
+\r
+TEST_P(MatchTemplate, FindPatternInBlack)\r
+{\r
+    ASSERT_TRUE(!image.empty() && !pattern.empty());\r
+\r
+    const char* matchTemplateMethodStr = matchTemplateMethods[method];\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(matchTemplateMethodStr);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_dst;\r
+        cv::gpu::matchTemplate(cv::gpu::GpuMat(image), cv::gpu::GpuMat(pattern), dev_dst, method);\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    double maxValue;\r
+    cv::Point maxLoc;\r
+    cv::minMaxLoc(dst, NULL, &maxValue, NULL, &maxLoc);\r
+\r
+    ASSERT_EQ(maxLocGold, maxLoc);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values((int)CV_TM_CCOEFF_NORMED, (int)CV_TM_CCORR_NORMED)));\r
+\r
+////////////////////////////////////////////////////////////////////////////\r
+// MulSpectrums\r
+\r
+struct MulSpectrums : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int flag;\r
+\r
+    cv::Mat a, b; \r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        flag = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        a = cvtest::randomMat(rng, cv::Size(rng.uniform(100, 200), rng.uniform(100, 200)), CV_32FC2, 0.0, 10.0, false);\r
+        b = cvtest::randomMat(rng, a.size(), CV_32FC2, 0.0, 10.0, false);\r
+    }\r
+};\r
+\r
+TEST_P(MulSpectrums, Simple)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(flag);\r
+\r
+    cv::Mat c_gold;\r
+    cv::mulSpectrums(a, b, c_gold, flag, false);\r
+    \r
+    cv::Mat c;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat d_c;\r
+\r
+        cv::gpu::mulSpectrums(cv::gpu::GpuMat(a), cv::gpu::GpuMat(b), d_c, flag, false);\r
+\r
+        d_c.download(c);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(c_gold, c, 1e-4);\r
+}\r
+\r
+TEST_P(MulSpectrums, Scaled)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_PARAM(flag);\r
+\r
+    float scale = 1.f / a.size().area();\r
+\r
+    cv::Mat c_gold;\r
+    cv::mulSpectrums(a, b, c_gold, flag, false);\r
+    c_gold.convertTo(c_gold, c_gold.type(), scale);\r
+\r
+    cv::Mat c;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat d_c;\r
+\r
+        cv::gpu::mulAndScaleSpectrums(cv::gpu::GpuMat(a), cv::gpu::GpuMat(b), d_c, flag, scale, false);\r
+\r
+        d_c.download(c);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(c_gold, c, 1e-4);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::Values(0, (int)cv::DFT_ROWS)));\r
+\r
+////////////////////////////////////////////////////////////////////////////\r
+// Dft\r
+\r
+struct Dft : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    }\r
+};\r
+\r
+static void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace)\r
+{\r
+    PRINT_PARAM(hint);\r
+    PRINT_PARAM(cols);\r
+    PRINT_PARAM(rows);\r
+    PRINT_PARAM(flags);\r
+    PRINT_PARAM(inplace);\r
+\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    cv::Mat a = cvtest::randomMat(rng, cv::Size(cols, rows), CV_32FC2, 0.0, 10.0, false);\r
+\r
+    cv::Mat b_gold;\r
+    cv::dft(a, b_gold, flags);\r
+\r
+    cv::gpu::GpuMat d_b;\r
+    cv::gpu::GpuMat d_b_data;\r
+    if (inplace)\r
+    {\r
+        d_b_data.create(1, a.size().area(), CV_32FC2);\r
+        d_b = cv::gpu::GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
+    }\r
+    cv::gpu::dft(cv::gpu::GpuMat(a), d_b, cv::Size(cols, rows), flags);\r
+\r
+    EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());\r
+    ASSERT_EQ(CV_32F, d_b.depth());\r
+    ASSERT_EQ(2, d_b.channels());\r
+    EXPECT_MAT_NEAR(b_gold, d_b, rows * cols * 1e-4);\r
+}\r
+\r
+TEST_P(Dft, C2C)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;\r
+\r
+    ASSERT_NO_THROW(\r
+        for (int i = 0; i < 2; ++i)\r
+        {\r
+            bool inplace = i != 0;\r
+\r
+            testC2C("no flags", cols, rows, 0, inplace);\r
+            testC2C("no flags 0 1", cols, rows + 1, 0, inplace);\r
+            testC2C("no flags 1 0", cols, rows + 1, 0, inplace);\r
+            testC2C("no flags 1 1", cols + 1, rows, 0, inplace);\r
+            testC2C("DFT_INVERSE", cols, rows, cv::DFT_INVERSE, inplace);\r
+            testC2C("DFT_ROWS", cols, rows, cv::DFT_ROWS, inplace);\r
+            testC2C("single col", 1, rows, 0, inplace);\r
+            testC2C("single row", cols, 1, 0, inplace);\r
+            testC2C("single col inversed", 1, rows, cv::DFT_INVERSE, inplace);\r
+            testC2C("single row inversed", cols, 1, cv::DFT_INVERSE, inplace);\r
+            testC2C("single row DFT_ROWS", cols, 1, cv::DFT_ROWS, inplace);\r
+            testC2C("size 1 2", 1, 2, 0, inplace);\r
+            testC2C("size 2 1", 2, 1, 0, inplace);\r
+        }\r
+    );\r
+}\r
+\r
+static void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)\r
+{\r
+    PRINT_PARAM(hint);\r
+    PRINT_PARAM(cols);\r
+    PRINT_PARAM(rows);\r
+    PRINT_PARAM(inplace);\r
+    \r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    cv::Mat a = cvtest::randomMat(rng, cv::Size(cols, rows), CV_32FC1, 0.0, 10.0, false);\r
+\r
+    cv::gpu::GpuMat d_b, d_c;\r
+    cv::gpu::GpuMat d_b_data, d_c_data;\r
+    if (inplace)\r
+    {\r
+        if (a.cols == 1)\r
+        {\r
+            d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);\r
+            d_b = cv::gpu::GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
+        }\r
+        else\r
+        {\r
+            d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);\r
+            d_b = cv::gpu::GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());\r
+        }\r
+        d_c_data.create(1, a.size().area(), CV_32F);\r
+        d_c = cv::gpu::GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());\r
+    }\r
+\r
+    cv::gpu::dft(cv::gpu::GpuMat(a), d_b, cv::Size(cols, rows), 0);\r
+    cv::gpu::dft(d_b, d_c, cv::Size(cols, rows), cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);\r
+    \r
+    EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());\r
+    EXPECT_TRUE(!inplace || d_c.ptr() == d_c_data.ptr());\r
+    ASSERT_EQ(CV_32F, d_c.depth());\r
+    ASSERT_EQ(1, d_c.channels());\r
+\r
+    cv::Mat c(d_c);\r
+    EXPECT_MAT_NEAR(a, c, rows * cols * 1e-5);\r
+}\r
+\r
+TEST_P(Dft, R2CThenC2R)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;\r
+\r
+    ASSERT_NO_THROW(\r
+        testR2CThenC2R("sanity", cols, rows, false);\r
+        testR2CThenC2R("sanity 0 1", cols, rows + 1, false);\r
+        testR2CThenC2R("sanity 1 0", cols + 1, rows, false);\r
+        testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, false);\r
+        testR2CThenC2R("single col", 1, rows, false);\r
+        testR2CThenC2R("single col 1", 1, rows + 1, false);\r
+        testR2CThenC2R("single row", cols, 1, false);\r
+        testR2CThenC2R("single row 1", cols + 1, 1, false);\r
+\r
+        testR2CThenC2R("sanity", cols, rows, true);\r
+        testR2CThenC2R("sanity 0 1", cols, rows + 1, true);\r
+        testR2CThenC2R("sanity 1 0", cols + 1, rows, true);\r
+        testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);\r
+        testR2CThenC2R("single row", cols, 1, true);\r
+        testR2CThenC2R("single row 1", cols + 1, 1, true);\r
+    );\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::ValuesIn(devices()));\r
+\r
+////////////////////////////////////////////////////////////////////////////\r
+// blend\r
+\r
+template <typename T> static void blendLinearGold(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& weights1, const cv::Mat& weights2, cv::Mat& result_gold)\r
+{\r
+    result_gold.create(img1.size(), img1.type());\r
+\r
+    int cn = img1.channels();\r
+\r
+    for (int y = 0; y < img1.rows; ++y)\r
+    {\r
+        const float* weights1_row = weights1.ptr<float>(y);\r
+        const float* weights2_row = weights2.ptr<float>(y);\r
+        const T* img1_row = img1.ptr<T>(y);\r
+        const T* img2_row = img2.ptr<T>(y);\r
+        T* result_gold_row = result_gold.ptr<T>(y);\r
+        for (int x = 0; x < img1.cols * cn; ++x)\r
+        {\r
+            float w1 = weights1_row[x / cn];\r
+            float w2 = weights2_row[x / cn];\r
+            result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));\r
+        }\r
+    }\r
+}\r
+\r
+struct Blend : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int depth;\r
+    int cn;\r
+\r
+    int type;\r
+    cv::Size size;\r
+    cv::Mat img1;\r
+    cv::Mat img2;\r
+    cv::Mat weights1;\r
+    cv::Mat weights2;\r
+\r
+    cv::Mat result_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        depth = std::tr1::get<1>(GetParam());\r
+        cn = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        type = CV_MAKETYPE(depth, cn);\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(200 + cvtest::randInt(rng) % 1000, 200 + cvtest::randInt(rng) % 1000);\r
+\r
+        img1 = cvtest::randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);\r
+        img2 = cvtest::randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);\r
+        weights1 = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
+        weights2 = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
+        \r
+        if (depth == CV_8U)\r
+            blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);\r
+        else\r
+            blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Blend, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat result;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat d_result;\r
+\r
+        cv::gpu::blendLinear(cv::gpu::GpuMat(img1), cv::gpu::GpuMat(img2), cv::gpu::GpuMat(weights1), cv::gpu::GpuMat(weights2), d_result);\r
+\r
+        d_result.download(result);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(result_gold, result, depth == CV_8U ? 1.0 : 1e-5);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(ImgProc, Blend, testing::Combine(\r
+                        testing::ValuesIn(devices()),\r
+                        testing::Values(CV_8U, CV_32F),\r
+                        testing::Range(1, 5)));\r
+\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_imgproc_gpu.cpp b/modules/gpu/test/test_imgproc_gpu.cpp
deleted file mode 100644 (file)
index d45d7c7..0000000
+++ /dev/null
@@ -1,966 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <cmath>\r
-#include <limits>\r
-#include "test_precomp.hpp"\r
-\r
-using namespace cv;\r
-using namespace std;\r
-using namespace gpu;\r
-\r
-class CV_GpuImageProcTest : public cvtest::BaseTest\r
-{\r
-public:\r
-    virtual ~CV_GpuImageProcTest() {}\r
-\r
-protected:\r
-    void run(int);\r
-\r
-    int test8UC1 (const Mat& img);\r
-    int test8UC4 (const Mat& img);\r
-    int test32SC1(const Mat& img);\r
-    int test32FC1(const Mat& img);\r
-\r
-    virtual int test(const Mat& img) = 0;\r
-\r
-    int CheckNorm(const Mat& m1, const Mat& m2);\r
-\r
-    // Checks whether two images are similar enough using normalized\r
-    // cross-correlation as an error measure\r
-    int CheckSimilarity(const Mat& m1, const Mat& m2, float max_err=1e-3f);\r
-};\r
-\r
-\r
-int CV_GpuImageProcTest::test8UC1(const Mat& img)\r
-{\r
-    cv::Mat img_C1;\r
-    cvtColor(img, img_C1, CV_BGR2GRAY);\r
-\r
-    return test(img_C1);\r
-}\r
-\r
-int CV_GpuImageProcTest::test8UC4(const Mat& img)\r
-{\r
-    cv::Mat img_C4;\r
-    cvtColor(img, img_C4, CV_BGR2BGRA);\r
-\r
-    return test(img_C4);\r
-}\r
-\r
-int CV_GpuImageProcTest::test32SC1(const Mat& img)\r
-{\r
-    cv::Mat img_C1;\r
-    cvtColor(img, img_C1, CV_BGR2GRAY);\r
-    img_C1.convertTo(img_C1, CV_32S);\r
-\r
-    return test(img_C1);\r
-}\r
-\r
-int CV_GpuImageProcTest::test32FC1(const Mat& img)\r
-{\r
-    cv::Mat temp, img_C1;\r
-    img.convertTo(temp, CV_32F, 1.f / 255.f);\r
-    cvtColor(temp, img_C1, CV_BGR2GRAY);\r
-\r
-    return test(img_C1);\r
-}\r
-\r
-int CV_GpuImageProcTest::CheckNorm(const Mat& m1, const Mat& m2)\r
-{\r
-    double ret = norm(m1, m2, NORM_INF);\r
-\r
-    if (ret < std::numeric_limits<double>::epsilon())\r
-    {\r
-        return cvtest::TS::OK;\r
-    }\r
-    else\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "Norm: %f\n", ret);\r
-        return cvtest::TS::FAIL_GENERIC;\r
-    }\r
-}\r
-\r
-int CV_GpuImageProcTest::CheckSimilarity(const Mat& m1, const Mat& m2, float max_err)\r
-{\r
-    Mat diff;\r
-    cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
-\r
-    float err = abs(diff.at<float>(0, 0) - 1.f);\r
-\r
-    if (err > max_err)\r
-        return cvtest::TS::FAIL_INVALID_OUTPUT;\r
-\r
-    return cvtest::TS::OK;\r
-}\r
-\r
-void CV_GpuImageProcTest::run( int )\r
-{\r
-    //load image\r
-    cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-\r
-    if (img.empty())\r
-    {\r
-        ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-        return;\r
-    }\r
-\r
-    int testResult = cvtest::TS::OK;\r
-    //run tests\r
-    ts->printf(cvtest::TS::LOG, "\n========Start test 8UC1========\n");\r
-    if (test8UC1(img) == cvtest::TS::OK)\r
-        ts->printf(cvtest::TS::LOG, "SUCCESS\n");\r
-    else\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "FAIL\n");\r
-        testResult = cvtest::TS::FAIL_GENERIC;\r
-    }\r
-\r
-    ts->printf(cvtest::TS::LOG, "\n========Start test 8UC4========\n");\r
-    if (test8UC4(img) == cvtest::TS::OK)\r
-        ts->printf(cvtest::TS::LOG, "SUCCESS\n");\r
-    else\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "FAIL\n");\r
-        testResult = cvtest::TS::FAIL_GENERIC;\r
-    }\r
-\r
-    ts->printf(cvtest::TS::LOG, "\n========Start test 32SC1========\n");\r
-    if (test32SC1(img) == cvtest::TS::OK)\r
-        ts->printf(cvtest::TS::LOG, "SUCCESS\n");\r
-    else\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "FAIL\n");\r
-        testResult = cvtest::TS::FAIL_GENERIC;\r
-    }\r
-\r
-    ts->printf(cvtest::TS::LOG, "\n========Start test 32FC1========\n");\r
-    if (test32FC1(img) == cvtest::TS::OK)\r
-        ts->printf(cvtest::TS::LOG, "SUCCESS\n");\r
-    else\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "FAIL\n");\r
-        testResult = cvtest::TS::FAIL_GENERIC;\r
-    }\r
-\r
-    ts->set_failed_test_info(testResult);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// threshold\r
-struct CV_GpuImageThresholdTest : public CV_GpuImageProcTest\r
-{\r
-public:\r
-    CV_GpuImageThresholdTest() {}\r
-\r
-    int test(const Mat& img)\r
-    {\r
-        if (img.type() != CV_8UC1 && img.type() != CV_32FC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nUnsupported type\n");\r
-            return cvtest::TS::OK;\r
-        }\r
-\r
-        const double maxVal = img.type() == CV_8UC1 ? 255 : 1.0;\r
-\r
-        cv::RNG& rng = ts->get_rng();\r
-\r
-        int res = cvtest::TS::OK;\r
-\r
-        for (int type = THRESH_BINARY; type <= THRESH_TOZERO_INV; ++type)\r
-        {\r
-            const double thresh = rng.uniform(0.0, maxVal);\r
-\r
-            cv::Mat cpuRes;\r
-            cv::threshold(img, cpuRes, thresh, maxVal, type);\r
-\r
-            GpuMat gpu1(img);\r
-            GpuMat gpuRes;\r
-            cv::gpu::threshold(gpu1, gpuRes, thresh, maxVal, type);\r
-\r
-            if (CheckNorm(cpuRes, gpuRes) != cvtest::TS::OK)\r
-                res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
-\r
-        return res;\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// resize\r
-struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest\r
-{\r
-    CV_GpuNppImageResizeTest() {}\r
-    int test(const Mat& img)\r
-    {\r
-        if (img.type() != CV_8UC1 && img.type() != CV_8UC4)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Unsupported type\n");\r
-            return cvtest::TS::OK;\r
-        }\r
-\r
-        int interpolations[] = {INTER_NEAREST, INTER_LINEAR, /*INTER_CUBIC,*/ /*INTER_LANCZOS4*/};\r
-        const char* interpolations_str[] = {"INTER_NEAREST", "INTER_LINEAR", /*"INTER_CUBIC",*/ /*"INTER_LANCZOS4"*/};\r
-        int interpolations_num = sizeof(interpolations) / sizeof(int);\r
-\r
-        int test_res = cvtest::TS::OK;\r
-\r
-        for (int i = 0; i < interpolations_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "Interpolation: %s\n", interpolations_str[i]);\r
-\r
-            Mat cpu_res1, cpu_res2;\r
-            cv::resize(img, cpu_res1, Size(), 2.0, 2.0, interpolations[i]);\r
-            cv::resize(cpu_res1, cpu_res2, Size(), 0.5, 0.5, interpolations[i]);\r
-\r
-            GpuMat gpu1(img), gpu_res1, gpu_res2;\r
-            cv::gpu::resize(gpu1, gpu_res1, Size(), 2.0, 2.0, interpolations[i]);\r
-            cv::gpu::resize(gpu_res1, gpu_res2, Size(), 0.5, 0.5, interpolations[i]);\r
-\r
-            if (CheckSimilarity(cpu_res2, gpu_res2) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
-\r
-        return test_res;\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// copyMakeBorder\r
-struct CV_GpuNppImageCopyMakeBorderTest : public CV_GpuImageProcTest\r
-{\r
-    CV_GpuNppImageCopyMakeBorderTest() {}\r
-\r
-    int test(const Mat& img)\r
-    {\r
-        if (img.type() != CV_8UC1 && img.type() != CV_8UC4 && img.type() != CV_32SC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nUnsupported type\n");\r
-            return cvtest::TS::OK;\r
-        }\r
-\r
-        cv::RNG& rng = ts->get_rng();\r
-        int top = rng.uniform(1, 10);\r
-        int botton = rng.uniform(1, 10);\r
-        int left = rng.uniform(1, 10);\r
-        int right = rng.uniform(1, 10);\r
-        cv::Scalar val(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));\r
-\r
-        Mat cpudst;\r
-        cv::copyMakeBorder(img, cpudst, top, botton, left, right, BORDER_CONSTANT, val);\r
-\r
-        GpuMat gpu1(img);\r
-        GpuMat gpudst;\r
-        cv::gpu::copyMakeBorder(gpu1, gpudst, top, botton, left, right, val);\r
-\r
-        return CheckNorm(cpudst, gpudst);\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// warpAffine\r
-struct CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest\r
-{\r
-    CV_GpuNppImageWarpAffineTest() {}\r
-\r
-    int test(const Mat& img)\r
-    {\r
-        if (img.type() == CV_32SC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nUnsupported type\n");\r
-            return cvtest::TS::OK;\r
-        }\r
-\r
-        static double reflect[2][3] = { {-1, 0, 0},\r
-                                        { 0, -1, 0} };\r
-        reflect[0][2] = img.cols;\r
-        reflect[1][2] = img.rows;\r
-\r
-        Mat M(2, 3, CV_64F, (void*)reflect);\r
-\r
-        int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};\r
-        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"};\r
-        int flags_num = sizeof(flags) / sizeof(int);\r
-\r
-        int test_res = cvtest::TS::OK;\r
-\r
-        for (int i = 0; i < flags_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nFlags: %s\n", flags_str[i]);\r
-\r
-            Mat cpudst;\r
-            cv::warpAffine(img, cpudst, M, img.size(), flags[i]);\r
-\r
-            GpuMat gpu1(img);\r
-            GpuMat gpudst;\r
-            cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]);\r
-\r
-            // Check inner parts (ignoring 1 pixel width border)\r
-            if (CheckSimilarity(cpudst.rowRange(1, cpudst.rows - 1).colRange(1, cpudst.cols - 1),\r
-                                gpudst.rowRange(1, gpudst.rows - 1).colRange(1, gpudst.cols - 1)) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
-\r
-        return test_res;\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// warpPerspective\r
-struct CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest\r
-{\r
-    CV_GpuNppImageWarpPerspectiveTest() {}\r
-\r
-\r
-    int test(const Mat& img)\r
-    {\r
-        if (img.type() == CV_32SC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nUnsupported type\n");\r
-            return cvtest::TS::OK;\r
-        }\r
-\r
-        static double reflect[3][3] = { { -1, 0, 0},\r
-                                        { 0, -1, 0},\r
-                                        { 0, 0, 1 }};\r
-        reflect[0][2] = img.cols;\r
-        reflect[1][2] = img.rows;\r
-        Mat M(3, 3, CV_64F, (void*)reflect);\r
-\r
-        int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};\r
-        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"};\r
-        int flags_num = sizeof(flags) / sizeof(int);\r
-\r
-        int test_res = cvtest::TS::OK;\r
-\r
-        for (int i = 0; i < flags_num; ++i)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nFlags: %s\n", flags_str[i]);\r
-\r
-            Mat cpudst;\r
-            cv::warpPerspective(img, cpudst, M, img.size(), flags[i]);\r
-\r
-            GpuMat gpu1(img);\r
-            GpuMat gpudst;\r
-            cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]);\r
-\r
-            // Check inner parts (ignoring 1 pixel width border)\r
-            if (CheckSimilarity(cpudst.rowRange(1, cpudst.rows - 1).colRange(1, cpudst.cols - 1),\r
-                                gpudst.rowRange(1, gpudst.rows - 1).colRange(1, gpudst.cols - 1)) != cvtest::TS::OK)\r
-                test_res = cvtest::TS::FAIL_GENERIC;\r
-        }\r
-\r
-        return test_res;\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// integral\r
-struct CV_GpuNppImageIntegralTest : public CV_GpuImageProcTest\r
-{\r
-    CV_GpuNppImageIntegralTest() {}\r
-\r
-    int test(const Mat& img)\r
-    {\r
-        if (img.type() != CV_8UC1)\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nUnsupported type\n");\r
-            return cvtest::TS::OK;\r
-        }\r
-\r
-        Mat cpusum;\r
-        cv::integral(img, cpusum, CV_32S);\r
-\r
-        GpuMat gpu1(img);\r
-        GpuMat gpusum;\r
-        cv::gpu::integral(gpu1, gpusum);\r
-\r
-        return CheckNorm(cpusum, gpusum) == cvtest::TS::OK ? cvtest::TS::OK : cvtest::TS::FAIL_GENERIC;\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Canny\r
-//struct CV_GpuNppImageCannyTest : public CV_GpuImageProcTest\r
-//{\r
-//    CV_GpuNppImageCannyTest() : CV_GpuImageProcTest( "GPU-NppImageCanny", "Canny" ) {}\r
-//\r
-//    int test(const Mat& img)\r
-//    {\r
-//        if (img.type() != CV_8UC1)\r
-//        {\r
-//            ts->printf(cvtest::TS::LOG, "\nUnsupported type\n");\r
-//            return cvtest::TS::OK;\r
-//        }\r
-//\r
-//        const double threshold1 = 1.0, threshold2 = 10.0;\r
-//\r
-//        Mat cpudst;\r
-//        cv::Canny(img, cpudst, threshold1, threshold2);\r
-//\r
-//        GpuMat gpu1(img);\r
-//        GpuMat gpudst;\r
-//        cv::gpu::Canny(gpu1, gpudst, threshold1, threshold2);\r
-//\r
-//        return CheckNorm(cpudst, gpudst);\r
-//    }\r
-//};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// cvtColor\r
-class CV_GpuCvtColorTest : public cvtest::BaseTest\r
-{\r
-public:\r
-    CV_GpuCvtColorTest() {}\r
-    ~CV_GpuCvtColorTest() {};\r
-\r
-protected:\r
-    void run(int);\r
-\r
-    int CheckNorm(const Mat& m1, const Mat& m2);\r
-};\r
-\r
-\r
-int CV_GpuCvtColorTest::CheckNorm(const Mat& m1, const Mat& m2)\r
-{\r
-    float max_err = 1e-2f;\r
-\r
-    Mat diff;\r
-    cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
-\r
-    float err = abs(diff.at<float>(0, 0) - 1.f);\r
-\r
-    if (err > max_err)\r
-        return cvtest::TS::FAIL_INVALID_OUTPUT;\r
-\r
-    return cvtest::TS::OK;\r
-}\r
-\r
-void CV_GpuCvtColorTest::run( int )\r
-{\r
-    cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-\r
-    if (img.empty())\r
-    {\r
-        ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-        return;\r
-    }\r
-\r
-    int testResult = cvtest::TS::OK;\r
-    cv::Mat cpuRes;\r
-    cv::gpu::GpuMat gpuImg(img), gpuRes;\r
-\r
-    int codes[] = { CV_BGR2RGB, CV_RGB2BGRA, CV_BGRA2RGB,\r
-                    CV_RGB2BGR555, CV_BGR5552BGR, CV_BGR2BGR565, CV_BGR5652RGB,\r
-                    CV_RGB2YCrCb, CV_YCrCb2BGR, CV_BGR2YUV, CV_YUV2RGB,\r
-                    CV_RGB2XYZ, CV_XYZ2BGR, CV_BGR2XYZ, CV_XYZ2RGB,\r
-                    CV_RGB2HSV, CV_HSV2BGR, CV_BGR2HSV_FULL, CV_HSV2RGB_FULL,\r
-                    CV_RGB2HLS, CV_HLS2BGR, CV_BGR2HLS_FULL, CV_HLS2RGB_FULL,\r
-                    CV_RGB2GRAY, CV_GRAY2BGRA, CV_BGRA2GRAY,\r
-                    CV_GRAY2BGR555, CV_BGR5552GRAY, CV_GRAY2BGR565, CV_BGR5652GRAY};\r
-    const char* codes_str[] = { "CV_BGR2RGB", "CV_RGB2BGRA", "CV_BGRA2RGB",\r
-                                "CV_RGB2BGR555", "CV_BGR5552BGR", "CV_BGR2BGR565", "CV_BGR5652RGB",\r
-                                "CV_RGB2YCrCb", "CV_YCrCb2BGR", "CV_BGR2YUV", "CV_YUV2RGB",\r
-                                "CV_RGB2XYZ", "CV_XYZ2BGR", "CV_BGR2XYZ", "CV_XYZ2RGB",\r
-                                "CV_RGB2HSV", "CV_HSV2RGB", "CV_BGR2HSV_FULL", "CV_HSV2RGB_FULL",\r
-                                "CV_RGB2HLS", "CV_HLS2RGB", "CV_BGR2HLS_FULL", "CV_HLS2RGB_FULL",\r
-                                "CV_RGB2GRAY", "CV_GRAY2BGRA", "CV_BGRA2GRAY",\r
-                                "CV_GRAY2BGR555", "CV_BGR5552GRAY", "CV_GRAY2BGR565", "CV_BGR5652GRAY"};\r
-    int codes_num = sizeof(codes) / sizeof(int);\r
-\r
-    for (int i = 0; i < codes_num; ++i)\r
-    {\r
-        ts->printf(cvtest::TS::LOG, "\n%s\n", codes_str[i]);\r
-\r
-        cv::cvtColor(img, cpuRes, codes[i]);\r
-        cv::gpu::cvtColor(gpuImg, gpuRes, codes[i]);\r
-\r
-        if (CheckNorm(cpuRes, gpuRes) == cvtest::TS::OK)\r
-            ts->printf(cvtest::TS::LOG, "\nSUCCESS\n");\r
-        else\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nFAIL\n");\r
-            testResult = cvtest::TS::FAIL_GENERIC;\r
-        }\r
-\r
-        img = cpuRes;\r
-        gpuImg = gpuRes;\r
-    }\r
-\r
-    ts->set_failed_test_info(testResult);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Histograms\r
-class CV_GpuHistogramsTest : public cvtest::BaseTest\r
-{\r
-public:\r
-    CV_GpuHistogramsTest() {}\r
-    ~CV_GpuHistogramsTest() {};\r
-\r
-protected:\r
-    void run(int);\r
-\r
-    int CheckNorm(const Mat& m1, const Mat& m2)\r
-    {\r
-        double ret = norm(m1, m2, NORM_INF);\r
-\r
-        if (ret < std::numeric_limits<double>::epsilon())\r
-        {\r
-            return cvtest::TS::OK;\r
-        }\r
-        else\r
-        {\r
-            ts->printf(cvtest::TS::LOG, "\nNorm: %f\n", ret);\r
-            return cvtest::TS::FAIL_GENERIC;\r
-        }\r
-    }\r
-};\r
-\r
-void CV_GpuHistogramsTest::run( int )\r
-{\r
-    //load image\r
-    cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-\r
-    if (img.empty())\r
-    {\r
-        ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-        return;\r
-    }\r
-\r
-    Mat hsv;\r
-    cv::cvtColor(img, hsv, CV_BGR2HSV);\r
-\r
-    int hbins = 30;\r
-    int histSize[] = {hbins};\r
-\r
-    float hranges[] = {0, 180};\r
-    const float* ranges[] = {hranges};\r
-\r
-    MatND hist;\r
-\r
-    int channels[] = {0};\r
-    calcHist(&hsv, 1, channels, Mat(), hist, 1, histSize, ranges);\r
-\r
-    GpuMat gpuHsv(hsv);\r
-    std::vector<GpuMat> srcs;\r
-    cv::gpu::split(gpuHsv, srcs);\r
-    GpuMat gpuHist;\r
-    histEven(srcs[0], gpuHist, hbins, (int)hranges[0], (int)hranges[1]);\r
-\r
-    Mat cpuHist = hist;\r
-    cpuHist = cpuHist.t();\r
-    cpuHist.convertTo(cpuHist, CV_32S);\r
-\r
-    ts->set_failed_test_info(CheckNorm(cpuHist, gpuHist));\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Corner Harris feature detector\r
-\r
-struct CV_GpuCornerHarrisTest: cvtest::BaseTest\r
-{\r
-    CV_GpuCornerHarrisTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        for (int i = 0; i < 5; ++i)\r
-        {\r
-            int rows = 25 + rand() % 300, cols = 25 + rand() % 300;\r
-            if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
-            if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, -1)) return;\r
-            if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
-            if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, -1)) return;\r
-        }\r
-    }\r
-\r
-    bool compareToCpuTest(int rows, int cols, int depth, int blockSize, int apertureSize)\r
-    {\r
-        RNG rng;\r
-        cv::Mat src(rows, cols, depth);\r
-        if (depth == CV_32F)\r
-            rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));\r
-        else if (depth == CV_8U)\r
-            rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(256));\r
-\r
-        double k = 0.1;\r
-\r
-        cv::Mat dst_gold;\r
-        cv::gpu::GpuMat dst;\r
-        cv::Mat dsth;\r
-        int borderType;\r
-\r
-        borderType = BORDER_REFLECT101;\r
-        cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);\r
-        cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k, borderType);\r
-\r
-        dsth = dst;\r
-        for (int i = 0; i < dst.rows; ++i)\r
-        {\r
-            for (int j = 0; j < dst.cols; ++j)\r
-            {\r
-                float a = dst_gold.at<float>(i, j);\r
-                float b = dsth.at<float>(i, j);\r
-                if (fabs(a - b) > 1e-3f)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d\n", i, j, a, b, apertureSize);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                };\r
-            }\r
-        }\r
-\r
-        borderType = BORDER_REPLICATE;\r
-        cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);\r
-        cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k, borderType);\r
-\r
-        dsth = dst;\r
-        for (int i = 0; i < dst.rows; ++i)\r
-        {\r
-            for (int j = 0; j < dst.cols; ++j)\r
-            {\r
-                float a = dst_gold.at<float>(i, j);\r
-                float b = dsth.at<float>(i, j);\r
-                if (fabs(a - b) > 1e-3f)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d\n", i, j, a, b, apertureSize);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                };\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Corner Min Eigen Val\r
-\r
-struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest\r
-{\r
-    CV_GpuCornerMinEigenValTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        for (int i = 0; i < 3; ++i)\r
-        {\r
-            int rows = 25 + rand() % 300, cols = 25 + rand() % 300;\r
-            if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, -1)) return;\r
-            if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
-            if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, -1)) return;\r
-            if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
-        }\r
-    }\r
-\r
-    bool compareToCpuTest(int rows, int cols, int depth, int blockSize, int apertureSize)\r
-    {\r
-        RNG rng;\r
-        cv::Mat src(rows, cols, depth);\r
-        if (depth == CV_32F)\r
-            rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));\r
-        else if (depth == CV_8U)\r
-            rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(256));\r
-\r
-        cv::Mat dst_gold;\r
-        cv::gpu::GpuMat dst;\r
-        cv::Mat dsth;\r
-\r
-        int borderType;\r
-\r
-        borderType = BORDER_REFLECT101;\r
-        cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);\r
-        cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType);\r
-\r
-        dsth = dst;\r
-        for (int i = 0; i < dst.rows; ++i)\r
-        {\r
-            for (int j = 0; j < dst.cols; ++j)\r
-            {\r
-                float a = dst_gold.at<float>(i, j);\r
-                float b = dsth.at<float>(i, j);\r
-                if (fabs(a - b) > 1e-2f)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d %d\n", i, j, a, b, apertureSize, blockSize);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                };\r
-            }\r
-        }\r
-\r
-        borderType = BORDER_REPLICATE;\r
-        cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);\r
-        cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType);\r
-\r
-        dsth = dst;\r
-        for (int i = 0; i < dst.rows; ++i)\r
-        {\r
-            for (int j = 0; j < dst.cols; ++j)\r
-            {\r
-                float a = dst_gold.at<float>(i, j);\r
-                float b = dsth.at<float>(i, j);\r
-                if (fabs(a - b) > 1e-2f)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d %d\n", i, j, a, b, apertureSize, blockSize);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return false;\r
-                };\r
-            }\r
-        }\r
-\r
-        return true;\r
-    }\r
-};\r
-\r
-struct CV_GpuColumnSumTest: cvtest::BaseTest\r
-{\r
-    CV_GpuColumnSumTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        int cols = 375;\r
-        int rows = 1072;\r
-\r
-        Mat src(rows, cols, CV_32F);\r
-        RNG rng(1);\r
-        rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(1));\r
-\r
-        GpuMat d_dst;\r
-        columnSum(GpuMat(src), d_dst);\r
-\r
-        Mat dst = d_dst;\r
-        for (int j = 0; j < src.cols; ++j)\r
-        {\r
-            float a = src.at<float>(0, j);\r
-            float b = dst.at<float>(0, j);\r
-            if (fabs(a - b) > 0.5f)\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "big diff at %d %d: %f %f\n", 0, j, a, b);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
-        }\r
-        for (int i = 1; i < src.rows; ++i)\r
-        {\r
-            for (int j = 0; j < src.cols; ++j)\r
-            {\r
-                float a = src.at<float>(i, j) += src.at<float>(i - 1, j);\r
-                float b = dst.at<float>(i, j);\r
-                if (fabs(a - b) > 0.5f)\r
-                {\r
-                    ts->printf(cvtest::TS::CONSOLE, "big diff at %d %d: %f %f\n", i, j, a, b);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-            }\r
-        }\r
-    }\r
-};\r
-\r
-struct CV_GpuNormTest : cvtest::BaseTest\r
-{\r
-    CV_GpuNormTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        RNG rng(0);\r
-\r
-        int rows = rng.uniform(1, 500);\r
-        int cols = rng.uniform(1, 500);\r
-\r
-        for (int cn = 1; cn <= 4; ++cn)\r
-        {\r
-            test(NORM_L1, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
-            test(NORM_L1, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_L1, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
-            test(NORM_L1, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_L1, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_L1, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
-\r
-            test(NORM_L2, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
-            test(NORM_L2, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_L2, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
-            test(NORM_L2, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_L2, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_L2, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
-\r
-            test(NORM_INF, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
-            test(NORM_INF, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_INF, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
-            test(NORM_INF, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_INF, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
-            test(NORM_INF, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
-        }\r
-    }\r
-\r
-    void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)\r
-    {\r
-        mat.create(rows, cols, type);\r
-        RNG rng(0);\r
-        rng.fill(mat, RNG::UNIFORM, low, high);\r
-    }\r
-\r
-    void test(int norm_type, int rows, int cols, int depth, int cn, Scalar low, Scalar high)\r
-    {\r
-        int type = CV_MAKE_TYPE(depth, cn);\r
-\r
-        Mat src;\r
-        gen(src, rows, cols, type, low, high);\r
-\r
-        double gold = norm(src, norm_type);\r
-        double mine = norm(GpuMat(src), norm_type);\r
-\r
-        if (abs(gold - mine) > 1e-3)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "failed test: gold=%f, mine=%f, norm_type=%d, rows=%d, "\r
-                       "cols=%d, depth=%d, cn=%d\n", gold, mine, norm_type, rows, cols, depth, cn);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-        }\r
-    }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// reprojectImageTo3D\r
-class CV_GpuReprojectImageTo3DTest : public cvtest::BaseTest\r
-{\r
-public:\r
-    CV_GpuReprojectImageTo3DTest() {}\r
-\r
-protected:\r
-    void run(int)\r
-    {\r
-        Mat disp(320, 240, CV_8UC1);\r
-\r
-        RNG& rng = ts->get_rng();\r
-        rng.fill(disp, RNG::UNIFORM, Scalar(5), Scalar(30));\r
-\r
-        Mat Q(4, 4, CV_32FC1);\r
-        rng.fill(Q, RNG::UNIFORM, Scalar(0.1), Scalar(1));\r
-\r
-        Mat cpures;\r
-        GpuMat gpures;\r
-\r
-        reprojectImageTo3D(disp, cpures, Q, false);\r
-        reprojectImageTo3D(GpuMat(disp), gpures, Q);\r
-\r
-        Mat temp = gpures;\r
-\r
-        for (int y = 0; y < cpures.rows; ++y)\r
-        {\r
-            const Vec3f* cpu_row = cpures.ptr<Vec3f>(y);\r
-            const Vec4f* gpu_row = temp.ptr<Vec4f>(y);\r
-            for (int x = 0; x < cpures.cols; ++x)\r
-            {\r
-                Vec3f a = cpu_row[x];\r
-                Vec4f b = gpu_row[x];\r
-\r
-                if (fabs(a[0] - b[0]) > 1e-5 || fabs(a[1] - b[1]) > 1e-5 || fabs(a[2] - b[2]) > 1e-5)\r
-                {\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-            }\r
-        }\r
-    }\r
-};\r
-\r
-TEST(threshold, accuracy) { CV_GpuImageThresholdTest test; test.safe_run(); }\r
-TEST(resize, accuracy) { CV_GpuNppImageResizeTest test; test.safe_run(); }\r
-TEST(copyMakeBorder, accuracy) { CV_GpuNppImageCopyMakeBorderTest test; test.safe_run(); }\r
-TEST(warpAffine, accuracy) { CV_GpuNppImageWarpAffineTest test; test.safe_run(); }\r
-TEST(warpPerspective, accuracy) { CV_GpuNppImageWarpPerspectiveTest test; test.safe_run(); }\r
-TEST(integral, accuracy) { CV_GpuNppImageIntegralTest test; test.safe_run(); }\r
-TEST(cvtColor, accuracy) { CV_GpuCvtColorTest test; test.safe_run(); }\r
-TEST(histograms, accuracy) { CV_GpuHistogramsTest test; test.safe_run(); }\r
-TEST(cornerHearris, accuracy) { CV_GpuCornerHarrisTest test; test.safe_run(); }\r
-TEST(minEigen, accuracy) { CV_GpuCornerMinEigenValTest test; test.safe_run(); }\r
-TEST(columnSum, accuracy) { CV_GpuColumnSumTest test; test.safe_run(); }\r
-TEST(norm, accuracy) { CV_GpuNormTest test; test.safe_run(); }\r
-TEST(reprojectImageTo3D, accuracy) { CV_GpuReprojectImageTo3DTest test; test.safe_run(); }\r
-\r
-TEST(downsample, accuracy_on_8U)\r
-{\r
-    RNG& rng = cvtest::TS::ptr()->get_rng();\r
-    Size size(200 + cvtest::randInt(rng) % 1000, 200 + cvtest::randInt(rng) % 1000);\r
-    Mat src = cvtest::randomMat(rng, size, CV_8U, 0, 255, false);\r
-\r
-    for (int k = 2; k <= 5; ++k)\r
-    {\r
-        GpuMat d_dst;\r
-        downsample(GpuMat(src), d_dst, k);\r
-\r
-        Size dst_gold_size((src.cols + k - 1) / k, (src.rows + k - 1) / k);\r
-        ASSERT_EQ(dst_gold_size.width, d_dst.cols)\r
-            << "rows=" << size.height << ", cols=" << size.width << ", k=" << k;\r
-        ASSERT_EQ(dst_gold_size.height, d_dst.rows)\r
-            << "rows=" << size.height << ", cols=" << size.width << ", k=" << k;\r
-\r
-        Mat dst = d_dst;\r
-        for (int y = 0; y < dst.rows; ++y)\r
-            for (int x = 0; x < dst.cols; ++x)\r
-                ASSERT_EQ(src.at<uchar>(y * k, x * k), dst.at<uchar>(y, x))\r
-                    << "rows=" << size.height << ", cols=" << size.width << ", k=" << k;\r
-    }\r
-}\r
-\r
-TEST(downsample, accuracy_on_32F)\r
-{\r
-    RNG& rng = cvtest::TS::ptr()->get_rng();\r
-    Size size(200 + cvtest::randInt(rng) % 1000, 200 + cvtest::randInt(rng) % 1000);\r
-    Mat src = cvtest::randomMat(rng, size, CV_32F, 0, 1, false);\r
-\r
-    for (int k = 2; k <= 5; ++k)\r
-    {\r
-        GpuMat d_dst;\r
-        downsample(GpuMat(src), d_dst, k);\r
-\r
-        Size dst_gold_size((src.cols + k - 1) / k, (src.rows + k - 1) / k);\r
-        ASSERT_EQ(dst_gold_size.width, d_dst.cols)\r
-            << "rows=" << size.height << ", cols=" << size.width << ", k=" << k;\r
-        ASSERT_EQ(dst_gold_size.height, d_dst.rows)\r
-            << "rows=" << size.height << ", cols=" << size.width << ", k=" << k;\r
-\r
-        Mat dst = d_dst;\r
-        for (int y = 0; y < dst.rows; ++y)\r
-            for (int x = 0; x < dst.cols; ++x)\r
-                ASSERT_FLOAT_EQ(src.at<float>(y * k, x * k), dst.at<float>(y, x))\r
-                    << "rows=" << size.height << ", cols=" << size.width << ", k=" << k;\r
-    }\r
-}\r
index 89c1b27..3a2df60 100644 (file)
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
 #include "test_precomp.hpp"\r
 \r
-int main(int argc, char **argv)\r
+#ifdef HAVE_CUDA\r
+\r
+void print_info()\r
+{\r
+    int deviceCount = cv::gpu::getCudaEnabledDeviceCount();\r
+\r
+    printf("Found %d CUDA devices\n\n", deviceCount);\r
+\r
+    for (int i = 0; i < deviceCount; ++i)\r
+    {\r
+        cv::gpu::DeviceInfo info(i);\r
+        printf("Device %d:\n", i);\r
+        printf("\tName: %s\n", info.name().c_str());\r
+        printf("\tCompute capability version: %d.%d\n", info.majorVersion(), info.minorVersion());\r
+        printf("\tTotal memory: %d Mb\n", static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0));\r
+        printf("\tFree memory: %d Mb\n", static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0));\r
+        if (!info.isCompatible())\r
+            printf("\tThis device is not compatible with current GPU module build\n");\r
+        printf("\n");\r
+    }\r
+    \r
+    printf("GPU module was compiled for next GPU archs:\n");\r
+    printf("\tBIN:%s\n", CUDA_ARCH_BIN);\r
+    printf("\tPTX:%s\n\n", CUDA_ARCH_PTX);\r
+}\r
+\r
+enum OutputLevel\r
+{\r
+    OutputLevelNone,\r
+    OutputLevelCompact,\r
+    OutputLevelFull\r
+};\r
+\r
+extern OutputLevel nvidiaTestOutputLevel;\r
+\r
+int main(int argc, char** argv)\r
 {\r
     cvtest::TS::ptr()->init("gpu");\r
-    ::testing::InitGoogleTest(&argc, argv);\r
-#ifdef HAVE_CUDA\r
+    testing::InitGoogleTest(&argc, argv);\r
+\r
+    cv::CommandLineParser parser(argc, (const char**)argv);\r
+\r
+    std::string outputLevel = parser.get<std::string>("nvtest_output_level", "none");\r
+\r
+    if (outputLevel == "none")\r
+        nvidiaTestOutputLevel = OutputLevelNone;\r
+    else if (outputLevel == "compact")\r
+        nvidiaTestOutputLevel = OutputLevelCompact;\r
+    else if (outputLevel == "full")\r
+        nvidiaTestOutputLevel = OutputLevelFull;\r
+\r
+    print_info();\r
     return RUN_ALL_TESTS();\r
-#else\r
-    std::cerr << "opencv_test_gpu: OpenCV was compiled without GPU support\n";\r
-    return -1;\r
-#endif\r
-}
\ No newline at end of file
+}\r
+\r
+#else // HAVE_CUDA\r
+\r
+int main(int argc, char** argv)\r
+{\r
+    printf("OpenCV was built without CUDA support\n");\r
+    return 0;\r
+}\r
+\r
+#endif // HAVE_CUDA
\ No newline at end of file
diff --git a/modules/gpu/test/test_match_template.cpp b/modules/gpu/test/test_match_template.cpp
deleted file mode 100644 (file)
index b646723..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                           License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other GpuMaterials provided with the distribution.\r
-//\r
-//   * The name of the copyright holders may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or bpied warranties, including, but not limited to, the bpied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-#include <string>\r
-#include <iostream>\r
-\r
-//#define SHOW_TIME\r
-\r
-#ifdef SHOW_TIME\r
-#include <ctime>\r
-#define F(x) x\r
-#else\r
-#define F(x)\r
-#endif\r
-\r
-using namespace cv;\r
-using namespace std;\r
-\r
-struct CV_GpuMatchTemplateTest: cvtest::BaseTest \r
-{\r
-    CV_GpuMatchTemplateTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&\r
-                         gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-        if (!double_ok)\r
-        {\r
-            // For sqrIntegral\r
-            ts->printf(cvtest::TS::CONSOLE, "\nCode and device double support is required (CC >= 1.3)");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\r
-\r
-        Mat image, templ;\r
-        Mat dst_gold;\r
-        gpu::GpuMat dst;\r
-        int n, m, h, w;\r
-        F(clock_t t;)\r
-\r
-        RNG& rng = ts->get_rng();\r
-\r
-        for (int cn = 1; cn <= 4; ++cn)\r
-        {\r
-            F(ts->printf(cvtest::TS::CONSOLE, "cn: %d\n", cn);)\r
-            for (int i = 0; i <= 0; ++i)\r
-            {\r
-                n = rng.uniform(30, 100);\r
-                m = rng.uniform(30, 100);\r
-                h = rng.uniform(5, n - 1);\r
-                w = rng.uniform(5, m - 1);\r
-\r
-                gen(image, n, m, CV_8U, cn);\r
-                gen(templ, h, w, CV_8U, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_SQDIFF);\r
-                F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_SQDIFF);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), 5 * h * w * 1e-4f, "SQDIFF 8U")) return;\r
-\r
-                gen(image, n, m, CV_8U, cn);\r
-                gen(templ, h, w, CV_8U, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_SQDIFF_NORMED);\r
-                F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_SQDIFF_NORMED);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), h * w * 1e-5f, "SQDIFF_NOREMD 8U")) return;\r
-\r
-                gen(image, n, m, CV_8U, cn);\r
-                gen(templ, h, w, CV_8U, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_CCORR);\r
-                F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), 5 * h * w * cn * cn * 1e-5f, "CCORR 8U")) return;\r
-\r
-                gen(image, n, m, CV_8U, cn);\r
-                gen(templ, h, w, CV_8U, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_CCORR_NORMED);\r
-                F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR_NORMED);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), h * w * 1e-6f, "CCORR_NORMED 8U")) return;\r
-\r
-                gen(image, n, m, CV_8U, cn);\r
-                gen(templ, h, w, CV_8U, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_CCOEFF);\r
-                F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCOEFF);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), 5 * h * w * cn * cn * 1e-5f, "CCOEFF 8U")) return;\r
-\r
-                gen(image, n, m, CV_8U, cn);\r
-                gen(templ, h, w, CV_8U, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_CCOEFF_NORMED);\r
-                F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCOEFF_NORMED);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), h * w * 1e-6f, "CCOEFF_NORMED 8U")) return;\r
-\r
-                gen(image, n, m, CV_32F, cn);\r
-                gen(templ, h, w, CV_32F, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_SQDIFF);\r
-                F(cout << "depth: 32F cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_SQDIFF);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), 0.25f * h * w * 1e-5f, "SQDIFF 32F")) return;\r
-\r
-                gen(image, n, m, CV_32F, cn);\r
-                gen(templ, h, w, CV_32F, cn);\r
-                F(t = clock();)\r
-                matchTemplate(image, templ, dst_gold, CV_TM_CCORR);\r
-                F(cout << "depth: 32F cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
-                F(cout << "cpu:" << clock() - t << endl;)\r
-                F(t = clock();)\r
-                gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR);\r
-                F(cout << "gpu_block: " << clock() - t << endl;)\r
-                if (!check(dst_gold, Mat(dst), 0.25f * h * w * 1e-5f, "CCORR 32F")) return;\r
-            }\r
-        }\r
-    }\r
-\r
-    void gen(Mat& a, int rows, int cols, int depth, int cn)\r
-    {\r
-        RNG rng;\r
-        a.create(rows, cols, CV_MAKETYPE(depth, cn));\r
-        if (depth == CV_8U)\r
-            rng.fill(a, RNG::UNIFORM, Scalar::all(1), Scalar::all(10));\r
-        else if (depth == CV_32F)\r
-            rng.fill(a, RNG::UNIFORM, Scalar::all(0.001f), Scalar::all(1.f));\r
-    }\r
-\r
-    bool check(const Mat& a, const Mat& b, float max_err, const string& method="")\r
-    {\r
-        if (a.size() != b.size())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad size, method=%s\n", method.c_str());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-\r
-        //for (int i = 0; i < a.rows; ++i)\r
-        //{\r
-        //    for (int j = 0; j < a.cols; ++j)\r
-        //    {\r
-        //        float a_ = a.at<float>(i, j);\r
-        //        float b_ = b.at<float>(i, j);\r
-        //        if (fabs(a_ - b_) > max_err)\r
-        //        {\r
-        //            ts->printf(cvtest::TS::CONSOLE, "a=%f, b=%f, i=%d, j=%d\n", a_, b_, i, j);\r
-        //            cin.get();\r
-        //        }\r
-        //    }\r
-        //}\r
-\r
-        float err = (float)norm(a, b, NORM_INF);\r
-        if (err > max_err)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad accuracy: %f, method=%s\n", err, method.c_str());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return false;\r
-        }\r
-\r
-        return true;\r
-    }\r
-};\r
-\r
-TEST(matchTemplate, accuracy) { CV_GpuMatchTemplateTest test; test.safe_run(); }\r
-\r
-struct CV_GpuMatchTemplateFindPatternInBlackTest: cvtest::BaseTest \r
-{\r
-    CV_GpuMatchTemplateFindPatternInBlackTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) &&\r
-                         gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-        if (!double_ok)\r
-        {\r
-            // For sqrIntegral\r
-            ts->printf(cvtest::TS::CONSOLE, "\nCode and device double support is required (CC >= 1.3)");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\r
-\r
-        Mat image = imread(std::string(ts->get_data_path()) + "matchtemplate/black.png");\r
-        if (image.empty())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "can't open file '%s'", (std::string(ts->get_data_path())\r
-                                                               + "matchtemplate/black.png").c_str());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-            return;\r
-        }\r
-\r
-        Mat pattern = imread(std::string(ts->get_data_path()) + "matchtemplate/cat.png");\r
-        if (pattern.empty())\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "can't open file '%s'", (std::string(ts->get_data_path())\r
-                                                               + "matchtemplate/cat.png").c_str());\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-            return;\r
-        }\r
-\r
-        gpu::GpuMat d_image(image);\r
-        gpu::GpuMat d_pattern(pattern);\r
-        gpu::GpuMat d_result;\r
-\r
-        double maxValue;\r
-        Point maxLoc;\r
-        Point maxLocGold(284, 12);\r
-\r
-        gpu::matchTemplate(d_image, d_pattern, d_result, CV_TM_CCOEFF_NORMED);\r
-        gpu::minMaxLoc(d_result, NULL, &maxValue, NULL, &maxLoc );\r
-        if (maxLoc != maxLocGold)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad match (CV_TM_CCOEFF_NORMED): %d %d, must be at: %d %d",\r
-                       maxLoc.x, maxLoc.y, maxLocGold.x, maxLocGold.y);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return;\r
-        }\r
-\r
-        gpu::matchTemplate(d_image, d_pattern, d_result, CV_TM_CCORR_NORMED);\r
-        gpu::minMaxLoc(d_result, NULL, &maxValue, NULL, &maxLoc );\r
-        if (maxLoc != maxLocGold)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "bad match (CV_TM_CCORR_NORMED): %d %d, must be at: %d %d",\r
-                       maxLoc.x, maxLoc.y, maxLocGold.x, maxLocGold.y);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return;\r
-        }\r
-    }\r
-};\r
-\r
-TEST(matchTemplate, find_pattern_in_black) { CV_GpuMatchTemplateFindPatternInBlackTest test; test.safe_run(); }\r
diff --git a/modules/gpu/test/test_matop.cpp b/modules/gpu/test/test_matop.cpp
new file mode 100644 (file)
index 0000000..470306d
--- /dev/null
@@ -0,0 +1,614 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                           License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other GpuMaterials provided with the distribution.\r
+//\r
+//   * The name of the copyright holders may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or bpied warranties, including, but not limited to, the bpied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "test_precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// merge\r
+\r
+struct Merge : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    std::vector<cv::Mat> src;\r
+\r
+    cv::Mat dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        int depth = CV_MAT_DEPTH(type);\r
+        int num_channels = CV_MAT_CN(type);\r
+        src.reserve(num_channels);\r
+        for (int i = 0; i < num_channels; ++i)\r
+            src.push_back(cv::Mat(size, depth, cv::Scalar::all(i))); \r
+\r
+        cv::merge(src, dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Merge, Accuracy)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        std::vector<cv::gpu::GpuMat> dev_src;\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        for (size_t i = 0; i < src.size(); ++i)\r
+            dev_src.push_back(cv::gpu::GpuMat(src[i]));\r
+\r
+        cv::gpu::merge(dev_src, dev_dst); \r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, Merge, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(all_types())));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// split\r
+\r
+struct Split : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    std::vector<cv::Mat> dst_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src.create(size, type);\r
+        src.setTo(cv::Scalar(1.0, 2.0, 3.0, 4.0));\r
+        cv::split(src, dst_gold);\r
+    }\r
+};\r
+\r
+TEST_P(Split, Accuracy)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    std::vector<cv::Mat> dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        std::vector<cv::gpu::GpuMat> dev_dst;\r
+        cv::gpu::split(cv::gpu::GpuMat(src), dev_dst);\r
+\r
+        dst.resize(dev_dst.size());\r
+        for (size_t i = 0; i < dev_dst.size(); ++i)\r
+            dev_dst[i].download(dst[i]);\r
+    );\r
+\r
+    ASSERT_EQ(dst_gold.size(), dst.size());\r
+\r
+    for (size_t i = 0; i < dst_gold.size(); ++i)\r
+    {\r
+        EXPECT_MAT_NEAR(dst_gold[i], dst[i], 0.0);\r
+    }\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, Split, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(all_types())));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// split_merge_consistency\r
+\r
+struct SplitMerge : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat orig;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        orig.create(size, type);\r
+        orig.setTo(cv::Scalar(1.0, 2.0, 3.0, 4.0));\r
+    }\r
+};\r
+\r
+TEST_P(SplitMerge, Consistency)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat final;\r
+\r
+    ASSERT_NO_THROW(\r
+        std::vector<cv::gpu::GpuMat> dev_vec;\r
+        cv::gpu::GpuMat dev_final;\r
+\r
+        cv::gpu::split(cv::gpu::GpuMat(orig), dev_vec);    \r
+        cv::gpu::merge(dev_vec, dev_final);\r
+\r
+        dev_final.download(final);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(orig, final, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, SplitMerge, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(all_types())));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// setTo\r
+\r
+struct SetTo : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat mat_gold;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        mat_gold.create(size, type);\r
+    }\r
+};\r
+\r
+TEST_P(SetTo, Zero)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    static cv::Scalar zero = cv::Scalar::all(0);\r
+\r
+    cv::Mat mat;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_mat(mat_gold);\r
+\r
+        mat_gold.setTo(zero);\r
+        dev_mat.setTo(zero);\r
+\r
+        dev_mat.download(mat);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(mat_gold, mat, 0.0);\r
+}\r
+\r
+TEST_P(SetTo, SameVal)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    static cv::Scalar s = cv::Scalar::all(1);\r
+\r
+    cv::Mat mat;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_mat(mat_gold);\r
+\r
+        mat_gold.setTo(s);\r
+        dev_mat.setTo(s);\r
+\r
+        dev_mat.download(mat);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(mat_gold, mat, 0.0);\r
+}\r
+\r
+TEST_P(SetTo, DifferentVal)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    static cv::Scalar s = cv::Scalar(1, 2, 3, 4);\r
+\r
+    cv::Mat mat;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_mat(mat_gold);\r
+\r
+        mat_gold.setTo(s);\r
+        dev_mat.setTo(s);\r
+\r
+        dev_mat.download(mat);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(mat_gold, mat, 0.0);\r
+}\r
+\r
+TEST_P(SetTo, Masked)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    static cv::Scalar s = cv::Scalar(1, 2, 3, 4);\r
+\r
+    cv::Mat mat;\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+    cv::Mat mask = cvtest::randomMat(rng, mat.size(), CV_8UC1, 0.0, 1.5, false);\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_mat(mat_gold);\r
+\r
+        mat_gold.setTo(s, mask);\r
+        dev_mat.setTo(s, cv::gpu::GpuMat(mask));\r
+\r
+        dev_mat.download(mat);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(mat_gold, mat, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(all_types())));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// copyTo\r
+\r
+struct CopyTo : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int type;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        type = std::tr1::get<1>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, type, 0.0, 127.0, false);\r
+    }\r
+};\r
+\r
+TEST_P(CopyTo, WithoutMask)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst_gold;\r
+    src.copyTo(dst_gold);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_src(src);\r
+\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        dev_src.copyTo(dev_dst);\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+TEST_P(CopyTo, Masked)\r
+{\r
+    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(type);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    cv::Mat mask = cvtest::randomMat(rng, src.size(), CV_8UC1, 0.0, 1.5, false);\r
+\r
+    cv::Mat dst_gold;\r
+    src.copyTo(dst_gold, mask);\r
+\r
+    cv::Mat dst;\r
+\r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_src(src);\r
+\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        dev_src.copyTo(dev_dst, cv::gpu::GpuMat(mask));\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, CopyTo, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(all_types())));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// convertTo\r
+\r
+struct ConvertTo : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, int> >\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+    int depth1;\r
+    int depth2;\r
+\r
+    cv::Size size;\r
+    cv::Mat src;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = std::tr1::get<0>(GetParam());\r
+        depth1 = std::tr1::get<1>(GetParam());\r
+        depth2 = std::tr1::get<2>(GetParam());\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+        \r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
+\r
+        src = cvtest::randomMat(rng, size, depth1, 0.0, 127.0, false);\r
+    }\r
+};\r
+\r
+TEST_P(ConvertTo, WithoutScaling)\r
+{\r
+    if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(depth1);\r
+    PRINT_TYPE(depth2);\r
+    PRINT_PARAM(size);\r
+\r
+    cv::Mat dst_gold;\r
+    src.convertTo(dst_gold, depth2);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_src(src);\r
+\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        dev_src.convertTo(dev_dst, depth2);\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+TEST_P(ConvertTo, WithScaling)\r
+{\r
+    if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))\r
+        return;\r
+\r
+    PRINT_PARAM(devInfo);\r
+    PRINT_TYPE(depth1);\r
+    PRINT_TYPE(depth2);\r
+    PRINT_PARAM(size);\r
+    \r
+    cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+    const double a = rng.uniform(0.0, 1.0);\r
+    const double b = rng.uniform(-10.0, 10.0);\r
+    \r
+    PRINT_PARAM(a);\r
+    PRINT_PARAM(b);\r
+\r
+    cv::Mat dst_gold;\r
+    src.convertTo(dst_gold, depth2, a, b);\r
+\r
+    cv::Mat dst;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::GpuMat dev_src(src);\r
+\r
+        cv::gpu::GpuMat dev_dst;\r
+\r
+        dev_src.convertTo(dev_dst, depth2, a, b);\r
+\r
+        dev_dst.download(dst);\r
+    );\r
+\r
+    const double eps = depth2 < CV_32F ? 1 : 1e-4;\r
+\r
+    EXPECT_MAT_NEAR(dst_gold, dst, eps);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine(\r
+                        testing::ValuesIn(devices()), \r
+                        testing::ValuesIn(types(CV_8U, CV_64F, 1, 1)), \r
+                        testing::ValuesIn(types(CV_8U, CV_64F, 1, 1))));\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+// async\r
+\r
+struct Async : testing::TestWithParam<cv::gpu::DeviceInfo>\r
+{\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    cv::gpu::CudaMem src;\r
+\r
+    cv::Mat dst_gold0;\r
+    cv::Mat dst_gold1;\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+        cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
+\r
+        int rows = rng.uniform(100, 200);\r
+        int cols = rng.uniform(100, 200);\r
+\r
+        src = cv::gpu::CudaMem(cv::Mat::zeros(rows, cols, CV_8UC1));        \r
+\r
+        dst_gold0 = cv::Mat(rows, cols, CV_8UC1, cv::Scalar::all(255));\r
+        dst_gold1 = cv::Mat(rows, cols, CV_8UC1, cv::Scalar::all(128));\r
+    }\r
+};\r
+\r
+TEST_P(Async, Accuracy)\r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    cv::Mat dst0, dst1;\r
+    \r
+    ASSERT_NO_THROW(\r
+        cv::gpu::CudaMem cpudst0;\r
+        cv::gpu::CudaMem cpudst1;\r
+\r
+        cv::gpu::GpuMat gpusrc;\r
+        cv::gpu::GpuMat gpudst0;\r
+        cv::gpu::GpuMat gpudst1(src.rows, src.cols, CV_8UC1);\r
+\r
+        cv::gpu::Stream stream0;\r
+        cv::gpu::Stream stream1;\r
+\r
+        stream0.enqueueUpload(src, gpusrc);\r
+        cv::gpu::bitwise_not(gpusrc, gpudst0, cv::gpu::GpuMat(), stream0);\r
+        stream0.enqueueDownload(gpudst0, cpudst0);\r
+\r
+        stream1.enqueueMemSet(gpudst1, cv::Scalar::all(128));\r
+        stream1.enqueueDownload(gpudst1, cpudst1);\r
+\r
+        stream0.waitForCompletion();\r
+        stream1.waitForCompletion();\r
+\r
+        dst0 = cpudst0.createMatHeader();\r
+        dst1 = cpudst1.createMatHeader();\r
+    );\r
+\r
+    EXPECT_MAT_NEAR(dst_gold0, dst0, 0.0);\r
+    EXPECT_MAT_NEAR(dst_gold1, dst1, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(MatOp, Async, testing::ValuesIn(devices()));\r
+\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_meanshift.cpp b/modules/gpu/test/test_meanshift.cpp
deleted file mode 100644 (file)
index b297b98..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-#include <iostream>\r
-#include <string>\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-\r
-\r
-struct CV_GpuMeanShiftTest : public cvtest::BaseTest\r
-{\r
-    CV_GpuMeanShiftTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
-        if (!cc12_ok)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nCompute capability 1.2 is required");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\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;       \r
-        \r
-        if (cv::gpu::TargetArchs::builtWith(cv::gpu::FEATURE_SET_COMPUTE_20) &&\r
-            cv::gpu::DeviceInfo().supports(cv::gpu::FEATURE_SET_COMPUTE_20))\r
-            img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");\r
-        else\r
-            img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result_CC1X.png");\r
-\r
-        if (img.empty() || img_template.empty())\r
-        {\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-            return;\r
-        }\r
-\r
-        cv::Mat rgba;\r
-        cvtColor(img, rgba, CV_BGR2BGRA);\r
-\r
-\r
-        cv::gpu::GpuMat res;\r
-        cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );\r
-\r
-        if (res.type() != CV_8UC4)\r
-        {\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return;\r
-        }\r
-\r
-        cv::Mat result;\r
-        res.download(result);\r
-\r
-        uchar maxDiff = 0;\r
-        for (int j = 0; j < result.rows; ++j)\r
-        {\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
-                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(cvtest::TS::LOG, "\nMeanShift maxDiff = %d\n", maxDiff);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\r
-\r
-        ts->set_failed_test_info(cvtest::TS::OK);\r
-    }\r
-\r
-};\r
-\r
-TEST(meanShift, accuracy) { CV_GpuMeanShiftTest test; test.safe_run(); }\r
-\r
-struct CV_GpuMeanShiftProcTest : public cvtest::BaseTest\r
-{\r
-    CV_GpuMeanShiftProcTest() {}\r
-\r
-    void run(int)\r
-    {\r
-        bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
-        if (!cc12_ok)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nCompute capability 1.2 is required");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\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
-\r
-        if (img.empty())\r
-        {\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-            return;\r
-        }\r
-\r
-        cv::Mat rgba;\r
-        cvtColor(img, rgba, CV_BGR2BGRA);\r
-\r
-        cv::gpu::GpuMat h_rmap_filtered;\r
-        cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), h_rmap_filtered, spatialRad, colorRad );\r
-\r
-        cv::gpu::GpuMat d_rmap;\r
-        cv::gpu::GpuMat d_spmap;\r
-        cv::gpu::meanShiftProc( cv::gpu::GpuMat(rgba), d_rmap, d_spmap, spatialRad, colorRad );\r
-\r
-        if (d_rmap.type() != CV_8UC4)\r
-        {\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            return;\r
-        }\r
-\r
-        cv::Mat rmap_filtered;\r
-        h_rmap_filtered.download(rmap_filtered);\r
-\r
-        cv::Mat rmap;\r
-        d_rmap.download(rmap);\r
-\r
-        uchar maxDiff = 0;\r
-        for (int j = 0; j < rmap_filtered.rows; ++j)\r
-        {\r
-            const uchar* res_line = rmap_filtered.ptr<uchar>(j);\r
-            const uchar* ref_line = rmap.ptr<uchar>(j);\r
-\r
-            for (int i = 0; i < rmap_filtered.cols; ++i)\r
-            {\r
-                for (int k = 0; k < 3; ++k)\r
-                {\r
-                    const uchar& ch1 = res_line[rmap_filtered.channels()*i + k];\r
-                    const uchar& ch2 = ref_line[rmap.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(cvtest::TS::LOG, "\nMeanShiftProc maxDiff = %d\n", maxDiff);\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\r
-\r
-        cv::Mat spmap;\r
-        d_spmap.download(spmap);\r
-\r
-        cv::Mat spmap_template;\r
-        cv::FileStorage fs;\r
-\r
-        if (cv::gpu::TargetArchs::builtWith(cv::gpu::FEATURE_SET_COMPUTE_20) &&\r
-            cv::gpu::DeviceInfo().supports(cv::gpu::FEATURE_SET_COMPUTE_20))\r
-            fs.open(std::string(ts->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);\r
-        else\r
-            fs.open(std::string(ts->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);\r
-        fs["spmap"] >> spmap_template;\r
-\r
-        for (int y = 0; y < spmap.rows; ++y) {\r
-            for (int x = 0; x < spmap.cols; ++x) {\r
-                cv::Point_<short> expected = spmap_template.at<cv::Point_<short> >(y, x);\r
-                cv::Point_<short> actual = spmap.at<cv::Point_<short> >(y, x);\r
-                int diff = (expected - actual).dot(expected - actual);\r
-                if (actual != expected) {\r
-                    ts->printf(cvtest::TS::LOG, "\nMeanShiftProc SpMap is bad, diff=%d\n", diff);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-                    return;\r
-                }\r
-            }\r
-        }\r
-\r
-        ts->set_failed_test_info(cvtest::TS::OK);\r
-    }\r
-\r
-};\r
-\r
-TEST(meanShiftProc, accuracy) { CV_GpuMeanShiftProcTest test; test.safe_run(); }\r
diff --git a/modules/gpu/test/test_mssegmentation.cpp b/modules/gpu/test/test_mssegmentation.cpp
deleted file mode 100644 (file)
index b649147..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <string>\r
-#include <iosfwd>\r
-#include "test_precomp.hpp"\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-struct CV_GpuMeanShiftSegmentationTest : public cvtest::BaseTest {\r
-    CV_GpuMeanShiftSegmentationTest() {}\r
-\r
-    void run(int) \r
-    {\r
-        bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
-        if (!cc12_ok)\r
-        {\r
-            ts->printf(cvtest::TS::CONSOLE, "\nCompute capability 1.2 is required");\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-            return;\r
-        }\r
-\r
-        Mat img_rgb = imread(string(ts->get_data_path()) + "meanshift/cones.png");\r
-        if (img_rgb.empty())\r
-        {\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-            return;\r
-        }\r
-\r
-        Mat img;\r
-        cvtColor(img_rgb, img, CV_BGR2BGRA);\r
-\r
-\r
-        for (int minsize = 0; minsize < 2000; minsize = (minsize + 1) * 4)\r
-        {\r
-            stringstream path;\r
-            path << ts->get_data_path() << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;\r
-            if (TargetArchs::builtWith(FEATURE_SET_COMPUTE_20) && DeviceInfo().supports(FEATURE_SET_COMPUTE_20))\r
-                path << ".png";\r
-            else\r
-                path << "_CC1X.png";\r
-\r
-            Mat dst;\r
-            meanShiftSegmentation((GpuMat)img, dst, 10, 10, minsize);\r
-            Mat dst_rgb;\r
-            cvtColor(dst, dst_rgb, CV_BGRA2BGR);\r
-\r
-            //imwrite(path.str(), dst_rgb);\r
-            Mat dst_ref = imread(path.str());\r
-            if (dst_ref.empty())\r
-            {\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-                return;\r
-            }\r
-            if (CheckSimilarity(dst_rgb, dst_ref, 1e-3f) != cvtest::TS::OK)\r
-            {\r
-                ts->printf(cvtest::TS::LOG, "\ndiffers from image *minsize%d.png\n", minsize);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);\r
-            }\r
-        }\r
-\r
-        ts->set_failed_test_info(cvtest::TS::OK);\r
-    }    \r
-\r
-    int CheckSimilarity(const Mat& m1, const Mat& m2, float max_err)\r
-    {\r
-        Mat diff;\r
-        cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
-\r
-        float err = abs(diff.at<float>(0, 0) - 1.f);\r
-\r
-        if (err > max_err)\r
-            return cvtest::TS::FAIL_INVALID_OUTPUT;\r
-\r
-        return cvtest::TS::OK;\r
-    }\r
-\r
-\r
-};\r
-\r
-\r
-TEST(meanShiftSegmentation, regression) { CV_GpuMeanShiftSegmentationTest test; test.safe_run(); }\r
index 412e5fc..2620dd7 100644 (file)
 //M*/\r
 \r
 #include "test_precomp.hpp"\r
-#include "cvconfig.h"\r
 \r
-class CV_NVidiaTestsCaller : public cvtest::BaseTest\r
+#ifdef HAVE_CUDA\r
+\r
+enum OutputLevel\r
+{\r
+    OutputLevelNone,\r
+    OutputLevelCompact,\r
+    OutputLevelFull\r
+};\r
+\r
+bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NPPST_Resize(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NPPST_Vector_Operations(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NPPST_Transpose(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NCV_Vector_Operations(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NCV_Haar_Cascade_Loader(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NCV_Haar_Cascade_Application(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NCV_Hypotheses_Filtration(const std::string& test_data_path, OutputLevel outputLevel);\r
+bool nvidia_NCV_Visualization(const std::string& test_data_path, OutputLevel outputLevel);\r
+\r
+struct NVidiaTest : testing::TestWithParam<cv::gpu::DeviceInfo>\r
 {\r
-public:\r
-    CV_NVidiaTestsCaller() {}\r
-    virtual ~CV_NVidiaTestsCaller() {}\r
-\r
-protected:\r
-    \r
-       void run( int )\r
-       {   \r
-               ;\r
-\r
-#if defined(HAVE_CUDA)\r
-               bool main_nvidia(const std::string&);\r
-\r
-               // Invoke all NVIDIA Staging tests and obtain the result\r
-               bool passed = main_nvidia(std::string(ts->get_data_path()) + "haarcascade/");\r
-\r
-               if (passed)\r
-                   ts->set_failed_test_info(cvtest::TS::OK);\r
-               else\r
-                   ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-\r
-#else\r
-               ts->set_failed_test_info(cvtest::TS::SKIPPED);\r
-#endif\r
-       }   \r
+    static std::string path;\r
+\r
+    cv::gpu::DeviceInfo devInfo;\r
+\r
+    static void SetUpTestCase() \r
+    {\r
+        path = std::string(cvtest::TS::ptr()->get_data_path()) + "haarcascade/";\r
+    }\r
+\r
+    virtual void SetUp() \r
+    {\r
+        devInfo = GetParam();\r
+\r
+        cv::gpu::setDevice(devInfo.deviceID());\r
+    }\r
 };\r
 \r
-TEST(NVidia, multitest) { CV_NVidiaTestsCaller test; test.safe_run(); }\r
+std::string NVidiaTest::path;\r
+\r
+struct NPPST : NVidiaTest {};\r
+struct NCV : NVidiaTest {};\r
+\r
+OutputLevel nvidiaTestOutputLevel = OutputLevelNone;\r
+\r
+TEST_P(NPPST, Integral) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NPPST_Integral_Image(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NPPST, SquaredIntegral) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NPPST_Squared_Integral_Image(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NPPST, RectStdDev) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NPPST_RectStdDev(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NPPST, Resize) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NPPST_Resize(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NPPST, VectorOperations) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NPPST_Vector_Operations(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NPPST, Transpose) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NPPST_Transpose(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NCV, VectorOperations) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NCV_Vector_Operations(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NCV, HaarCascadeLoader) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NCV_Haar_Cascade_Loader(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NCV, HaarCascadeApplication) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NCV_Haar_Cascade_Application(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NCV, HypothesesFiltration) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NCV_Hypotheses_Filtration(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+TEST_P(NCV, Visualization) \r
+{\r
+    PRINT_PARAM(devInfo);\r
+\r
+    bool res;\r
+\r
+    ASSERT_NO_THROW(\r
+        res = nvidia_NCV_Visualization(path, nvidiaTestOutputLevel);\r
+    );\r
+\r
+    ASSERT_TRUE(res);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(NVidia, NPPST, testing::ValuesIn(devices()));\r
+INSTANTIATE_TEST_CASE_P(NVidia, NCV, testing::ValuesIn(devices()));\r
+\r
+#endif // HAVE_CUDA\r
diff --git a/modules/gpu/test/test_operator_async_call.cpp b/modules/gpu/test/test_operator_async_call.cpp
deleted file mode 100644 (file)
index 34843c7..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-using namespace cv::gpu;
-
-struct CV_AsyncGpuMatTest : public cvtest::BaseTest
-{
-    CV_AsyncGpuMatTest() {}
-
-    void run(int)
-    {
-        CudaMem src(Mat::zeros(100, 100, CV_8UC1));
-
-        GpuMat gpusrc;
-        GpuMat gpudst0, gpudst1(100, 100, CV_8UC1);
-
-        CudaMem cpudst0;
-        CudaMem cpudst1;
-
-        Stream stream0, stream1;
-
-        stream0.enqueueUpload(src, gpusrc);
-        bitwise_not(gpusrc, gpudst0, GpuMat(), stream0);
-        stream0.enqueueDownload(gpudst0, cpudst0);
-
-        stream1.enqueueMemSet(gpudst1, Scalar::all(128));
-        stream1.enqueueDownload(gpudst1, cpudst1);
-
-        stream0.waitForCompletion();
-        stream1.waitForCompletion();
-
-        Mat cpu_gold0(100, 100, CV_8UC1, Scalar::all(255));
-        Mat cpu_gold1(100, 100, CV_8UC1, Scalar::all(128));
-
-        if (norm((Mat)cpudst0, cpu_gold0, NORM_INF) > 0 || norm((Mat)cpudst1, cpu_gold1, NORM_INF) > 0)
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
-        else
-            ts->set_failed_test_info(cvtest::TS::OK);
-    }
-};
-
-TEST(GpuMat, async) { CV_AsyncGpuMatTest test; test.safe_run(); }
diff --git a/modules/gpu/test/test_operator_convert_to.cpp b/modules/gpu/test/test_operator_convert_to.cpp
deleted file mode 100644 (file)
index c5c55b3..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-#include <fstream>
-#include <iterator>
-#include <numeric>
-
-using namespace cv;
-using namespace std;
-using namespace gpu;
-
-class CV_GpuMatOpConvertToTest : public cvtest::BaseTest
-{
-    public:
-        CV_GpuMatOpConvertToTest() {}
-        ~CV_GpuMatOpConvertToTest() {}
-
-    protected:
-        void run(int);
-};
-
-void CV_GpuMatOpConvertToTest::run(int /* start_from */)
-{
-    const Size img_size(67, 35);
-
-    const char* types_str[] = {"CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F"};
-
-    bool passed = true;
-    int lastType = CV_32F;
-
-    if (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))
-        lastType = CV_64F;
-
-    for (int i = 0; i <= lastType && passed; ++i)
-    {
-        for (int j = 0; j <= lastType && passed; ++j)
-        {
-            for (int c = 1; c < 5 && passed; ++c)
-            {
-                const int src_type = CV_MAKETYPE(i, c);
-                const int dst_type = j;
-
-                cv::RNG& rng = ts->get_rng();
-
-                Mat cpumatsrc(img_size, src_type);
-                rng.fill(cpumatsrc, RNG::UNIFORM, Scalar::all(0), Scalar::all(300));
-
-                GpuMat gpumatsrc(cpumatsrc);
-                Mat cpumatdst;
-                GpuMat gpumatdst;
-
-                cpumatsrc.convertTo(cpumatdst, dst_type, 0.5, 3.0);
-                gpumatsrc.convertTo(gpumatdst, dst_type, 0.5, 3.0);
-
-                double r = norm(cpumatdst, (Mat)gpumatdst, NORM_INF);
-                if (r > 1)
-                {
-                    ts->printf(cvtest::TS::LOG,
-                               "\nFAILED: SRC_TYPE=%sC%d DST_TYPE=%s NORM = %f\n",
-                               types_str[i], c, types_str[j], r);
-                    passed = false;
-                }
-            }
-        }
-    }
-
-    ts->set_failed_test_info(passed ? cvtest::TS::OK : cvtest::TS::FAIL_GENERIC);
-}
-
-TEST(GpuMat_convertTo, accuracy) { CV_GpuMatOpConvertToTest test; test.safe_run(); }
diff --git a/modules/gpu/test/test_operator_copy_to.cpp b/modules/gpu/test/test_operator_copy_to.cpp
deleted file mode 100644 (file)
index dc1e228..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include <fstream>
-#include <iterator>
-#include <numeric>
-#include <iomanip> // for  cout << setw()
-
-using namespace cv;
-using namespace std;
-using namespace gpu;
-
-class CV_GpuMatOpCopyToTest : public cvtest::BaseTest
-{
-    public:
-        CV_GpuMatOpCopyToTest()
-        {
-            rows = 234;
-            cols = 123;
-        }
-        ~CV_GpuMatOpCopyToTest() {}
-
-    protected:
-        void run(int);
-        template <typename T>
-        void print_mat(const T & mat, const std::string & name) const;
-        bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
-
-    private:
-        int rows;
-        int cols;
-};
-
-template<typename T>
-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)
-{
-    Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
-    GpuMat gmat(cmat);
-
-    Mat cpumask(cpumat.size(), CV_8U);
-
-    cv::RNG& rng = ts->get_rng();
-
-    rng.fill(cpumask, RNG::NORMAL, Scalar::all(0), Scalar::all(127));
-
-    threshold(cpumask, cpumask, 0, 127, THRESH_BINARY);
-
-    GpuMat gpumask(cpumask);
-
-    //int64 time = getTickCount();
-    cpumat.copyTo(cmat, cpumask);
-    //int64 time1 = getTickCount();
-    gpumat.copyTo(gmat, gpumask);
-    //int64 time2 = getTickCount();
-
-    //std::cout << "\ntime cpu: " << std::fixed << std::setprecision(12) << 1.0 / double((time1 - time)  / (double)getTickFrequency());
-    //std::cout << "\ntime gpu: " << std::fixed << std::setprecision(12) << 1.0 / double((time2 - time1) / (double)getTickFrequency());
-    //std::cout << "\n";
-
-#ifdef PRINT_MATRIX
-    print_mat(cmat, "cpu mat");
-    print_mat(gmat, "gpu mat");
-    print_mat(cpumask, "cpu mask");
-    print_mat(gpumask, "gpu mask");
-    cv::waitKey(0);
-#endif
-
-    double ret = norm(cmat, (Mat)gmat);
-
-    if (ret < 1.0)
-        return true;
-    else
-    {
-        ts->printf(cvtest::TS::LOG, "\nNorm: %f\n", ret);
-        return false;
-    }
-}
-
-void CV_GpuMatOpCopyToTest::run( int /* start_from */)
-{
-    bool is_test_good = true;
-
-    int lastType = CV_32F;
-
-    if (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))
-        lastType = CV_64F;
-
-    for (int i = 0 ; i <= lastType; i++)
-    {
-        Mat cpumat(rows, cols, i);
-        cpumat.setTo(Scalar::all(127));
-
-        GpuMat gpumat(cpumat);
-
-        is_test_good &= compare_matrix(cpumat, gpumat);
-    }
-
-    if (is_test_good == true)
-        ts->set_failed_test_info(cvtest::TS::OK);
-    else
-        ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
-}
-
-TEST(GpuMat_copyTo, accuracy) { CV_GpuMatOpCopyToTest test; test.safe_run(); }
diff --git a/modules/gpu/test/test_operator_set_to.cpp b/modules/gpu/test/test_operator_set_to.cpp
deleted file mode 100644 (file)
index f09f411..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv;
-using namespace std;
-using namespace gpu;
-
-class CV_GpuMatOpSetToTest : public cvtest::BaseTest
-{
-public:
-    CV_GpuMatOpSetToTest();
-    ~CV_GpuMatOpSetToTest() {}
-
-protected:
-    void run(int);
-
-    bool testSetTo(cv::Mat& cpumat, gpu::GpuMat& gpumat, const cv::Mat& cpumask = cv::Mat(), const cv::gpu::GpuMat& gpumask = cv::gpu::GpuMat());
-
-private:
-    int rows;
-    int cols;
-    Scalar s;
-};
-
-CV_GpuMatOpSetToTest::CV_GpuMatOpSetToTest()
-{
-    rows = 35;
-    cols = 67;
-
-    s.val[0] = 127.0;
-    s.val[1] = 127.0;
-    s.val[2] = 127.0;
-    s.val[3] = 127.0;
-}
-
-bool CV_GpuMatOpSetToTest::testSetTo(cv::Mat& cpumat, gpu::GpuMat& gpumat, const cv::Mat& cpumask, const cv::gpu::GpuMat& gpumask)
-{
-    cpumat.setTo(s, cpumask);
-    gpumat.setTo(s, gpumask);
-
-    double ret = norm(cpumat, (Mat)gpumat, NORM_INF);
-
-    if (ret < std::numeric_limits<double>::epsilon())
-        return true;
-    else
-    {
-        ts->printf(cvtest::TS::LOG, "\nNorm: %f\n", ret);
-        return false;
-    }
-}
-
-void CV_GpuMatOpSetToTest::run( int /* start_from */)
-{
-    bool is_test_good = true;
-
-    cv::Mat cpumask(rows, cols, CV_8UC1);
-    cv::RNG& rng = ts->get_rng();
-    rng.fill(cpumask, RNG::UNIFORM, cv::Scalar::all(0.0), cv::Scalar(1.5));
-    cv::gpu::GpuMat gpumask(cpumask);
-
-    int lastType = CV_32F;
-
-    if (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))
-        lastType = CV_64F;
-
-    for (int i = 0; i <= lastType; i++)
-    {
-        for (int cn = 1; cn <= 4; ++cn)
-        {
-            int mat_type = CV_MAKETYPE(i, cn);
-            Mat cpumat(rows, cols, mat_type, Scalar::all(0));
-            GpuMat gpumat(cpumat);
-            is_test_good &= testSetTo(cpumat, gpumat, cpumask, gpumask);
-        }
-    }
-
-    if (is_test_good == true)
-        ts->set_failed_test_info(cvtest::TS::OK);
-    else
-        ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
-}
-
-TEST(GpuMat_setTo, accuracy) { CV_GpuMatOpSetToTest test; test.safe_run(); }
index 26a8f3f..34acf2a 100644 (file)
@@ -1 +1,42 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
 #include "test_precomp.hpp"\r
index f114994..5ddafaa 100644 (file)
@@ -1,13 +1,62 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                        Intel License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of Intel Corporation may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
 #ifndef __OPENCV_TEST_PRECOMP_HPP__\r
 #define __OPENCV_TEST_PRECOMP_HPP__\r
 \r
-#include <iostream>\r
+#include <cmath>\r
+#include <cstdio>\r
+#include <fstream>\r
+#include <sstream>\r
 #include <limits>\r
+#include <string>\r
+#include <algorithm>\r
+#include <iterator>\r
 #include "cvconfig.h"\r
 #include "opencv2/core/core.hpp"\r
 #include "opencv2/highgui/highgui.hpp"\r
 #include "opencv2/calib3d/calib3d.hpp"\r
+#include "opencv2/imgproc/imgproc.hpp"\r
 #include "opencv2/ts/ts.hpp"\r
 #include "opencv2/gpu/gpu.hpp"\r
+#include "test_gpu_base.hpp"\r
 \r
 #endif\r
diff --git a/modules/gpu/test/test_split_merge.cpp b/modules/gpu/test/test_split_merge.cpp
deleted file mode 100644 (file)
index ca5f4a9..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                           License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other GpuMaterials provided with the distribution.\r
-//\r
-//   * The name of the copyright holders may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or bpied warranties, including, but not limited to, the bpied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-\r
-using namespace std;\r
-using namespace cv;\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Merge\r
-\r
-struct CV_MergeTest : public cvtest::BaseTest\r
-{\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
-};\r
-\r
-\r
-void CV_MergeTest::can_merge(size_t rows, size_t cols)\r
-{\r
-    bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
-                     gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-    size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
-    for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
-        for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
-        {\r
-            vector<Mat> src;\r
-            for (size_t i = 0; i < num_channels; ++i)\r
-                src.push_back(Mat(rows, cols, depth, Scalar::all(static_cast<double>(i))));\r
-            \r
-            Mat dst(rows, cols, CV_MAKETYPE(depth, num_channels));   \r
-\r
-            cv::merge(src, dst);   \r
-\r
-            vector<gpu::GpuMat> dev_src;\r
-            for (size_t i = 0; i < num_channels; ++i)\r
-                dev_src.push_back(gpu::GpuMat(src[i]));\r
-\r
-            gpu::GpuMat dev_dst(rows, cols, CV_MAKETYPE(depth, num_channels));\r
-            cv::gpu::merge(dev_src, dev_dst); \r
-\r
-            Mat host_dst = dev_dst;\r
-\r
-            double err = norm(dst, host_dst, NORM_INF);\r
-\r
-            if (err > 1e-3)\r
-            {\r
-                //ts->printf(cvtest::TS::CONSOLE, "\nNorm: %f\n", err);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Depth: %d\n", depth);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Rows: %d\n", rows);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Cols: %d\n", cols);\r
-                //ts->printf(cvtest::TS::CONSOLE, "NumChannels: %d\n", num_channels);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
-        }\r
-}\r
-\r
-\r
-void CV_MergeTest::can_merge_submatrixes(size_t rows, size_t cols)\r
-{\r
-    bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
-                     gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-    size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
-    for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
-        for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
-        {\r
-            vector<Mat> src;\r
-            for (size_t i = 0; i < num_channels; ++i) \r
-            {\r
-                Mat m(rows * 2, cols * 2, depth, Scalar::all(static_cast<double>(i)));\r
-                src.push_back(m(Range(rows / 2, rows / 2 + rows), Range(cols / 2, cols / 2 + cols)));\r
-            }\r
-\r
-            Mat dst(rows, cols, CV_MAKETYPE(depth, num_channels));   \r
-\r
-            cv::merge(src, dst);   \r
-\r
-            vector<gpu::GpuMat> dev_src;\r
-            for (size_t i = 0; i < num_channels; ++i)\r
-                dev_src.push_back(gpu::GpuMat(src[i]));\r
-\r
-            gpu::GpuMat dev_dst(rows, cols, CV_MAKETYPE(depth, num_channels));\r
-            cv::gpu::merge(dev_src, dev_dst);\r
-\r
-            Mat host_dst = dev_dst;\r
-\r
-            double err = norm(dst, host_dst, NORM_INF);\r
-\r
-            if (err > 1e-3)\r
-            {\r
-                //ts->printf(cvtest::TS::CONSOLE, "\nNorm: %f\n", err);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Depth: %d\n", depth);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Rows: %d\n", rows);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Cols: %d\n", cols);\r
-                //ts->printf(cvtest::TS::CONSOLE, "NumChannels: %d\n", num_channels);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
-        }\r
-}\r
-\r
-void CV_MergeTest::run(int) \r
-{\r
-    can_merge(1, 1);\r
-    can_merge(1, 7);\r
-    can_merge(53, 7);\r
-    can_merge_submatrixes(1, 1);\r
-    can_merge_submatrixes(1, 7);\r
-    can_merge_submatrixes(53, 7);\r
-}\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Split\r
-\r
-struct CV_SplitTest : public cvtest::BaseTest\r
-{\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
-};\r
-\r
-void CV_SplitTest::can_split(size_t rows, size_t cols)\r
-{\r
-    bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
-                     gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-    size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
-    for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
-        for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
-        {\r
-            Mat src(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0));   \r
-            vector<Mat> dst;\r
-            cv::split(src, dst);   \r
-\r
-            gpu::GpuMat dev_src(src);\r
-            vector<gpu::GpuMat> dev_dst;\r
-            cv::gpu::split(dev_src, dev_dst);\r
-\r
-            if (dev_dst.size() != dst.size())\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "Bad output sizes");\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            }\r
-\r
-            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);\r
-\r
-                if (err > 1e-3)\r
-                {\r
-                    //ts->printf(cvtest::TS::CONSOLE, "\nNorm: %f\n", err);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "Depth: %d\n", depth);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "Rows: %d\n", rows);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "Cols: %d\n", cols);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "NumChannels: %d\n", num_channels);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-            }\r
-        }\r
-}\r
-\r
-void CV_SplitTest::can_split_submatrix(size_t rows, size_t cols)\r
-{\r
-    bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
-                     gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-    size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
-    for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
-        for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
-        {\r
-            Mat src_data(rows * 2, cols * 2, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0));   \r
-            Mat src(src_data(Range(rows / 2, rows / 2 + rows), Range(cols / 2, cols / 2 + cols)));\r
-            vector<Mat> dst;\r
-            cv::split(src, dst);   \r
-\r
-            gpu::GpuMat dev_src(src);\r
-            vector<gpu::GpuMat> dev_dst;\r
-            cv::gpu::split(dev_src, dev_dst);\r
-\r
-            if (dev_dst.size() != dst.size())\r
-            {\r
-                ts->printf(cvtest::TS::CONSOLE, "Bad output sizes");\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-            }\r
-\r
-            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);\r
-\r
-                if (err > 1e-3)\r
-                {\r
-                    //ts->printf(cvtest::TS::CONSOLE, "\nNorm: %f\n", err);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "Depth: %d\n", depth);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "Rows: %d\n", rows);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "Cols: %d\n", cols);\r
-                    //ts->printf(cvtest::TS::CONSOLE, "NumChannels: %d\n", num_channels);\r
-                    ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                    return;\r
-                }\r
-            }\r
-        }\r
-}\r
-\r
-void CV_SplitTest::run(int)\r
-{\r
-    can_split(1, 1);\r
-    can_split(1, 7);\r
-    can_split(7, 53);\r
-    can_split_submatrix(1, 1);\r
-    can_split_submatrix(1, 7);\r
-    can_split_submatrix(7, 53);\r
-}\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Split and merge\r
-\r
-struct CV_SplitMergeTest : public cvtest::BaseTest\r
-{\r
-    void can_split_merge(size_t rows, size_t cols);    \r
-    void run(int);\r
-};\r
-\r
-void CV_SplitMergeTest::can_split_merge(size_t rows, size_t cols) {\r
-    bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
-                     gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
-    size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
-    for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
-        for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
-        {\r
-            Mat orig(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0));   \r
-            gpu::GpuMat dev_orig(orig);\r
-            vector<gpu::GpuMat> dev_vec;\r
-            cv::gpu::split(dev_orig, dev_vec);\r
-\r
-            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);\r
-            if (err > 1e-3)\r
-            {\r
-                //ts->printf(cvtest::TS::CONSOLE, "\nNorm: %f\n", err);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Depth: %d\n", depth);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Rows: %d\n", rows);\r
-                //ts->printf(cvtest::TS::CONSOLE, "Cols: %d\n", cols);\r
-                //ts->printf(cvtest::TS::CONSOLE, "NumChannels: %d\n", num_channels);\r
-                ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);\r
-                return;\r
-            }\r
-        }\r
-}\r
-\r
-\r
-void CV_SplitMergeTest::run(int) \r
-{\r
-    can_split_merge(1, 1);\r
-    can_split_merge(1, 7);\r
-    can_split_merge(7, 53);\r
-}\r
-\r
-\r
-TEST(merge, accuracy) { CV_MergeTest test; test.safe_run(); }\r
-TEST(split, accuracy) { CV_SplitTest test; test.safe_run(); }\r
-TEST(split, merge_consistency) { CV_SplitMergeTest test; test.safe_run(); }\r
diff --git a/modules/gpu/test/test_stereo_bm.cpp b/modules/gpu/test/test_stereo_bm.cpp
deleted file mode 100644 (file)
index 7a4806e..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv;
-using namespace cv::gpu;
-
-struct CV_GpuStereoBMTest : public cvtest::BaseTest
-{
-    void run_stress()
-    {                
-        RNG rng;
-
-        for(int i = 0; i < 10; ++i)
-        {
-            int winSize = cvRound(rng.uniform(2, 11)) * 2 + 1;
-
-            for(int j = 0; j < 10; ++j)
-            {
-                int ndisp = cvRound(rng.uniform(5, 32)) * 8;
-
-                for(int s = 0; s < 10; ++s)
-                {
-                    int w =  cvRound(rng.uniform(1024, 2048));
-                    int h =  cvRound(rng.uniform(768, 1152));
-
-                    for(int p = 0; p < 2; ++p)
-                    {
-                        //int winSize = winsz[i];
-                        //int disp = disps[j];
-                        Size imgSize(w, h);//res[s];
-                        int preset = p;
-
-                        printf("Preset = %d, nidsp = %d, winsz = %d, width = %d, height = %d\n", p, ndisp, winSize, imgSize.width, imgSize.height);
-
-                        GpuMat l(imgSize, CV_8U);
-                        GpuMat r(imgSize, CV_8U);
-
-                        GpuMat disparity;
-                        StereoBM_GPU bm(preset, ndisp, winSize);
-                        bm(l, r, disparity);
-
-            
-                    }
-                }
-            }
-        }
-    }
-
-    void run(int )
-    {
-        /*run_stress();
-        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);
-
-        if (img_l.empty() || img_r.empty() || img_reference.empty())
-        {
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
-            return;
-        }
-
-        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((Mat)disp, img_reference, cv::NORM_INF);
-
-        //cv::imwrite(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", disp);
-
-        /*cv::imshow("disp", disp);
-        cv::imshow("img_reference", img_reference);
-
-        cv::Mat diff = (cv::Mat)disp - (cv::Mat)img_reference;
-        cv::imshow("diff", diff);
-        cv::waitKey();*/
-
-        if (norm >= 100)
-        {
-            ts->printf(cvtest::TS::LOG, "\nStereoBM norm = %f\n", norm);
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
-            return;
-        }
-
-        ts->set_failed_test_info(cvtest::TS::OK);
-    }
-};
-
-TEST(StereoBM, regression) { CV_GpuStereoBMTest test; test.safe_run(); }
diff --git a/modules/gpu/test/test_stereo_bm_async.cpp b/modules/gpu/test/test_stereo_bm_async.cpp
deleted file mode 100644 (file)
index f9632dd..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv;
-using namespace std;
-
-struct CV_AsyncStereoBMTest : public cvtest::BaseTest
-{
-    void 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())
-        {
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
-            return;
-        }
-
-        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((Mat)disp, img_reference, cv::NORM_INF);
-
-        if (norm >= 100)
-        {
-            ts->printf(cvtest::TS::LOG, "\nStereoBM norm = %f\n", norm);
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
-            return;
-        }
-
-        ts->set_failed_test_info(cvtest::TS::OK);
-    }
-};
-
-TEST(StereoBM, async) { CV_AsyncStereoBMTest test; test.safe_run(); }
diff --git a/modules/gpu/test/test_stereo_bp.cpp b/modules/gpu/test/test_stereo_bp.cpp
deleted file mode 100644 (file)
index 7788917..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-//  By downloading, copying, installing or using the software you agree to this license.\r
-//  If you do not agree to this license, do not download, install,\r
-//  copy or use the software.\r
-//\r
-//\r
-//                        Intel License Agreement\r
-//                For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-//   * Redistribution's of source code must retain the above copyright notice,\r
-//     this list of conditions and the following disclaimer.\r
-//\r
-//   * Redistribution's in binary form must reproduce the above copyright notice,\r
-//     this list of conditions and the following disclaimer in the documentation\r
-//     and/or other materials provided with the distribution.\r
-//\r
-//   * The name of Intel Corporation may not be used to endorse or promote products\r
-//     derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-\r
-struct CV_GpuStereoBPTest : public cvtest::BaseTest\r
-{\r
-    void run(int)\r
-    {\r
-        cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-        cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");\r
-        cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", 0);\r
-\r
-        if (img_l.empty() || img_r.empty() || img_template.empty())\r
-        {\r
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
-            return;\r
-        }\r
-\r
-        {cv::Mat temp; cv::cvtColor(img_l, temp, CV_BGR2BGRA); cv::swap(temp, img_l);}\r
-        {cv::Mat temp; cv::cvtColor(img_r, temp, CV_BGR2BGRA); cv::swap(temp, img_r);}\r
-\r
-        cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);\r
-        cv::gpu::GpuMat disp;\r
-\r
-        bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);\r
-\r
-        //cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);\r
-\r
-        disp.convertTo(disp, img_template.type());\r
-\r
-        double norm = cv::norm((cv::Mat)disp, img_template, cv::NORM_INF);\r
-           if (norm >= 0.5)\r
-        {\r
-               ts->printf(cvtest::TS::LOG, "\nStereoBP norm = %f\n", norm);\r
-               ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);\r
-               return;\r
-        }\r
-\r
-        ts->set_failed_test_info(cvtest::TS::OK);\r
-    }\r
-};\r
-\r
-TEST(StereoBP, regression) { CV_GpuStereoBPTest test; test.safe_run(); }\r
diff --git a/modules/gpu/test/test_stereo_csbp.cpp b/modules/gpu/test/test_stereo_csbp.cpp
deleted file mode 100644 (file)
index a2f794f..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-struct CV_GpuStereoCSBPTest : public cvtest::BaseTest
-{
-    void run(int )
-    {
-        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;
-
-        if (cv::gpu::TargetArchs::builtWith(cv::gpu::FEATURE_SET_COMPUTE_20) &&
-            cv::gpu::DeviceInfo().supports(cv::gpu::FEATURE_SET_COMPUTE_20))
-            img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
-        else
-            img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp_CC1X.png", CV_LOAD_IMAGE_GRAYSCALE);
-
-        if (img_l.empty() || img_r.empty() || img_template.empty())
-        {
-            ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
-            return;
-        }
-
-        {cv::Mat temp; cv::cvtColor(img_l, temp, CV_BGR2BGRA); cv::swap(temp, img_l);}
-        {cv::Mat temp; cv::cvtColor(img_r, temp, CV_BGR2BGRA); cv::swap(temp, img_r);}
-
-        cv::gpu::GpuMat disp;
-        cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
-
-        bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
-
-        //cv::imwrite(std::string(ts->get_data_path()) + "csstereobp/aloe-disp_CC1X.png", cv::Mat(disp));
-
-        disp.convertTo(disp, img_template.type());
-
-        double norm = cv::norm((cv::Mat)disp, img_template, cv::NORM_INF);
-        if (norm >= 1.5)
-        {
-            ts->printf(cvtest::TS::LOG, "\nConstantSpaceStereoBP norm = %f\n", norm);
-            ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
-            return;
-        }
-
-        ts->set_failed_test_info(cvtest::TS::OK);
-    }
-};
-
-TEST(StereoConstantSpaceBP, regression) { CV_GpuStereoCSBPTest test; test.safe_run(); }