Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/core/perf/perf_convertTo.cpp
16354 views
1
#include "perf_precomp.hpp"
2
3
namespace opencv_test
4
{
5
using namespace perf;
6
7
typedef tuple<Size, MatType, MatType, int, double> Size_DepthSrc_DepthDst_Channels_alpha_t;
8
typedef perf::TestBaseWithParam<Size_DepthSrc_DepthDst_Channels_alpha_t> Size_DepthSrc_DepthDst_Channels_alpha;
9
10
PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,
11
testing::Combine
12
(
13
testing::Values(szVGA, sz1080p),
14
testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
15
testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
16
testing::Values(1, 4),
17
testing::Values(1.0, 1./255)
18
)
19
)
20
{
21
Size sz = get<0>(GetParam());
22
int depthSrc = get<1>(GetParam());
23
int depthDst = get<2>(GetParam());
24
int channels = get<3>(GetParam());
25
double alpha = get<4>(GetParam());
26
27
int maxValue = 255;
28
29
Mat src(sz, CV_MAKETYPE(depthSrc, channels));
30
randu(src, 0, maxValue);
31
Mat dst(sz, CV_MAKETYPE(depthDst, channels));
32
33
int runs = (sz.width <= 640) ? 8 : 1;
34
TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha);
35
36
double eps = depthSrc <= CV_32S && (depthDst <= CV_32S || depthDst == CV_64F) ? 1e-12 : (FLT_EPSILON * maxValue);
37
eps = eps * std::max(1.0, fabs(alpha));
38
SANITY_CHECK(dst, eps);
39
}
40
41
} // namespace
42
43