mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
added BFM perf. test
This commit is contained in:
parent
ba32b447ee
commit
feff022422
@ -56,7 +56,7 @@ void TestSystem::flushSubtestData()
|
||||
int cpu_time = static_cast<int>(cpu_elapsed_ / getTickFrequency() * 1000.0);
|
||||
int gpu_time = static_cast<int>(gpu_elapsed_ / getTickFrequency() * 1000.0);
|
||||
|
||||
double speedup = static_cast<double>(cpu_elapsed_) / gpu_elapsed_;
|
||||
double speedup = static_cast<double>(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);
|
||||
}
|
||||
|
@ -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<float> > matcher;
|
||||
|
||||
Mat query;
|
||||
gen(query, rng.uniform(100, 300), desc_len, CV_32F, 0, 10);
|
||||
|
||||
vector<Mat> 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<float> > d_matcher;
|
||||
|
||||
gpu::GpuMat d_query(query);
|
||||
|
||||
vector<gpu::GpuMat> 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<DMatch> > matches(1);
|
||||
vector< vector<DMatch> > 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user