Skip to content

Commit

Permalink
Fixed initUndistortRectifyMap AVX2 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
terfendail committed Jul 4, 2019
1 parent 2370079 commit 82e5b96
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions modules/calib3d/test/test_undistort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec2f>(i, j) = Vec2f((float)j, (float)i);
}
}

Matx<double, 1, 14> 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
2 changes: 1 addition & 1 deletion modules/imgproc/src/undistort.avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82e5b96

Please sign in to comment.