mirror of
https://github.com/opencv/opencv.git
synced 2025-01-19 23:19:23 +08:00
fixed some more tests on Windows; changed inheritance Matx -> Vec to Vec -> Matx
This commit is contained in:
parent
5a53d82e30
commit
d8ace43753
@ -89,16 +89,17 @@ bool is_smaller(const std::pair<int, float>& p1, const std::pair<int, float>& p2
|
||||
void orderContours(const vector<vector<Point> >& contours, Point2f point, vector<std::pair<int, float> >& order)
|
||||
{
|
||||
order.clear();
|
||||
int i, j, n = (int)contours.size();
|
||||
size_t i, j, n = contours.size();
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
size_t ni = contours[i].size();
|
||||
double min_dist = std::numeric_limits<double>::max();
|
||||
for(j = 0; j < n; j++)
|
||||
for(j = 0; j < ni; j++)
|
||||
{
|
||||
double dist = norm(Point2f((float)contours[i][j].x, (float)contours[i][j].y) - point);
|
||||
min_dist = MIN(min_dist, dist);
|
||||
}
|
||||
order.push_back(std::pair<int, float>(i, (float)min_dist));
|
||||
order.push_back(std::pair<int, float>((int)i, (float)min_dist));
|
||||
}
|
||||
|
||||
std::sort(order.begin(), order.end(), is_smaller);
|
||||
|
@ -399,104 +399,6 @@ template<> class DataDepth<float> { public: enum { value = CV_32F, fmt=(int)'f'
|
||||
template<> class DataDepth<double> { public: enum { value = CV_64F, fmt=(int)'d' }; };
|
||||
template<typename _Tp> class DataDepth<_Tp*> { public: enum { value = CV_USRTYPE1, fmt=(int)'r' }; };
|
||||
|
||||
/*!
|
||||
A short numerical vector.
|
||||
|
||||
This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements)
|
||||
on which you can perform basic arithmetical operations, access individual elements using [] operator etc.
|
||||
The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc.,
|
||||
which elements are dynamically allocated in the heap.
|
||||
|
||||
The template takes 2 parameters:
|
||||
-# _Tp element type
|
||||
-# cn the number of elements
|
||||
|
||||
In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
|
||||
for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
|
||||
*/
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
enum { depth = DataDepth<_Tp>::value, channels = cn, type = CV_MAKETYPE(depth, channels) };
|
||||
|
||||
//! default constructor
|
||||
Vec();
|
||||
|
||||
Vec(_Tp v0); //!< 1-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor
|
||||
explicit Vec(const _Tp* values);
|
||||
|
||||
Vec(const Vec<_Tp, cn>& v);
|
||||
static Vec all(_Tp alpha);
|
||||
//! dot product
|
||||
_Tp dot(const Vec& v) const;
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Vec& v) const;
|
||||
//! per-element multiplication
|
||||
Vec mul(const Vec<_Tp, cn>& v) const;
|
||||
|
||||
/*!
|
||||
cross product of the two 3D vectors.
|
||||
|
||||
For other dimensionalities the exception is raised
|
||||
*/
|
||||
Vec cross(const Vec& v) const;
|
||||
//! convertion to another data type
|
||||
template<typename T2> operator Vec<T2, cn>() const;
|
||||
//! conversion to 4-element CvScalar.
|
||||
operator CvScalar() const;
|
||||
|
||||
Matx<_Tp, 1, cn> t() const;
|
||||
|
||||
/*! element access */
|
||||
const _Tp& operator [](int i) const;
|
||||
_Tp& operator[](int i);
|
||||
const _Tp& operator ()(int i) const;
|
||||
_Tp& operator ()(int i);
|
||||
|
||||
_Tp val[cn]; //< vector elements
|
||||
};
|
||||
|
||||
|
||||
/* \typedef
|
||||
|
||||
Shorter aliases for the most popular specializations of Vec<T,n>
|
||||
*/
|
||||
typedef Vec<uchar, 2> Vec2b;
|
||||
typedef Vec<uchar, 3> Vec3b;
|
||||
typedef Vec<uchar, 4> Vec4b;
|
||||
|
||||
typedef Vec<short, 2> Vec2s;
|
||||
typedef Vec<short, 3> Vec3s;
|
||||
typedef Vec<short, 4> Vec4s;
|
||||
|
||||
typedef Vec<ushort, 2> Vec2w;
|
||||
typedef Vec<ushort, 3> Vec3w;
|
||||
typedef Vec<ushort, 4> Vec4w;
|
||||
|
||||
typedef Vec<int, 2> Vec2i;
|
||||
typedef Vec<int, 3> Vec3i;
|
||||
typedef Vec<int, 4> Vec4i;
|
||||
|
||||
typedef Vec<float, 2> Vec2f;
|
||||
typedef Vec<float, 3> Vec3f;
|
||||
typedef Vec<float, 4> Vec4f;
|
||||
typedef Vec<float, 6> Vec6f;
|
||||
|
||||
typedef Vec<double, 2> Vec2d;
|
||||
typedef Vec<double, 3> Vec3d;
|
||||
typedef Vec<double, 4> Vec4d;
|
||||
typedef Vec<double, 6> Vec6d;
|
||||
|
||||
|
||||
////////////////////////////// Small Matrix ///////////////////////////
|
||||
|
||||
@ -523,12 +425,11 @@ struct CV_EXPORTS Matx_MulOp {};
|
||||
struct CV_EXPORTS Matx_MatMulOp {};
|
||||
struct CV_EXPORTS Matx_TOp {};
|
||||
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx : public Vec<_Tp, m*n>
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
typedef Vec<_Tp, m*n> base_type;
|
||||
typedef Vec<_Tp, MIN(m, n)> diag_type;
|
||||
typedef Matx<_Tp, MIN(m, n), 1> diag_type;
|
||||
typedef Matx<_Tp, m, n> mat_type;
|
||||
enum { depth = DataDepth<_Tp>::value, rows = m, cols = n, channels = rows*cols,
|
||||
type = CV_MAKETYPE(depth, channels) };
|
||||
@ -555,15 +456,20 @@ public:
|
||||
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
||||
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
||||
|
||||
Matx(const base_type& v);
|
||||
static Matx all(_Tp alpha);
|
||||
static Matx zeros();
|
||||
static Matx ones();
|
||||
static Matx eye();
|
||||
static Matx diag(const Vec<_Tp, MIN(m,n)>& d);
|
||||
static Matx diag(const diag_type& d);
|
||||
static Matx randu(_Tp a, _Tp b);
|
||||
static Matx randn(_Tp a, _Tp b);
|
||||
|
||||
//! dot product computed with the default precision
|
||||
_Tp dot(const Matx<_Tp, m, n>& v) const;
|
||||
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Matx<_Tp, m, n>& v) const;
|
||||
|
||||
//! convertion to another data type
|
||||
template<typename T2> operator Matx<T2, m, n>() const;
|
||||
|
||||
@ -577,10 +483,10 @@ public:
|
||||
Matx<_Tp, 1, n> row(int i) const;
|
||||
|
||||
//! extract the matrix column
|
||||
Vec<_Tp, m> col(int i) const;
|
||||
Matx<_Tp, m, 1> col(int i) const;
|
||||
|
||||
//! extract the matrix diagonal
|
||||
Vec<_Tp, MIN(m,n)> diag() const;
|
||||
Matx<_Tp, MIN(m,n), 1> diag() const;
|
||||
|
||||
//! transpose the matrix
|
||||
Matx<_Tp, n, m> t() const;
|
||||
@ -590,7 +496,7 @@ public:
|
||||
|
||||
//! solve linear system
|
||||
template<int l> Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const;
|
||||
Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const;
|
||||
Matx<_Tp, n, 1> solve(const Matx<_Tp, m, 1>& rhs, int method) const;
|
||||
|
||||
//! multiply two matrices element-wise
|
||||
Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const;
|
||||
@ -609,6 +515,8 @@ public:
|
||||
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp);
|
||||
template<int l> Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp);
|
||||
Matx(const Matx<_Tp, n, m>& a, Matx_TOp);
|
||||
|
||||
_Tp val[m*n]; //< matrix elements
|
||||
};
|
||||
|
||||
|
||||
@ -649,7 +557,100 @@ typedef Matx<float, 4, 4> Matx44f;
|
||||
typedef Matx<double, 4, 4> Matx44d;
|
||||
typedef Matx<float, 6, 6> Matx66f;
|
||||
typedef Matx<double, 6, 6> Matx66d;
|
||||
|
||||
|
||||
/*!
|
||||
A short numerical vector.
|
||||
|
||||
This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements)
|
||||
on which you can perform basic arithmetical operations, access individual elements using [] operator etc.
|
||||
The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc.,
|
||||
which elements are dynamically allocated in the heap.
|
||||
|
||||
The template takes 2 parameters:
|
||||
-# _Tp element type
|
||||
-# cn the number of elements
|
||||
|
||||
In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
|
||||
for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
|
||||
*/
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec : public Matx<_Tp, cn, 1>
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
enum { depth = DataDepth<_Tp>::value, channels = cn, type = CV_MAKETYPE(depth, channels) };
|
||||
|
||||
//! default constructor
|
||||
Vec();
|
||||
|
||||
Vec(_Tp v0); //!< 1-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor
|
||||
explicit Vec(const _Tp* values);
|
||||
|
||||
Vec(const Vec<_Tp, cn>& v);
|
||||
static Vec all(_Tp alpha);
|
||||
|
||||
//! per-element multiplication
|
||||
Vec mul(const Vec<_Tp, cn>& v) const;
|
||||
|
||||
/*!
|
||||
cross product of the two 3D vectors.
|
||||
|
||||
For other dimensionalities the exception is raised
|
||||
*/
|
||||
Vec cross(const Vec& v) const;
|
||||
//! convertion to another data type
|
||||
template<typename T2> operator Vec<T2, cn>() const;
|
||||
//! conversion to 4-element CvScalar.
|
||||
operator CvScalar() const;
|
||||
|
||||
/*! element access */
|
||||
const _Tp& operator [](int i) const;
|
||||
_Tp& operator[](int i);
|
||||
const _Tp& operator ()(int i) const;
|
||||
_Tp& operator ()(int i);
|
||||
};
|
||||
|
||||
|
||||
/* \typedef
|
||||
|
||||
Shorter aliases for the most popular specializations of Vec<T,n>
|
||||
*/
|
||||
typedef Vec<uchar, 2> Vec2b;
|
||||
typedef Vec<uchar, 3> Vec3b;
|
||||
typedef Vec<uchar, 4> Vec4b;
|
||||
|
||||
typedef Vec<short, 2> Vec2s;
|
||||
typedef Vec<short, 3> Vec3s;
|
||||
typedef Vec<short, 4> Vec4s;
|
||||
|
||||
typedef Vec<ushort, 2> Vec2w;
|
||||
typedef Vec<ushort, 3> Vec3w;
|
||||
typedef Vec<ushort, 4> Vec4w;
|
||||
|
||||
typedef Vec<int, 2> Vec2i;
|
||||
typedef Vec<int, 3> Vec3i;
|
||||
typedef Vec<int, 4> Vec4i;
|
||||
|
||||
typedef Vec<float, 2> Vec2f;
|
||||
typedef Vec<float, 3> Vec3f;
|
||||
typedef Vec<float, 4> Vec4f;
|
||||
typedef Vec<float, 6> Vec6f;
|
||||
|
||||
typedef Vec<double, 2> Vec2d;
|
||||
typedef Vec<double, 3> Vec3d;
|
||||
typedef Vec<double, 4> Vec4d;
|
||||
typedef Vec<double, 6> Vec6d;
|
||||
|
||||
|
||||
//////////////////////////////// Complex //////////////////////////////
|
||||
|
||||
/*!
|
||||
@ -918,8 +919,6 @@ public:
|
||||
|
||||
//! per-element product
|
||||
Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1 ) const;
|
||||
//! another helper conversion method. \see cvScalarToRawData
|
||||
template<typename T2> void convertTo(T2* buf, int channels, int unroll_to=0) const;
|
||||
|
||||
// returns (v0, -v1, -v2, -v3)
|
||||
Scalar_<_Tp> conj() const;
|
||||
@ -930,6 +929,8 @@ public:
|
||||
|
||||
typedef Scalar_<double> Scalar;
|
||||
|
||||
CV_EXPORTS void scalarToRawData(const Scalar& s, void* buf, int type, int unroll_to=0);
|
||||
|
||||
//////////////////////////////// Range /////////////////////////////////
|
||||
|
||||
/*!
|
||||
@ -2784,28 +2785,25 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp, int n> class CV_EXPORTS VecCommaInitializer
|
||||
{
|
||||
public:
|
||||
VecCommaInitializer(Vec<_Tp, n>* _vec);
|
||||
template<typename T2> VecCommaInitializer<_Tp, n>& operator , (T2 val);
|
||||
Vec<_Tp, n> operator *() const;
|
||||
|
||||
Vec<_Tp, n>* vec;
|
||||
int idx;
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS MatxCommaInitializer :
|
||||
public VecCommaInitializer<_Tp, m*n>
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS MatxCommaInitializer
|
||||
{
|
||||
public:
|
||||
MatxCommaInitializer(Matx<_Tp, m, n>* _mtx);
|
||||
template<typename T2> MatxCommaInitializer<_Tp, m, n>& operator , (T2 val);
|
||||
Matx<_Tp, m, n> operator *() const;
|
||||
|
||||
Matx<_Tp, m, n>* dst;
|
||||
int idx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename _Tp, int m> class CV_EXPORTS VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1>
|
||||
{
|
||||
public:
|
||||
VecCommaInitializer(Vec<_Tp, m>* _vec);
|
||||
template<typename T2> VecCommaInitializer<_Tp, m>& operator , (T2 val);
|
||||
Vec<_Tp, m> operator *() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
Automatically Allocated Buffer Class
|
||||
|
||||
|
@ -1873,15 +1873,15 @@ static inline MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t
|
||||
|
||||
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
||||
operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatConstIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
||||
operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a)
|
||||
{ return (MatConstIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
||||
operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatConstIterator_<_Tp>&)((const MatConstIterator&)a - ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatConstIterator_<_Tp>&)t; }
|
||||
|
||||
inline uchar* MatConstIterator::operator [](ptrdiff_t i) const
|
||||
{ return *(*this + i); }
|
||||
@ -1891,15 +1891,15 @@ template<typename _Tp> inline _Tp MatConstIterator_<_Tp>::operator [](ptrdiff_t
|
||||
|
||||
template<typename _Tp> static inline MatIterator_<_Tp>
|
||||
operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatIterator_<_Tp>
|
||||
operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a)
|
||||
{ return (MatIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatIterator_<_Tp>
|
||||
operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatIterator_<_Tp>&)((const MatConstIterator&)a - ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> inline _Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const
|
||||
{ return *(*this + i); }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1296,8 +1296,8 @@ inRangeS_( const Mat& srcmat1, const Scalar& _a, const Scalar& _b, Mat& dstmat )
|
||||
size_t dstep = dstmat.step;
|
||||
Size size = getContinuousSize( srcmat1, dstmat );
|
||||
int cn = srcmat1.channels();
|
||||
_a.convertTo((WT1*)&a, cn);
|
||||
_b.convertTo((WT1*)&b, cn);
|
||||
scalarToRawData(_a, &a, CV_MAKETYPE(DataType<WT>::depth, cn));
|
||||
scalarToRawData(_b, &b, CV_MAKETYPE(DataType<WT>::depth, cn));
|
||||
|
||||
for( int y = 0; y < size.height; y++, dst += dstep )
|
||||
{
|
||||
|
@ -759,6 +759,81 @@ int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) con
|
||||
(isContinuous() || step.p[1] == step.p[2]*size.p[2])))
|
||||
? (int)(total()*channels()/_elemChannels) : -1;
|
||||
}
|
||||
|
||||
|
||||
void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to)
|
||||
{
|
||||
int i, depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
CV_Assert(cn <= 4);
|
||||
switch(depth)
|
||||
{
|
||||
case CV_8U:
|
||||
{
|
||||
uchar* buf = (uchar*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<uchar>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
}
|
||||
break;
|
||||
case CV_8S:
|
||||
{
|
||||
schar* buf = (schar*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<schar>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
}
|
||||
break;
|
||||
case CV_16U:
|
||||
{
|
||||
ushort* buf = (ushort*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<ushort>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
}
|
||||
break;
|
||||
case CV_16S:
|
||||
{
|
||||
short* buf = (short*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<short>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
}
|
||||
break;
|
||||
case CV_32S:
|
||||
{
|
||||
int* buf = (int*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<int>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
}
|
||||
break;
|
||||
case CV_32F:
|
||||
{
|
||||
float* buf = (float*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<float>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
}
|
||||
break;
|
||||
case CV_64F:
|
||||
{
|
||||
double* buf = (double*)_buf;
|
||||
for(i = 0; i < cn; i++)
|
||||
buf[i] = saturate_cast<double>(s.val[i]);
|
||||
for(; i < unroll_to; i++)
|
||||
buf[i] = buf[i-cn];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
CV_Error(CV_StsUnsupportedFormat,"");
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************************************\
|
||||
Matrix Operations
|
||||
|
@ -325,7 +325,7 @@ binarySOpCn_( const Mat& srcmat, Mat& dstmat, const Scalar& _scalar )
|
||||
int cn = dstmat.channels();
|
||||
Size size = getContinuousSize( srcmat, dstmat, cn );
|
||||
WT scalar[12];
|
||||
_scalar.convertTo(scalar, cn, 12);
|
||||
scalarToRawData(_scalar, scalar, CV_MAKETYPE(DataType<WT>::depth,cn), 12);
|
||||
|
||||
for( ; size.height--; src0 += step1, dst0 += step )
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
{
|
||||
int index_type;
|
||||
load_value(stream,index_type);
|
||||
IndexParams* params = ParamsFactory::instance().create((flann_algorithm_t)index_type);
|
||||
IndexParams* params = ParamsFactory_instance().create((flann_algorithm_t)index_type);
|
||||
bestIndex = create_index_by_type(dataset, *params);
|
||||
bestIndex->loadIndex(stream);
|
||||
load_value(stream, bestSearchParams);
|
||||
|
@ -123,7 +123,7 @@ NNIndex<T>* load_saved_index(const Matrix<T>& dataset, const string& filename)
|
||||
throw FLANNException("The index saved belongs to a different dataset");
|
||||
}
|
||||
|
||||
IndexParams* params = ParamsFactory::instance().create(header.index_type);
|
||||
IndexParams* params = ParamsFactory_instance().create(header.index_type);
|
||||
NNIndex<T>* nnIndex = create_index_by_type(dataset, *params);
|
||||
nnIndex->loadIndex(fin);
|
||||
fclose(fin);
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
|
||||
|
||||
typedef ObjectFactory<IndexParams, flann_algorithm_t> ParamsFactory;
|
||||
|
||||
CV_EXPORTS ParamsFactory& ParamsFactory_instance();
|
||||
|
||||
struct CV_EXPORTS SearchParams {
|
||||
SearchParams(int checks_ = 32) :
|
||||
|
@ -50,7 +50,7 @@ class ObjectFactory
|
||||
std::map<UniqueIdType, CreateObjectFunc> object_registry;
|
||||
|
||||
// singleton class, private constructor
|
||||
ObjectFactory() {};
|
||||
//ObjectFactory() {};
|
||||
|
||||
public:
|
||||
typedef typename std::map<UniqueIdType, CreateObjectFunc>::iterator Iterator;
|
||||
@ -81,11 +81,11 @@ public:
|
||||
return ((*iter).second)();
|
||||
}
|
||||
|
||||
static ObjectFactory<BaseClass,UniqueIdType>& instance()
|
||||
/*static ObjectFactory<BaseClass,UniqueIdType>& instance()
|
||||
{
|
||||
static ObjectFactory<BaseClass,UniqueIdType> the_factory;
|
||||
return the_factory;
|
||||
}
|
||||
}*/
|
||||
|
||||
};
|
||||
|
||||
|
@ -195,16 +195,24 @@ void set_distance_type(flann_distance_t distance_type, int order)
|
||||
flann_minkowski_order_ = order;
|
||||
}
|
||||
|
||||
|
||||
static ParamsFactory the_factory;
|
||||
|
||||
ParamsFactory& ParamsFactory_instance()
|
||||
{
|
||||
return the_factory;
|
||||
}
|
||||
|
||||
class StaticInit
|
||||
{
|
||||
public:
|
||||
StaticInit()
|
||||
{
|
||||
ParamsFactory::instance().register_<LinearIndexParams>(LINEAR);
|
||||
ParamsFactory::instance().register_<KDTreeIndexParams>(KDTREE);
|
||||
ParamsFactory::instance().register_<KMeansIndexParams>(KMEANS);
|
||||
ParamsFactory::instance().register_<CompositeIndexParams>(COMPOSITE);
|
||||
ParamsFactory::instance().register_<AutotunedIndexParams>(AUTOTUNED);
|
||||
ParamsFactory_instance().register_<LinearIndexParams>(LINEAR);
|
||||
ParamsFactory_instance().register_<KDTreeIndexParams>(KDTREE);
|
||||
ParamsFactory_instance().register_<KMeansIndexParams>(KMEANS);
|
||||
ParamsFactory_instance().register_<CompositeIndexParams>(COMPOSITE);
|
||||
ParamsFactory_instance().register_<AutotunedIndexParams>(AUTOTUNED);
|
||||
// ParamsFactory::instance().register_<SavedIndexParams>(SAVED);
|
||||
}
|
||||
};
|
||||
|
@ -188,7 +188,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag,
|
||||
const CvMat* _responses, const CvMat* _var_idx,
|
||||
const CvMat* _sample_idx, const CvMat* _var_type,
|
||||
const CvMat* _missing_mask,
|
||||
CvGBTreesParams _params, bool _update ) //update is not supported
|
||||
CvGBTreesParams _params, bool /*_update*/ ) //update is not supported
|
||||
{
|
||||
CvMemStorage* storage = 0;
|
||||
|
||||
@ -1071,7 +1071,7 @@ bool CvGBTrees::train( const cv::Mat& trainData, int tflag,
|
||||
bool update )
|
||||
{
|
||||
CvMat _trainData = trainData, _responses = responses;
|
||||
CvMat _varIdx = varIdx, _sampleIdx = sampleIdx, _varType = _varType;
|
||||
CvMat _varIdx = varIdx, _sampleIdx = sampleIdx, _varType = varType;
|
||||
CvMat _missingDataMask = missingDataMask;
|
||||
|
||||
return train(&_trainData, tflag, &_responses, varIdx.empty() ? &_varIdx : 0,
|
||||
|
Loading…
Reference in New Issue
Block a user