From: Alexey Spizhevoy Date: Wed, 26 Jan 2011 15:28:42 +0000 (+0000) Subject: added BFM perf. test X-Git-Tag: accepted/2.0/20130307.220821~3613 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=feff022422d2a3ed26f443bf482fe1432bab0088;p=profile%2Fivi%2Fopencv.git added BFM perf. test --- diff --git a/samples/gpu/performance/performance.cpp b/samples/gpu/performance/performance.cpp index dd665e3..b45dd54 100644 --- a/samples/gpu/performance/performance.cpp +++ b/samples/gpu/performance/performance.cpp @@ -56,7 +56,7 @@ void TestSystem::flushSubtestData() int cpu_time = static_cast(cpu_elapsed_ / getTickFrequency() * 1000.0); int gpu_time = static_cast(gpu_elapsed_ / getTickFrequency() * 1000.0); - double speedup = static_cast(cpu_elapsed_) / gpu_elapsed_; + double speedup = static_cast(cpu_elapsed_) / std::max((int64)1, gpu_elapsed_); speedup_total_ += speedup; printItem(cpu_time, gpu_time, speedup); @@ -80,7 +80,7 @@ void TestSystem::printSummary() { cout << setiosflags(ios_base::fixed); cout << "\naverage GPU speedup: x" - << setprecision(3) << speedup_total_ / num_subtests_called_ + << setprecision(3) << speedup_total_ / std::max(1, num_subtests_called_) << endl; cout << resetiosflags(ios_base::fixed); } diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index d591fdf..953a444 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -273,4 +273,78 @@ TEST(SURF) d_surf(d_src1, gpu::GpuMat(), d_keypoints1); d_surf(d_src2, gpu::GpuMat(), d_keypoints2); GPU_OFF; +} + + +TEST(BruteForceMatcher) +{ + RNG rng(0); + + // Init CPU matcher + + int desc_len = 128; + int num_trains = rng.uniform(1, 5); + + BruteForceMatcher< L2 > matcher; + + Mat query; + gen(query, rng.uniform(100, 300), desc_len, CV_32F, 0, 10); + + vector trains(num_trains); + for (int i = 0; i < num_trains; ++i) + { + Mat train; + gen(train, rng.uniform(100, 300), desc_len, CV_32F, 0, 10); + trains[i] = train; + } + matcher.add(trains); + + // Init GPU matcher + + gpu::BruteForceMatcher_GPU< L2 > d_matcher; + + gpu::GpuMat d_query(query); + + vector d_trains(num_trains); + for (int i = 0; i < num_trains; ++i) + { + d_trains[i] = trains[i]; + } + d_matcher.add(d_trains); + + // Output + vector< vector > matches(1); + vector< vector > d_matches(1); + + SUBTEST << "match"; + + CPU_ON; + matcher.match(query, matches[0]); + CPU_OFF; + + GPU_ON; + d_matcher.match(d_query, d_matches[0]); + GPU_OFF; + + SUBTEST << "knnMatch"; + int knn = rng.uniform(3, 10); + + CPU_ON; + matcher.knnMatch(query, matches, knn); + CPU_OFF; + + GPU_ON; + d_matcher.knnMatch(d_query, d_matches, knn); + GPU_OFF; + + SUBTEST << "radiusMatch"; + float max_distance = rng.uniform(25.0f, 65.0f); + + CPU_ON; + matcher.radiusMatch(query, matches, max_distance); + CPU_OFF; + + GPU_ON; + d_matcher.radiusMatch(d_query, d_matches, max_distance); + GPU_OFF; } \ No newline at end of file