Path: blob/master/modules/core/perf/perf_convertTo.cpp
16354 views
#include "perf_precomp.hpp"12namespace opencv_test3{4using namespace perf;56typedef tuple<Size, MatType, MatType, int, double> Size_DepthSrc_DepthDst_Channels_alpha_t;7typedef perf::TestBaseWithParam<Size_DepthSrc_DepthDst_Channels_alpha_t> Size_DepthSrc_DepthDst_Channels_alpha;89PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,10testing::Combine11(12testing::Values(szVGA, sz1080p),13testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),14testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),15testing::Values(1, 4),16testing::Values(1.0, 1./255)17)18)19{20Size sz = get<0>(GetParam());21int depthSrc = get<1>(GetParam());22int depthDst = get<2>(GetParam());23int channels = get<3>(GetParam());24double alpha = get<4>(GetParam());2526int maxValue = 255;2728Mat src(sz, CV_MAKETYPE(depthSrc, channels));29randu(src, 0, maxValue);30Mat dst(sz, CV_MAKETYPE(depthDst, channels));3132int runs = (sz.width <= 640) ? 8 : 1;33TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha);3435double eps = depthSrc <= CV_32S && (depthDst <= CV_32S || depthDst == CV_64F) ? 1e-12 : (FLT_EPSILON * maxValue);36eps = eps * std::max(1.0, fabs(alpha));37SANITY_CHECK(dst, eps);38}3940} // namespace414243