2017-11-05 21:48:40 +08:00
|
|
|
// This file is part of OpenCV project.
|
|
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
|
|
// of this distribution and at http://opencv.org/license.html.
|
2011-09-06 23:30:28 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
2017-11-05 21:48:40 +08:00
|
|
|
namespace opencv_test {
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2017-11-05 21:48:40 +08:00
|
|
|
typedef tuple<MatType, Size, Size> MatInfo_Size_Size_t;
|
2011-09-06 23:30:28 +08:00
|
|
|
typedef TestBaseWithParam<MatInfo_Size_Size_t> MatInfo_Size_Size;
|
2019-12-09 19:54:06 +08:00
|
|
|
typedef tuple<Size,Size> Size_Size_t;
|
|
|
|
typedef tuple<MatType, Size_Size_t> MatInfo_SizePair_t;
|
|
|
|
typedef TestBaseWithParam<MatInfo_SizePair_t> MatInfo_SizePair;
|
|
|
|
|
|
|
|
#define MATTYPE_NE_VALUES CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, \
|
|
|
|
CV_16UC1, CV_16UC2, CV_16UC3, CV_16UC4, \
|
|
|
|
CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4
|
|
|
|
|
2011-09-06 23:30:28 +08:00
|
|
|
PERF_TEST_P(MatInfo_Size_Size, resizeUpLinear,
|
2011-12-30 00:46:16 +08:00
|
|
|
testing::Values(
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC1, szVGA, szqHD),
|
2017-12-20 23:11:21 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC2, szVGA, szqHD),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, szVGA, szqHD),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC4, szVGA, szqHD),
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC1, szVGA, sz720p),
|
2017-12-20 23:11:21 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC2, szVGA, sz720p),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, szVGA, sz720p),
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC4, szVGA, sz720p)
|
|
|
|
)
|
2011-12-30 00:46:16 +08:00
|
|
|
)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
int matType = get<0>(GetParam());
|
|
|
|
Size from = get<1>(GetParam());
|
|
|
|
Size to = get<2>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2013-01-23 21:25:30 +08:00
|
|
|
cv::Mat src(from, matType), dst(to, matType);
|
2024-10-03 19:01:36 +08:00
|
|
|
cvtest::fillGradient<uint8_t>(src);
|
2013-01-23 21:25:30 +08:00
|
|
|
declare.in(src).out(dst);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2017-12-13 20:00:38 +08:00
|
|
|
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR_EXACT);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2017-07-10 17:43:59 +08:00
|
|
|
#ifdef __ANDROID__
|
2013-01-23 21:25:30 +08:00
|
|
|
SANITY_CHECK(dst, 5);
|
2012-11-29 21:27:44 +08:00
|
|
|
#else
|
2011-12-28 00:37:24 +08:00
|
|
|
SANITY_CHECK(dst, 1 + 1e-6);
|
2012-11-29 21:27:44 +08:00
|
|
|
#endif
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2019-12-09 19:54:06 +08:00
|
|
|
PERF_TEST_P(MatInfo_SizePair, resizeUpLinearNonExact,
|
|
|
|
testing::Combine
|
|
|
|
(
|
|
|
|
testing::Values( MATTYPE_NE_VALUES ),
|
|
|
|
testing::Values( Size_Size_t(szVGA, szqHD), Size_Size_t(szVGA, sz720p) )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int matType = get<0>(GetParam());
|
|
|
|
Size_Size_t sizes = get<1>(GetParam());
|
|
|
|
Size from = get<0>(sizes);
|
|
|
|
Size to = get<1>(sizes);
|
|
|
|
|
|
|
|
cv::Mat src(from, matType), dst(to, matType);
|
|
|
|
switch(src.depth())
|
|
|
|
{
|
2024-10-03 19:01:36 +08:00
|
|
|
case CV_8U: cvtest::fillGradient<uint8_t>(src); break;
|
|
|
|
case CV_16U: cvtest::fillGradient<ushort>(src); break;
|
|
|
|
case CV_32F: cvtest::fillGradient<float>(src); break;
|
2019-12-09 19:54:06 +08:00
|
|
|
}
|
|
|
|
declare.in(src).out(dst);
|
|
|
|
|
|
|
|
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR);
|
|
|
|
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
|
|
}
|
|
|
|
|
2011-09-06 23:30:28 +08:00
|
|
|
PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear,
|
2011-12-30 00:46:16 +08:00
|
|
|
testing::Values(
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC1, szVGA, szQVGA),
|
2017-12-20 23:11:21 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC2, szVGA, szQVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, szVGA, szQVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC4, szVGA, szQVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC1, szqHD, szVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC2, szqHD, szVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, szqHD, szVGA),
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC4, szqHD, szVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC1, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
|
2017-12-20 23:11:21 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC2, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
|
|
|
|
MatInfo_Size_Size_t(CV_8UC4, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
|
|
|
|
MatInfo_Size_Size_t(CV_8UC1, sz720p, szVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC2, sz720p, szVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, sz720p, szVGA),
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC4, sz720p, szVGA),
|
2017-12-20 23:11:21 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC1, sz720p, szQVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC2, sz720p, szQVGA),
|
|
|
|
MatInfo_Size_Size_t(CV_8UC3, sz720p, szQVGA),
|
2011-09-06 23:30:28 +08:00
|
|
|
MatInfo_Size_Size_t(CV_8UC4, sz720p, szQVGA)
|
|
|
|
)
|
2011-12-30 00:46:16 +08:00
|
|
|
)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
int matType = get<0>(GetParam());
|
|
|
|
Size from = get<1>(GetParam());
|
|
|
|
Size to = get<2>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2013-01-23 21:25:30 +08:00
|
|
|
cv::Mat src(from, matType), dst(to, matType);
|
2024-10-03 19:01:36 +08:00
|
|
|
cvtest::fillGradient<uint8_t>(src);
|
2013-01-23 21:25:30 +08:00
|
|
|
declare.in(src).out(dst);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2017-12-13 20:00:38 +08:00
|
|
|
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR_EXACT);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2017-07-10 17:43:59 +08:00
|
|
|
#ifdef __ANDROID__
|
2013-01-23 21:25:30 +08:00
|
|
|
SANITY_CHECK(dst, 5);
|
2012-11-29 21:27:44 +08:00
|
|
|
#else
|
2011-12-28 00:37:24 +08:00
|
|
|
SANITY_CHECK(dst, 1 + 1e-6);
|
2012-11-29 21:27:44 +08:00
|
|
|
#endif
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2019-12-09 19:54:06 +08:00
|
|
|
PERF_TEST_P(MatInfo_SizePair, resizeDownLinearNonExact,
|
|
|
|
testing::Combine
|
|
|
|
(
|
|
|
|
testing::Values( MATTYPE_NE_VALUES ),
|
|
|
|
testing::Values
|
|
|
|
(
|
|
|
|
Size_Size_t(szVGA, szQVGA),
|
|
|
|
Size_Size_t(szqHD, szVGA),
|
|
|
|
Size_Size_t(sz720p, Size(120 * sz720p.width / sz720p.height, 120)),
|
|
|
|
Size_Size_t(sz720p, szVGA),
|
|
|
|
Size_Size_t(sz720p, szQVGA)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int matType = get<0>(GetParam());
|
|
|
|
Size_Size_t sizes = get<1>(GetParam());
|
|
|
|
Size from = get<0>(sizes);
|
|
|
|
Size to = get<1>(sizes);
|
|
|
|
|
|
|
|
cv::Mat src(from, matType), dst(to, matType);
|
|
|
|
switch(src.depth())
|
|
|
|
{
|
2024-10-03 19:01:36 +08:00
|
|
|
case CV_8U: cvtest::fillGradient<uint8_t>(src); break;
|
|
|
|
case CV_16U: cvtest::fillGradient<ushort>(src); break;
|
|
|
|
case CV_32F: cvtest::fillGradient<float>(src); break;
|
2019-12-09 19:54:06 +08:00
|
|
|
}
|
|
|
|
declare.in(src).out(dst);
|
|
|
|
|
|
|
|
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR);
|
|
|
|
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
|
|
}
|
|
|
|
|
2011-12-29 19:55:26 +08:00
|
|
|
|
2017-11-05 21:48:40 +08:00
|
|
|
typedef tuple<MatType, Size, int> MatInfo_Size_Scale_t;
|
2011-12-29 19:55:26 +08:00
|
|
|
typedef TestBaseWithParam<MatInfo_Size_Scale_t> MatInfo_Size_Scale;
|
|
|
|
|
2012-08-22 15:49:21 +08:00
|
|
|
PERF_TEST_P(MatInfo_Size_Scale, ResizeAreaFast,
|
2011-12-30 00:46:16 +08:00
|
|
|
testing::Combine(
|
2012-12-11 19:14:50 +08:00
|
|
|
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4),
|
2011-12-30 00:46:16 +08:00
|
|
|
testing::Values(szVGA, szqHD, sz720p, sz1080p),
|
2012-08-22 15:49:21 +08:00
|
|
|
testing::Values(2)
|
2011-12-30 00:46:16 +08:00
|
|
|
)
|
|
|
|
)
|
2011-12-29 19:55:26 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
int matType = get<0>(GetParam());
|
|
|
|
Size from = get<1>(GetParam());
|
|
|
|
int scale = get<2>(GetParam());
|
2011-12-29 19:55:26 +08:00
|
|
|
|
|
|
|
from.width = (from.width/scale)*scale;
|
|
|
|
from.height = (from.height/scale)*scale;
|
|
|
|
|
|
|
|
cv::Mat src(from, matType);
|
|
|
|
cv::Mat dst(from.height / scale, from.width / scale, matType);
|
|
|
|
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-06-26 19:07:39 +08:00
|
|
|
int runs = 15;
|
|
|
|
TEST_CYCLE_MULTIRUN(runs) resize(src, dst, dst.size(), 0, 0, INTER_AREA);
|
2011-12-29 19:55:26 +08:00
|
|
|
|
|
|
|
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
|
|
|
|
SANITY_CHECK(dst, 1);
|
|
|
|
}
|
2012-08-22 15:49:21 +08:00
|
|
|
|
|
|
|
|
2017-11-05 21:48:40 +08:00
|
|
|
typedef TestBaseWithParam<tuple<MatType, Size, double> > MatInfo_Size_Scale_Area;
|
2012-08-22 15:49:21 +08:00
|
|
|
|
|
|
|
PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea,
|
|
|
|
testing::Combine(
|
2023-10-17 14:43:15 +08:00
|
|
|
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4),
|
|
|
|
testing::Values(szVGA, szqHD, sz720p, sz1080p, sz2160p),
|
|
|
|
testing::Values(0.1, 0.25, 0.81)
|
2012-08-22 15:49:21 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int matType = get<0>(GetParam());
|
|
|
|
Size from = get<1>(GetParam());
|
|
|
|
double scale = get<2>(GetParam());
|
|
|
|
|
|
|
|
cv::Mat src(from, matType);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2012-08-22 15:49:21 +08:00
|
|
|
Size to(cvRound(from.width * scale), cvRound(from.height * scale));
|
|
|
|
cv::Mat dst(to, matType);
|
|
|
|
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
2012-11-28 18:13:24 +08:00
|
|
|
declare.time(100);
|
2012-08-22 15:49:21 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2017-05-31 23:44:35 +08:00
|
|
|
|
|
|
|
typedef MatInfo_Size_Scale_Area MatInfo_Size_Scale_NN;
|
|
|
|
|
|
|
|
PERF_TEST_P(MatInfo_Size_Scale_NN, ResizeNN,
|
|
|
|
testing::Combine(
|
|
|
|
testing::Values(CV_8UC1, CV_8UC2, CV_8UC4),
|
|
|
|
testing::Values(szVGA, szqHD, sz720p, sz1080p, sz2160p),
|
|
|
|
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);
|
|
|
|
declare.time(100);
|
|
|
|
|
|
|
|
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_NEAREST);
|
|
|
|
|
|
|
|
EXPECT_GT(countNonZero(dst.reshape(1)), 0);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
|
|
}
|
2017-11-05 21:48:40 +08:00
|
|
|
|
2020-08-29 02:20:05 +08:00
|
|
|
PERF_TEST_P(MatInfo_Size_Scale_NN, ResizeNNExact,
|
|
|
|
testing::Combine(
|
|
|
|
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4),
|
|
|
|
testing::Values(sz720p, sz1080p),
|
|
|
|
testing::Values(0.25, 0.5, 2.0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
declare.time(100);
|
|
|
|
|
|
|
|
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_NEAREST_EXACT);
|
|
|
|
|
|
|
|
EXPECT_GT(countNonZero(dst.reshape(1)), 0);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
|
|
}
|
|
|
|
|
2017-11-05 21:48:40 +08:00
|
|
|
} // namespace
|