fixed gpu::Laplacian
authorVladislav Vinogradov <no@email>
Mon, 2 Apr 2012 11:21:45 +0000 (11:21 +0000)
committerVladislav Vinogradov <no@email>
Mon, 2 Apr 2012 11:21:45 +0000 (11:21 +0000)
fixed gpu performance sample

modules/gpu/include/opencv2/gpu/gpu.hpp
modules/gpu/src/filtering.cpp
modules/gpu/test/test_filters.cpp
samples/gpu/performance/tests.cpp

index 949acba..db5aa43 100644 (file)
@@ -395,7 +395,7 @@ CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, GpuMat&
 \r
 //! applies Laplacian operator to the image\r
 //! supports only ksize = 1 and ksize = 3\r
-CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1, Stream& stream = Stream::Null());\r
+CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1, int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null());\r
 \r
 \r
 ////////////////////////////// Arithmetics ///////////////////////////////////\r
@@ -1094,8 +1094,8 @@ public:
 \r
     bool use_local_init_data_cost;\r
 private:\r
-       GpuMat messages_buffers;\r
-        \r
+    GpuMat messages_buffers;\r
+\r
     GpuMat temp;\r
     GpuMat out;\r
 };\r
index 2349857..ebf9900 100644 (file)
@@ -87,7 +87,7 @@ void cv::gpu::Scharr(const GpuMat&, GpuMat&, int, int, int, double, int, int) {
 void cv::gpu::Scharr(const GpuMat&, GpuMat&, int, int, int, GpuMat&, double, int, int, Stream&) { throw_nogpu(); }\r
 void cv::gpu::GaussianBlur(const GpuMat&, GpuMat&, Size, double, double, int, int) { throw_nogpu(); }\r
 void cv::gpu::GaussianBlur(const GpuMat&, GpuMat&, Size, GpuMat&, double, double, int, int, Stream&) { throw_nogpu(); }\r
-void cv::gpu::Laplacian(const GpuMat&, GpuMat&, int, int, double, Stream&) { throw_nogpu(); }\r
+void cv::gpu::Laplacian(const GpuMat&, GpuMat&, int, int, double, int, Stream&) { throw_nogpu(); }\r
 \r
 #else\r
 \r
@@ -664,8 +664,8 @@ namespace cv { namespace gpu { namespace device
     namespace imgproc\r
     {\r
         template <typename T, typename D>\r
-        void filter2D_gpu(DevMem2Db srcWhole, int ofsX, int ofsY, DevMem2Db dst, \r
-                          int kWidth, int kHeight, int anchorX, int anchorY, const float* kernel, \r
+        void filter2D_gpu(DevMem2Db srcWhole, int ofsX, int ofsY, DevMem2Db dst,\r
+                          int kWidth, int kHeight, int anchorX, int anchorY, const float* kernel,\r
                           int borderMode, const float* borderValue, cudaStream_t stream);\r
     }\r
 }}}\r
@@ -708,14 +708,14 @@ namespace
         nppFilter2D_t func;\r
     };\r
 \r
-    typedef void (*gpuFilter2D_t)(DevMem2Db srcWhole, int ofsX, int ofsY, DevMem2Db dst, \r
-                                   int kWidth, int kHeight, int anchorX, int anchorY, const float* kernel, \r
+    typedef void (*gpuFilter2D_t)(DevMem2Db srcWhole, int ofsX, int ofsY, DevMem2Db dst,\r
+                                   int kWidth, int kHeight, int anchorX, int anchorY, const float* kernel,\r
                                    int borderMode, const float* borderValue, cudaStream_t stream);\r
 \r
     struct GpuFilter2D : public BaseFilter_GPU\r
     {\r
         GpuFilter2D(Size ksize_, Point anchor_, gpuFilter2D_t func_, const GpuMat& kernel_, int brd_type_) :\r
-            BaseFilter_GPU(ksize_, anchor_), func(func_), kernel(kernel_), brd_type(brd_type_) \r
+            BaseFilter_GPU(ksize_, anchor_), func(func_), kernel(kernel_), brd_type(brd_type_)\r
         {\r
         }\r
 \r
@@ -1193,7 +1193,7 @@ void cv::gpu::Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy,
     sepFilter2D(src, dst, ddepth, kx, ky, buf, Point(-1,-1), rowBorderType, columnBorderType, stream);\r
 }\r
 \r
-void cv::gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize, double scale, Stream& stream)\r
+void cv::gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize, double scale, int borderType, Stream& stream)\r
 {\r
     CV_Assert(ksize == 1 || ksize == 3);\r
 \r
@@ -1206,7 +1206,7 @@ void cv::gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize, d
     if (scale != 1)\r
         kernel *= scale;\r
 \r
-    filter2D(src, dst, ddepth, kernel, Point(-1,-1), stream);\r
+    filter2D(src, dst, ddepth, kernel, Point(-1,-1), borderType, stream);\r
 }\r
 \r
 ////////////////////////////////////////////////////////////////////////////////////////////////////\r
index 6f7b8d9..99c463b 100644 (file)
@@ -334,10 +334,7 @@ TEST_P(Laplacian, Accuracy)
     cv::Mat dst_gold;\r
     cv::Laplacian(src, dst_gold, -1, ksize.width);\r
 \r
-    if (type == CV_32FC1)\r
-        EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-    else\r
-        EXPECT_MAT_NEAR(getInnerROI(dst_gold, cv::Size(3, 3)), getInnerROI(dst, cv::Size(3, 3)), 0.0);\r
+    EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
 }\r
 \r
 INSTANTIATE_TEST_CASE_P(GPU_Filter, Laplacian, testing::Combine(\r
index a49ba2a..e025d7d 100644 (file)
@@ -273,7 +273,7 @@ TEST(SURF)
 \r
     SURF surf;\r
     vector<KeyPoint> keypoints;\r
-    vector<float> descriptors;\r
+    Mat descriptors;\r
 \r
     surf(src, Mat(), keypoints, descriptors);\r
 \r
@@ -899,7 +899,6 @@ TEST(solvePnPRansac)
     }\r
 }\r
 \r
-\r
 TEST(GaussianBlur)\r
 {\r
     for (int size = 1000; size <= 4000; size += 1000)\r
@@ -928,6 +927,39 @@ TEST(GaussianBlur)
     }\r
 }\r
 \r
+TEST(filter2D)\r
+{\r
+    for (int size = 512; size <= 2048; size *= 2)\r
+    {\r
+        Mat src;\r
+        gen(src, size, size, CV_8UC4, 0, 256);\r
+                \r
+        for (int ksize = 3; ksize <= 16; ksize += 2)\r
+        {        \r
+            SUBTEST << "ksize = " << ksize << ", " << size << 'x' << size << ", 8UC4";\r
+            \r
+            Mat kernel;\r
+            gen(kernel, ksize, ksize, CV_32FC1, 0.0, 1.0);\r
+\r
+            Mat dst;\r
+            cv::filter2D(src, dst, -1, kernel);\r
+\r
+            CPU_ON;\r
+            cv::filter2D(src, dst, -1, kernel);\r
+            CPU_OFF;\r
+\r
+            gpu::GpuMat d_src(src);\r
+            gpu::GpuMat d_dst;\r
+\r
+            gpu::filter2D(d_src, d_dst, -1, kernel);\r
+\r
+            GPU_ON;\r
+            gpu::filter2D(d_src, d_dst, -1, kernel);\r
+            GPU_OFF;\r
+        }\r
+    }\r
+}\r
+\r
 TEST(pyrDown)\r
 {\r
     for (int size = 4000; size >= 1000; size -= 1000)\r