From: Alexey Spizhevoy Date: Mon, 31 Jan 2011 10:42:33 +0000 (+0000) Subject: added buffered version of gpu::integral function and updated performance test (it... X-Git-Tag: accepted/2.0/20130307.220821~3586 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a29d96cf41ed4e0b14670e4e650a3d13caa2c85;p=profile%2Fivi%2Fopencv.git added buffered version of gpu::integral function and updated performance test (it still works too slow) --- diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index 967b813..b719417 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -650,6 +650,9 @@ namespace cv //! supports only CV_8UC1 source type CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum); + //! buffered version + CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer); + //! computes the integral image and integral for the squared image //! sum will have CV_32S type, sqsum - CV32F type //! supports only CV_8UC1 source type diff --git a/modules/gpu/src/imgproc_gpu.cpp b/modules/gpu/src/imgproc_gpu.cpp index 4c24684..35aa3d5 100644 --- a/modules/gpu/src/imgproc_gpu.cpp +++ b/modules/gpu/src/imgproc_gpu.cpp @@ -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(); } void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int) { throw_nogpu(); } void cv::gpu::integral(const GpuMat&, GpuMat&) { throw_nogpu(); } +void cv::gpu::integralBuffered(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::integral(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::sqrIntegral(const GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::columnSum(const GpuMat&, GpuMat&) { throw_nogpu(); } @@ -546,6 +547,12 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d void cv::gpu::integral(const GpuMat& src, GpuMat& sum) { + GpuMat buffer; + integralBuffered(src, sum, buffer); +} + +void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer) +{ CV_Assert(src.type() == CV_8UC1); sum.create(src.rows + 1, src.cols + 1, CV_32S); @@ -555,10 +562,8 @@ void cv::gpu::integral(const GpuMat& src, GpuMat& sum) roiSize.height = src.rows; NppSt32u bufSize; - nppSafeCall( nppiStIntegralGetSize_8u32u(roiSize, &bufSize) ); - - GpuMat buffer(1, bufSize, CV_8UC1); + ensureSizeIsEnough(1, bufSize, CV_8UC1, buffer); nppSafeCall( nppiStIntegral_8u32u_C1R(const_cast(src.ptr()), src.step, sum.ptr(), sum.step, roiSize, buffer.ptr(), bufSize) ); diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index eea14c0..469c84e 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -170,24 +170,26 @@ TEST(cornerHarris) TEST(integral) { Mat src, sum; - gpu::GpuMat d_src, d_sum; + gpu::GpuMat d_src, d_sum, d_buf; - for (int size = 1000; size <= 8000; size *= 2) + int size = 4000; + + gen(src, size, size, CV_8U, 0, 256); + sum.create(size + 1, size + 1, CV_32S); + + d_src = src; + d_sum.create(size + 1, size + 1, CV_32S); + + for (int i = 0; i < 5; ++i) { SUBTEST << "size " << size << ", 8U"; - gen(src, size, size, CV_8U, 0, 256); - sum.create(size + 1, size + 1, CV_32S); - CPU_ON; integral(src, sum); CPU_OFF; - d_src = src; - d_sum.create(size + 1, size + 1, CV_32S); - GPU_ON; - gpu::integral(d_src, d_sum); + gpu::integralBuffered(d_src, d_sum, d_buf); GPU_OFF; } }