1 #include "perf_precomp.hpp"
2
3 using namespace std;
4 using namespace cv;
5 using namespace perf;
6 using std::tr1::make_tuple;
7 using std::tr1::get;
8
9 typedef tr1::tuple<MatType, Size, Size> MatInfo_Size_Size_t;
10 typedef TestBaseWithParam<MatInfo_Size_Size_t> MatInfo_Size_Size;
11
PERF_TEST_P(MatInfo_Size_Size,resizeUpLinear,testing::Values (MatInfo_Size_Size_t (CV_8UC1,szVGA,szqHD),MatInfo_Size_Size_t (CV_8UC1,szVGA,sz720p),MatInfo_Size_Size_t (CV_8UC4,szVGA,sz720p)))12 PERF_TEST_P(MatInfo_Size_Size, resizeUpLinear,
13 testing::Values(
14 MatInfo_Size_Size_t(CV_8UC1, szVGA, szqHD),
15 MatInfo_Size_Size_t(CV_8UC1, szVGA, sz720p),
16 MatInfo_Size_Size_t(CV_8UC4, szVGA, sz720p)
17 )
18 )
19 {
20 int matType = get<0>(GetParam());
21 Size from = get<1>(GetParam());
22 Size to = get<2>(GetParam());
23
24 cv::Mat src(from, matType), dst(to, matType);
25 cvtest::fillGradient(src);
26 declare.in(src).out(dst);
27
28 TEST_CYCLE_MULTIRUN(10) resize(src, dst, to);
29
30 #ifdef ANDROID
31 SANITY_CHECK(dst, 5);
32 #else
33 SANITY_CHECK(dst, 1 + 1e-6);
34 #endif
35 }
36
37 PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear,
38 testing::Values(
39 MatInfo_Size_Size_t(CV_8UC1, szVGA, szQVGA),
40 MatInfo_Size_Size_t(CV_8UC4, szqHD, szVGA),
41 MatInfo_Size_Size_t(CV_8UC1, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
42 MatInfo_Size_Size_t(CV_8UC4, sz720p, szVGA),
43 MatInfo_Size_Size_t(CV_8UC4, sz720p, szQVGA)
44 )
45 )
46 {
47 int matType = get<0>(GetParam());
48 Size from = get<1>(GetParam());
49 Size to = get<2>(GetParam());
50
51 cv::Mat src(from, matType), dst(to, matType);
52 cvtest::fillGradient(src);
53 declare.in(src).out(dst);
54
55 TEST_CYCLE_MULTIRUN(10) resize(src, dst, to);
56
57 #ifdef ANDROID
58 SANITY_CHECK(dst, 5);
59 #else
60 SANITY_CHECK(dst, 1 + 1e-6);
61 #endif
62 }
63
64
65 typedef tr1::tuple<MatType, Size, int> MatInfo_Size_Scale_t;
66 typedef TestBaseWithParam<MatInfo_Size_Scale_t> MatInfo_Size_Scale;
67
68 PERF_TEST_P(MatInfo_Size_Scale, ResizeAreaFast,
69 testing::Combine(
70 testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4),
71 testing::Values(szVGA, szqHD, sz720p, sz1080p),
72 testing::Values(2)
73 )
74 )
75 {
76 int matType = get<0>(GetParam());
77 Size from = get<1>(GetParam());
78 int scale = get<2>(GetParam());
79
80 from.width = (from.width/scale)*scale;
81 from.height = (from.height/scale)*scale;
82
83 cv::Mat src(from, matType);
84 cv::Mat dst(from.height / scale, from.width / scale, matType);
85
86 declare.in(src, WARMUP_RNG).out(dst);
87
88 int runs = 15;
89 TEST_CYCLE_MULTIRUN(runs) resize(src, dst, dst.size(), 0, 0, INTER_AREA);
90
91 //difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
92 SANITY_CHECK(dst, 1);
93 }
94
95
96 typedef TestBaseWithParam<tr1::tuple<MatType, Size, double> > MatInfo_Size_Scale_Area;
97
98 PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea,
99 testing::Combine(
100 testing::Values(CV_8UC1, CV_8UC4),
101 testing::Values(szVGA, szqHD, sz720p),
102 testing::Values(2.4, 3.4, 1.3)
103 )
104 )
105 {
106 int matType = get<0>(GetParam());
107 Size from = get<1>(GetParam());
108 double scale = get<2>(GetParam());
109
110 cv::Mat src(from, matType);
111
112 Size to(cvRound(from.width * scale), cvRound(from.height * scale));
113 cv::Mat dst(to, matType);
114
115 declare.in(src, WARMUP_RNG).out(dst);
116 declare.time(100);
117
118 TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_AREA);
119
120 //difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
121 SANITY_CHECK(dst, 1);
122 }
123