From 82e5b961d362e29585da8542f704ddb3007cdd64 Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Wed, 3 Jul 2019 15:15:28 +0300 Subject: [PATCH] Fixed initUndistortRectifyMap AVX2 implementation --- modules/calib3d/test/test_undistort.cpp | 30 +++++++++++++++++++++++++ modules/imgproc/src/undistort.avx2.cpp | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/calib3d/test/test_undistort.cpp b/modules/calib3d/test/test_undistort.cpp index a4590b45e6..42ad294e51 100644 --- a/modules/calib3d/test/test_undistort.cpp +++ b/modules/calib3d/test/test_undistort.cpp @@ -1114,4 +1114,34 @@ TEST(Calib3d_UndistortPoints, outputShape) } } +TEST(Calib3d_initUndistortRectifyMap, regression_14467) +{ + Size size_w_h(512 + 3, 512); + Matx33f k( + 6200, 0, size_w_h.width / 2.0f, + 0, 6200, size_w_h.height / 2.0f, + 0, 0, 1 + ); + + Mat mesh_uv(size_w_h, CV_32FC2); + for (int i = 0; i < size_w_h.height; i++) + { + for (int j = 0; j < size_w_h.width; j++) + { + mesh_uv.at(i, j) = Vec2f((float)j, (float)i); + } + } + + Matx d( + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0.09, 0.0 + ); + Mat mapxy, dst; + initUndistortRectifyMap(k, d, noArray(), k, size_w_h, CV_32FC2, mapxy, noArray()); + undistortPoints(mapxy.reshape(2, (int)mapxy.total()), dst, k, d, noArray(), k); + dst = dst.reshape(2, mapxy.rows); + EXPECT_LE(cvtest::norm(dst, mesh_uv, NORM_INF), 1e-3); +} + }} // namespace diff --git a/modules/imgproc/src/undistort.avx2.cpp b/modules/imgproc/src/undistort.avx2.cpp index 69998be39b..9b6608a783 100644 --- a/modules/imgproc/src/undistort.avx2.cpp +++ b/modules/imgproc/src/undistort.avx2.cpp @@ -124,7 +124,7 @@ int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m _mm256_mul_pd(__matTilt_20, __xd), _mm256_mul_pd(__matTilt_21, __yd)), __matTilt_22); #endif __m256d __invProj = _mm256_blendv_pd( - __one, _mm256_div_pd(__one, __vecTilt2), + _mm256_div_pd(__one, __vecTilt2), __one, _mm256_cmp_pd(__vecTilt2, _mm256_setzero_pd(), _CMP_EQ_OQ)); #if CV_FMA3