mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
Merge pull request #339 from vpisarev:core_fixes
This commit is contained in:
commit
98fdd70466
@ -716,12 +716,12 @@ template<typename _Tp, int m> struct CV_EXPORTS Matx_DetOp
|
|||||||
double operator ()(const Matx<_Tp, m, m>& a) const
|
double operator ()(const Matx<_Tp, m, m>& a) const
|
||||||
{
|
{
|
||||||
Matx<_Tp, m, m> temp = a;
|
Matx<_Tp, m, m> temp = a;
|
||||||
double p = LU(temp.val, m, m, 0, 0, 0);
|
double p = LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0);
|
||||||
if( p == 0 )
|
if( p == 0 )
|
||||||
return p;
|
return p;
|
||||||
for( int i = 0; i < m; i++ )
|
for( int i = 0; i < m; i++ )
|
||||||
p *= temp(i, i);
|
p *= temp(i, i);
|
||||||
return p;
|
return 1./p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -342,9 +342,8 @@ CV_INLINE int cvFloor( double value )
|
|||||||
return i - (i > value);
|
return i - (i > value);
|
||||||
#else
|
#else
|
||||||
int i = cvRound(value);
|
int i = cvRound(value);
|
||||||
Cv32suf diff;
|
float diff = (float)(value - i);
|
||||||
diff.f = (float)(value - i);
|
return i - (diff < 0);
|
||||||
return i - (diff.i < 0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,9 +359,8 @@ CV_INLINE int cvCeil( double value )
|
|||||||
return i + (i < value);
|
return i + (i < value);
|
||||||
#else
|
#else
|
||||||
int i = cvRound(value);
|
int i = cvRound(value);
|
||||||
Cv32suf diff;
|
float diff = (float)(i - value);
|
||||||
diff.f = (float)(i - value);
|
return i + (diff < 0);
|
||||||
return i + (diff.i < 0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,31 +369,19 @@ CV_INLINE int cvCeil( double value )
|
|||||||
|
|
||||||
CV_INLINE int cvIsNaN( double value )
|
CV_INLINE int cvIsNaN( double value )
|
||||||
{
|
{
|
||||||
#if 1/*defined _MSC_VER || defined __BORLANDC__
|
|
||||||
return _isnan(value);
|
|
||||||
#elif defined __GNUC__
|
|
||||||
return isnan(value);
|
|
||||||
#else*/
|
|
||||||
Cv64suf ieee754;
|
Cv64suf ieee754;
|
||||||
ieee754.f = value;
|
ieee754.f = value;
|
||||||
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
|
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
|
||||||
((unsigned)ieee754.u != 0) > 0x7ff00000;
|
((unsigned)ieee754.u != 0) > 0x7ff00000;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_INLINE int cvIsInf( double value )
|
CV_INLINE int cvIsInf( double value )
|
||||||
{
|
{
|
||||||
#if 1/*defined _MSC_VER || defined __BORLANDC__
|
|
||||||
return !_finite(value);
|
|
||||||
#elif defined __GNUC__
|
|
||||||
return isinf(value);
|
|
||||||
#else*/
|
|
||||||
Cv64suf ieee754;
|
Cv64suf ieee754;
|
||||||
ieee754.f = value;
|
ieee754.f = value;
|
||||||
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
|
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
|
||||||
(unsigned)ieee754.u == 0;
|
(unsigned)ieee754.u == 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -830,7 +830,8 @@ int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) con
|
|||||||
{
|
{
|
||||||
return (depth() == _depth || _depth <= 0) &&
|
return (depth() == _depth || _depth <= 0) &&
|
||||||
(isContinuous() || !_requireContinuous) &&
|
(isContinuous() || !_requireContinuous) &&
|
||||||
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) || (cols == _elemChannels))) ||
|
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
|
||||||
|
(cols == _elemChannels && channels() == 1))) ||
|
||||||
(dims == 3 && channels() == 1 && size.p[2] == _elemChannels && (size.p[0] == 1 || size.p[1] == 1) &&
|
(dims == 3 && channels() == 1 && size.p[2] == _elemChannels && (size.p[0] == 1 || size.p[1] == 1) &&
|
||||||
(isContinuous() || step.p[1] == step.p[2]*size.p[2])))
|
(isContinuous() || step.p[1] == step.p[2]*size.p[2])))
|
||||||
? (int)(total()*channels()/_elemChannels) : -1;
|
? (int)(total()*channels()/_elemChannels) : -1;
|
||||||
|
@ -998,6 +998,23 @@ bool CV_OperationsTest::operations1()
|
|||||||
|
|
||||||
add(Mat::zeros(6, 1, CV_64F), 1, c, noArray(), c.type());
|
add(Mat::zeros(6, 1, CV_64F), 1, c, noArray(), c.type());
|
||||||
CV_Assert( norm(Matx61f(1.f, 1.f, 1.f, 1.f, 1.f, 1.f), c, CV_C) == 0 );
|
CV_Assert( norm(Matx61f(1.f, 1.f, 1.f, 1.f, 1.f, 1.f), c, CV_C) == 0 );
|
||||||
|
|
||||||
|
vector<Point2f> pt2d(3);
|
||||||
|
vector<Point3d> pt3d(2);
|
||||||
|
|
||||||
|
CV_Assert( Mat(pt2d).checkVector(2) == 3 && Mat(pt2d).checkVector(3) < 0 &&
|
||||||
|
Mat(pt3d).checkVector(2) < 0 && Mat(pt3d).checkVector(3) == 2 );
|
||||||
|
|
||||||
|
Matx44f m44(0.8147f, 0.6324f, 0.9575f, 0.9572f,
|
||||||
|
0.9058f, 0.0975f, 0.9649f, 0.4854f,
|
||||||
|
0.1270f, 0.2785f, 0.1576f, 0.8003f,
|
||||||
|
0.9134f, 0.5469f, 0.9706f, 0.1419f);
|
||||||
|
double d = determinant(m44);
|
||||||
|
CV_Assert( fabs(d - (-0.0262)) <= 0.001 );
|
||||||
|
|
||||||
|
Cv32suf z;
|
||||||
|
z.i = 0x80000000;
|
||||||
|
CV_Assert( cvFloor(z.f) == 0 && cvCeil(z.f) == 0 && cvRound(z.f) == 0 );
|
||||||
}
|
}
|
||||||
catch(const test_excep&)
|
catch(const test_excep&)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user