Path: blob/master/modules/imgproc/perf/perf_remap.cpp
16339 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3#include "perf_precomp.hpp"45namespace opencv_test {67CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4)89typedef TestBaseWithParam< tuple<Size, MatType, MatType, InterType> > TestRemap;1011PERF_TEST_P( TestRemap, Remap,12Combine(13Values( szVGA, sz1080p ),14Values( CV_16UC1, CV_16SC1, CV_32FC1 ),15Values( CV_16SC2, CV_32FC1, CV_32FC2 ),16InterType::all()17)18)19{20Size sz;21int src_type, map1_type, inter_type;2223sz = get<0>(GetParam());24src_type = get<1>(GetParam());25map1_type = get<2>(GetParam());26inter_type = get<3>(GetParam());2728Mat src(sz, src_type), dst(sz, src_type), map1(sz, map1_type), map2;29if (map1_type == CV_32FC1)30map2.create(sz, CV_32FC1);31else if (inter_type != INTER_NEAREST && map1_type == CV_16SC2)32{33map2.create(sz, CV_16UC1);34map2 = Scalar::all(0);35}3637RNG rng;38rng.fill(src, RNG::UNIFORM, 0, 256);3940for (int j = 0; j < map1.rows; ++j)41for (int i = 0; i < map1.cols; ++i)42switch (map1_type)43{44case CV_32FC1:45map1.at<float>(j, i) = static_cast<float>(src.cols - i - 1);46map2.at<float>(j, i) = static_cast<float>(j);47break;48case CV_32FC2:49map1.at<Vec2f>(j, i)[0] = static_cast<float>(src.cols - i - 1);50map1.at<Vec2f>(j, i)[1] = static_cast<float>(j);51break;52case CV_16SC2:53map1.at<Vec2s>(j, i)[0] = static_cast<short>(src.cols - i - 1);54map1.at<Vec2s>(j, i)[1] = static_cast<short>(j);55break;56default:57CV_Assert(0);58}596061declare.in(src, WARMUP_RNG).out(dst).time(20);6263int runs = (sz.width <= 640) ? 3 : 1;64TEST_CYCLE_MULTIRUN(runs) remap(src, dst, map1, map2, inter_type);6566SANITY_CHECK(dst);67}6869} // namespace707172