1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2018-04-16 12:41:47 +03:00
45 changed files with 2886 additions and 1278 deletions
+32 -19
View File
@@ -77,6 +77,7 @@ protected:
virtual void run_func() = 0;
virtual void run_reference_func() = 0;
virtual float get_success_error_level(int _interpolation, int _depth) const;
virtual void validate_results() const;
virtual void prepare_test_data_for_reference_func();
@@ -229,6 +230,20 @@ void CV_ImageWarpBaseTest::run(int)
ts->set_gtest_status();
}
float CV_ImageWarpBaseTest::get_success_error_level(int _interpolation, int) const
{
if (_interpolation == INTER_CUBIC)
return 1.0f;
else if (_interpolation == INTER_LANCZOS4)
return 1.0f;
else if (_interpolation == INTER_NEAREST)
return 1.0f;
else if (_interpolation == INTER_AREA)
return 2.0f;
else
return 1.0f;
}
void CV_ImageWarpBaseTest::validate_results() const
{
Mat _dst;
@@ -237,15 +252,7 @@ void CV_ImageWarpBaseTest::validate_results() const
Size dsize = dst.size(), ssize = src.size();
int cn = _dst.channels();
dsize.width *= cn;
float t = 1.0f;
if (interpolation == INTER_CUBIC)
t = 1.0f;
else if (interpolation == INTER_LANCZOS4)
t = 1.0f;
else if (interpolation == INTER_NEAREST)
t = 1.0f;
else if (interpolation == INTER_AREA)
t = 2.0f;
float t = get_success_error_level(interpolation & INTER_MAX, dst.depth());
for (int dy = 0; dy < dsize.height; ++dy)
{
@@ -1034,7 +1041,7 @@ public:
protected:
virtual void generate_test_data();
virtual void prepare_test_data_for_reference_func();
virtual float get_success_error_level(int _interpolation, int _depth) const;
virtual void run_func();
virtual void run_reference_func();
@@ -1083,16 +1090,16 @@ void CV_WarpAffine_Test::run_func()
cv::warpAffine(src, dst, M, dst.size(), interpolation, borderType, borderValue);
}
void CV_WarpAffine_Test::prepare_test_data_for_reference_func()
float CV_WarpAffine_Test::get_success_error_level(int _interpolation, int _depth) const
{
CV_ImageWarpBaseTest::prepare_test_data_for_reference_func();
return _depth == CV_8U ? 0 : CV_ImageWarpBaseTest::get_success_error_level(_interpolation, _depth);
}
void CV_WarpAffine_Test::run_reference_func()
{
prepare_test_data_for_reference_func();
warpAffine(src, reference_dst);
Mat tmp = Mat::zeros(dst.size(), dst.type());
warpAffine(src, tmp);
tmp.convertTo(reference_dst, reference_dst.depth());
}
void CV_WarpAffine_Test::warpAffine(const Mat& _src, Mat& _dst)
@@ -1123,7 +1130,7 @@ void CV_WarpAffine_Test::warpAffine(const Mat& _src, Mat& _dst)
const int AB_SCALE = 1 << AB_BITS;
int round_delta = (inter == INTER_NEAREST) ? AB_SCALE / 2 : (AB_SCALE / INTER_TAB_SIZE / 2);
const double* data_tM = tM.ptr<double>(0);
const softdouble* data_tM = tM.ptr<softdouble>(0);
for (int dy = 0; dy < dsize.height; ++dy)
{
short* yM = mapx.ptr<short>(dy);
@@ -1162,6 +1169,7 @@ public:
protected:
virtual void generate_test_data();
virtual float get_success_error_level(int _interpolation, int _depth) const;
virtual void run_func();
virtual void run_reference_func();
@@ -1204,11 +1212,16 @@ void CV_WarpPerspective_Test::run_func()
cv::warpPerspective(src, dst, M, dst.size(), interpolation, borderType, borderValue);
}
float CV_WarpPerspective_Test::get_success_error_level(int _interpolation, int _depth) const
{
return CV_ImageWarpBaseTest::get_success_error_level(_interpolation, _depth);
}
void CV_WarpPerspective_Test::run_reference_func()
{
prepare_test_data_for_reference_func();
warpPerspective(src, reference_dst);
Mat tmp = Mat::zeros(dst.size(), dst.type());
warpPerspective(src, tmp);
tmp.convertTo(reference_dst, reference_dst.depth());
}
void CV_WarpPerspective_Test::warpPerspective(const Mat& _src, Mat& _dst)