mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
refactored gpu perf tests and fixed sanity tests
This commit is contained in:
parent
0d12f451be
commit
a138e12a26
@ -3,15 +3,14 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoBM
|
||||
|
||||
typedef std::tr1::tuple<string, string> pair_string;
|
||||
DEF_PARAM_TEST_1(ImagePair, pair_string);
|
||||
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png", "gpu/perf/aloeR.png")))
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBM,
|
||||
Values(pair_string("gpu/perf/aloe.png", "gpu/perf/aloeR.png")))
|
||||
{
|
||||
declare.time(5.0);
|
||||
|
||||
@ -28,18 +27,13 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
|
||||
{
|
||||
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;
|
||||
const cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
const cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
d_bm(d_imgLeft, d_imgRight, d_dst);
|
||||
TEST_CYCLE() d_bm(d_imgLeft, d_imgRight, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_bm(d_imgLeft, d_imgRight, d_dst);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -47,12 +41,7 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
bm(imgLeft, imgRight, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
bm(imgLeft, imgRight, dst);
|
||||
}
|
||||
TEST_CYCLE() bm(imgLeft, imgRight, dst);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -61,7 +50,8 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoBeliefPropagation
|
||||
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation,
|
||||
Values(pair_string("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
|
||||
{
|
||||
declare.time(10.0);
|
||||
|
||||
@ -77,29 +67,25 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/
|
||||
{
|
||||
cv::gpu::StereoBeliefPropagation d_bp(ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
const cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
d_bp(d_imgLeft, d_imgRight, d_dst);
|
||||
TEST_CYCLE() d_bp(d_imgLeft, d_imgRight, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_bp(d_imgLeft, d_imgRight, d_dst);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL() << "No such CPU implementation analogy.";
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoConstantSpaceBP
|
||||
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png")))
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP,
|
||||
Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png")))
|
||||
{
|
||||
declare.time(10.0);
|
||||
|
||||
@ -115,29 +101,25 @@ PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/st
|
||||
{
|
||||
cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_imgLeft(imgLeft);
|
||||
const cv::gpu::GpuMat d_imgRight(imgRight);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
d_csbp(d_imgLeft, d_imgRight, d_dst);
|
||||
TEST_CYCLE() d_csbp(d_imgLeft, d_imgRight, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_csbp(d_imgLeft, d_imgRight, d_dst);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL() << "No such CPU implementation analogy.";
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DisparityBilateralFilter
|
||||
|
||||
PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png")))
|
||||
PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter,
|
||||
Values(pair_string("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png")))
|
||||
{
|
||||
const cv::Mat img = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
@ -151,22 +133,17 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
|
||||
{
|
||||
cv::gpu::DisparityBilateralFilter d_filter(ndisp);
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat d_disp(disp);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_img(img);
|
||||
const cv::gpu::GpuMat d_disp(disp);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
d_filter(d_disp, d_img, d_dst);
|
||||
TEST_CYCLE() d_filter(d_disp, d_img, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_filter(d_disp, d_img, d_dst);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL() << "No such CPU implementation analogy.";
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,45 +152,42 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
|
||||
|
||||
DEF_PARAM_TEST_1(Count, int);
|
||||
|
||||
PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
|
||||
PERF_TEST_P(Count, Calib3D_TransformPoints,
|
||||
Values(5000, 10000, 20000))
|
||||
{
|
||||
const int count = GetParam();
|
||||
|
||||
cv::Mat src(1, count, CV_32FC3);
|
||||
fillRandom(src, -100, 100);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
|
||||
TEST_CYCLE() cv::gpu::transformPoints(d_src, rvec, tvec, dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL() << "No such CPU implementation analogy.";
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ProjectPoints
|
||||
|
||||
PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
|
||||
PERF_TEST_P(Count, Calib3D_ProjectPoints,
|
||||
Values(5000, 10000, 20000))
|
||||
{
|
||||
const int count = GetParam();
|
||||
|
||||
cv::Mat src(1, count, CV_32FC3);
|
||||
fillRandom(src, -100, 100);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
|
||||
@ -221,28 +195,18 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat 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(), dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(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);
|
||||
}
|
||||
TEST_CYCLE() cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -251,17 +215,18 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SolvePnPRansac
|
||||
|
||||
PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
|
||||
PERF_TEST_P(Count, Calib3D_SolvePnPRansac,
|
||||
Values(5000, 10000, 20000))
|
||||
{
|
||||
declare.time(10.0);
|
||||
|
||||
const int count = GetParam();
|
||||
|
||||
cv::Mat object(1, count, CV_32FC3);
|
||||
fillRandom(object, -100, 100);
|
||||
declare.in(object, WARMUP_RNG);
|
||||
|
||||
cv::Mat camera_mat(3, 3, CV_32FC1);
|
||||
fillRandom(camera_mat, 0.5, 1);
|
||||
cv::randu(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;
|
||||
@ -269,79 +234,66 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
|
||||
|
||||
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);
|
||||
fillRandom(rvec_gold, 0, 1);
|
||||
cv::randu(rvec_gold, 0, 1);
|
||||
|
||||
cv::Mat tvec_gold(1, 3, CV_32FC1);
|
||||
fillRandom(tvec_gold, 0, 1);
|
||||
cv::randu(tvec_gold, 0, 1);
|
||||
|
||||
std::vector<cv::Point2f> image_vec;
|
||||
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec);
|
||||
|
||||
cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
|
||||
const cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
|
||||
|
||||
cv::Mat rvec;
|
||||
cv::Mat tvec;
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
TEST_CYCLE() cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
}
|
||||
GPU_SANITY_CHECK(rvec, 1e-3);
|
||||
GPU_SANITY_CHECK(tvec, 1e-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
TEST_CYCLE() cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
}
|
||||
CPU_SANITY_CHECK(rvec, 1e-6);
|
||||
CPU_SANITY_CHECK(tvec, 1e-6);
|
||||
}
|
||||
|
||||
CPU_SANITY_CHECK(rvec);
|
||||
CPU_SANITY_CHECK(tvec);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ReprojectImageTo3D
|
||||
|
||||
PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
|
||||
PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16S)))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
|
||||
cv::Mat src(size, depth);
|
||||
fillRandom(src, 5.0, 30.0);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
cv::Mat Q(4, 4, CV_32FC1);
|
||||
fillRandom(Q, 0.1, 1.0);
|
||||
cv::randu(Q, 0.1, 1.0);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
|
||||
TEST_CYCLE() cv::gpu::reprojectImageTo3D(d_src, dst, Q);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::reprojectImageTo3D(src, dst, Q);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::reprojectImageTo3D(src, dst, Q);
|
||||
}
|
||||
TEST_CYCLE() cv::reprojectImageTo3D(src, dst, Q);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -350,32 +302,27 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DrawColorDisp
|
||||
|
||||
PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
|
||||
PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16S)))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src, 0, 255);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::drawColorDisp(d_src, d_dst, 255);
|
||||
TEST_CYCLE() cv::gpu::drawColorDisp(d_src, dst, 255);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::drawColorDisp(d_src, d_dst, 255);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL() << "No such CPU implementation analogy.";
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,8 +3,7 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
#define GPU_DENOISING_IMAGE_SIZES testing::Values(perf::szVGA, perf::szXGA, perf::sz720p, perf::sz1080p)
|
||||
|
||||
#define GPU_DENOISING_IMAGE_SIZES testing::Values(perf::szVGA, perf::sz720p)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BilateralFilter
|
||||
@ -12,96 +11,86 @@ using namespace testing;
|
||||
DEF_PARAM_TEST(Sz_Depth_Cn_KernelSz, cv::Size, MatDepth, MatCn, int);
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES, Values(CV_8U, CV_32F), GPU_CHANNELS_1_3, Values(3, 5, 9)))
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES,
|
||||
Values(CV_8U, CV_32F),
|
||||
GPU_CHANNELS_1_3,
|
||||
Values(3, 5, 9)))
|
||||
{
|
||||
declare.time(60.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
int kernel_size = GET_PARAM(3);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
const int kernel_size = GET_PARAM(3);
|
||||
|
||||
float sigma_color = 7;
|
||||
float sigma_spatial = 5;
|
||||
int borderMode = cv::BORDER_REFLECT101;
|
||||
const float sigma_color = 7;
|
||||
const float sigma_spatial = 5;
|
||||
const int borderMode = cv::BORDER_REFLECT101;
|
||||
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
|
||||
TEST_CYCLE() cv::gpu::bilateralFilter(d_src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
|
||||
}
|
||||
TEST_CYCLE() cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nonLocalMeans
|
||||
|
||||
DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), GPU_CHANNELS_1_3, Values(21), Values(5, 7)))
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES,
|
||||
Values<MatDepth>(CV_8U),
|
||||
GPU_CHANNELS_1_3,
|
||||
Values(21),
|
||||
Values(5)))
|
||||
{
|
||||
declare.time(60.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
const int search_widow_size = GET_PARAM(3);
|
||||
const int block_size = GET_PARAM(4);
|
||||
|
||||
int search_widow_size = GET_PARAM(3);
|
||||
int block_size = GET_PARAM(4);
|
||||
const float h = 10;
|
||||
const int borderMode = cv::BORDER_REFLECT101;
|
||||
|
||||
float h = 10;
|
||||
int borderMode = cv::BORDER_REFLECT101;
|
||||
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
|
||||
TEST_CYCLE() cv::gpu::nonLocalMeans(d_src, dst, h, search_widow_size, block_size, borderMode);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL() << "No such CPU implementation analogy";
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,46 +101,41 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
|
||||
DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), GPU_CHANNELS_1_3, Values(21), Values(7)))
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES,
|
||||
Values<MatDepth>(CV_8U),
|
||||
GPU_CHANNELS_1_3,
|
||||
Values(21),
|
||||
Values(7)))
|
||||
{
|
||||
declare.time(150.0);
|
||||
declare.time(60.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int search_widow_size = GET_PARAM(2);
|
||||
const int block_size = GET_PARAM(3);
|
||||
|
||||
int search_widow_size = GET_PARAM(2);
|
||||
int block_size = GET_PARAM(3);
|
||||
|
||||
float h = 10;
|
||||
int type = CV_MAKE_TYPE(depth, 1);
|
||||
const float h = 10;
|
||||
const int type = CV_MAKE_TYPE(depth, 1);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::FastNonLocalMeansDenoising fnlmd;
|
||||
|
||||
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
|
||||
}
|
||||
TEST_CYCLE() fnlmd.simpleMethod(d_src, dst, h, search_widow_size, block_size);
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
|
||||
}
|
||||
TEST_CYCLE() cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -163,47 +147,41 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
|
||||
DEF_PARAM_TEST(Sz_Depth_WinSz_BlockSz, cv::Size, MatDepth, int, int);
|
||||
|
||||
PERF_TEST_P(Sz_Depth_WinSz_BlockSz, Denoising_FastNonLocalMeansColored,
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES, Values<MatDepth>(CV_8U), Values(21), Values(7)))
|
||||
Combine(GPU_DENOISING_IMAGE_SIZES,
|
||||
Values<MatDepth>(CV_8U),
|
||||
Values(21),
|
||||
Values(7)))
|
||||
{
|
||||
declare.time(350.0);
|
||||
declare.time(60.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int search_widow_size = GET_PARAM(2);
|
||||
const int block_size = GET_PARAM(3);
|
||||
|
||||
int search_widow_size = GET_PARAM(2);
|
||||
int block_size = GET_PARAM(3);
|
||||
|
||||
float h = 10;
|
||||
int type = CV_MAKE_TYPE(depth, 3);
|
||||
const float h = 10;
|
||||
const int type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
cv::gpu::FastNonLocalMeansDenoising fnlmd;
|
||||
|
||||
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
|
||||
}
|
||||
TEST_CYCLE() fnlmd.labMethod(d_src, dst, h, h, search_widow_size, block_size);
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
|
||||
}
|
||||
TEST_CYCLE() cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,139 +3,194 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
struct KeypointIdxCompare
|
||||
{
|
||||
std::vector<cv::KeyPoint>* keypoints;
|
||||
|
||||
explicit KeypointIdxCompare(std::vector<cv::KeyPoint>* _keypoints) : keypoints(_keypoints) {}
|
||||
|
||||
bool operator ()(size_t i1, size_t i2) const
|
||||
{
|
||||
cv::KeyPoint kp1 = (*keypoints)[i1];
|
||||
cv::KeyPoint kp2 = (*keypoints)[i2];
|
||||
if (kp1.pt.x != kp2.pt.x)
|
||||
return kp1.pt.x < kp2.pt.x;
|
||||
if (kp1.pt.y != kp2.pt.y)
|
||||
return kp1.pt.y < kp2.pt.y;
|
||||
if (kp1.response != kp2.response)
|
||||
return kp1.response < kp2.response;
|
||||
return kp1.octave < kp2.octave;
|
||||
}
|
||||
};
|
||||
|
||||
static void sortKeyPoints(std::vector<cv::KeyPoint>& keypoints, cv::InputOutputArray _descriptors = cv::noArray())
|
||||
{
|
||||
std::vector<size_t> indexies(keypoints.size());
|
||||
for (size_t i = 0; i < indexies.size(); ++i)
|
||||
indexies[i] = i;
|
||||
|
||||
std::sort(indexies.begin(), indexies.end(), KeypointIdxCompare(&keypoints));
|
||||
|
||||
std::vector<cv::KeyPoint> new_keypoints;
|
||||
cv::Mat new_descriptors;
|
||||
|
||||
new_keypoints.resize(keypoints.size());
|
||||
|
||||
cv::Mat descriptors;
|
||||
if (_descriptors.needed())
|
||||
{
|
||||
descriptors = _descriptors.getMat();
|
||||
new_descriptors.create(descriptors.size(), descriptors.type());
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < indexies.size(); ++i)
|
||||
{
|
||||
size_t new_idx = indexies[i];
|
||||
new_keypoints[i] = keypoints[new_idx];
|
||||
if (!new_descriptors.empty())
|
||||
descriptors.row((int) new_idx).copyTo(new_descriptors.row((int) i));
|
||||
}
|
||||
|
||||
keypoints.swap(new_keypoints);
|
||||
if (_descriptors.needed())
|
||||
new_descriptors.copyTo(_descriptors);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SURF
|
||||
|
||||
DEF_PARAM_TEST_1(Image, string);
|
||||
|
||||
PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.png"))
|
||||
PERF_TEST_P(Image, Features2D_SURF,
|
||||
Values<string>("gpu/perf/aloe.png"))
|
||||
{
|
||||
declare.time(50.0);
|
||||
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::SURF_GPU d_surf;
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
const 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);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
||||
}
|
||||
std::vector<cv::KeyPoint> gpu_keypoints;
|
||||
d_surf.downloadKeypoints(d_keypoints, gpu_keypoints);
|
||||
|
||||
GPU_SANITY_CHECK(d_descriptors, 1e-4);
|
||||
GPU_SANITY_CHECK_KEYPOINTS(SURF, d_keypoints);
|
||||
cv::Mat gpu_descriptors(d_descriptors);
|
||||
|
||||
sortKeyPoints(gpu_keypoints, gpu_descriptors);
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(gpu_keypoints);
|
||||
SANITY_CHECK(gpu_descriptors);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::SURF surf;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
std::vector<cv::KeyPoint> cpu_keypoints;
|
||||
cv::Mat cpu_descriptors;
|
||||
|
||||
surf(img, cv::noArray(), keypoints, descriptors);
|
||||
TEST_CYCLE() surf(img, cv::noArray(), cpu_keypoints, cpu_descriptors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
keypoints.clear();
|
||||
surf(img, cv::noArray(), keypoints, descriptors);
|
||||
}
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(keypoints);
|
||||
SANITY_CHECK(descriptors, 1e-4);
|
||||
SANITY_CHECK_KEYPOINTS(cpu_keypoints);
|
||||
SANITY_CHECK(cpu_descriptors);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// FAST
|
||||
|
||||
PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.png"))
|
||||
DEF_PARAM_TEST(Image_Threshold_NonMaxSupression, string, int, bool);
|
||||
|
||||
PERF_TEST_P(Image_Threshold_NonMaxSupression, Features2D_FAST,
|
||||
Combine(Values<string>("gpu/perf/aloe.png"),
|
||||
Values(20),
|
||||
Bool()))
|
||||
{
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat img = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
const int threshold = GET_PARAM(1);
|
||||
const bool nonMaxSuppersion = GET_PARAM(2);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::FAST_GPU d_fast(20);
|
||||
cv::gpu::FAST_GPU d_fast(threshold, nonMaxSuppersion, 0.5);
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
const 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);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
|
||||
}
|
||||
std::vector<cv::KeyPoint> gpu_keypoints;
|
||||
d_fast.downloadKeypoints(d_keypoints, gpu_keypoints);
|
||||
|
||||
GPU_SANITY_CHECK_RESPONSE(FAST, d_keypoints);
|
||||
sortKeyPoints(gpu_keypoints);
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(gpu_keypoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
std::vector<cv::KeyPoint> cpu_keypoints;
|
||||
|
||||
cv::FAST(img, keypoints, 20);
|
||||
TEST_CYCLE() cv::FAST(img, cpu_keypoints, threshold, nonMaxSuppersion);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
keypoints.clear();
|
||||
cv::FAST(img, keypoints, 20);
|
||||
}
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(keypoints);
|
||||
SANITY_CHECK_KEYPOINTS(cpu_keypoints);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ORB
|
||||
|
||||
PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
|
||||
DEF_PARAM_TEST(Image_NFeatures, string, int);
|
||||
|
||||
PERF_TEST_P(Image_NFeatures, Features2D_ORB,
|
||||
Combine(Values<string>("gpu/perf/aloe.png"),
|
||||
Values(4000)))
|
||||
{
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat img = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
const int nFeatures = GET_PARAM(1);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::ORB_GPU d_orb(4000);
|
||||
cv::gpu::ORB_GPU d_orb(nFeatures);
|
||||
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
const 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);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
|
||||
}
|
||||
std::vector<cv::KeyPoint> gpu_keypoints;
|
||||
d_orb.downloadKeyPoints(d_keypoints, gpu_keypoints);
|
||||
|
||||
GPU_SANITY_CHECK_KEYPOINTS(ORB, d_keypoints);
|
||||
GPU_SANITY_CHECK(d_descriptors);
|
||||
cv::Mat gpu_descriptors(d_descriptors);
|
||||
|
||||
gpu_keypoints.resize(10);
|
||||
gpu_descriptors = gpu_descriptors.rowRange(0, 10);
|
||||
|
||||
sortKeyPoints(gpu_keypoints, gpu_descriptors);
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(gpu_keypoints);
|
||||
SANITY_CHECK(gpu_descriptors);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::ORB orb(4000);
|
||||
cv::ORB orb(nFeatures);
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
std::vector<cv::KeyPoint> cpu_keypoints;
|
||||
cv::Mat cpu_descriptors;
|
||||
|
||||
orb(img, cv::noArray(), keypoints, descriptors);
|
||||
TEST_CYCLE() orb(img, cv::noArray(), cpu_keypoints, cpu_descriptors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
keypoints.clear();
|
||||
orb(img, cv::noArray(), keypoints, descriptors);
|
||||
}
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(keypoints);
|
||||
SANITY_CHECK(descriptors);
|
||||
SANITY_CHECK_KEYPOINTS(cpu_keypoints);
|
||||
SANITY_CHECK(cpu_descriptors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,166 +199,165 @@ PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
|
||||
|
||||
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))))
|
||||
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);
|
||||
const int desc_size = GET_PARAM(0);
|
||||
const int normType = GET_PARAM(1);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
const int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
|
||||
cv::Mat query(3000, desc_size, type);
|
||||
fillRandom(query);
|
||||
declare.in(query, WARMUP_RNG);
|
||||
|
||||
cv::Mat train(3000, desc_size, type);
|
||||
fillRandom(train);
|
||||
declare.in(train, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat d_query(query);
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
const cv::gpu::GpuMat d_query(query);
|
||||
const 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);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
||||
}
|
||||
std::vector<cv::DMatch> gpu_matches;
|
||||
d_matcher.matchDownload(d_trainIdx, d_distance, gpu_matches);
|
||||
|
||||
GPU_SANITY_CHECK(d_trainIdx);
|
||||
GPU_SANITY_CHECK(d_distance);
|
||||
SANITY_CHECK_MATCHES(gpu_matches);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BFMatcher matcher(normType);
|
||||
|
||||
std::vector<cv::DMatch> matches;
|
||||
std::vector<cv::DMatch> cpu_matches;
|
||||
|
||||
matcher.match(query, train, matches);
|
||||
TEST_CYCLE() matcher.match(query, train, cpu_matches);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.match(query, train, matches);
|
||||
}
|
||||
|
||||
SANITY_CHECK(matches);
|
||||
SANITY_CHECK_MATCHES(cpu_matches);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BFKnnMatch
|
||||
|
||||
static void toOneRowMatches(const std::vector< std::vector<cv::DMatch> >& src, std::vector<cv::DMatch>& dst)
|
||||
{
|
||||
dst.clear();
|
||||
for (size_t i = 0; i < src.size(); ++i)
|
||||
for (size_t j = 0; j < src[i].size(); ++j)
|
||||
dst.push_back(src[i][j]);
|
||||
}
|
||||
|
||||
DEF_PARAM_TEST(DescSize_K_Norm, int, int, 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))))
|
||||
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))))
|
||||
{
|
||||
declare.time(30.0);
|
||||
|
||||
int desc_size = GET_PARAM(0);
|
||||
int k = GET_PARAM(1);
|
||||
int normType = GET_PARAM(2);
|
||||
const int desc_size = GET_PARAM(0);
|
||||
const int k = GET_PARAM(1);
|
||||
const int normType = GET_PARAM(2);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
const int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
|
||||
cv::Mat query(3000, desc_size, type);
|
||||
fillRandom(query);
|
||||
declare.in(query, WARMUP_RNG);
|
||||
|
||||
cv::Mat train(3000, desc_size, type);
|
||||
fillRandom(train);
|
||||
declare.in(train, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat d_query(query);
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
const cv::gpu::GpuMat d_query(query);
|
||||
const 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);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
|
||||
}
|
||||
std::vector< std::vector<cv::DMatch> > matchesTbl;
|
||||
d_matcher.knnMatchDownload(d_trainIdx, d_distance, matchesTbl);
|
||||
|
||||
GPU_SANITY_CHECK(d_trainIdx);
|
||||
GPU_SANITY_CHECK(d_distance);
|
||||
std::vector<cv::DMatch> gpu_matches;
|
||||
toOneRowMatches(matchesTbl, gpu_matches);
|
||||
|
||||
SANITY_CHECK_MATCHES(gpu_matches);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BFMatcher matcher(normType);
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
std::vector< std::vector<cv::DMatch> > matchesTbl;
|
||||
|
||||
matcher.knnMatch(query, train, matches, k);
|
||||
TEST_CYCLE() matcher.knnMatch(query, train, matchesTbl, k);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.knnMatch(query, train, matches, k);
|
||||
}
|
||||
std::vector<cv::DMatch> cpu_matches;
|
||||
toOneRowMatches(matchesTbl, cpu_matches);
|
||||
|
||||
SANITY_CHECK(matches);
|
||||
SANITY_CHECK_MATCHES(cpu_matches);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BFRadiusMatch
|
||||
|
||||
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))))
|
||||
PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch,
|
||||
Combine(Values(64, 128, 256),
|
||||
Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
|
||||
{
|
||||
declare.time(30.0);
|
||||
|
||||
int desc_size = GET_PARAM(0);
|
||||
int normType = GET_PARAM(1);
|
||||
const int desc_size = GET_PARAM(0);
|
||||
const int normType = GET_PARAM(1);
|
||||
|
||||
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
const int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
|
||||
const float maxDistance = 10000;
|
||||
|
||||
cv::Mat query(3000, desc_size, type);
|
||||
fillRandom(query, 0.0, 1.0);
|
||||
declare.in(query, WARMUP_RNG);
|
||||
|
||||
cv::Mat train(3000, desc_size, type);
|
||||
fillRandom(train, 0.0, 1.0);
|
||||
declare.in(train, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU d_matcher(normType);
|
||||
|
||||
cv::gpu::GpuMat d_query(query);
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
const cv::gpu::GpuMat d_query(query);
|
||||
const 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, maxDistance);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
|
||||
}
|
||||
std::vector< std::vector<cv::DMatch> > matchesTbl;
|
||||
d_matcher.radiusMatchDownload(d_trainIdx, d_distance, d_nMatches, matchesTbl);
|
||||
|
||||
GPU_SANITY_CHECK(d_trainIdx);
|
||||
GPU_SANITY_CHECK(d_distance);
|
||||
std::vector<cv::DMatch> gpu_matches;
|
||||
toOneRowMatches(matchesTbl, gpu_matches);
|
||||
|
||||
SANITY_CHECK_MATCHES(gpu_matches);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BFMatcher matcher(normType);
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
std::vector< std::vector<cv::DMatch> > matchesTbl;
|
||||
|
||||
matcher.radiusMatch(query, train, matches, 2.0);
|
||||
TEST_CYCLE() matcher.radiusMatch(query, train, matchesTbl, maxDistance);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
matcher.radiusMatch(query, train, matches, 2.0);
|
||||
}
|
||||
std::vector<cv::DMatch> cpu_matches;
|
||||
toOneRowMatches(matchesTbl, cpu_matches);
|
||||
|
||||
SANITY_CHECK(matches);
|
||||
SANITY_CHECK_MATCHES(cpu_matches);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -3,48 +3,39 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Blur
|
||||
|
||||
DEF_PARAM_TEST(Sz_Type_KernelSz, cv::Size, MatType, int);
|
||||
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), Values(3, 5, 7)))
|
||||
PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8UC1, CV_8UC4),
|
||||
Values(3, 5, 7)))
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
const int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
|
||||
TEST_CYCLE() cv::gpu::blur(d_src, dst, cv::Size(ksize, ksize));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::blur(src, dst, cv::Size(ksize, ksize));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::blur(src, dst, cv::Size(ksize, ksize));
|
||||
}
|
||||
TEST_CYCLE() cv::blur(src, dst, cv::Size(ksize, ksize));
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -57,38 +48,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
const int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat 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, dst, -1, 1, 1, d_buf, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::Sobel(src, dst, -1, 1, 1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Sobel(src, dst, -1, 1, 1, ksize);
|
||||
}
|
||||
TEST_CYCLE() cv::Sobel(src, dst, -1, 1, 1, ksize);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -101,37 +82,27 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat 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, dst, -1, 1, 0, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::Scharr(src, dst, -1, 1, 0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Scharr(src, dst, -1, 1, 0);
|
||||
}
|
||||
TEST_CYCLE() cv::Scharr(src, dst, -1, 1, 0);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -144,38 +115,28 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
const int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat 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, 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);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
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);
|
||||
}
|
||||
TEST_CYCLE() cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -188,37 +149,27 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
const int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
|
||||
TEST_CYCLE() cv::gpu::Laplacian(d_src, dst, -1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::Laplacian(src, dst, -1, ksize);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Laplacian(src, dst, -1, ksize);
|
||||
}
|
||||
TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -231,39 +182,29 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
const cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::erode(d_src, d_dst, ker, d_buf);
|
||||
TEST_CYCLE() cv::gpu::erode(d_src, dst, ker, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::erode(d_src, d_dst, ker, d_buf);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::erode(src, dst, ker);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::erode(src, dst, ker);
|
||||
}
|
||||
TEST_CYCLE() cv::erode(src, dst, ker);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -276,39 +217,29 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
const cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
|
||||
TEST_CYCLE() cv::gpu::dilate(d_src, dst, ker, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::dilate(src, dst, ker);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::dilate(src, dst, ker);
|
||||
}
|
||||
TEST_CYCLE() cv::dilate(src, dst, ker);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -326,41 +257,31 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int morphOp = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
const int morphOp = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
const cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat 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, dst, morphOp, ker, d_buf1, d_buf2);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::morphologyEx(src, dst, morphOp, ker);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::morphologyEx(src, dst, morphOp, ker);
|
||||
}
|
||||
TEST_CYCLE() cv::morphologyEx(src, dst, morphOp, ker);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -373,43 +294,31 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int type = GET_PARAM(1);
|
||||
int ksize = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int type = GET_PARAM(1);
|
||||
const int ksize = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
cv::Mat kernel(ksize, ksize, CV_32FC1);
|
||||
fillRandom(kernel, 0.0, 1.0);
|
||||
declare.in(kernel, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
|
||||
TEST_CYCLE() cv::gpu::filter2D(d_src, dst, -1, kernel);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::filter2D(src, dst, -1, kernel);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::filter2D(src, dst, -1, kernel);
|
||||
}
|
||||
TEST_CYCLE() cv::filter2D(src, dst, -1, kernel);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,8 +3,6 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
DEF_PARAM_TEST_1(Image, string);
|
||||
|
||||
struct GreedyLabeling
|
||||
@ -100,28 +98,45 @@ struct GreedyLabeling
|
||||
dot* stack;
|
||||
};
|
||||
|
||||
PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/aloe-disp.png"))
|
||||
PERF_TEST_P(Image, Labeling_ConnectivityMask,
|
||||
Values<string>("gpu/labeling/aloe-disp.png"))
|
||||
{
|
||||
declare.time(1.0);
|
||||
|
||||
cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_image(image);
|
||||
cv::gpu::GpuMat mask;
|
||||
mask.create(image.rows, image.cols, CV_8UC1);
|
||||
|
||||
TEST_CYCLE() cv::gpu::connectivityMask(d_image, mask, cv::Scalar::all(0), cv::Scalar::all(2));
|
||||
|
||||
GPU_SANITY_CHECK(mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL_NO_CPU();
|
||||
}
|
||||
}
|
||||
|
||||
PERF_TEST_P(Image, Labeling_ConnectedComponents,
|
||||
Values<string>("gpu/labeling/aloe-disp.png"))
|
||||
{
|
||||
declare.time(1.0);
|
||||
|
||||
const cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_mask;
|
||||
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), d_mask, cv::Scalar::all(0), cv::Scalar::all(2));
|
||||
|
||||
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);
|
||||
}
|
||||
TEST_CYCLE() cv::gpu::labelComponents(d_mask, components);
|
||||
|
||||
GPU_SANITY_CHECK(components);
|
||||
}
|
||||
@ -129,17 +144,9 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
|
||||
{
|
||||
GreedyLabeling host(image);
|
||||
|
||||
host(host._labels);
|
||||
TEST_CYCLE() host(host._labels);
|
||||
|
||||
declare.time(1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
host(host._labels);
|
||||
}
|
||||
|
||||
CPU_SANITY_CHECK(host._labels);
|
||||
cv::Mat components = host._labels;
|
||||
CPU_SANITY_CHECK(components);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace{
|
||||
|
||||
static void printOsInfo()
|
||||
{
|
||||
#if defined _WIN32
|
||||
@ -69,6 +67,4 @@ static void printCudaInfo()
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CV_PERF_TEST_MAIN(gpu, printCudaInfo())
|
||||
CV_PERF_TEST_MAIN(gpu, printCudaInfo())
|
||||
|
@ -3,137 +3,112 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetTo
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), GPU_CHANNELS_1_3_4))
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
GPU_CHANNELS_1_3_4))
|
||||
{
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Scalar val(1, 2, 3, 4);
|
||||
const cv::Scalar val(1, 2, 3, 4);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(size, type);
|
||||
cv::gpu::GpuMat dst(size, type);
|
||||
|
||||
d_src.setTo(val);
|
||||
TEST_CYCLE() dst.setTo(val);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.setTo(val);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_src);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat src(size, type);
|
||||
cv::Mat dst(size, type);
|
||||
|
||||
src.setTo(val);
|
||||
TEST_CYCLE() dst.setTo(val);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.setTo(val);
|
||||
}
|
||||
|
||||
CPU_SANITY_CHECK(src);
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetToMasked
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), GPU_CHANNELS_1_3_4))
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
GPU_CHANNELS_1_3_4))
|
||||
{
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat mask(size, CV_8UC1);
|
||||
fillRandom(mask, 0, 2);
|
||||
declare.in(src, mask, WARMUP_RNG);
|
||||
|
||||
cv::Scalar val(1, 2, 3, 4);
|
||||
const cv::Scalar val(1, 2, 3, 4);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_mask(mask);
|
||||
cv::gpu::GpuMat dst(src);
|
||||
const cv::gpu::GpuMat d_mask(mask);
|
||||
|
||||
d_src.setTo(val, d_mask);
|
||||
TEST_CYCLE() dst.setTo(val, d_mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.setTo(val, d_mask);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_src);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
src.setTo(val, mask);
|
||||
cv::Mat dst = src;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.setTo(val, mask);
|
||||
}
|
||||
TEST_CYCLE() dst.setTo(val, mask);
|
||||
|
||||
CPU_SANITY_CHECK(src);
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CopyToMasked
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), GPU_CHANNELS_1_3_4))
|
||||
PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
GPU_CHANNELS_1_3_4))
|
||||
{
|
||||
cv::Size size = GET_PARAM(0);
|
||||
int depth = GET_PARAM(1);
|
||||
int channels = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
fillRandom(src);
|
||||
|
||||
cv::Mat mask(size, CV_8UC1);
|
||||
fillRandom(mask, 0, 2);
|
||||
declare.in(src, mask, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_mask(mask);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
const cv::gpu::GpuMat d_mask(mask);
|
||||
cv::gpu::GpuMat dst(d_src.size(), d_src.type(), cv::Scalar::all(0));
|
||||
|
||||
d_src.copyTo(d_dst, d_mask);
|
||||
TEST_CYCLE() d_src.copyTo(dst, d_mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.copyTo(d_dst, d_mask);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
cv::Mat dst(src.size(), src.type(), cv::Scalar::all(0));
|
||||
|
||||
src.copyTo(dst, mask);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.copyTo(dst, mask);
|
||||
}
|
||||
TEST_CYCLE() src.copyTo(dst, mask);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
@ -144,42 +119,36 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu
|
||||
|
||||
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)))
|
||||
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::Size size = GET_PARAM(0);
|
||||
int depth1 = GET_PARAM(1);
|
||||
int depth2 = GET_PARAM(2);
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth1 = GET_PARAM(1);
|
||||
const int depth2 = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, depth1);
|
||||
fillRandom(src);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
const double a = 0.5;
|
||||
const double b = 1.0;
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat d_dst;
|
||||
const cv::gpu::GpuMat d_src(src);
|
||||
cv::gpu::GpuMat dst;
|
||||
|
||||
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
|
||||
TEST_CYCLE() d_src.convertTo(dst, depth2, a, b);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_dst);
|
||||
GPU_SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
src.convertTo(dst, depth2, 0.5, 1.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.convertTo(dst, depth2, 0.5, 1.0);
|
||||
}
|
||||
TEST_CYCLE() src.convertTo(dst, depth2, a, b);
|
||||
|
||||
CPU_SANITY_CHECK(dst);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -3,90 +3,47 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace {
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// HOG
|
||||
|
||||
DEF_PARAM_TEST_1(Image, string);
|
||||
|
||||
PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
|
||||
PERF_TEST_P(Image, ObjDetect_HOG,
|
||||
Values<string>("gpu/hog/road.png",
|
||||
"gpu/caltech/image_00000009_0.png",
|
||||
"gpu/caltech/image_00000032_0.png",
|
||||
"gpu/caltech/image_00000165_0.png",
|
||||
"gpu/caltech/image_00000261_0.png",
|
||||
"gpu/caltech/image_00000469_0.png",
|
||||
"gpu/caltech/image_00000527_0.png",
|
||||
"gpu/caltech/image_00000574_0.png"))
|
||||
{
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
std::vector<cv::Rect> found_locations;
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
cv::gpu::GpuMat d_img(img);
|
||||
const cv::gpu::GpuMat d_img(img);
|
||||
std::vector<cv::Rect> gpu_found_locations;
|
||||
|
||||
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, gpu_found_locations);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_hog.detectMultiScale(d_img, found_locations);
|
||||
}
|
||||
SANITY_CHECK(gpu_found_locations);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<cv::Rect> cpu_found_locations;
|
||||
|
||||
cv::HOGDescriptor hog;
|
||||
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
|
||||
|
||||
hog.detectMultiScale(img, found_locations);
|
||||
TEST_CYCLE() hog.detectMultiScale(img, cpu_found_locations);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
hog.detectMultiScale(img, found_locations);
|
||||
}
|
||||
SANITY_CHECK(cpu_found_locations);
|
||||
}
|
||||
|
||||
SANITY_CHECK(found_locations);
|
||||
}
|
||||
|
||||
//===========test for CalTech data =============//
|
||||
DEF_PARAM_TEST_1(HOG, string);
|
||||
|
||||
PERF_TEST_P(HOG, CalTech, Values<string>("gpu/caltech/image_00000009_0.png", "gpu/caltech/image_00000032_0.png",
|
||||
"gpu/caltech/image_00000165_0.png", "gpu/caltech/image_00000261_0.png", "gpu/caltech/image_00000469_0.png",
|
||||
"gpu/caltech/image_00000527_0.png", "gpu/caltech/image_00000574_0.png"))
|
||||
{
|
||||
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
std::vector<cv::Rect> found_locations;
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK(found_locations);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@ -96,9 +53,9 @@ 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")))
|
||||
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/perf/haarcascade_frontalface_alt.xml")))
|
||||
{
|
||||
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
@ -106,33 +63,28 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
|
||||
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;
|
||||
const cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat objects_buffer;
|
||||
int detections_num = 0;
|
||||
|
||||
d_cascade.detectMultiScale(d_img, d_objects_buffer);
|
||||
TEST_CYCLE() detections_num = d_cascade.detectMultiScale(d_img, objects_buffer);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_cascade.detectMultiScale(d_img, d_objects_buffer);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_objects_buffer);
|
||||
std::vector<cv::Rect> gpu_rects(detections_num);
|
||||
cv::Mat gpu_rects_mat(1, detections_num, cv::DataType<cv::Rect>::type, &gpu_rects[0]);
|
||||
objects_buffer.colRange(0, detections_num).download(gpu_rects_mat);
|
||||
cv::groupRectangles(gpu_rects, 3, 0.2);
|
||||
SANITY_CHECK(gpu_rects);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::CascadeClassifier cascade;
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
|
||||
|
||||
std::vector<cv::Rect> rects;
|
||||
std::vector<cv::Rect> cpu_rects;
|
||||
|
||||
cascade.detectMultiScale(img, rects);
|
||||
TEST_CYCLE() cascade.detectMultiScale(img, cpu_rects);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cascade.detectMultiScale(img, rects);
|
||||
}
|
||||
|
||||
CPU_SANITY_CHECK(rects);
|
||||
SANITY_CHECK(cpu_rects);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,9 +92,9 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
|
||||
// LBP cascade
|
||||
|
||||
PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
|
||||
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml")))
|
||||
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml")))
|
||||
{
|
||||
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
if (PERF_RUN_GPU())
|
||||
@ -150,34 +102,27 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
|
||||
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;
|
||||
const cv::gpu::GpuMat d_img(img);
|
||||
cv::gpu::GpuMat objects_buffer;
|
||||
int detections_num = 0;
|
||||
|
||||
d_cascade.detectMultiScale(d_img, d_gpu_rects);
|
||||
TEST_CYCLE() detections_num = d_cascade.detectMultiScale(d_img, objects_buffer);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_cascade.detectMultiScale(d_img, d_gpu_rects);
|
||||
}
|
||||
|
||||
GPU_SANITY_CHECK(d_gpu_rects);
|
||||
std::vector<cv::Rect> gpu_rects(detections_num);
|
||||
cv::Mat gpu_rects_mat(1, detections_num, cv::DataType<cv::Rect>::type, &gpu_rects[0]);
|
||||
objects_buffer.colRange(0, detections_num).download(gpu_rects_mat);
|
||||
cv::groupRectangles(gpu_rects, 3, 0.2);
|
||||
SANITY_CHECK(gpu_rects);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::CascadeClassifier cascade;
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
|
||||
|
||||
std::vector<cv::Rect> rects;
|
||||
std::vector<cv::Rect> cpu_rects;
|
||||
|
||||
cascade.detectMultiScale(img, rects);
|
||||
TEST_CYCLE() cascade.detectMultiScale(img, cpu_rects);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cascade.detectMultiScale(img, rects);
|
||||
}
|
||||
|
||||
CPU_SANITY_CHECK(rects);
|
||||
SANITY_CHECK(cpu_rects);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
File diff suppressed because it is too large
Load Diff
@ -2,13 +2,6 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
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)
|
||||
{
|
||||
@ -188,4 +181,4 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
|
||||
};
|
||||
|
||||
*os << str[info.code];
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,9 @@
|
||||
#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"
|
||||
|
||||
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;
|
||||
@ -17,12 +15,13 @@ CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONS
|
||||
|
||||
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, cv::NORM_MINMAX)
|
||||
|
||||
const int Gray = 1, TwoChannel = 2, BGR = 3, BGRA = 4;
|
||||
enum { Gray = 1, TwoChannel = 2, BGR = 3, BGRA = 4 };
|
||||
CV_ENUM(MatCn, Gray, TwoChannel, BGR, BGRA)
|
||||
#define GPU_CHANNELS_1_3_4 testing::Values(Gray, BGR, BGRA)
|
||||
#define GPU_CHANNELS_1_3 testing::Values(Gray, BGR)
|
||||
#define GPU_CHANNELS_1_3_4 testing::Values(MatCn(Gray), MatCn(BGR), MatCn(BGRA))
|
||||
#define GPU_CHANNELS_1_3 testing::Values(MatCn(Gray), MatCn(BGR))
|
||||
|
||||
struct CvtColorInfo
|
||||
{
|
||||
@ -30,7 +29,8 @@ struct CvtColorInfo
|
||||
int dcn;
|
||||
int code;
|
||||
|
||||
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
|
||||
CvtColorInfo() {}
|
||||
explicit CvtColorInfo(int scn_, int dcn_, int code_) : scn(scn_), dcn(dcn_), code(code_) {}
|
||||
};
|
||||
void PrintTo(const CvtColorInfo& info, std::ostream* os);
|
||||
|
||||
@ -46,39 +46,18 @@ DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, MatCn);
|
||||
|
||||
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p)
|
||||
|
||||
#define GPU_SANITY_CHECK(dmat, ...) \
|
||||
#define FAIL_NO_CPU() FAIL() << "No such CPU implementation analogy"
|
||||
|
||||
#define GPU_SANITY_CHECK(mat, ...) \
|
||||
do{ \
|
||||
cv::Mat d##dmat(dmat); \
|
||||
SANITY_CHECK(d##dmat, ## __VA_ARGS__); \
|
||||
cv::Mat gpu_##mat(mat); \
|
||||
SANITY_CHECK(gpu_##mat, ## __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define CPU_SANITY_CHECK(cmat, ...) \
|
||||
#define CPU_SANITY_CHECK(mat, ...) \
|
||||
do{ \
|
||||
SANITY_CHECK(cmat, ## __VA_ARGS__); \
|
||||
cv::Mat cpu_##mat(mat); \
|
||||
SANITY_CHECK(cpu_##mat, ## __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define GPU_SANITY_CHECK_KEYPOINTS(alg, dmat, ...) \
|
||||
do{ \
|
||||
cv::Mat d##dmat(dmat); \
|
||||
cv::Mat __pt_x = d##dmat.row(cv::gpu::alg##_GPU::X_ROW); \
|
||||
cv::Mat __pt_y = d##dmat.row(cv::gpu::alg##_GPU::Y_ROW); \
|
||||
cv::Mat __angle = d##dmat.row(cv::gpu::alg##_GPU::ANGLE_ROW); \
|
||||
cv::Mat __octave = d##dmat.row(cv::gpu::alg##_GPU::OCTAVE_ROW); \
|
||||
cv::Mat __size = d##dmat.row(cv::gpu::alg##_GPU::SIZE_ROW); \
|
||||
::perf::Regression::add(this, std::string(#dmat) + "-pt-x-row", __pt_x, ## __VA_ARGS__); \
|
||||
::perf::Regression::add(this, std::string(#dmat) + "-pt-y-row", __pt_y, ## __VA_ARGS__); \
|
||||
::perf::Regression::add(this, std::string(#dmat) + "-angle-row", __angle, ## __VA_ARGS__); \
|
||||
::perf::Regression::add(this, std::string(#dmat) + "octave-row", __octave, ## __VA_ARGS__); \
|
||||
::perf::Regression::add(this, std::string(#dmat) + "-pt-size-row", __size, ## __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define GPU_SANITY_CHECK_RESPONSE(alg, dmat, ...) \
|
||||
do{ \
|
||||
cv::Mat d##dmat(dmat); \
|
||||
cv::Mat __response = d##dmat.row(cv::gpu::alg##_GPU::RESPONSE_ROW); \
|
||||
::perf::Regression::add(this, std::string(#dmat) + "-response-row", __response, ## __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define FAIL_NO_CPU() FAIL() << "No such CPU implementation analogy"
|
||||
|
||||
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
|
||||
|
@ -104,12 +104,12 @@ void cv::gpu::connectivityMask(const GpuMat& image, GpuMat& mask, const cv::Scal
|
||||
|
||||
void cv::gpu::labelComponents(const GpuMat& mask, GpuMat& components, int flags, Stream& s)
|
||||
{
|
||||
if (!TargetArchs::builtWith(SHARED_ATOMICS) || !DeviceInfo().supports(SHARED_ATOMICS))
|
||||
CV_Error(CV_StsNotImplemented, "The device doesn't support shared atomics and communicative synchronization!");
|
||||
CV_Assert(!mask.empty() && mask.type() == CV_8U);
|
||||
|
||||
if (mask.size() != components.size() || components.type() != CV_32SC1)
|
||||
components.create(mask.size(), CV_32SC1);
|
||||
if (!deviceSupports(SHARED_ATOMICS))
|
||||
CV_Error(CV_StsNotImplemented, "The device doesn't support shared atomics and communicative synchronization!");
|
||||
|
||||
components.create(mask.size(), CV_32SC1);
|
||||
|
||||
cudaStream_t stream = StreamAccessor::getStream(s);
|
||||
device::ccl::labelComponents(mask, components, flags, stream);
|
||||
|
@ -522,6 +522,7 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
|
||||
CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);
|
||||
|
||||
dst.create(dsize, src.type());
|
||||
dst.setTo(Scalar::all(0));
|
||||
|
||||
funcs[src.depth()][src.channels() - 1](src, dst, dsize, angle, xShift, yShift, interpolation, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
@ -382,6 +382,7 @@ void cv::gpu::meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr,
|
||||
dstcol[0] = static_cast<uchar>(sumcol[0] / comps.size[parent]);
|
||||
dstcol[1] = static_cast<uchar>(sumcol[1] / comps.size[parent]);
|
||||
dstcol[2] = static_cast<uchar>(sumcol[2] / comps.size[parent]);
|
||||
dstcol[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +209,8 @@ void cv::gpu::PyrLKOpticalFlow::dense(const GpuMat& prevImg, const GpuMat& nextI
|
||||
ensureSizeIsEnough(prevImg.size(), CV_32FC1, vPyr_[0]);
|
||||
ensureSizeIsEnough(prevImg.size(), CV_32FC1, uPyr_[1]);
|
||||
ensureSizeIsEnough(prevImg.size(), CV_32FC1, vPyr_[1]);
|
||||
uPyr_[0].setTo(Scalar::all(0));
|
||||
vPyr_[0].setTo(Scalar::all(0));
|
||||
uPyr_[1].setTo(Scalar::all(0));
|
||||
vPyr_[1].setTo(Scalar::all(0));
|
||||
|
||||
|
@ -232,10 +232,8 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
|
||||
};
|
||||
|
||||
bool useNpp = borderMode == BORDER_CONSTANT && ofs.x == 0 && ofs.y == 0 && useNppTab[src.depth()][src.channels() - 1][interpolation];
|
||||
#ifdef linux
|
||||
// NPP bug on float data
|
||||
useNpp = useNpp && src.depth() != CV_32F;
|
||||
#endif
|
||||
// NPP bug on float data
|
||||
useNpp = useNpp && src.depth() != CV_32F;
|
||||
|
||||
if (useNpp)
|
||||
{
|
||||
@ -372,10 +370,8 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
|
||||
};
|
||||
|
||||
bool useNpp = borderMode == BORDER_CONSTANT && ofs.x == 0 && ofs.y == 0 && useNppTab[src.depth()][src.channels() - 1][interpolation];
|
||||
#ifdef linux
|
||||
// NPP bug on float data
|
||||
useNpp = useNpp && src.depth() != CV_32F;
|
||||
#endif
|
||||
// NPP bug on float data
|
||||
useNpp = useNpp && src.depth() != CV_32F;
|
||||
|
||||
if (useNpp)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user