2011-09-12 15:48:09 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
using namespace std;
|
|
|
|
using namespace testing;
|
|
|
|
|
|
|
|
namespace {
|
2011-12-28 20:53:08 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-05-23 20:58:01 +08:00
|
|
|
// SURF
|
2011-12-28 20:53:08 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
DEF_PARAM_TEST_1(Image, string);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.jpg"))
|
|
|
|
{
|
|
|
|
declare.time(2.0);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
|
|
|
ASSERT_FALSE(img.empty());
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::SURF_GPU d_surf;
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::GpuMat d_img(img);
|
|
|
|
cv::gpu::GpuMat d_keypoints, d_descriptors;
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE()
|
2011-09-12 15:48:09 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
2011-09-12 15:48:09 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-05-23 20:58:01 +08:00
|
|
|
// FAST
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.jpg"))
|
2011-09-12 15:48:09 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
|
|
|
ASSERT_FALSE(img.empty());
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::FAST_GPU d_fast(20);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::GpuMat d_img(img);
|
|
|
|
cv::gpu::GpuMat d_keypoints;
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE()
|
2011-09-12 15:48:09 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
|
2011-09-12 15:48:09 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-05-23 20:58:01 +08:00
|
|
|
// ORB
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.jpg"))
|
2011-09-12 15:48:09 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
|
|
|
ASSERT_FALSE(img.empty());
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::ORB_GPU d_orb(4000);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::GpuMat d_img(img);
|
|
|
|
cv::gpu::GpuMat d_keypoints, d_descriptors;
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE()
|
2011-09-12 15:48:09 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
2011-09-12 15:48:09 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-08-17 19:14:14 +08:00
|
|
|
// BFMatch
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
DEF_PARAM_TEST(DescSize_Norm, int, NormType);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
|
2012-05-23 20:58:01 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
declare.time(3.0);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
int desc_size = GET_PARAM(0);
|
|
|
|
int normType = GET_PARAM(1);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-05-23 20:58:01 +08:00
|
|
|
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat query(3000, desc_size, type);
|
|
|
|
fillRandom(query);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat train(3000, desc_size, type);
|
|
|
|
fillRandom(train);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::GpuMat d_query(query);
|
|
|
|
cv::gpu::GpuMat d_train(train);
|
|
|
|
cv::gpu::GpuMat d_trainIdx, d_distance;
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE()
|
2011-09-12 15:48:09 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
2011-09-12 15:48:09 +08:00
|
|
|
}
|
2011-12-27 17:33:20 +08:00
|
|
|
}
|
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-08-17 19:14:14 +08:00
|
|
|
// BFKnnMatch
|
2011-12-28 20:53:08 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
DEF_PARAM_TEST(DescSize_K_Norm, int, int, NormType);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
|
|
|
|
Values(64, 128, 256),
|
|
|
|
Values(2, 3),
|
|
|
|
Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
|
2012-05-23 20:58:01 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
declare.time(3.0);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
int desc_size = GET_PARAM(0);
|
|
|
|
int k = GET_PARAM(1);
|
|
|
|
int normType = GET_PARAM(2);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-05-23 20:58:01 +08:00
|
|
|
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
2011-09-12 15:48:09 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat query(3000, desc_size, type);
|
|
|
|
fillRandom(query);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat train(3000, desc_size, type);
|
|
|
|
fillRandom(train);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::GpuMat d_query(query);
|
|
|
|
cv::gpu::GpuMat d_train(train);
|
|
|
|
cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist;
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE()
|
2011-12-27 17:33:20 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
|
2011-12-27 17:33:20 +08:00
|
|
|
}
|
2011-09-12 15:48:09 +08:00
|
|
|
}
|
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-08-17 19:14:14 +08:00
|
|
|
// BFRadiusMatch
|
2011-12-28 20:53:08 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
|
2011-12-27 17:33:20 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
declare.time(3.0);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
int desc_size = GET_PARAM(0);
|
|
|
|
int normType = GET_PARAM(1);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-05-23 20:58:01 +08:00
|
|
|
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat query(3000, desc_size, type);
|
|
|
|
fillRandom(query, 0.0, 1.0);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat train(3000, desc_size, type);
|
|
|
|
fillRandom(train, 0.0, 1.0);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::gpu::GpuMat d_query(query);
|
|
|
|
cv::gpu::GpuMat d_train(train);
|
|
|
|
cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance;
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
|
2011-12-27 17:33:20 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE()
|
2011-12-27 17:33:20 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
|
2011-12-27 17:33:20 +08:00
|
|
|
}
|
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
} // namespace
|