//! 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
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
\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
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
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