This source file includes following definitions.
- PERF_TEST_P
- PERF_TEST_P
- PERF_TEST_P
- PERF_TEST_P
- PERF_TEST_P
#include "perf_precomp.hpp"
using namespace std;
using namespace testing;
using namespace perf;
PERF_TEST_P(Sz_Depth, HistEvenC1,
Combine(CUDA_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_16S)))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
cv::Mat src(size, depth);
declare.in(src, WARMUP_RNG);
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat dst;
TEST_CYCLE() cv::cuda::histEven(d_src, dst, 30, 0, 180);
CUDA_SANITY_CHECK(dst);
}
else
{
const int hbins = 30;
const float hranges[] = {0.0f, 180.0f};
const int histSize[] = {hbins};
const float* ranges[] = {hranges};
const int channels[] = {0};
cv::Mat dst;
TEST_CYCLE() cv::calcHist(&src, 1, channels, cv::Mat(), dst, 1, histSize, ranges);
CPU_SANITY_CHECK(dst);
}
}
PERF_TEST_P(Sz_Depth, HistEvenC4,
Combine(CUDA_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_16S)))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
cv::Mat src(size, CV_MAKE_TYPE(depth, 4));
declare.in(src, WARMUP_RNG);
int histSize[] = {30, 30, 30, 30};
int lowerLevel[] = {0, 0, 0, 0};
int upperLevel[] = {180, 180, 180, 180};
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat d_hist[4];
TEST_CYCLE() cv::cuda::histEven(d_src, d_hist, histSize, lowerLevel, upperLevel);
cv::Mat cpu_hist0, cpu_hist1, cpu_hist2, cpu_hist3;
d_hist[0].download(cpu_hist0);
d_hist[1].download(cpu_hist1);
d_hist[2].download(cpu_hist2);
d_hist[3].download(cpu_hist3);
SANITY_CHECK(cpu_hist0);
SANITY_CHECK(cpu_hist1);
SANITY_CHECK(cpu_hist2);
SANITY_CHECK(cpu_hist3);
}
else
{
FAIL_NO_CPU();
}
}
PERF_TEST_P(Sz, CalcHist,
CUDA_TYPICAL_MAT_SIZES)
{
const cv::Size size = GetParam();
cv::Mat src(size, CV_8UC1);
declare.in(src, WARMUP_RNG);
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat dst;
TEST_CYCLE() cv::cuda::calcHist(d_src, dst);
CUDA_SANITY_CHECK(dst);
}
else
{
FAIL_NO_CPU();
}
}
PERF_TEST_P(Sz, EqualizeHist,
CUDA_TYPICAL_MAT_SIZES)
{
const cv::Size size = GetParam();
cv::Mat src(size, CV_8UC1);
declare.in(src, WARMUP_RNG);
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat dst;
TEST_CYCLE() cv::cuda::equalizeHist(d_src, dst);
CUDA_SANITY_CHECK(dst);
}
else
{
cv::Mat dst;
TEST_CYCLE() cv::equalizeHist(src, dst);
CPU_SANITY_CHECK(dst);
}
}
DEF_PARAM_TEST(Sz_ClipLimit, cv::Size, double);
PERF_TEST_P(Sz_ClipLimit, CLAHE,
Combine(CUDA_TYPICAL_MAT_SIZES,
Values(0.0, 40.0)))
{
const cv::Size size = GET_PARAM(0);
const double clipLimit = GET_PARAM(1);
cv::Mat src(size, CV_8UC1);
declare.in(src, WARMUP_RNG);
if (PERF_RUN_CUDA())
{
cv::Ptr<cv::cuda::CLAHE> clahe = cv::cuda::createCLAHE(clipLimit);
cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat dst;
TEST_CYCLE() clahe->apply(d_src, dst);
CUDA_SANITY_CHECK(dst);
}
else
{
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit);
cv::Mat dst;
TEST_CYCLE() clahe->apply(src, dst);
CPU_SANITY_CHECK(dst);
}
}