added buffered version of gpu::integral function and updated performance test (it...
authorAlexey Spizhevoy <no@email>
Mon, 31 Jan 2011 10:42:33 +0000 (10:42 +0000)
committerAlexey Spizhevoy <no@email>
Mon, 31 Jan 2011 10:42:33 +0000 (10:42 +0000)
modules/gpu/include/opencv2/gpu/gpu.hpp
modules/gpu/src/imgproc_gpu.cpp
samples/gpu/performance/tests.cpp

index 967b813..b719417 100644 (file)
@@ -650,6 +650,9 @@ namespace cv
         //! supports only CV_8UC1 source type\r
         CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum);\r
 \r
+        //! buffered version\r
+        CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer);\r
+\r
         //! computes the integral image and integral for the squared image\r
         //! sum will have CV_32S type, sqsum - CV32F type\r
         //! supports only CV_8UC1 source type\r
index 4c24684..35aa3d5 100644 (file)
@@ -61,6 +61,7 @@ void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_
 void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_nogpu(); }\r
 void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int) { throw_nogpu(); }\r
 void cv::gpu::integral(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::integralBuffered(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }\r
 void cv::gpu::integral(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }\r
 void cv::gpu::sqrIntegral(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
 void cv::gpu::columnSum(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
@@ -546,6 +547,12 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
 \r
 void cv::gpu::integral(const GpuMat& src, GpuMat& sum)\r
 {\r
+    GpuMat buffer;\r
+    integralBuffered(src, sum, buffer);\r
+}\r
+\r
+void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer)\r
+{\r
     CV_Assert(src.type() == CV_8UC1);\r
 \r
     sum.create(src.rows + 1, src.cols + 1, CV_32S);\r
@@ -555,10 +562,8 @@ void cv::gpu::integral(const GpuMat& src, GpuMat& sum)
     roiSize.height = src.rows;\r
 \r
     NppSt32u bufSize;\r
-\r
     nppSafeCall( nppiStIntegralGetSize_8u32u(roiSize, &bufSize) );\r
-\r
-    GpuMat buffer(1, bufSize, CV_8UC1);\r
+    ensureSizeIsEnough(1, bufSize, CV_8UC1, buffer);\r
 \r
     nppSafeCall( nppiStIntegral_8u32u_C1R(const_cast<NppSt8u*>(src.ptr<NppSt8u>()), src.step, \r
         sum.ptr<NppSt32u>(), sum.step, roiSize, buffer.ptr<NppSt8u>(), bufSize) );\r
index eea14c0..469c84e 100644 (file)
@@ -170,24 +170,26 @@ TEST(cornerHarris)
 TEST(integral)\r
 {\r
     Mat src, sum;\r
-    gpu::GpuMat d_src, d_sum;\r
+    gpu::GpuMat d_src, d_sum, d_buf;\r
 \r
-    for (int size = 1000; size <= 8000; size *= 2)\r
+    int size = 4000;\r
+\r
+    gen(src, size, size, CV_8U, 0, 256);\r
+    sum.create(size + 1, size + 1, CV_32S);\r
+\r
+    d_src = src;\r
+    d_sum.create(size + 1, size + 1, CV_32S);\r
+\r
+    for (int i = 0; i < 5; ++i)\r
     {\r
         SUBTEST << "size " << size << ", 8U";\r
 \r
-        gen(src, size, size, CV_8U, 0, 256);\r
-        sum.create(size + 1, size + 1, CV_32S);\r
-\r
         CPU_ON;\r
         integral(src, sum);\r
         CPU_OFF;\r
 \r
-        d_src = src;\r
-        d_sum.create(size + 1, size + 1, CV_32S);\r
-\r
         GPU_ON;\r
-        gpu::integral(d_src, d_sum);\r
+        gpu::integralBuffered(d_src, d_sum, d_buf);\r
         GPU_OFF;\r
     }\r
 }\r