increased singularity epsilon in LU decomposition. This solved singular case from http://code.opencv.org/issues/3305. Added the respective test.
This commit is contained in:
@@ -49,7 +49,7 @@ namespace cv { namespace hal {
|
||||
\****************************************************************************************/
|
||||
|
||||
template<typename _Tp> static inline int
|
||||
LUImpl(_Tp* A, size_t astep, int m, _Tp* b, size_t bstep, int n)
|
||||
LUImpl(_Tp* A, size_t astep, int m, _Tp* b, size_t bstep, int n, _Tp eps)
|
||||
{
|
||||
int i, j, k, p = 1;
|
||||
astep /= sizeof(A[0]);
|
||||
@@ -63,7 +63,7 @@ LUImpl(_Tp* A, size_t astep, int m, _Tp* b, size_t bstep, int n)
|
||||
if( std::abs(A[j*astep + i]) > std::abs(A[k*astep + i]) )
|
||||
k = j;
|
||||
|
||||
if( std::abs(A[k*astep + i]) < std::numeric_limits<_Tp>::epsilon() )
|
||||
if( std::abs(A[k*astep + i]) < eps )
|
||||
return 0;
|
||||
|
||||
if( k != i )
|
||||
@@ -111,13 +111,13 @@ LUImpl(_Tp* A, size_t astep, int m, _Tp* b, size_t bstep, int n)
|
||||
|
||||
int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n)
|
||||
{
|
||||
return LUImpl(A, astep, m, b, bstep, n);
|
||||
return LUImpl(A, astep, m, b, bstep, n, FLT_EPSILON*10);
|
||||
}
|
||||
|
||||
|
||||
int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n)
|
||||
{
|
||||
return LUImpl(A, astep, m, b, bstep, n);
|
||||
return LUImpl(A, astep, m, b, bstep, n, DBL_EPSILON*100);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1654,4 +1654,18 @@ TEST(Imgproc_Warp, multichannel)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Imgproc_GetAffineTransform, singularity)
|
||||
{
|
||||
Point2f A_sample[3];
|
||||
A_sample[0] = cv::Point2f(8, 9);
|
||||
A_sample[1] = cv::Point2f(40, 41);
|
||||
A_sample[2] = cv::Point2f(47, 48);
|
||||
Point2f B_sample[3];
|
||||
B_sample[0] = cv::Point2f(7.37465, 11.8295);
|
||||
B_sample[1] = cv::Point2f(15.0113, 12.8994);
|
||||
B_sample[2] = cv::Point2f(38.9943, 9.56297);
|
||||
Mat trans = cv::getAffineTransform(A_sample, B_sample);
|
||||
ASSERT_EQ(0.0, norm(trans, NORM_INF));
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
Reference in New Issue
Block a user