opencv/modules/gpu/perf_cpu/perf_features2d.cpp

188 lines
4.8 KiB
C++
Raw Normal View History

2012-05-22 12:29:58 +02:00
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// SURF
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo)
{
2012-05-23 14:58:01 +02:00
cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
2012-05-23 14:58:01 +02:00
cv::SURF surf;
2012-05-23 14:58:01 +02:00
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
2012-05-23 14:58:01 +02:00
surf(img, cv::noArray(), keypoints, descriptors);
2012-05-23 14:58:01 +02:00
declare.time(50.0);
TEST_CYCLE()
{
2012-05-28 10:08:14 +02:00
keypoints.clear();
2012-05-23 14:58:01 +02:00
surf(img, cv::noArray(), keypoints, descriptors);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// FAST
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo)
{
2012-05-23 14:58:01 +02:00
cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
2012-05-23 14:58:01 +02:00
std::vector<cv::KeyPoint> keypoints;
2012-05-23 14:58:01 +02:00
cv::FAST(img, keypoints, 20);
TEST_CYCLE()
{
2012-05-28 10:08:14 +02:00
keypoints.clear();
2012-05-23 14:58:01 +02:00
cv::FAST(img, keypoints, 20);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// ORB
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo)
{
2012-05-23 14:58:01 +02:00
cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
2012-05-23 14:58:01 +02:00
cv::ORB orb(4000);
2012-05-23 14:58:01 +02:00
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
2012-05-23 14:58:01 +02:00
orb(img, cv::noArray(), keypoints, descriptors);
TEST_CYCLE()
{
2012-05-28 10:08:14 +02:00
keypoints.clear();
2012-05-23 14:58:01 +02:00
orb(img, cv::noArray(), keypoints, descriptors);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// BruteForceMatcher_match
2012-05-23 14:58:01 +02:00
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType)
{
2012-05-23 14:58:01 +02:00
int desc_size = GET_PARAM(1);
int normType = GET_PARAM(2);
2012-05-23 14:58:01 +02:00
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
2012-05-23 14:58:01 +02:00
cv::Mat query(3000, desc_size, type);
fill(query, 0.0, 10.0);
2012-05-23 14:58:01 +02:00
cv::Mat train(3000, desc_size, type);
fill(train, 0.0, 10.0);
2012-05-23 14:58:01 +02:00
cv::BFMatcher matcher(normType);
std::vector<cv::DMatch> matches;
matcher.match(query, train, matches);
declare.time(20.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
matcher.match(query, train, matches);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// BruteForceMatcher_knnMatch
2012-05-23 14:58:01 +02:00
IMPLEMENT_PARAM_CLASS(K, int)
GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType)
{
2012-05-23 14:58:01 +02:00
int desc_size = GET_PARAM(1);
int k = GET_PARAM(2);
int normType = GET_PARAM(3);
2012-05-23 14:58:01 +02:00
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
2012-05-23 14:58:01 +02:00
cv::Mat query(3000, desc_size, type);
fill(query, 0.0, 10.0);
cv::Mat train(3000, desc_size, type);
fill(train, 0.0, 10.0);
cv::BFMatcher matcher(normType);
std::vector< std::vector<cv::DMatch> > matches;
matcher.knnMatch(query, train, matches, k);
declare.time(30.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
matcher.knnMatch(query, train, matches, k);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(K(2), K(3)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// BruteForceMatcher_radiusMatch
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType)
{
2012-05-23 14:58:01 +02:00
int desc_size = GET_PARAM(1);
int normType = GET_PARAM(2);
2012-05-23 14:58:01 +02:00
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
2012-05-23 14:58:01 +02:00
cv::Mat query(3000, desc_size, type);
fill(query, 0.0, 1.0);
2012-05-23 14:58:01 +02:00
cv::Mat train(3000, desc_size, type);
fill(train, 0.0, 1.0);
cv::BFMatcher matcher(normType);
std::vector< std::vector<cv::DMatch> > matches;
matcher.radiusMatch(query, train, matches, 2.0);
declare.time(30.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
matcher.radiusMatch(query, train, matches, 2.0);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
#endif