1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 #include "perf_precomp.hpp"
5 
6 namespace opencv_test {
7 
8 CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4)
9 
10 typedef TestBaseWithParam< tuple<Size, MatType, MatType, InterType> > TestRemap;
11 
PERF_TEST_P(TestRemap,Remap,Combine (Values (szVGA,sz1080p),Values (CV_16UC1,CV_16SC1,CV_32FC1),Values (CV_16SC2,CV_32FC1,CV_32FC2),InterType::all ()))12 PERF_TEST_P( TestRemap, Remap,
13              Combine(
14                 Values( szVGA, sz1080p ),
15                 Values( CV_16UC1, CV_16SC1, CV_32FC1 ),
16                 Values( CV_16SC2, CV_32FC1, CV_32FC2 ),
17                 InterType::all()
18              )
19 )
20 {
21     Size sz;
22     int src_type, map1_type, inter_type;
23 
24     sz         = get<0>(GetParam());
25     src_type   = get<1>(GetParam());
26     map1_type  = get<2>(GetParam());
27     inter_type = get<3>(GetParam());
28 
29     Mat src(sz, src_type), dst(sz, src_type), map1(sz, map1_type), map2;
30     if (map1_type == CV_32FC1)
31         map2.create(sz, CV_32FC1);
32     else if (inter_type != INTER_NEAREST && map1_type == CV_16SC2)
33     {
34         map2.create(sz, CV_16UC1);
35         map2 = Scalar::all(0);
36     }
37 
38     RNG rng;
39     rng.fill(src, RNG::UNIFORM, 0, 256);
40 
41     for (int j = 0; j < map1.rows; ++j)
42         for (int i = 0; i < map1.cols; ++i)
43             switch (map1_type)
44             {
45                 case CV_32FC1:
46                     map1.at<float>(j, i) = static_cast<float>(src.cols - i - 1);
47                     map2.at<float>(j, i) = static_cast<float>(j);
48                     break;
49                 case CV_32FC2:
50                     map1.at<Vec2f>(j, i)[0] = static_cast<float>(src.cols - i - 1);
51                     map1.at<Vec2f>(j, i)[1] = static_cast<float>(j);
52                     break;
53                 case CV_16SC2:
54                     map1.at<Vec2s>(j, i)[0] = static_cast<short>(src.cols - i - 1);
55                     map1.at<Vec2s>(j, i)[1] = static_cast<short>(j);
56                     break;
57                 default:
58                     CV_Assert(0);
59             }
60 
61 
62     declare.in(src, WARMUP_RNG).out(dst).time(20);
63 
64     int runs = (sz.width <= 640) ? 3 : 1;
65     TEST_CYCLE_MULTIRUN(runs) remap(src, dst, map1, map2, inter_type);
66 
67     SANITY_CHECK(dst);
68 }
69 
70 } // namespace
71