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