parallel version of remap, resize, warpaffine, warpPerspective. Some optimization for 2x decimation in resize algorithm
This commit is contained in:
68
modules/imgproc/perf/perf_remap.cpp
Normal file
68
modules/imgproc/perf/perf_remap.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#include "perf_precomp.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace cv;
|
||||||
|
using namespace perf;
|
||||||
|
using namespace testing;
|
||||||
|
using std::tr1::make_tuple;
|
||||||
|
using std::tr1::get;
|
||||||
|
|
||||||
|
CV_ENUM(MatrixType, CV_16UC1, CV_16SC1, CV_32FC1)
|
||||||
|
CV_ENUM(MapType, CV_16SC2, CV_32FC1, CV_32FC2)
|
||||||
|
CV_ENUM(InterType, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4, INTER_NEAREST)
|
||||||
|
|
||||||
|
typedef TestBaseWithParam< tr1::tuple<Size, MatrixType, MapType, InterType> > TestRemap;
|
||||||
|
|
||||||
|
PERF_TEST_P( TestRemap, Remap,
|
||||||
|
Combine(
|
||||||
|
Values( szVGA, sz1080p ),
|
||||||
|
ValuesIn( MatrixType::all() ),
|
||||||
|
ValuesIn( MapType::all() ),
|
||||||
|
ValuesIn( InterType::all() )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Size sz;
|
||||||
|
int src_type, map1_type, inter_type;
|
||||||
|
|
||||||
|
sz = get<0>(GetParam());
|
||||||
|
src_type = get<1>(GetParam());
|
||||||
|
map1_type = get<2>(GetParam());
|
||||||
|
inter_type = get<3>(GetParam());
|
||||||
|
|
||||||
|
Mat src(sz, src_type);
|
||||||
|
Mat map1(sz, map1_type);
|
||||||
|
Mat dst(sz, src_type);
|
||||||
|
|
||||||
|
Mat map2(map1_type == CV_32FC1 ? sz : Size(), CV_32FC1);
|
||||||
|
|
||||||
|
RNG rng;
|
||||||
|
rng.fill(src, RNG::UNIFORM, 0, 256);
|
||||||
|
|
||||||
|
for (int j = 0; j < map1.rows; ++j)
|
||||||
|
for (int i = 0; i < map1.cols; ++i)
|
||||||
|
switch (map1_type)
|
||||||
|
{
|
||||||
|
case CV_32FC1:
|
||||||
|
map1.at<float>(j, i) = src.cols - i;
|
||||||
|
map2.at<float>(j, i) = j;
|
||||||
|
break;
|
||||||
|
case CV_32FC2:
|
||||||
|
map1.at<Vec2f>(j, i)[0] = src.cols - i;
|
||||||
|
map1.at<Vec2f>(j, i)[1] = j;
|
||||||
|
break;
|
||||||
|
case CV_16SC2:
|
||||||
|
map1.at<Vec2s>(j, i)[0] = src.cols - i;
|
||||||
|
map1.at<Vec2s>(j, i)[1] = j;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CV_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst).time(20);
|
||||||
|
|
||||||
|
TEST_CYCLE() remap(src, dst, map1, map2, inter_type);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst);
|
||||||
|
}
|
@@ -59,11 +59,11 @@ PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear,
|
|||||||
typedef tr1::tuple<MatType, Size, int> MatInfo_Size_Scale_t;
|
typedef tr1::tuple<MatType, Size, int> MatInfo_Size_Scale_t;
|
||||||
typedef TestBaseWithParam<MatInfo_Size_Scale_t> MatInfo_Size_Scale;
|
typedef TestBaseWithParam<MatInfo_Size_Scale_t> MatInfo_Size_Scale;
|
||||||
|
|
||||||
PERF_TEST_P(MatInfo_Size_Scale, resizeAreaFast,
|
PERF_TEST_P(MatInfo_Size_Scale, ResizeAreaFast,
|
||||||
testing::Combine(
|
testing::Combine(
|
||||||
testing::Values(CV_8UC1, CV_8UC4),
|
testing::Values(CV_8UC1, CV_8UC4),
|
||||||
testing::Values(szVGA, szqHD, sz720p, sz1080p),
|
testing::Values(szVGA, szqHD, sz720p, sz1080p),
|
||||||
testing::Values(2, 4)
|
testing::Values(2)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -84,3 +84,31 @@ PERF_TEST_P(MatInfo_Size_Scale, resizeAreaFast,
|
|||||||
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
|
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
|
||||||
SANITY_CHECK(dst, 1);
|
SANITY_CHECK(dst, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef TestBaseWithParam<tr1::tuple<MatType, Size, double> > MatInfo_Size_Scale_Area;
|
||||||
|
|
||||||
|
PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea,
|
||||||
|
testing::Combine(
|
||||||
|
testing::Values(CV_8UC1, CV_8UC4),
|
||||||
|
testing::Values(szVGA, szqHD, sz720p, sz1080p),
|
||||||
|
testing::Values(2.4, 3.4, 1.3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int matType = get<0>(GetParam());
|
||||||
|
Size from = get<1>(GetParam());
|
||||||
|
double scale = get<2>(GetParam());
|
||||||
|
|
||||||
|
cv::Mat src(from, matType);
|
||||||
|
|
||||||
|
Size to(cvRound(from.width * scale), cvRound(from.height * scale));
|
||||||
|
cv::Mat dst(to, matType);
|
||||||
|
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_AREA);
|
||||||
|
|
||||||
|
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
|
||||||
|
SANITY_CHECK(dst, 1);
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user