From 397a63539c1b69eea84ac4f98618653279bc944c Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Tue, 25 Jan 2011 11:45:29 +0000 Subject: [PATCH] fixed bug in performance test matrix generation --- samples/gpu/performance/performance.cpp | 14 ++------------ samples/gpu/performance/performance.h | 4 ++-- samples/gpu/performance/tests.cpp | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/samples/gpu/performance/performance.cpp b/samples/gpu/performance/performance.cpp index 668b733eea..1da6330e75 100644 --- a/samples/gpu/performance/performance.cpp +++ b/samples/gpu/performance/performance.cpp @@ -4,22 +4,12 @@ using namespace std; using namespace cv; -void Test::gen(Mat& mat, int rows, int cols, int type) -{ - mat.create(rows, cols, type); - Mat mat8u(rows, cols * mat.elemSize(), CV_8U, mat.data, mat.step); - - RNG rng(0); - rng.fill(mat, RNG::UNIFORM, Scalar(0), Scalar(256)); -} - - -void Test::gen(Mat& mat, int rows, int cols, int type, double low, double high) +void Test::gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high) { mat.create(rows, cols, type); RNG rng(0); - rng.fill(mat, RNG::UNIFORM, Scalar::all(low), Scalar::all(high)); + rng.fill(mat, RNG::UNIFORM, low, high); } diff --git a/samples/gpu/performance/performance.h b/samples/gpu/performance/performance.h index 9fbb1f6f2a..cecec45841 100644 --- a/samples/gpu/performance/performance.h +++ b/samples/gpu/performance/performance.h @@ -14,8 +14,8 @@ public: const std::string& name() const { return name_; } - void gen(cv::Mat& mat, int rows, int cols, int type); - void gen(cv::Mat& mat, int rows, int cols, int type, double low, double high); + void gen(cv::Mat& mat, int rows, int cols, int type, + cv::Scalar low, cv::Scalar high); virtual void run() = 0; diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index f9de6d8807..8aa3bdc320 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "performance.h" @@ -8,7 +9,7 @@ using namespace cv; TEST(matchTemplate) { Mat image, templ, result; - gen(image, 3000, 3000, CV_32F); + gen(image, 3000, 3000, CV_32F, 0, 1); gpu::GpuMat d_image(image), d_templ, d_result; @@ -16,7 +17,7 @@ TEST(matchTemplate) { SUBTEST << "img " << image.rows << ", templ " << templ_size << ", 32F, CCORR"; - gen(templ, templ_size, templ_size, CV_32F); + gen(templ, templ_size, templ_size, CV_32F, 0, 1); CPU_ON; matchTemplate(image, templ, result, CV_TM_CCORR); @@ -43,7 +44,7 @@ TEST(minMaxLoc) { SUBTEST << "img " << size << ", 32F, no mask"; - gen(src, size, size, CV_32F); + gen(src, size, size, CV_32F, 0, 1); CPU_ON; minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc); @@ -67,9 +68,9 @@ TEST(remap) { SUBTEST << "img " << size << " and 8UC1, 32FC1 maps"; - gen(src, size, size, CV_8UC1); - gen(xmap, size, size, CV_32FC1, 0, size); - gen(ymap, size, size, CV_32FC1, 0, size); + gen(src, size, size, CV_8UC1, 0, 256); + gen(xmap, size, size, CV_32F, 0, size); + gen(ymap, size, size, CV_32F, 0, size); CPU_ON; remap(src, dst, xmap, ymap, INTER_LINEAR); @@ -91,11 +92,11 @@ TEST(dft) Mat src, dst; gpu::GpuMat d_src, d_dst; - for (int size = 1000; size <= 4000; size += 1000) + for (int size = 1000; size <= 4000; size *= 2) { SUBTEST << "size " << size << ", 32FC2, complex-to-complex"; - gen(src, size, size, CV_32FC2); + gen(src, size, size, CV_32FC2, Scalar::all(0), Scalar::all(1)); CPU_ON; dft(src, dst); @@ -119,7 +120,7 @@ TEST(cornerHarris) { SUBTEST << "size " << size << ", 32FC1"; - gen(src, size, size, CV_32FC1); + gen(src, size, size, CV_32F, 0, 1); CPU_ON; cornerHarris(src, dst, 5, 7, 0.1, BORDER_REFLECT101);