This source file includes following definitions.
- PERF_TEST_P
- PERF_TEST_P
#include "perf_precomp.hpp"
using namespace std;
using namespace testing;
using namespace perf;
DEF_PARAM_TEST(Image_Type_Border_BlockSz_ApertureSz, string, MatType, BorderMode, int, int);
PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, CornerHarris,
Combine(Values<string>("gpu/stereobm/aloe-L.png"),
Values(CV_8UC1, CV_32FC1),
Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
Values(3, 5, 7),
Values(0, 3, 5, 7)))
{
const string fileName = GET_PARAM(0);
const int type = GET_PARAM(1);
const int borderMode = GET_PARAM(2);
const int blockSize = GET_PARAM(3);
const int apertureSize = GET_PARAM(4);
cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
const double k = 0.5;
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_img(img);
cv::cuda::GpuMat dst;
cv::Ptr<cv::cuda::CornernessCriteria> harris = cv::cuda::createHarrisCorner(img.type(), blockSize, apertureSize, k, borderMode);
TEST_CYCLE() harris->compute(d_img, dst);
CUDA_SANITY_CHECK(dst, 1e-4);
}
else
{
cv::Mat dst;
TEST_CYCLE() cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
CPU_SANITY_CHECK(dst);
}
}
PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, CornerMinEigenVal,
Combine(Values<string>("gpu/stereobm/aloe-L.png"),
Values(CV_8UC1, CV_32FC1),
Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
Values(3, 5, 7),
Values(0, 3, 5, 7)))
{
const string fileName = GET_PARAM(0);
const int type = GET_PARAM(1);
const int borderMode = GET_PARAM(2);
const int blockSize = GET_PARAM(3);
const int apertureSize = GET_PARAM(4);
cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_img(img);
cv::cuda::GpuMat dst;
cv::Ptr<cv::cuda::CornernessCriteria> minEigenVal = cv::cuda::createMinEigenValCorner(img.type(), blockSize, apertureSize, borderMode);
TEST_CYCLE() minEigenVal->compute(d_img, dst);
CUDA_SANITY_CHECK(dst, 1e-4);
}
else
{
cv::Mat dst;
TEST_CYCLE() cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
CPU_SANITY_CHECK(dst);
}
}