Merge branch 'gpu-tests'
This commit is contained in:
125
modules/gpu/perf/main.cpp
Normal file
125
modules/gpu/perf/main.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
void printOsInfo()
|
||||
{
|
||||
#if defined _WIN32
|
||||
# if defined _WIN64
|
||||
cout << "OS: Windows x64 \n" << endl;
|
||||
# else
|
||||
cout << "OS: Windows x32 \n" << endl;
|
||||
# endif
|
||||
#elif defined linux
|
||||
# if defined _LP64
|
||||
cout << "OS: Linux x64 \n" << endl;
|
||||
# else
|
||||
cout << "OS: Linux x32 \n" << endl;
|
||||
# endif
|
||||
#elif defined __APPLE__
|
||||
# if defined _LP64
|
||||
cout << "OS: Apple x64 \n" << endl;
|
||||
# else
|
||||
cout << "OS: Apple x32 \n" << endl;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void printCudaInfo()
|
||||
{
|
||||
#ifndef HAVE_CUDA
|
||||
cout << "OpenCV was built without CUDA support \n" << endl;
|
||||
#else
|
||||
int driver;
|
||||
cudaDriverGetVersion(&driver);
|
||||
|
||||
cout << "CUDA Driver version: " << driver << '\n';
|
||||
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n';
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << "GPU module was compiled for the following GPU archs:" << endl;
|
||||
cout << " BIN: " << CUDA_ARCH_BIN << '\n';
|
||||
cout << " PTX: " << CUDA_ARCH_PTX << '\n';
|
||||
|
||||
cout << endl;
|
||||
|
||||
int deviceCount = getCudaEnabledDeviceCount();
|
||||
cout << "CUDA device count: " << deviceCount << '\n';
|
||||
|
||||
cout << endl;
|
||||
|
||||
for (int i = 0; i < deviceCount; ++i)
|
||||
{
|
||||
DeviceInfo info(i);
|
||||
|
||||
cout << "Device [" << i << "] \n";
|
||||
cout << "\t Name: " << info.name() << '\n';
|
||||
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n';
|
||||
cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n';
|
||||
cout << "\t Total memory: " << static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n";
|
||||
cout << "\t Free memory: " << static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n";
|
||||
if (!info.isCompatible())
|
||||
cout << "\t !!! This device is NOT compatible with current GPU module build \n";
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CommandLineParser cmd(argc, (const char**) argv,
|
||||
"{ print_info_only | print_info_only | false | Print information about system and exit }"
|
||||
"{ device | device | 0 | Device on which tests will be executed }"
|
||||
"{ cpu | cpu | false | Run tests on cpu }"
|
||||
);
|
||||
|
||||
printOsInfo();
|
||||
printCudaInfo();
|
||||
|
||||
if (cmd.get<bool>("print_info_only"))
|
||||
return 0;
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
bool cpu = cmd.get<bool>("cpu");
|
||||
#ifndef HAVE_CUDA
|
||||
cpu = true;
|
||||
#endif
|
||||
|
||||
if (cpu)
|
||||
{
|
||||
runOnGpu = false;
|
||||
|
||||
cout << "Run tests on CPU \n" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
runOnGpu = true;
|
||||
|
||||
if (device < 0 || device >= getCudaEnabledDeviceCount())
|
||||
{
|
||||
cerr << "Incorrect device index - " << device << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
DeviceInfo info(device);
|
||||
if (!info.isCompatible())
|
||||
{
|
||||
cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
setDevice(device);
|
||||
|
||||
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
|
||||
}
|
||||
|
||||
InitGoogleTest(&argc, argv);
|
||||
perf::TestBase::Init(argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
@@ -1,219 +1,263 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoBM
|
||||
|
||||
GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo)
|
||||
typedef pair<string, string> pair_string;
|
||||
DEF_PARAM_TEST_1(ImagePair, pair_string);
|
||||
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(make_pair<string, string>("gpu/perf/aloe.jpg", "gpu/perf/aloeR.jpg")))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_l_host.empty());
|
||||
|
||||
cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_r_host.empty());
|
||||
|
||||
cv::gpu::StereoBM_GPU bm(0, 256);
|
||||
cv::gpu::GpuMat img_l(img_l_host);
|
||||
cv::gpu::GpuMat img_r(img_r_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
bm(img_l, img_r, dst);
|
||||
|
||||
declare.time(5.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
const cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(imgLeft.empty());
|
||||
|
||||
const cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(imgRight.empty());
|
||||
|
||||
const int preset = 0;
|
||||
const int ndisp = 256;
|
||||
|
||||
if (runOnGpu)
|
||||
{
|
||||
bm(img_l, img_r, dst);
|
||||
cv::gpu::StereoBM_GPU d_bm(preset, ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
d_bm(d_imgLeft, d_imgRight, d_dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_bm(d_imgLeft, d_imgRight, d_dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::StereoBM bm(preset, ndisp);
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
bm(imgLeft, imgRight, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
bm(imgLeft, imgRight, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoBeliefPropagation
|
||||
|
||||
GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo)
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(make_pair<string, string>("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png");
|
||||
ASSERT_FALSE(img_l_host.empty());
|
||||
|
||||
cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png");
|
||||
ASSERT_FALSE(img_r_host.empty());
|
||||
|
||||
cv::gpu::StereoBeliefPropagation bp(64);
|
||||
cv::gpu::GpuMat img_l(img_l_host);
|
||||
cv::gpu::GpuMat img_r(img_r_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
bp(img_l, img_r, dst);
|
||||
|
||||
declare.time(10.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
const cv::Mat imgLeft = readImage(GetParam().first);
|
||||
ASSERT_FALSE(imgLeft.empty());
|
||||
|
||||
const cv::Mat imgRight = readImage(GetParam().second);
|
||||
ASSERT_FALSE(imgRight.empty());
|
||||
|
||||
const int ndisp = 64;
|
||||
|
||||
if (runOnGpu)
|
||||
{
|
||||
bp(img_l, img_r, dst);
|
||||
cv::gpu::StereoBeliefPropagation d_bp(ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
d_bp(d_imgLeft, d_imgRight, d_dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_bp(d_imgLeft, d_imgRight, d_dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoConstantSpaceBP
|
||||
|
||||
GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo)
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(make_pair<string, string>("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png")))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_l_host.empty());
|
||||
|
||||
cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_r_host.empty());
|
||||
|
||||
cv::gpu::StereoConstantSpaceBP csbp(128);
|
||||
cv::gpu::GpuMat img_l(img_l_host);
|
||||
cv::gpu::GpuMat img_r(img_r_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
csbp(img_l, img_r, dst);
|
||||
|
||||
declare.time(10.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
const cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(imgLeft.empty());
|
||||
|
||||
const cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(imgRight.empty());
|
||||
|
||||
const int ndisp = 128;
|
||||
|
||||
if (runOnGpu)
|
||||
{
|
||||
csbp(img_l, img_r, dst);
|
||||
cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
d_csbp(d_imgLeft, d_imgRight, d_dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_csbp(d_imgLeft, d_imgRight, d_dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DisparityBilateralFilter
|
||||
|
||||
GPU_PERF_TEST_1(DisparityBilateralFilter, cv::gpu::DeviceInfo)
|
||||
PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(make_pair<string, string>("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png")))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::Mat img_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
const cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(disp.empty());
|
||||
|
||||
cv::Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(disp_host.empty());
|
||||
const int ndisp = 128;
|
||||
|
||||
cv::gpu::DisparityBilateralFilter f(128);
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat disp(disp_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
f(disp, img, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
f(disp, img, dst);
|
||||
cv::gpu::DisparityBilateralFilter d_filter(ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_disp(disp);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
d_filter(d_disp, d_img, d_dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_filter(d_disp, d_img, d_dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, DisparityBilateralFilter, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// TransformPoints
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(Count, int)
|
||||
DEF_PARAM_TEST_1(Count, int);
|
||||
|
||||
GPU_PERF_TEST(TransformPoints, cv::gpu::DeviceInfo, Count)
|
||||
PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const int count = GetParam();
|
||||
|
||||
int count = GET_PARAM(1);
|
||||
cv::Mat src(1, count, CV_32FC3);
|
||||
fillRandom(src, -100, 100);
|
||||
|
||||
cv::Mat src_host(1, count, CV_32FC3);
|
||||
fill(src_host, -100, 100);
|
||||
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::transformPoints(src, rvec, tvec, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::transformPoints(src, rvec, tvec, dst);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values<Count>(5000, 10000, 20000)));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ProjectPoints
|
||||
|
||||
GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count)
|
||||
PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const int count = GetParam();
|
||||
|
||||
int count = GET_PARAM(1);
|
||||
cv::Mat src(1, count, CV_32FC3);
|
||||
fillRandom(src, -100, 100);
|
||||
|
||||
cv::Mat src_host(1, count, CV_32FC3);
|
||||
fill(src_host, -100, 100);
|
||||
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
const cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values<Count>(5000, 10000, 20000)));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SolvePnPRansac
|
||||
|
||||
GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count)
|
||||
PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(10.0);
|
||||
|
||||
int count = GET_PARAM(1);
|
||||
const int count = GetParam();
|
||||
|
||||
cv::Mat object(1, count, CV_32FC3);
|
||||
fill(object, -100, 100);
|
||||
fillRandom(object, -100, 100);
|
||||
|
||||
cv::Mat camera_mat(3, 3, CV_32FC1);
|
||||
fill(camera_mat, 0.5, 1);
|
||||
fillRandom(camera_mat, 0.5, 1);
|
||||
camera_mat.at<float>(0, 1) = 0.f;
|
||||
camera_mat.at<float>(1, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 1) = 0.f;
|
||||
|
||||
cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
|
||||
const cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
|
||||
|
||||
std::vector<cv::Point2f> image_vec;
|
||||
cv::Mat rvec_gold(1, 3, CV_32FC1);
|
||||
fill(rvec_gold, 0, 1);
|
||||
fillRandom(rvec_gold, 0, 1);
|
||||
cv::Mat tvec_gold(1, 3, CV_32FC1);
|
||||
fill(tvec_gold, 0, 1);
|
||||
fillRandom(tvec_gold, 0, 1);
|
||||
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec);
|
||||
|
||||
cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
|
||||
@@ -221,82 +265,92 @@ GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count)
|
||||
cv::Mat rvec;
|
||||
cv::Mat tvec;
|
||||
|
||||
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
|
||||
declare.time(3.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values<Count>(5000, 10000, 20000)));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ReprojectImageTo3D
|
||||
|
||||
GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth)
|
||||
PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int depth = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, depth);
|
||||
fill(src_host, 5.0, 30.0);
|
||||
cv::Mat src(size, depth);
|
||||
fillRandom(src, 5.0, 30.0);
|
||||
|
||||
cv::Mat Q(4, 4, CV_32FC1);
|
||||
fill(Q, 0.1, 1.0);
|
||||
fillRandom(Q, 0.1, 1.0);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::reprojectImageTo3D(src, dst, Q);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::reprojectImageTo3D(src, dst, Q);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::reprojectImageTo3D(src, dst, Q);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::reprojectImageTo3D(src, dst, Q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, ReprojectImageTo3D, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values<MatDepth>(CV_8U, CV_16S)));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DrawColorDisp
|
||||
|
||||
GPU_PERF_TEST(DrawColorDisp, cv::gpu::DeviceInfo, cv::Size, MatDepth)
|
||||
PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src, 0, 255);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0, 255);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::drawColorDisp(src, dst, 255);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::drawColorDisp(src, dst, 255);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::drawColorDisp(d_src, d_dst, 255);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::drawColorDisp(d_src, d_dst, 255);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, DrawColorDisp, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16S))));
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,209 +1,278 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SURF
|
||||
|
||||
GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo)
|
||||
DEF_PARAM_TEST_1(Image, string);
|
||||
|
||||
PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.jpg"))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(50.0);
|
||||
|
||||
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::gpu::SURF_GPU surf;
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat keypoints, descriptors;
|
||||
|
||||
surf(img, cv::gpu::GpuMat(), keypoints, descriptors);
|
||||
|
||||
declare.time(2.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
surf(img, cv::gpu::GpuMat(), keypoints, descriptors);
|
||||
cv::gpu::SURF_GPU d_surf;
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_keypoints, d_descriptors;
|
||||
|
||||
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::SURF surf;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
|
||||
surf(img, cv::noArray(), keypoints, descriptors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
keypoints.clear();
|
||||
surf(img, cv::noArray(), keypoints, descriptors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// FAST
|
||||
|
||||
GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo)
|
||||
PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.jpg"))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
|
||||
cv::gpu::FAST_GPU fast(20);
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat keypoints;
|
||||
|
||||
fast(img, cv::gpu::GpuMat(), keypoints);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
fast(img, cv::gpu::GpuMat(), keypoints);
|
||||
cv::gpu::FAST_GPU d_fast(20);
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_keypoints;
|
||||
|
||||
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
|
||||
cv::FAST(img, keypoints, 20);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
keypoints.clear();
|
||||
cv::FAST(img, keypoints, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ORB
|
||||
|
||||
GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo)
|
||||
PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.jpg"))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
|
||||
cv::gpu::ORB_GPU orb(4000);
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat keypoints, descriptors;
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
orb(img, cv::gpu::GpuMat(), keypoints, descriptors);
|
||||
cv::gpu::ORB_GPU d_orb(4000);
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_keypoints, d_descriptors;
|
||||
|
||||
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::ORB orb(4000);
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
|
||||
orb(img, cv::noArray(), keypoints, descriptors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
keypoints.clear();
|
||||
orb(img, cv::noArray(), keypoints, descriptors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES);
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BFMatch
|
||||
|
||||
DEF_PARAM_TEST(DescSize_Norm, int, NormType);
|
||||
|
||||
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))))
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
int desc_size = GET_PARAM(0);
|
||||
int normType = GET_PARAM(1);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
|
||||
cv::Mat query(3000, desc_size, type);
|
||||
fillRandom(query);
|
||||
|
||||
cv::Mat train(3000, desc_size, type);
|
||||
fillRandom(train);
|
||||
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat d_query(query);
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
cv::gpu::GpuMat d_trainIdx, d_distance;
|
||||
|
||||
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BFMatcher matcher(normType);
|
||||
|
||||
std::vector<cv::DMatch> matches;
|
||||
|
||||
matcher.match(query, train, matches);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.match(query, train, matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BruteForceMatcher_match
|
||||
// BFKnnMatch
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
|
||||
DEF_PARAM_TEST(DescSize_K_Norm, int, int, NormType);
|
||||
|
||||
GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType)
|
||||
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))))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(30.0);
|
||||
|
||||
int desc_size = GET_PARAM(1);
|
||||
int desc_size = GET_PARAM(0);
|
||||
int k = GET_PARAM(1);
|
||||
int normType = GET_PARAM(2);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
|
||||
cv::Mat query_host(3000, desc_size, type);
|
||||
fill(query_host, 0.0, 10.0);
|
||||
cv::Mat query(3000, desc_size, type);
|
||||
fillRandom(query);
|
||||
|
||||
cv::Mat train_host(3000, desc_size, type);
|
||||
fill(train_host, 0.0, 10.0);
|
||||
cv::Mat train(3000, desc_size, type);
|
||||
fillRandom(train);
|
||||
|
||||
cv::gpu::BFMatcher_GPU matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat query(query_host);
|
||||
cv::gpu::GpuMat train(train_host);
|
||||
cv::gpu::GpuMat trainIdx, distance;
|
||||
|
||||
matcher.matchSingle(query, train, trainIdx, distance);
|
||||
|
||||
declare.time(3.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
matcher.matchSingle(query, train, trainIdx, distance);
|
||||
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat d_query(query);
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist;
|
||||
|
||||
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BFMatcher matcher(normType);
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
matcher.knnMatch(query, train, matches, k);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.knnMatch(query, train, matches, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BruteForceMatcher_knnMatch
|
||||
// BFRadiusMatch
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(K, int)
|
||||
|
||||
GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType)
|
||||
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))))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(30.0);
|
||||
|
||||
int desc_size = GET_PARAM(1);
|
||||
int k = GET_PARAM(2);
|
||||
int normType = GET_PARAM(3);
|
||||
int desc_size = GET_PARAM(0);
|
||||
int normType = GET_PARAM(1);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
|
||||
cv::Mat query_host(3000, desc_size, type);
|
||||
fill(query_host, 0.0, 10.0);
|
||||
cv::Mat query(3000, desc_size, type);
|
||||
fillRandom(query, 0.0, 1.0);
|
||||
|
||||
cv::Mat train_host(3000, desc_size, type);
|
||||
fill(train_host, 0.0, 10.0);
|
||||
cv::Mat train(3000, desc_size, type);
|
||||
fillRandom(train, 0.0, 1.0);
|
||||
|
||||
cv::gpu::BFMatcher_GPU matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat query(query_host);
|
||||
cv::gpu::GpuMat train(train_host);
|
||||
cv::gpu::GpuMat trainIdx, distance, allDist;
|
||||
|
||||
matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k);
|
||||
|
||||
declare.time(3.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k);
|
||||
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat d_query(query);
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance;
|
||||
|
||||
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BFMatcher matcher(normType);
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
matcher.radiusMatch(query, train, matches, 2.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.radiusMatch(query, train, matches, 2.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BruteForceMatcher_radiusMatch
|
||||
|
||||
GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
int desc_size = GET_PARAM(1);
|
||||
int normType = GET_PARAM(2);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
|
||||
cv::Mat query_host(3000, desc_size, type);
|
||||
fill(query_host, 0.0, 1.0);
|
||||
|
||||
cv::Mat train_host(3000, desc_size, type);
|
||||
fill(train_host, 0.0, 1.0);
|
||||
|
||||
cv::gpu::BFMatcher_GPU matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat query(query_host);
|
||||
cv::gpu::GpuMat train(train_host);
|
||||
cv::gpu::GpuMat trainIdx, nMatches, distance;
|
||||
|
||||
matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0);
|
||||
|
||||
declare.time(3.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
} // namespace
|
||||
|
@@ -1,308 +1,379 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Blur
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(KernelSize, int)
|
||||
DEF_PARAM_TEST(Sz_Type_KernelSz, cv::Size, MatType, int);
|
||||
|
||||
GPU_PERF_TEST(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), Values(3, 5, 7)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int ksize = GET_PARAM(3);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::blur(src, dst, cv::Size(ksize, ksize));
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::blur(src, dst, cv::Size(ksize, ksize));
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::blur(src, dst, cv::Size(ksize, ksize));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::blur(src, dst, cv::Size(ksize, ksize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Blur, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
|
||||
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sobel
|
||||
|
||||
GPU_PERF_TEST(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int ksize = GET_PARAM(3);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat buf;
|
||||
|
||||
cv::gpu::Sobel(src, dst, -1, 1, 1, buf, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::Sobel(src, dst, -1, 1, 1, buf, ksize);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::Sobel(src, dst, -1, 1, 1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Sobel(src, dst, -1, 1, 1, ksize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Sobel, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),
|
||||
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Scharr
|
||||
|
||||
GPU_PERF_TEST(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType)
|
||||
PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat buf;
|
||||
|
||||
cv::gpu::Scharr(src, dst, -1, 1, 0, buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::Scharr(src, dst, -1, 1, 0, buf);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::Scharr(src, dst, -1, 1, 0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Scharr(src, dst, -1, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Scharr, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GaussianBlur
|
||||
|
||||
GPU_PERF_TEST(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int ksize = GET_PARAM(3);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat buf;
|
||||
|
||||
cv::gpu::GaussianBlur(src, dst, cv::Size(ksize, ksize), buf, 0.5);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GaussianBlur(src, dst, cv::Size(ksize, ksize), buf, 0.5);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, GaussianBlur, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),
|
||||
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Laplacian
|
||||
|
||||
GPU_PERF_TEST(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 3)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int ksize = GET_PARAM(3);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::Laplacian(src, dst, -1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::Laplacian(src, dst, -1, ksize);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::Laplacian(src, dst, -1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Laplacian(src, dst, -1, ksize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Laplacian, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)),
|
||||
testing::Values(KernelSize(1), KernelSize(3))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Erode
|
||||
|
||||
GPU_PERF_TEST(Erode, cv::gpu::DeviceInfo, cv::Size, MatType)
|
||||
PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat buf;
|
||||
|
||||
cv::gpu::erode(src, dst, ker, buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::erode(src, dst, ker, buf);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::erode(d_src, d_dst, ker, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::erode(d_src, d_dst, ker, d_buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::erode(src, dst, ker);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::erode(src, dst, ker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Erode, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Dilate
|
||||
|
||||
GPU_PERF_TEST(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType)
|
||||
PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat buf;
|
||||
|
||||
cv::gpu::dilate(src, dst, ker, buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::dilate(src, dst, ker, buf);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::dilate(src, dst, ker);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::dilate(src, dst, ker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Dilate, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// MorphologyEx
|
||||
|
||||
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
|
||||
#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT))
|
||||
#define ALL_MORPH_OPS ValuesIn(MorphOp::all())
|
||||
|
||||
GPU_PERF_TEST(MorphologyEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp)
|
||||
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, MorphOp);
|
||||
|
||||
PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), ALL_MORPH_OPS))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int morphOp = GET_PARAM(3);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int morphOp = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat buf1;
|
||||
cv::gpu::GpuMat buf2;
|
||||
|
||||
cv::gpu::morphologyEx(src, dst, morphOp, ker, buf1, buf2);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::morphologyEx(src, dst, morphOp, ker, buf1, buf2);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::GpuMat d_buf1;
|
||||
cv::gpu::GpuMat d_buf2;
|
||||
|
||||
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::morphologyEx(src, dst, morphOp, ker);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::morphologyEx(src, dst, morphOp, ker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, MorphologyEx, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
|
||||
ALL_MORPH_OPS));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Filter2D
|
||||
|
||||
GPU_PERF_TEST(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(3, 5, 7, 9, 11, 13, 15)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int ksize = GET_PARAM(3);
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0.0, 255.0);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat kernel(ksize, ksize, CV_32FC1);
|
||||
fill(kernel, 0.0, 1.0);
|
||||
fillRandom(kernel, 0.0, 1.0);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::filter2D(src, dst, -1, kernel);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::filter2D(src, dst, -1, kernel);
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::filter2D(src, dst, -1, kernel);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::filter2D(src, dst, -1, kernel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Filters, Filter2D, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)),
|
||||
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
|
||||
|
||||
#endif
|
||||
} // namespace
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,75 +1,136 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size)
|
||||
namespace {
|
||||
|
||||
DEF_PARAM_TEST_1(Image, string);
|
||||
|
||||
struct GreedyLabeling
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
struct dot
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE);
|
||||
static dot make(int i, int j)
|
||||
{
|
||||
dot d; d.x = i; d.y = j;
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
// cv::threshold(image, image, 150, 255, CV_THRESH_BINARY);
|
||||
struct InInterval
|
||||
{
|
||||
InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {};
|
||||
const int lo, hi;
|
||||
|
||||
cv::gpu::GpuMat mask;
|
||||
mask.create(image.rows, image.cols, CV_8UC1);
|
||||
bool operator() (const unsigned char a, const unsigned char b) const
|
||||
{
|
||||
int d = a - b;
|
||||
return lo <= d && d <= hi;
|
||||
}
|
||||
};
|
||||
|
||||
cv::gpu::GpuMat components;
|
||||
components.create(image.rows, image.cols, CV_32SC1);
|
||||
GreedyLabeling(cv::Mat img)
|
||||
: image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];}
|
||||
|
||||
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
|
||||
~GreedyLabeling(){delete[] stack;}
|
||||
|
||||
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
|
||||
void operator() (cv::Mat labels) const
|
||||
{
|
||||
labels.setTo(cv::Scalar::all(-1));
|
||||
InInterval inInt(0, 2);
|
||||
int cc = -1;
|
||||
|
||||
int* dist_labels = (int*)labels.data;
|
||||
int pitch = labels.step1();
|
||||
|
||||
unsigned char* source = (unsigned char*)image.data;
|
||||
int width = image.cols;
|
||||
int height = image.rows;
|
||||
|
||||
for (int j = 0; j < image.rows; ++j)
|
||||
for (int i = 0; i < image.cols; ++i)
|
||||
{
|
||||
if (dist_labels[j * pitch + i] != -1) continue;
|
||||
|
||||
dot* top = stack;
|
||||
dot p = dot::make(i, j);
|
||||
cc++;
|
||||
|
||||
dist_labels[j * pitch + i] = cc;
|
||||
|
||||
while (top >= stack)
|
||||
{
|
||||
int* dl = &dist_labels[p.y * pitch + p.x];
|
||||
unsigned char* sp = &source[p.y * image.step1() + p.x];
|
||||
|
||||
dl[0] = cc;
|
||||
|
||||
//right
|
||||
if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1]))
|
||||
*top++ = dot::make(p.x + 1, p.y);
|
||||
|
||||
//left
|
||||
if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1]))
|
||||
*top++ = dot::make(p.x - 1, p.y);
|
||||
|
||||
//bottom
|
||||
if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()]))
|
||||
*top++ = dot::make(p.x, p.y + 1);
|
||||
|
||||
//top
|
||||
if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()]))
|
||||
*top++ = dot::make(p.x, p.y - 1);
|
||||
|
||||
p = *--top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cv::Mat image;
|
||||
cv::Mat _labels;
|
||||
dot* stack;
|
||||
};
|
||||
|
||||
PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/aloe-disp.png"))
|
||||
{
|
||||
declare.time(1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::labelComponents(mask, components);
|
||||
cv::gpu::GpuMat mask;
|
||||
mask.create(image.rows, image.cols, CV_8UC1);
|
||||
|
||||
cv::gpu::GpuMat components;
|
||||
components.create(image.rows, image.cols, CV_32SC1);
|
||||
|
||||
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
|
||||
|
||||
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::labelComponents(mask, components);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GreedyLabeling host(image);
|
||||
|
||||
host(host._labels);
|
||||
|
||||
declare.time(1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
host(host._labels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Labeling, ConnectedComponents, testing::Combine(ALL_DEVICES, testing::Values(cv::Size(261, 262))));
|
||||
|
||||
#endif
|
||||
} // namespace
|
||||
|
@@ -1,20 +0,0 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
perf::TestBase::Init(argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("OpenCV was built without CUDA support\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,141 +1,169 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetTo
|
||||
|
||||
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType)
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::gpu::GpuMat src(size, type);
|
||||
cv::Scalar val(1, 2, 3, 4);
|
||||
|
||||
src.setTo(val);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_src(size, type);
|
||||
|
||||
d_src.setTo(val);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.setTo(val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat src(size, type);
|
||||
|
||||
src.setTo(val);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.setTo(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
|
||||
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
|
||||
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
|
||||
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetToMasked
|
||||
|
||||
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0, 255);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat mask_host(size, CV_8UC1);
|
||||
fill(mask_host, 0, 2);
|
||||
cv::Mat mask(size, CV_8UC1);
|
||||
fillRandom(mask, 0, 2);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::Scalar val(1, 2, 3, 4);
|
||||
cv::gpu::GpuMat mask(mask_host);
|
||||
|
||||
src.setTo(val, mask);
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_mask(mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
d_src.setTo(val, d_mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.setTo(val, d_mask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
src.setTo(val, mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.setTo(val, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
|
||||
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
|
||||
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
|
||||
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CopyToMasked
|
||||
|
||||
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int type = GET_PARAM(2);
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src_host(size, type);
|
||||
fill(src_host, 0, 255);
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat mask_host(size, CV_8UC1);
|
||||
fill(mask_host, 0, 2);
|
||||
cv::Mat mask(size, CV_8UC1);
|
||||
fillRandom(mask, 0, 2);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat mask(mask_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
src.copyTo(dst, mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_mask(mask);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
d_src.copyTo(d_dst, d_mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.copyTo(d_dst, d_mask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
src.copyTo(dst, mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.copyTo(dst, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
|
||||
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
|
||||
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
|
||||
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ConvertTo
|
||||
|
||||
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth)
|
||||
DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
|
||||
|
||||
PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F)))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth1 = GET_PARAM(1);
|
||||
int depth2 = GET_PARAM(2);
|
||||
|
||||
cv::Size size = GET_PARAM(1);
|
||||
int depth1 = GET_PARAM(2);
|
||||
int depth2 = GET_PARAM(3);
|
||||
cv::Mat src(size, depth1);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat src_host(size, depth1);
|
||||
fill(src_host, 0, 255);
|
||||
|
||||
cv::gpu::GpuMat src(src_host);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
src.convertTo(dst, depth2, 0.5, 1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
src.convertTo(dst, depth2, 0.5, 1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.convertTo(dst, depth2, 0.5, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)),
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F))));
|
||||
|
||||
#endif
|
||||
} // namespace
|
||||
|
@@ -1,85 +1,131 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// HOG
|
||||
|
||||
GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo)
|
||||
DEF_PARAM_TEST_1(Image, string);
|
||||
|
||||
PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::Mat img_host = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
std::vector<cv::Rect> found_locations;
|
||||
|
||||
cv::gpu::HOGDescriptor hog;
|
||||
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
|
||||
|
||||
hog.detectMultiScale(img, found_locations);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
|
||||
cv::gpu::HOGDescriptor d_hog;
|
||||
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
|
||||
|
||||
d_hog.detectMultiScale(d_img, found_locations);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_hog.detectMultiScale(d_img, found_locations);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::HOGDescriptor hog;
|
||||
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
|
||||
|
||||
hog.detectMultiScale(img, found_locations);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
hog.detectMultiScale(img, found_locations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES);
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// HaarClassifier
|
||||
|
||||
GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo)
|
||||
typedef pair<string, string> pair_string;
|
||||
DEF_PARAM_TEST_1(ImageAndCascade, pair_string);
|
||||
|
||||
PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
|
||||
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/perf/haarcascade_frontalface_alt.xml")))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
|
||||
cv::gpu::CascadeClassifier_GPU cascade;
|
||||
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat objects_buffer;
|
||||
|
||||
cascade.detectMultiScale(img, objects_buffer);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cascade.detectMultiScale(img, objects_buffer);
|
||||
cv::gpu::CascadeClassifier_GPU d_cascade;
|
||||
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_objects_buffer;
|
||||
|
||||
d_cascade.detectMultiScale(d_img, d_objects_buffer);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_cascade.detectMultiScale(d_img, d_objects_buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::CascadeClassifier cascade;
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
|
||||
|
||||
std::vector<cv::Rect> rects;
|
||||
|
||||
cascade.detectMultiScale(img, rects);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cascade.detectMultiScale(img, rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES);
|
||||
///////////////////////////////////////////////////////////////
|
||||
// LBP cascade
|
||||
|
||||
//===================== LBP cascade ==========================//
|
||||
GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo)
|
||||
PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
|
||||
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml")))
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img_host.empty());
|
||||
|
||||
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat gpu_rects;
|
||||
cv::gpu::CascadeClassifier_GPU cascade;
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
|
||||
|
||||
cascade.detectMultiScale(img, gpu_rects);
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cascade.detectMultiScale(img, gpu_rects);
|
||||
cv::gpu::CascadeClassifier_GPU d_cascade;
|
||||
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_gpu_rects;
|
||||
|
||||
d_cascade.detectMultiScale(d_img, d_gpu_rects);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_cascade.detectMultiScale(d_img, d_gpu_rects);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::CascadeClassifier cascade;
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
|
||||
|
||||
std::vector<cv::Rect> rects;
|
||||
|
||||
cascade.detectMultiScale(img, rects);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cascade.detectMultiScale(img, rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES);
|
||||
|
||||
#endif
|
||||
} // namespace
|
||||
|
@@ -11,6 +11,10 @@
|
||||
|
||||
#include "cvconfig.h"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#endif
|
||||
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
|
||||
@@ -18,8 +22,12 @@
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/video/video.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
|
||||
#include "perf_utility.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
|
@@ -1,77 +0,0 @@
|
||||
#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__
|
||||
#define __OPENCV_PERF_GPU_UTILITY_HPP__
|
||||
|
||||
void fill(cv::Mat& m, double a, double b);
|
||||
|
||||
using perf::MatType;
|
||||
using perf::MatDepth;
|
||||
|
||||
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
|
||||
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
|
||||
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING)
|
||||
|
||||
struct CvtColorInfo
|
||||
{
|
||||
int scn;
|
||||
int dcn;
|
||||
int code;
|
||||
|
||||
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
|
||||
};
|
||||
|
||||
void PrintTo(const CvtColorInfo& info, std::ostream* os);
|
||||
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
class name \
|
||||
{ \
|
||||
public: \
|
||||
name ( type arg = type ()) : val_(arg) {} \
|
||||
operator type () const {return val_;} \
|
||||
private: \
|
||||
type val_; \
|
||||
}; \
|
||||
inline void PrintTo( name param, std::ostream* os) \
|
||||
{ \
|
||||
*os << #name << " = " << testing::PrintToString(static_cast< type >(param)); \
|
||||
}
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(Channels, int)
|
||||
|
||||
namespace cv { namespace gpu
|
||||
{
|
||||
void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os);
|
||||
}}
|
||||
|
||||
#define GPU_PERF_TEST(name, ...) \
|
||||
struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \
|
||||
{ \
|
||||
public: \
|
||||
name() {} \
|
||||
protected: \
|
||||
void PerfTestBody(); \
|
||||
}; \
|
||||
TEST_P(name, perf){ RunPerfTestBody(); } \
|
||||
void name :: PerfTestBody()
|
||||
|
||||
#define GPU_PERF_TEST_1(name, param_type) \
|
||||
struct name : perf::TestBaseWithParam< param_type > \
|
||||
{ \
|
||||
public: \
|
||||
name() {} \
|
||||
protected: \
|
||||
void PerfTestBody(); \
|
||||
}; \
|
||||
TEST_P(name, perf){ RunPerfTestBody(); } \
|
||||
void name :: PerfTestBody()
|
||||
|
||||
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500))
|
||||
|
||||
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
|
||||
|
||||
const std::vector<cv::gpu::DeviceInfo>& devices();
|
||||
|
||||
#define ALL_DEVICES testing::ValuesIn(devices())
|
||||
|
||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||
|
||||
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
|
File diff suppressed because it is too large
Load Diff
@@ -4,12 +4,19 @@ using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
void fill(Mat& m, double a, double b)
|
||||
bool runOnGpu = true;
|
||||
|
||||
void fillRandom(Mat& m, double a, double b)
|
||||
{
|
||||
RNG rng(123456789);
|
||||
rng.fill(m, RNG::UNIFORM, Scalar::all(a), Scalar::all(b));
|
||||
}
|
||||
|
||||
Mat readImage(const string& fileName, int flags)
|
||||
{
|
||||
return imread(perf::TestBase::getDataPath(fileName), flags);
|
||||
}
|
||||
|
||||
void PrintTo(const CvtColorInfo& info, ostream* os)
|
||||
{
|
||||
static const char* str[] =
|
||||
@@ -184,37 +191,3 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
|
||||
|
||||
*os << str[info.code];
|
||||
}
|
||||
|
||||
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
|
||||
{
|
||||
*os << info.name();
|
||||
}
|
||||
|
||||
Mat readImage(const string& fileName, int flags)
|
||||
{
|
||||
return imread(perf::TestBase::getDataPath(fileName), flags);
|
||||
}
|
||||
|
||||
const vector<DeviceInfo>& devices()
|
||||
{
|
||||
static vector<DeviceInfo> devs;
|
||||
static bool first = true;
|
||||
|
||||
if (first)
|
||||
{
|
||||
int deviceCount = getCudaEnabledDeviceCount();
|
||||
|
||||
devs.reserve(deviceCount);
|
||||
|
||||
for (int i = 0; i < deviceCount; ++i)
|
||||
{
|
||||
DeviceInfo info(i);
|
||||
if (info.isCompatible())
|
||||
devs.push_back(info);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
return devs;
|
||||
}
|
45
modules/gpu/perf/utility.hpp
Normal file
45
modules/gpu/perf/utility.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__
|
||||
#define __OPENCV_PERF_GPU_UTILITY_HPP__
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
|
||||
extern bool runOnGpu;
|
||||
|
||||
void fillRandom(cv::Mat& m, double a = 0.0, double b = 255.0);
|
||||
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
|
||||
|
||||
using perf::MatType;
|
||||
using perf::MatDepth;
|
||||
|
||||
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
|
||||
#define ALL_BORDER_MODES testing::ValuesIn(BorderMode::all())
|
||||
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
|
||||
#define ALL_INTERPOLATIONS testing::ValuesIn(Interpolation::all())
|
||||
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING)
|
||||
|
||||
struct CvtColorInfo
|
||||
{
|
||||
int scn;
|
||||
int dcn;
|
||||
int code;
|
||||
|
||||
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
|
||||
};
|
||||
void PrintTo(const CvtColorInfo& info, std::ostream* os);
|
||||
|
||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||
|
||||
#define DEF_PARAM_TEST(name, ...) typedef ::perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > name
|
||||
#define DEF_PARAM_TEST_1(name, param_type) typedef ::perf::TestBaseWithParam< param_type > name
|
||||
|
||||
DEF_PARAM_TEST_1(Sz, cv::Size);
|
||||
typedef perf::Size_MatType Sz_Type;
|
||||
DEF_PARAM_TEST(Sz_Depth, cv::Size, MatDepth);
|
||||
DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, int);
|
||||
|
||||
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz720p, perf::sz1080p)
|
||||
|
||||
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
|
Reference in New Issue
Block a user