opencv/modules/gpu/perf/perf_calib3d.cpp

303 lines
8.0 KiB
C++
Raw Normal View History

#include "perf_precomp.hpp"
2011-12-28 13:53:08 +01:00
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// StereoBM
2011-12-28 13:53:08 +01:00
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo)
{
2011-12-28 13:53:08 +01:00
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
2012-05-23 14:58:01 +02:00
cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_r_host.empty());
2012-05-23 14:58:01 +02:00
cv::gpu::StereoBM_GPU bm(0, 256);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
2011-12-28 13:53:08 +01:00
cv::gpu::GpuMat dst;
2012-05-23 14:58:01 +02:00
bm(img_l, img_r, dst);
declare.time(5.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
bm(img_l, img_r, dst);
}
2011-12-28 13:53:08 +01:00
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES);
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// StereoBeliefPropagation
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo)
{
2011-12-28 13:53:08 +01:00
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png");
ASSERT_FALSE(img_l_host.empty());
2012-05-23 14:58:01 +02:00
cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png");
ASSERT_FALSE(img_r_host.empty());
2012-05-23 14:58:01 +02:00
cv::gpu::StereoBeliefPropagation bp(64);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
2011-12-28 13:53:08 +01:00
cv::gpu::GpuMat dst;
2012-05-23 14:58:01 +02:00
bp(img_l, img_r, dst);
declare.time(10.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
bp(img_l, img_r, dst);
}
2011-12-28 13:53:08 +01:00
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES);
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// StereoConstantSpaceBP
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo)
{
2011-12-28 13:53:08 +01:00
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
2012-05-23 14:58:01 +02:00
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;
2012-05-23 14:58:01 +02:00
csbp(img_l, img_r, dst);
2012-05-23 14:58:01 +02:00
declare.time(10.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
csbp(img_l, img_r, dst);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// DisparityBilateralFilter
2011-12-28 13:53:08 +01:00
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST_1(DisparityBilateralFilter, cv::gpu::DeviceInfo)
{
2011-12-28 13:53:08 +01:00
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
cv::Mat img_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
2012-05-23 14:58:01 +02:00
cv::Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(disp_host.empty());
2012-05-23 14:58:01 +02:00
cv::gpu::DisparityBilateralFilter f(128);
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat disp(disp_host);
2011-12-28 13:53:08 +01:00
cv::gpu::GpuMat dst;
2012-05-23 14:58:01 +02:00
f(disp, img, dst);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
f(disp, img, dst);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, DisparityBilateralFilter, ALL_DEVICES);
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// TransformPoints
2011-12-28 13:53:08 +01:00
2012-05-23 14:58:01 +02:00
IMPLEMENT_PARAM_CLASS(Count, int)
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(TransformPoints, cv::gpu::DeviceInfo, Count)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
2011-12-28 13:53:08 +01:00
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
int count = GET_PARAM(1);
2012-05-23 14:58:01 +02:00
cv::Mat src_host(1, count, CV_32FC3);
fill(src_host, -100, 100);
2012-05-23 14:58:01 +02:00
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);
2011-12-28 13:53:08 +01:00
cv::gpu::GpuMat dst;
2012-05-23 14:58:01 +02:00
cv::gpu::transformPoints(src, rvec, tvec, dst);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
cv::gpu::transformPoints(src, rvec, tvec, dst);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// ProjectPoints
2011-12-28 13:53:08 +01:00
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count)
{
2012-05-23 14:58:01 +02:00
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
2011-12-28 13:53:08 +01:00
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
int count = GET_PARAM(1);
2012-05-23 14:58:01 +02:00
cv::Mat src_host(1, count, CV_32FC3);
fill(src_host, -100, 100);
2012-05-23 14:58:01 +02:00
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);
2011-12-28 13:53:08 +01:00
cv::gpu::GpuMat dst;
2012-05-23 14:58:01 +02:00
cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst);
2012-05-23 14:58:01 +02:00
TEST_CYCLE()
{
cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), 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)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
int count = GET_PARAM(1);
cv::Mat object(1, count, CV_32FC3);
fill(object, -100, 100);
cv::Mat camera_mat(3, 3, CV_32FC1);
fill(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));
std::vector<cv::Point2f> image_vec;
cv::Mat rvec_gold(1, 3, CV_32FC1);
fill(rvec_gold, 0, 1);
cv::Mat tvec_gold(1, 3, CV_32FC1);
fill(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]);
cv::Mat rvec;
cv::Mat tvec;
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
declare.time(3.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
}
}
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// ReprojectImageTo3D
2011-12-28 13:53:08 +01:00
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth)
{
2012-05-23 14:58:01 +02:00
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
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 Q(4, 4, CV_32FC1);
fill(Q, 0.1, 1.0);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::reprojectImageTo3D(src, dst, Q);
2012-05-23 14:58:01 +02:00
TEST_CYCLE()
{
cv::gpu::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)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
2011-12-28 13:53:08 +01:00
cv::gpu::setDevice(devInfo.deviceID());
2012-05-23 14:58:01 +02:00
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
2012-05-23 14:58:01 +02:00
cv::Mat src_host(size, type);
fill(src_host, 0, 255);
2012-05-23 14:58:01 +02:00
cv::gpu::GpuMat src(src_host);
2011-12-28 13:53:08 +01:00
cv::gpu::GpuMat dst;
2012-05-23 14:58:01 +02:00
cv::gpu::drawColorDisp(src, dst, 255);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
cv::gpu::drawColorDisp(src, dst, 255);
}
}
2011-12-28 13:53:08 +01:00
2012-05-23 14:58:01 +02:00
INSTANTIATE_TEST_CASE_P(Calib3D, DrawColorDisp, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16S))));
2011-12-28 13:53:08 +01:00
#endif