2011-09-12 09:48:09 +02:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
#ifdef HAVE_CUDA
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// BruteForceMatcher_match
|
|
|
|
|
|
|
|
GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, int)
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
int desc_size = GET_PARAM(1);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat query_host(3000, desc_size, CV_32FC1);
|
|
|
|
cv::Mat train_host(3000, desc_size, CV_32FC1);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
|
|
|
declare.in(query_host, train_host, WARMUP_RNG);
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat query(query_host);
|
|
|
|
cv::gpu::GpuMat train(train_host);
|
|
|
|
cv::gpu::GpuMat trainIdx, distance;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-10-12 12:23:03 +02:00
|
|
|
declare.time(3.0);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE()
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
|
|
|
matcher.matchSingle(query, train, trainIdx, distance);
|
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
testing::Values(64, 128, 256)));
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// BruteForceMatcher_knnMatch
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, int, int)
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
int desc_size = GET_PARAM(1);
|
|
|
|
int k = GET_PARAM(2);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat query_host(3000, desc_size, CV_32FC1);
|
|
|
|
cv::Mat train_host(3000, desc_size, CV_32FC1);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
|
|
|
declare.in(query_host, train_host, WARMUP_RNG);
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat query(query_host);
|
|
|
|
cv::gpu::GpuMat train(train_host);
|
|
|
|
cv::gpu::GpuMat trainIdx, distance, allDist;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-10-12 12:23:03 +02:00
|
|
|
declare.time(3.0);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE()
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-10-12 12:23:03 +02:00
|
|
|
matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k);
|
2011-09-12 09:48:09 +02:00
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
testing::Values(64, 128, 256),
|
|
|
|
testing::Values(2, 3)));
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// BruteForceMatcher_radiusMatch
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, int)
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
int desc_size = GET_PARAM(1);
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat query_host(3000, desc_size, CV_32FC1);
|
|
|
|
cv::Mat train_host(3000, desc_size, CV_32FC1);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
fill(query_host, 0, 1);
|
|
|
|
fill(train_host, 0, 1);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat query(query_host);
|
|
|
|
cv::gpu::GpuMat train(train_host);
|
|
|
|
cv::gpu::GpuMat trainIdx, nMatches, distance;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-10-12 12:23:03 +02:00
|
|
|
declare.time(3.0);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE()
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-09-27 08:45:17 +02:00
|
|
|
matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0);
|
2011-09-12 09:48:09 +02:00
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
testing::Values(64, 128, 256)));
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// SURF
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo)
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GetParam();
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
2011-09-12 09:48:09 +02:00
|
|
|
|
|
|
|
ASSERT_FALSE(img_host.empty());
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat img(img_host);
|
|
|
|
cv::gpu::GpuMat keypoints, descriptors;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::SURF_GPU surf;
|
2011-09-12 09:48:09 +02:00
|
|
|
|
|
|
|
declare.time(2.0);
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE()
|
2011-09-12 09:48:09 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
surf(img, cv::gpu::GpuMat(), keypoints, descriptors);
|
2011-09-12 09:48:09 +02:00
|
|
|
}
|
2011-12-27 10:33:20 +01:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(Features2D, SURF, DEVICES(cv::gpu::GLOBAL_ATOMICS));
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// FAST
|
|
|
|
|
|
|
|
GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo)
|
2011-12-27 10:33:20 +01:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GetParam();
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
2011-12-27 10:33:20 +01:00
|
|
|
|
|
|
|
ASSERT_FALSE(img_host.empty());
|
2011-09-12 09:48:09 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat img(img_host);
|
|
|
|
cv::gpu::GpuMat keypoints, descriptors;
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::FAST_GPU fastGPU(20);
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE()
|
2011-12-27 10:33:20 +01:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
fastGPU(img, cv::gpu::GpuMat(), keypoints);
|
2011-12-27 10:33:20 +01:00
|
|
|
}
|
2011-09-12 09:48:09 +02:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(Features2D, FAST, DEVICES(cv::gpu::GLOBAL_ATOMICS));
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// ORB
|
|
|
|
|
|
|
|
GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo)
|
2011-12-27 10:33:20 +01:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GetParam();
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
2011-12-27 10:33:20 +01:00
|
|
|
|
|
|
|
ASSERT_FALSE(img_host.empty());
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat img(img_host);
|
|
|
|
cv::gpu::GpuMat keypoints, descriptors;
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::ORB_GPU orbGPU(4000);
|
2011-12-27 10:33:20 +01:00
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE()
|
2011-12-27 10:33:20 +01:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
orbGPU(img, cv::gpu::GpuMat(), keypoints, descriptors);
|
2011-12-27 10:33:20 +01:00
|
|
|
}
|
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(Features2D, ORB, DEVICES(cv::gpu::GLOBAL_ATOMICS));
|
|
|
|
|
|
|
|
#endif
|