From 5c3495a07971085457d7421d61dfef850f768ae5 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Fri, 4 Feb 2011 08:16:09 +0000 Subject: [PATCH] added perf test for gpu::erode, fixed docs, refactored perf. sample --- doc/gpu_initialization.tex | 4 +- samples/gpu/performance/performance.h | 1 - samples/gpu/performance/tests.cpp | 79 +++++++++++++++++++++++------------ samples/gpu/stereo_multi.cpp | 3 ++ 4 files changed, 58 insertions(+), 29 deletions(-) diff --git a/doc/gpu_initialization.tex b/doc/gpu_initialization.tex index 4018e30..cc240a1 100644 --- a/doc/gpu_initialization.tex +++ b/doc/gpu_initialization.tex @@ -113,7 +113,7 @@ Returns true if the device has the given GPU feature, otherwise false. \cvdefCpp{bool DeviceInfo::has(GpuFeature feature);} \begin{description} -\cvarg{feature}{Feature to be checked. See \hyperref[cpp.gpu.GpuFeature]{gpu::GpuFeature}.} +\cvarg{feature}{Feature to be checked. See \hyperref[cpp.gpu.GpuFeature]{cv::gpu::GpuFeature}.} \end{description} @@ -131,7 +131,7 @@ This class provides functionality (as set of static methods) for checking which The following method checks whether the module was built with the support of the given feature: \cvdefCpp{static bool builtWith(GpuFeature feature);} \begin{description} -\cvarg{feature}{Feature to be checked. See \hyperref[cpp.gpu.GpuFeature]{gpu::GpuFeature}.} +\cvarg{feature}{Feature to be checked. See \hyperref[cpp.gpu.GpuFeature]{cv::gpu::GpuFeature}.} \end{description} There are a set of methods for checking whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s): diff --git a/samples/gpu/performance/performance.h b/samples/gpu/performance/performance.h index 1bfcff8..fccb561 100644 --- a/samples/gpu/performance/performance.h +++ b/samples/gpu/performance/performance.h @@ -125,7 +125,6 @@ private: void name##_test::run() #define SUBTEST TestSystem::instance().subtest() -#define DESCRIPTION TestSystem::instance().subtest() #define CPU_ON TestSystem::instance().cpuOn() #define GPU_ON TestSystem::instance().gpuOn() #define CPU_OFF TestSystem::instance().cpuOff() diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index 81d78a7..8f9d89b 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -167,32 +167,32 @@ TEST(cornerHarris) } -//TEST(integral) -//{ -// Mat src, sum; -// gpu::GpuMat d_src, d_sum, d_buf; -// -// 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"; -// -// CPU_ON; -// integral(src, sum); -// CPU_OFF; -// -// GPU_ON; -// gpu::integralBuffered(d_src, d_sum, d_buf); -// GPU_OFF; -// } -//} +TEST(integral) +{ + Mat src, sum; + gpu::GpuMat d_src, d_sum, d_buf; + + 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"; + + CPU_ON; + integral(src, sum); + CPU_OFF; + + GPU_ON; + gpu::integralBuffered(d_src, d_sum, d_buf); + GPU_OFF; + } +} TEST(norm) @@ -653,4 +653,31 @@ TEST(cvtColor) cv::swap(src, dst); d_src.swap(d_dst); +} + + +TEST(erode) +{ + Mat src, dst, ker; + gpu::GpuMat d_src, d_dst; + + for (int size = 2000; size <= 4000; size += 1000) + { + SUBTEST << "size " << size; + + gen(src, size, size, CV_8UC4, Scalar::all(0), Scalar::all(256)); + ker = getStructuringElement(MORPH_RECT, Size(3, 3)); + dst.create(src.size(), src.type()); + + CPU_ON; + erode(src, dst, ker); + CPU_OFF; + + d_src = src; + d_dst.create(d_src.size(), d_src.type()); + + GPU_ON; + gpu::erode(d_src, d_dst, ker); + GPU_OFF; + } } \ No newline at end of file diff --git a/samples/gpu/stereo_multi.cpp b/samples/gpu/stereo_multi.cpp index a380e5b..58d88c6 100644 --- a/samples/gpu/stereo_multi.cpp +++ b/samples/gpu/stereo_multi.cpp @@ -60,10 +60,13 @@ void inline contextOff() safeCall(cuCtxPopCurrent(&prev_context)); } +// GPUs data GpuMat d_left[2]; GpuMat d_right[2]; StereoBM_GPU* bm[2]; GpuMat d_result[2]; + +// CPU result Mat result; int main(int argc, char** argv) -- 2.7.4