mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge branch '2.4'
This commit is contained in:
@@ -4,7 +4,7 @@ Introduction
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
OpenCV (Open Source Computer Vision Library: http://opencv.willowgarage.com/wiki/) is an open-source BSD-licensed library that includes several hundreds of computer vision algorithms. The document describes the so-called OpenCV 2.x API, which is essentially a C++ API, as opposite to the C-based OpenCV 1.x API. The latter is described in opencv1x.pdf.
|
||||
OpenCV (Open Source Computer Vision Library: http://opencv.org) is an open-source BSD-licensed library that includes several hundreds of computer vision algorithms. The document describes the so-called OpenCV 2.x API, which is essentially a C++ API, as opposite to the C-based OpenCV 1.x API. The latter is described in opencv1x.pdf.
|
||||
|
||||
OpenCV has a modular structure, which means that the package includes several shared or static libraries. The following modules are available:
|
||||
|
||||
|
||||
@@ -45,4 +45,4 @@
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
@@ -360,6 +360,8 @@ CV_INLINE int cvRound( double value )
|
||||
fistp t;
|
||||
}
|
||||
return t;
|
||||
#elif defined _MSC_VER && defined _M_ARM && defined HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND(value);
|
||||
#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__
|
||||
# ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND(value);
|
||||
@@ -367,8 +369,12 @@ CV_INLINE int cvRound( double value )
|
||||
return (int)lrint(value);
|
||||
# endif
|
||||
#else
|
||||
// while this is not IEEE754-compliant rounding, it's usually a good enough approximation
|
||||
return (int)(value + (value >= 0 ? 0.5 : -0.5));
|
||||
double intpart, fractpart;
|
||||
fractpart = modf(value, &intpart);
|
||||
if ((fabs(fractpart) != 0.5) || ((((int)intpart) % 2) != 0))
|
||||
return (int)(value + (value >= 0 ? 0.5 : -0.5));
|
||||
else
|
||||
return (int)intpart;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1704,6 +1704,7 @@ public:
|
||||
SparseMatConstIterator_();
|
||||
//! the full constructor setting the iterator to the first sparse matrix element
|
||||
SparseMatConstIterator_(const SparseMat_<_Tp>* _m);
|
||||
SparseMatConstIterator_(const SparseMat* _m);
|
||||
//! the copy constructor
|
||||
SparseMatConstIterator_(const SparseMatConstIterator_& it);
|
||||
|
||||
@@ -1740,6 +1741,7 @@ public:
|
||||
SparseMatIterator_();
|
||||
//! the full constructor setting the iterator to the first sparse matrix element
|
||||
SparseMatIterator_(SparseMat_<_Tp>* _m);
|
||||
SparseMatIterator_(SparseMat* _m);
|
||||
//! the copy constructor
|
||||
SparseMatIterator_(const SparseMatIterator_& it);
|
||||
|
||||
|
||||
@@ -2587,6 +2587,13 @@ SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat_<_Tp>* _m)
|
||||
: SparseMatConstIterator(_m)
|
||||
{}
|
||||
|
||||
template<typename _Tp> inline
|
||||
SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat* _m)
|
||||
: SparseMatConstIterator(_m)
|
||||
{
|
||||
CV_Assert( _m->type() == DataType<_Tp>::type );
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMatConstIterator_<_Tp>& it)
|
||||
: SparseMatConstIterator(it)
|
||||
@@ -2634,6 +2641,11 @@ SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m)
|
||||
: SparseMatConstIterator_<_Tp>(_m)
|
||||
{}
|
||||
|
||||
template<typename _Tp> inline
|
||||
SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat* _m)
|
||||
: SparseMatConstIterator_<_Tp>(_m)
|
||||
{}
|
||||
|
||||
template<typename _Tp> inline
|
||||
SparseMatIterator_<_Tp>::SparseMatIterator_(const SparseMatIterator_<_Tp>& it)
|
||||
: SparseMatConstIterator_<_Tp>(it)
|
||||
|
||||
@@ -577,10 +577,10 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
|
||||
continue;
|
||||
|
||||
p *= 2;
|
||||
double beta = a - b, gamma = hypot((double)p, beta), delta;
|
||||
double beta = a - b, gamma = hypot((double)p, beta);
|
||||
if( beta < 0 )
|
||||
{
|
||||
delta = (gamma - beta)*0.5;
|
||||
double delta = (gamma - beta)*0.5;
|
||||
s = (_Tp)std::sqrt(delta/gamma);
|
||||
c = (_Tp)(p/(gamma*s*2));
|
||||
}
|
||||
@@ -588,36 +588,18 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
|
||||
{
|
||||
c = (_Tp)std::sqrt((gamma + beta)/(gamma*2));
|
||||
s = (_Tp)(p/(gamma*c*2));
|
||||
delta = p*p*0.5/(gamma + beta);
|
||||
}
|
||||
|
||||
W[i] += delta;
|
||||
W[j] -= delta;
|
||||
|
||||
if( iter % 2 != 0 && W[i] > 0 && W[j] > 0 )
|
||||
a = b = 0;
|
||||
for( k = 0; k < m; k++ )
|
||||
{
|
||||
k = vblas.givens(Ai, Aj, m, c, s);
|
||||
_Tp t0 = c*Ai[k] + s*Aj[k];
|
||||
_Tp t1 = -s*Ai[k] + c*Aj[k];
|
||||
Ai[k] = t0; Aj[k] = t1;
|
||||
|
||||
for( ; k < m; k++ )
|
||||
{
|
||||
_Tp t0 = c*Ai[k] + s*Aj[k];
|
||||
_Tp t1 = -s*Ai[k] + c*Aj[k];
|
||||
Ai[k] = t0; Aj[k] = t1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
a = b = 0;
|
||||
for( k = 0; k < m; k++ )
|
||||
{
|
||||
_Tp t0 = c*Ai[k] + s*Aj[k];
|
||||
_Tp t1 = -s*Ai[k] + c*Aj[k];
|
||||
Ai[k] = t0; Aj[k] = t1;
|
||||
|
||||
a += (double)t0*t0; b += (double)t1*t1;
|
||||
}
|
||||
W[i] = a; W[j] = b;
|
||||
a += (double)t0*t0; b += (double)t1*t1;
|
||||
}
|
||||
W[i] = a; W[j] = b;
|
||||
|
||||
changed = true;
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ void MatOp::augAssignXor(const MatExpr& expr, Mat& m) const
|
||||
{
|
||||
Mat temp;
|
||||
expr.op->assign(expr, temp);
|
||||
m /= temp;
|
||||
m ^= temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ static void finalizeHdr(Mat& m)
|
||||
void Mat::create(int d, const int* _sizes, int _type)
|
||||
{
|
||||
int i;
|
||||
CV_Assert(0 <= d && _sizes && d <= CV_MAX_DIM && _sizes);
|
||||
CV_Assert(0 <= d && d <= CV_MAX_DIM && _sizes);
|
||||
_type = CV_MAT_TYPE(_type);
|
||||
|
||||
if( data && (d == dims || (d == 1 && dims <= 2)) && _type == type() )
|
||||
|
||||
@@ -1551,3 +1551,16 @@ TEST(Core_Add, AddToColumnWhen4Rows)
|
||||
|
||||
ASSERT_EQ(0, countNonZero(m1 - m2));
|
||||
}
|
||||
|
||||
TEST(Core_round, CvRound)
|
||||
{
|
||||
ASSERT_EQ(2, cvRound(2.0));
|
||||
ASSERT_EQ(2, cvRound(2.1));
|
||||
ASSERT_EQ(-2, cvRound(-2.1));
|
||||
ASSERT_EQ(3, cvRound(2.8));
|
||||
ASSERT_EQ(-3, cvRound(-2.8));
|
||||
ASSERT_EQ(2, cvRound(2.5));
|
||||
ASSERT_EQ(4, cvRound(3.5));
|
||||
ASSERT_EQ(-2, cvRound(-2.5));
|
||||
ASSERT_EQ(-4, cvRound(-3.5));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user