1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #11630 from alalek:c_api_eliminate_constructors

This commit is contained in:
Alexander Alekhin
2018-09-06 20:07:16 +00:00
71 changed files with 971 additions and 691 deletions
+1 -1
View File
@@ -3064,7 +3064,7 @@ template<typename _Tp> inline void Seq<_Tp>::copyTo(std::vector<_Tp>& vec, const
size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start;
vec.resize(len);
if( seq && len )
cvCvtSeqToArray(seq, &vec[0], range);
cvCvtSeqToArray(seq, &vec[0], cvSlice(range));
}
template<typename _Tp> inline Seq<_Tp>::operator std::vector<_Tp>() const
+384 -105
View File
@@ -44,6 +44,29 @@
#ifndef OPENCV_CORE_TYPES_H
#define OPENCV_CORE_TYPES_H
#if !defined(__OPENCV_BUILD) && !defined(CV__DISABLE_C_API_CTORS)
#define CV__ENABLE_C_API_CTORS // enable C API ctors (must be removed)
#endif
//#define CV__VALIDATE_UNUNITIALIZED_VARS 1 // C++11 & GCC only
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#define CV_STRUCT_INITIALIZER {0,}
#else
#if defined(__GNUC__) && __GNUC__ == 4 // GCC 4.x warns on "= {}" initialization, fixed in GCC 5.0
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
#define CV_STRUCT_INITIALIZER {}
#endif
#else
#define CV_STRUCT_INITIALIZER {0}
#endif
#ifdef HAVE_IPL
# ifndef __IPL_H__
# if defined _WIN32
@@ -285,6 +308,11 @@ CV_INLINE double cvRandReal( CvRNG* rng )
#define IPL_BORDER_REFLECT 2
#define IPL_BORDER_WRAP 3
#ifdef __cplusplus
typedef struct _IplImage IplImage;
CV_EXPORTS _IplImage cvIplImage(const cv::Mat& m);
#endif
/** The IplImage is taken from the Intel Image Processing Library, in which the format is native. OpenCV
only supports a subset of possible IplImage formats, as outlined in the parameter list above.
@@ -294,9 +322,6 @@ hand, the Intel Image Processing Library processes the area of intersection betw
destination images (or ROIs), allowing them to vary independently.
*/
typedef struct
#ifdef __cplusplus
CV_EXPORTS
#endif
_IplImage
{
int nSize; /**< sizeof(IplImage) */
@@ -330,13 +355,22 @@ _IplImage
(not necessarily aligned) -
needed for correct deallocation */
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
_IplImage() {}
_IplImage(const cv::Mat& m);
_IplImage(const cv::Mat& m) { *this = cvIplImage(m); }
#endif
}
IplImage;
CV_INLINE IplImage cvIplImage()
{
#if !defined(CV__ENABLE_C_API_CTORS)
IplImage self = CV_STRUCT_INITIALIZER; self.nSize = sizeof(IplImage); return self;
#else
return _IplImage();
#endif
}
typedef struct _IplTileInfo IplTileInfo;
typedef struct _IplROI
@@ -460,13 +494,10 @@ typedef struct CvMat
int cols;
#endif
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvMat() {}
CvMat(const CvMat& m) { memcpy(this, &m, sizeof(CvMat));}
CvMat(const cv::Mat& m);
CvMat(const cv::Mat& m) { *this = cvMat(m); }
#endif
}
CvMat;
@@ -529,15 +560,8 @@ CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)
}
#ifdef __cplusplus
inline CvMat::CvMat(const cv::Mat& m)
{
CV_DbgAssert(m.dims <= 2);
*this = cvMat(m.rows, m.dims == 1 ? 1 : m.cols, m.type(), m.data);
step = (int)m.step[0];
type = (type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG);
}
inline CvMat cvMat(const cv::Mat& m)
CV_INLINE CvMat cvMat(const cv::Mat& m)
{
CvMat self;
CV_DbgAssert(m.dims <= 2);
@@ -546,7 +570,24 @@ inline CvMat cvMat(const cv::Mat& m)
self.type = (self.type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG);
return self;
}
CV_INLINE CvMat cvMat()
{
#if !defined(CV__ENABLE_C_API_CTORS)
CvMat self = CV_STRUCT_INITIALIZER; return self;
#else
return CvMat();
#endif
}
CV_INLINE CvMat cvMat(const CvMat& m)
{
#if !defined(CV__ENABLE_C_API_CTORS)
CvMat self = CV_STRUCT_INITIALIZER; memcpy(&self, &m, sizeof(self)); return self;
#else
return CvMat(m);
#endif
}
#endif // __cplusplus
#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \
@@ -630,13 +671,15 @@ CV_INLINE int cvIplDepth( int type )
#define CV_MAX_DIM 32
#ifdef __cplusplus
typedef struct CvMatND CvMatND;
CV_EXPORTS CvMatND cvMatND(const cv::Mat& m);
#endif
/**
@deprecated consider using cv::Mat instead
*/
typedef struct
#ifdef __cplusplus
CV_EXPORTS
#endif
CvMatND
{
int type;
@@ -661,13 +704,23 @@ CvMatND
}
dim[CV_MAX_DIM];
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvMatND() {}
CvMatND(const cv::Mat& m);
CvMatND(const cv::Mat& m) { *this = cvMatND(m); }
#endif
}
CvMatND;
CV_INLINE CvMatND cvMatND()
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvMatND self = CV_STRUCT_INITIALIZER; return self;
#else
return CvMatND();
#endif
}
#define CV_IS_MATND_HDR(mat) \
((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL)
@@ -684,11 +737,7 @@ CvMatND;
struct CvSet;
typedef struct
#ifdef __cplusplus
CV_EXPORTS
#endif
CvSparseMat
typedef struct CvSparseMat
{
int type;
int dims;
@@ -703,13 +752,13 @@ CvSparseMat
int size[CV_MAX_DIM];
#ifdef __cplusplus
void copyToSparseMat(cv::SparseMat& m) const;
CV_EXPORTS void copyToSparseMat(cv::SparseMat& m) const;
#endif
}
CvSparseMat;
#ifdef __cplusplus
CV_EXPORTS CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m);
CV_EXPORTS CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m);
#endif
#define CV_IS_SPARSE_MAT_HDR(mat) \
@@ -796,10 +845,23 @@ typedef struct CvRect
int width;
int height;
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvRect() __attribute__(( warning("Non-initialized variable") )) {};
template<typename _Tp> CvRect(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 4);
x = y = width = height = 0;
if (list.size() == 4)
{
x = list.begin()[0]; y = list.begin()[1]; width = list.begin()[2]; height = list.begin()[3];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvRect(int _x = 0, int _y = 0, int w = 0, int h = 0): x(_x), y(_y), width(w), height(h) {}
template<typename _Tp>
CvRect(const cv::Rect_<_Tp>& r): x(cv::saturate_cast<int>(r.x)), y(cv::saturate_cast<int>(r.y)), width(cv::saturate_cast<int>(r.width)), height(cv::saturate_cast<int>(r.height)) {}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Rect_<_Tp>() const { return cv::Rect_<_Tp>((_Tp)x, (_Tp)y, (_Tp)width, (_Tp)height); }
#endif
@@ -809,16 +871,16 @@ CvRect;
/** constructs CvRect structure. */
CV_INLINE CvRect cvRect( int x, int y, int width, int height )
{
CvRect r;
r.x = x;
r.y = y;
r.width = width;
r.height = height;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvRect r = {x, y, width, height};
#else
CvRect r(x, y , width, height);
#endif
return r;
}
#ifdef __cplusplus
CV_INLINE CvRect cvRect(const cv::Rect& rc) { return cvRect(rc.x, rc.y, rc.width, rc.height); }
#endif
CV_INLINE IplROI cvRectToROI( CvRect rect, int coi )
{
@@ -853,26 +915,28 @@ typedef struct CvTermCriteria
CV_TERMCRIT_EPS */
int max_iter;
double epsilon;
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvTermCriteria(int _type = 0, int _iter = 0, double _eps = 0) : type(_type), max_iter(_iter), epsilon(_eps) {}
CvTermCriteria(const cv::TermCriteria& t) : type(t.type), max_iter(t.maxCount), epsilon(t.epsilon) {}
#endif
#ifdef __cplusplus
operator cv::TermCriteria() const { return cv::TermCriteria(type, max_iter, epsilon); }
#endif
}
CvTermCriteria;
CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon )
{
CvTermCriteria t;
t.type = type;
t.max_iter = max_iter;
t.epsilon = (float)epsilon;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvTermCriteria t = { type, max_iter, (float)epsilon};
#else
CvTermCriteria t(type, max_iter, epsilon);
#endif
return t;
}
#ifdef __cplusplus
CV_INLINE CvTermCriteria cvTermCriteria(const cv::TermCriteria& t) { return cvTermCriteria(t.type, t.maxCount, t.epsilon); }
#endif
/******************************* CvPoint and variants ***********************************/
@@ -882,10 +946,23 @@ typedef struct CvPoint
int x;
int y;
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvPoint() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvPoint(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 2);
x = y = 0;
if (list.size() == 2)
{
x = list.begin()[0]; y = list.begin()[1];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvPoint(int _x = 0, int _y = 0): x(_x), y(_y) {}
template<typename _Tp>
CvPoint(const cv::Point_<_Tp>& pt): x((int)pt.x), y((int)pt.y) {}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); }
#endif
@@ -895,24 +972,39 @@ CvPoint;
/** constructs CvPoint structure. */
CV_INLINE CvPoint cvPoint( int x, int y )
{
CvPoint p;
p.x = x;
p.y = y;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvPoint p = {x, y};
#else
CvPoint p(x, y);
#endif
return p;
}
#ifdef __cplusplus
CV_INLINE CvPoint cvPoint(const cv::Point& pt) { return cvPoint(pt.x, pt.y); }
#endif
typedef struct CvPoint2D32f
{
float x;
float y;
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvPoint2D32f() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvPoint2D32f(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 2);
x = y = 0;
if (list.size() == 2)
{
x = list.begin()[0]; y = list.begin()[1];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvPoint2D32f(float _x = 0, float _y = 0): x(_x), y(_y) {}
template<typename _Tp>
CvPoint2D32f(const cv::Point_<_Tp>& pt): x((float)pt.x), y((float)pt.y) {}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); }
#endif
@@ -922,11 +1014,11 @@ CvPoint2D32f;
/** constructs CvPoint2D32f structure. */
CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y )
{
CvPoint2D32f p;
p.x = (float)x;
p.y = (float)y;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvPoint2D32f p = { (float)x, (float)y };
#else
CvPoint2D32f p((float)x, (float)y);
#endif
return p;
}
@@ -934,7 +1026,11 @@ CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y )
template<typename _Tp>
CvPoint2D32f cvPoint2D32f(const cv::Point_<_Tp>& pt)
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvPoint2D32f p = { (float)pt.x, (float)pt.y };
#else
CvPoint2D32f p((float)pt.x, (float)pt.y);
#endif
return p;
}
#endif
@@ -948,10 +1044,11 @@ CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point )
/** converts CvPoint2D32f to CvPoint. */
CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point )
{
CvPoint ipt;
ipt.x = cvRound(point.x);
ipt.y = cvRound(point.y);
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvPoint ipt = { cvRound(point.x), cvRound(point.y) };
#else
CvPoint ipt(cvRound(point.x), cvRound(point.y));
#endif
return ipt;
}
@@ -962,10 +1059,23 @@ typedef struct CvPoint3D32f
float y;
float z;
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvPoint3D32f() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvPoint3D32f(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 3);
x = y = z = 0;
if (list.size() == 3)
{
x = list.begin()[0]; y = list.begin()[1]; z = list.begin()[2];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvPoint3D32f(float _x = 0, float _y = 0, float _z = 0): x(_x), y(_y), z(_z) {}
template<typename _Tp>
CvPoint3D32f(const cv::Point3_<_Tp>& pt): x((float)pt.x), y((float)pt.y), z((float)pt.z) {}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Point3_<_Tp>() const { return cv::Point3_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y), cv::saturate_cast<_Tp>(z)); }
#endif
@@ -975,31 +1085,51 @@ CvPoint3D32f;
/** constructs CvPoint3D32f structure. */
CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z )
{
CvPoint3D32f p;
p.x = (float)x;
p.y = (float)y;
p.z = (float)z;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvPoint3D32f p = { (float)x, (float)y, (float)z };
#else
CvPoint3D32f p((float)x, (float)y, (float)z);
#endif
return p;
}
#ifdef __cplusplus
template<typename _Tp>
CvPoint3D32f cvPoint3D32f(const cv::Point3_<_Tp>& pt)
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvPoint3D32f p = { (float)pt.x, (float)pt.y, (float)pt.z };
#else
CvPoint3D32f p((float)pt.x, (float)pt.y, (float)pt.z);
#endif
return p;
}
#endif
typedef struct CvPoint2D64f
{
double x;
double y;
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvPoint2D64f() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvPoint2D64f(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 2);
x = y = 0;
if (list.size() == 2)
{
x = list.begin()[0]; y = list.begin()[1];
}
};
#endif
}
CvPoint2D64f;
/** constructs CvPoint2D64f structure.*/
CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y )
{
CvPoint2D64f p;
p.x = x;
p.y = y;
CvPoint2D64f p = { x, y };
return p;
}
@@ -1009,18 +1139,25 @@ typedef struct CvPoint3D64f
double x;
double y;
double z;
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvPoint3D64f() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvPoint3D64f(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 3);
x = y = z = 0;
if (list.size() == 3)
{
x = list.begin()[0]; y = list.begin()[1]; z = list.begin()[2];
}
};
#endif
}
CvPoint3D64f;
/** constructs CvPoint3D64f structure. */
CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z )
{
CvPoint3D64f p;
p.x = x;
p.y = y;
p.z = z;
CvPoint3D64f p = { x, y, z };
return p;
}
@@ -1032,10 +1169,23 @@ typedef struct CvSize
int width;
int height;
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvSize() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvSize(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 2);
width = 0; height = 0;
if (list.size() == 2)
{
width = list.begin()[0]; height = list.begin()[1];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvSize(int w = 0, int h = 0): width(w), height(h) {}
template<typename _Tp>
CvSize(const cv::Size_<_Tp>& sz): width(cv::saturate_cast<int>(sz.width)), height(cv::saturate_cast<int>(sz.height)) {}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Size_<_Tp>() const { return cv::Size_<_Tp>(cv::saturate_cast<_Tp>(width), cv::saturate_cast<_Tp>(height)); }
#endif
@@ -1045,23 +1195,48 @@ CvSize;
/** constructs CvSize structure. */
CV_INLINE CvSize cvSize( int width, int height )
{
CvSize s;
s.width = width;
s.height = height;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvSize s = { width, height };
#else
CvSize s(width, height);
#endif
return s;
}
#ifdef __cplusplus
CV_INLINE CvSize cvSize(const cv::Size& sz)
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvSize s = { sz.width, sz.height };
#else
CvSize s(sz.width, sz.height);
#endif
return s;
}
#endif
typedef struct CvSize2D32f
{
float width;
float height;
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvSize2D32f() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvSize2D32f(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 2);
width = 0; height = 0;
if (list.size() == 2)
{
width = list.begin()[0]; height = list.begin()[1];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvSize2D32f(float w = 0, float h = 0): width(w), height(h) {}
template<typename _Tp>
CvSize2D32f(const cv::Size_<_Tp>& sz): width(cv::saturate_cast<float>(sz.width)), height(cv::saturate_cast<float>(sz.height)) {}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Size_<_Tp>() const { return cv::Size_<_Tp>(cv::saturate_cast<_Tp>(width), cv::saturate_cast<_Tp>(height)); }
#endif
@@ -1071,13 +1246,25 @@ CvSize2D32f;
/** constructs CvSize2D32f structure. */
CV_INLINE CvSize2D32f cvSize2D32f( double width, double height )
{
CvSize2D32f s;
s.width = (float)width;
s.height = (float)height;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvSize2D32f s = { (float)width, (float)height };
#else
CvSize2D32f s((float)width, (float)height);
#endif
return s;
}
#ifdef __cplusplus
template<typename _Tp>
CvSize2D32f cvSize2D32f(const cv::Size_<_Tp>& sz)
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvSize2D32f s = { (float)sz.width, (float)sz.height };
#else
CvSize2D32f s((float)sz.width, (float)sz.height);
#endif
return s;
}
#endif
/** @sa RotatedRect
*/
@@ -1088,15 +1275,37 @@ typedef struct CvBox2D
float angle; /**< Angle between the horizontal axis */
/**< and the first side (i.e. length) in degrees */
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) : center(c), size(s), angle(a) {}
CvBox2D(const cv::RotatedRect& rr) : center(rr.center), size(rr.size), angle(rr.angle) {}
#endif
#ifdef __cplusplus
operator cv::RotatedRect() const { return cv::RotatedRect(center, size, angle); }
#endif
}
CvBox2D;
#ifdef __cplusplus
CV_INLINE CvBox2D cvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0)
{
CvBox2D self;
self.center = c;
self.size = s;
self.angle = a;
return self;
}
CV_INLINE CvBox2D cvBox2D(const cv::RotatedRect& rr)
{
CvBox2D self;
self.center = cvPoint2D32f(rr.center);
self.size = cvSize2D32f(rr.size);
self.angle = rr.angle;
return self;
}
#endif
/** Line iterator state: */
typedef struct CvLineIterator
{
@@ -1122,7 +1331,19 @@ typedef struct CvSlice
{
int start_index, end_index;
#if defined(__cplusplus) && !defined(__CUDACC__)
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvSlice() __attribute__(( warning("Non-initialized variable") )) {}
template<typename _Tp> CvSlice(const std::initializer_list<_Tp> list)
{
CV_Assert(list.size() == 0 || list.size() == 2);
start_index = end_index = 0;
if (list.size() == 2)
{
start_index = list.begin()[0]; end_index = list.begin()[1];
}
};
#endif
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) && !defined(__CUDACC__)
CvSlice(int start = 0, int end = 0) : start_index(start), end_index(end) {}
CvSlice(const cv::Range& r) { *this = (r.start != INT_MIN && r.end != INT_MAX) ? CvSlice(r.start, r.end) : CvSlice(0, CV_WHOLE_SEQ_END_INDEX); }
operator cv::Range() const { return (start_index == 0 && end_index == CV_WHOLE_SEQ_END_INDEX ) ? cv::Range::all() : cv::Range(start_index, end_index); }
@@ -1132,13 +1353,21 @@ CvSlice;
CV_INLINE CvSlice cvSlice( int start, int end )
{
CvSlice slice;
slice.start_index = start;
slice.end_index = end;
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvSlice slice = { start, end };
#else
CvSlice slice(start, end);
#endif
return slice;
}
#if defined(__cplusplus)
CV_INLINE CvSlice cvSlice(const cv::Range& r)
{
CvSlice slice = (r.start != INT_MIN && r.end != INT_MAX) ? cvSlice(r.start, r.end) : cvSlice(0, CV_WHOLE_SEQ_END_INDEX);
return slice;
}
#endif
/************************************* CvScalar *****************************************/
@@ -1148,13 +1377,22 @@ typedef struct CvScalar
{
double val[4];
#ifdef __cplusplus
#ifdef CV__VALIDATE_UNUNITIALIZED_VARS
CvScalar() __attribute__(( warning("Non-initialized variable") )) {}
CvScalar(const std::initializer_list<double> list)
{
CV_Assert(list.size() == 0 || list.size() == 4);
val[0] = val[1] = val[2] = val[3] = 0;
if (list.size() == 4)
{
val[0] = list.begin()[0]; val[1] = list.begin()[1]; val[2] = list.begin()[2]; val[3] = list.begin()[3];
}
};
#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvScalar() {}
CvScalar(double d0, double d1 = 0, double d2 = 0, double d3 = 0) { val[0] = d0; val[1] = d1; val[2] = d2; val[3] = d3; }
template<typename _Tp>
CvScalar(const cv::Scalar_<_Tp>& s) { val[0] = s.val[0]; val[1] = s.val[1]; val[2] = s.val[2]; val[3] = s.val[3]; }
template<typename _Tp>
operator cv::Scalar_<_Tp>() const { return cv::Scalar_<_Tp>(cv::saturate_cast<_Tp>(val[0]), cv::saturate_cast<_Tp>(val[1]), cv::saturate_cast<_Tp>(val[2]), cv::saturate_cast<_Tp>(val[3])); }
template<typename _Tp, int cn>
CvScalar(const cv::Vec<_Tp, cn>& v)
{
@@ -1163,22 +1401,59 @@ typedef struct CvScalar
for( ; i < 4; i++ ) val[i] = 0;
}
#endif
#ifdef __cplusplus
template<typename _Tp>
operator cv::Scalar_<_Tp>() const { return cv::Scalar_<_Tp>(cv::saturate_cast<_Tp>(val[0]), cv::saturate_cast<_Tp>(val[1]), cv::saturate_cast<_Tp>(val[2]), cv::saturate_cast<_Tp>(val[3])); }
#endif
}
CvScalar;
CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0),
double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0))
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvScalar scalar = CV_STRUCT_INITIALIZER;
#else
CvScalar scalar;
#endif
scalar.val[0] = val0; scalar.val[1] = val1;
scalar.val[2] = val2; scalar.val[3] = val3;
return scalar;
}
#ifdef __cplusplus
CV_INLINE CvScalar cvScalar()
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvScalar scalar = CV_STRUCT_INITIALIZER;
#else
CvScalar scalar;
#endif
scalar.val[0] = scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
return scalar;
}
CV_INLINE CvScalar cvScalar(const cv::Scalar& s)
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvScalar scalar = CV_STRUCT_INITIALIZER;
#else
CvScalar scalar;
#endif
scalar.val[0] = s.val[0];
scalar.val[1] = s.val[1];
scalar.val[2] = s.val[2];
scalar.val[3] = s.val[3];
return scalar;
}
#endif
CV_INLINE CvScalar cvRealScalar( double val0 )
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvScalar scalar = CV_STRUCT_INITIALIZER;
#else
CvScalar scalar;
#endif
scalar.val[0] = val0;
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
return scalar;
@@ -1186,7 +1461,11 @@ CV_INLINE CvScalar cvRealScalar( double val0 )
CV_INLINE CvScalar cvScalarAll( double val0123 )
{
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
CvScalar scalar = CV_STRUCT_INITIALIZER;
#else
CvScalar scalar;
#endif
scalar.val[0] = val0123;
scalar.val[1] = val0123;
scalar.val[2] = val0123;
@@ -1239,7 +1518,7 @@ typedef struct CvSeqBlock
{
struct CvSeqBlock* prev; /**< Previous sequence block. */
struct CvSeqBlock* next; /**< Next sequence block. */
int start_index; /**< Index of the first element in the block + */
int start_index; /**< Index of the first element in the block + */
/**< sequence->first->start_index. */
int count; /**< Number of elements in the block. */
schar* data; /**< Pointer to the first element of the block. */
+8 -16
View File
@@ -1017,7 +1017,7 @@ cvGetRawData( const CvArr* arr, uchar** data, int* step, CvSize* roi_size )
*data = mat->data.ptr;
if( roi_size )
*roi_size = cvGetMatSize( mat );
*roi_size = cvSize(cvGetMatSize( mat ));
}
else if( CV_IS_IMAGE( arr ))
{
@@ -1218,7 +1218,7 @@ cvGetDimSize( const CvArr* arr, int index )
CV_IMPL CvSize
cvGetSize( const CvArr* arr )
{
CvSize size;
CvSize size = {0, 0};
if( CV_IS_MAT_HDR_Z( arr ))
{
@@ -1918,7 +1918,7 @@ cvPtrND( const CvArr* arr, const int* idx, int* _type,
CV_IMPL CvScalar
cvGet1D( const CvArr* arr, int idx )
{
CvScalar scalar(0);
CvScalar scalar = cvScalar();
int type = 0;
uchar* ptr;
@@ -1953,7 +1953,7 @@ cvGet1D( const CvArr* arr, int idx )
CV_IMPL CvScalar
cvGet2D( const CvArr* arr, int y, int x )
{
CvScalar scalar(0);
CvScalar scalar = cvScalar();
int type = 0;
uchar* ptr;
@@ -1987,7 +1987,7 @@ cvGet2D( const CvArr* arr, int y, int x )
CV_IMPL CvScalar
cvGet3D( const CvArr* arr, int z, int y, int x )
{
CvScalar scalar(0);
CvScalar scalar = cvScalar();
int type = 0;
uchar* ptr;
@@ -2009,7 +2009,7 @@ cvGet3D( const CvArr* arr, int z, int y, int x )
CV_IMPL CvScalar
cvGetND( const CvArr* arr, const int* idx )
{
CvScalar scalar(0);
CvScalar scalar = cvScalar();
int type = 0;
uchar* ptr;
@@ -2916,15 +2916,7 @@ cvInitImageHeader( IplImage * image, CvSize size, int depth,
if( !image )
CV_Error( CV_HeaderIsNull, "null pointer to header" );
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset( image, 0, sizeof( *image ));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
image->nSize = sizeof( *image );
*image = cvIplImage();
icvGetColorModel( channels, &colorModel, &channelSeq );
for (int i = 0; i < 4; i++)
@@ -3081,7 +3073,7 @@ cvResetImageROI( IplImage* image )
CV_IMPL CvRect
cvGetImageROI( const IplImage* img )
{
CvRect rect;
CvRect rect = {0, 0, 0, 0};
if( !img )
CV_Error( CV_StsNullPtr, "Null pointer to image" );
+12 -8
View File
@@ -4,20 +4,24 @@
// glue
CvMatND::CvMatND(const cv::Mat& m)
CvMatND cvMatND(const cv::Mat& m)
{
cvInitMatNDHeader(this, m.dims, m.size, m.type(), m.data );
CvMatND self;
cvInitMatNDHeader(&self, m.dims, m.size, m.type(), m.data );
int i, d = m.dims;
for( i = 0; i < d; i++ )
dim[i].step = (int)m.step[i];
type |= m.flags & cv::Mat::CONTINUOUS_FLAG;
self.dim[i].step = (int)m.step[i];
self.type |= m.flags & cv::Mat::CONTINUOUS_FLAG;
return self;
}
_IplImage::_IplImage(const cv::Mat& m)
_IplImage cvIplImage(const cv::Mat& m)
{
_IplImage self;
CV_Assert( m.dims <= 2 );
cvInitImageHeader(this, m.size(), cvIplDepth(m.flags), m.channels());
cvSetData(this, m.data, (int)m.step[0]);
cvInitImageHeader(&self, cvSize(m.size()), cvIplDepth(m.flags), m.channels());
cvSetData(&self, m.data, (int)m.step[0]);
return self;
}
namespace cv {
@@ -222,7 +226,7 @@ CV_IMPL void cvSetIdentity( CvArr* arr, CvScalar value )
CV_IMPL CvScalar cvTrace( const CvArr* arr )
{
return cv::trace(cv::cvarrToMat(arr));
return cvScalar(cv::trace(cv::cvarrToMat(arr)));
}
+2 -2
View File
@@ -452,12 +452,12 @@ void write( FileStorage& fs, const String& name, const Mat& value )
{
if( value.dims <= 2 )
{
CvMat mat = value;
CvMat mat = cvMat(value);
cvWrite( *fs, name.size() ? name.c_str() : 0, &mat );
}
else
{
CvMatND mat = value;
CvMatND mat = cvMatND(value);
cvWrite( *fs, name.size() ? name.c_str() : 0, &mat );
}
}
+4 -4
View File
@@ -31,7 +31,7 @@ static void icvWriteMat( CvFileStorage* fs, const char* name, const void* struct
{
const CvMat* mat = (const CvMat*)struct_ptr;
char dt[16];
CvSize size;
cv::Size size;
int y;
assert( CV_IS_MAT_HDR_Z(mat) );
@@ -380,7 +380,7 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru
{
const IplImage* image = (const IplImage*)struct_ptr;
char dt_buf[16], *dt;
CvSize size;
cv::Size size;
int y, depth;
assert( CV_IS_IMAGE(image) );
@@ -435,7 +435,7 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node )
CvFileNode* data;
CvFileNode* roi_node;
CvSeqReader reader;
CvRect roi;
cv::Rect roi;
int y, width, height, elem_type, coi, depth;
const char* origin, *data_order;
@@ -472,7 +472,7 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node )
roi.height = cvReadIntByName( fs, roi_node, "height", 0 );
coi = cvReadIntByName( fs, roi_node, "coi", 0 );
cvSetImageROI( image, roi );
cvSetImageROI( image, cvRect(roi) );
cvSetImageCOI( image, coi );
}
+2 -2
View File
@@ -17,7 +17,7 @@ CV_IMPL CvScalar cvSum( const CvArr* srcarr )
sum = cv::Scalar(sum[coi-1]);
}
}
return sum;
return cvScalar(sum);
}
CV_IMPL int cvCountNonZero( const CvArr* imgarr )
@@ -43,7 +43,7 @@ cvAvg( const void* imgarr, const void* maskarr )
mean = cv::Scalar(mean[coi-1]);
}
}
return mean;
return cvScalar(mean);
}
+3 -3
View File
@@ -214,7 +214,7 @@ protected:
}
CvMat* m = (CvMat*)fs["test_mat"].readObj();
CvMat _test_mat = test_mat;
CvMat _test_mat = cvMat(test_mat);
double max_diff = 0;
CvMat stub1, _test_stub1;
cvReshape(m, &stub1, 1, 0);
@@ -234,7 +234,7 @@ protected:
cvReleaseMat(&m);
CvMatND* m_nd = (CvMatND*)fs["test_mat_nd"].readObj();
CvMatND _test_mat_nd = test_mat_nd;
CvMatND _test_mat_nd = cvMatND(test_mat_nd);
if( !m_nd || !CV_IS_MATND(m_nd) )
{
@@ -263,7 +263,7 @@ protected:
MatND mat_nd2;
fs["test_mat_nd"] >> mat_nd2;
CvMatND m_nd2 = mat_nd2;
CvMatND m_nd2 = cvMatND(mat_nd2);
cvGetMat(&m_nd2, &stub, 0, 1);
cvReshape(&stub, &stub1, 1, 0);
+17 -17
View File
@@ -415,15 +415,15 @@ TEST(Core_PCA, accuracy)
#ifdef CHECK_C
// 4. check C PCA & ROW
_points = rPoints;
_testPoints = rTestPoints;
_avg = avg;
_eval = eval;
_evec = evec;
_points = cvMat(rPoints);
_testPoints = cvMat(rTestPoints);
_avg = cvMat(avg);
_eval = cvMat(eval);
_evec = cvMat(evec);
prjTestPoints.create(rTestPoints.rows, maxComponents, rTestPoints.type() );
backPrjTestPoints.create(rPoints.size(), rPoints.type() );
_prjTestPoints = prjTestPoints;
_backPrjTestPoints = backPrjTestPoints;
_prjTestPoints = cvMat(prjTestPoints);
_backPrjTestPoints = cvMat(backPrjTestPoints);
cvCalcPCA( &_points, &_avg, &_eval, &_evec, CV_PCA_DATA_AS_ROW );
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
@@ -435,13 +435,13 @@ TEST(Core_PCA, accuracy)
ASSERT_LE(err, diffBackPrjEps) << "bad accuracy of cvBackProjectPCA() (CV_PCA_DATA_AS_ROW)";
// 5. check C PCA & COL
_points = cPoints;
_testPoints = cTestPoints;
avg = avg.t(); _avg = avg;
eval = eval.t(); _eval = eval;
evec = evec.t(); _evec = evec;
prjTestPoints = prjTestPoints.t(); _prjTestPoints = prjTestPoints;
backPrjTestPoints = backPrjTestPoints.t(); _backPrjTestPoints = backPrjTestPoints;
_points = cvMat(cPoints);
_testPoints = cvMat(cTestPoints);
avg = avg.t(); _avg = cvMat(avg);
eval = eval.t(); _eval = cvMat(eval);
evec = evec.t(); _evec = cvMat(evec);
prjTestPoints = prjTestPoints.t(); _prjTestPoints = cvMat(prjTestPoints);
backPrjTestPoints = backPrjTestPoints.t(); _backPrjTestPoints = cvMat(backPrjTestPoints);
cvCalcPCA( &_points, &_avg, &_eval, &_evec, CV_PCA_DATA_AS_COL );
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
@@ -615,7 +615,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
{
int sz3[] = {5, 10, 15};
MatND A(3, sz3, CV_32F), B(3, sz3, CV_16SC4);
CvMatND matA = A, matB = B;
CvMatND matA = cvMatND(A), matB = cvMatND(B);
RNG rng;
rng.fill(A, CV_RAND_UNI, Scalar::all(-10), Scalar::all(10));
rng.fill(B, CV_RAND_UNI, Scalar::all(-10), Scalar::all(10));
@@ -625,8 +625,8 @@ void Core_ArrayOpTest::run( int /* start_from */)
Scalar val1(-1000, 30, 3, 8);
cvSetRealND(&matA, idx0, val0);
cvSetReal3D(&matA, idx1[0], idx1[1], idx1[2], -val0);
cvSetND(&matB, idx0, val1);
cvSet3D(&matB, idx1[0], idx1[1], idx1[2], -val1);
cvSetND(&matB, idx0, cvScalar(val1));
cvSet3D(&matB, idx1[0], idx1[1], idx1[2], cvScalar(-val1));
Ptr<CvMatND> matC(cvCloneMatND(&matB));
if( A.at<float>(idx0[0], idx0[1], idx0[2]) != val0 ||
+19 -19
View File
@@ -526,7 +526,7 @@ void Core_CrossProductTest::get_test_array_types_and_sizes( int,
RNG& rng = ts->get_rng();
int depth = cvtest::randInt(rng) % 2 + CV_32F;
int cn = cvtest::randInt(rng) & 1 ? 3 : 1, type = CV_MAKETYPE(depth, cn);
CvSize sz;
Size sz;
types[INPUT][0] = types[INPUT][1] = types[OUTPUT][0] = types[REF_OUTPUT][0] = type;
@@ -549,7 +549,7 @@ void Core_CrossProductTest::run_func()
void Core_CrossProductTest::prepare_to_validation( int )
{
CvScalar a(0), b(0), c(0);
cv::Scalar a, b, c;
if( test_mat[INPUT][0].rows > 1 )
{
@@ -595,7 +595,7 @@ void Core_CrossProductTest::prepare_to_validation( int )
}
else
{
cvSet1D( test_array[REF_OUTPUT][0], 0, c );
cvSet1D( test_array[REF_OUTPUT][0], 0, cvScalar(c) );
}
}
@@ -896,7 +896,7 @@ double Core_TransformTest::get_success_error_level( int test_case_idx, int i, in
void Core_TransformTest::run_func()
{
CvMat _m = test_mat[INPUT][1], _shift = test_mat[INPUT][2];
CvMat _m = cvMat(test_mat[INPUT][1]), _shift = cvMat(test_mat[INPUT][2]);
cvTransform( test_array[INPUT][0], test_array[OUTPUT][0], &_m, _shift.data.ptr ? &_shift : 0);
}
@@ -1010,7 +1010,7 @@ double Core_PerspectiveTransformTest::get_success_error_level( int test_case_idx
void Core_PerspectiveTransformTest::run_func()
{
CvMat _m = test_mat[INPUT][1];
CvMat _m = cvMat(test_mat[INPUT][1]);
cvPerspectiveTransform( test_array[INPUT][0], test_array[OUTPUT][0], &_m );
}
@@ -1117,7 +1117,7 @@ static void cvTsPerspectiveTransform( const CvArr* _src, CvArr* _dst, const CvMa
void Core_PerspectiveTransformTest::prepare_to_validation( int )
{
CvMat transmat = test_mat[INPUT][1];
CvMat transmat = cvMat(test_mat[INPUT][1]);
cvTsPerspectiveTransform( test_array[INPUT][0], test_array[REF_OUTPUT][0], &transmat );
}
@@ -1287,9 +1287,9 @@ int Core_CovarMatrixTest::prepare_test_case( int test_case_idx )
if( single_matrix )
{
if( !are_images )
*((CvMat*)_hdr_data) = test_mat[INPUT][0];
*((CvMat*)_hdr_data) = cvMat(test_mat[INPUT][0]);
else
*((IplImage*)_hdr_data) = test_mat[INPUT][0];
*((IplImage*)_hdr_data) = cvIplImage(test_mat[INPUT][0]);
temp_hdrs[0] = _hdr_data;
}
else
@@ -1304,9 +1304,9 @@ int Core_CovarMatrixTest::prepare_test_case( int test_case_idx )
part = test_mat[INPUT][0].col(i);
if( !are_images )
*((CvMat*)ptr) = part;
*((CvMat*)ptr) = cvMat(part);
else
*((IplImage*)ptr) = part;
*((IplImage*)ptr) = cvIplImage(part);
temp_hdrs[i] = ptr;
}
@@ -1539,7 +1539,7 @@ static double cvTsLU( CvMat* a, CvMat* b=NULL, CvMat* x=NULL, int* rank=0 )
void Core_DetTest::prepare_to_validation( int )
{
test_mat[INPUT][0].convertTo(test_mat[TEMP][0], test_mat[TEMP][0].type());
CvMat temp0 = test_mat[TEMP][0];
CvMat temp0 = cvMat(test_mat[TEMP][0]);
test_mat[REF_OUTPUT][0].at<Scalar>(0,0) = cvRealScalar(cvTsLU(&temp0, 0, 0));
}
@@ -1676,7 +1676,7 @@ void Core_InvertTest::prepare_to_validation( int )
Mat& temp1 = test_mat[TEMP][1];
Mat& dst0 = test_mat[REF_OUTPUT][0];
Mat& dst = test_mat[OUTPUT][0];
CvMat _input = input;
CvMat _input = cvMat(input);
double ratio = 0, det = cvTsSVDet( &_input, &ratio );
double threshold = (input.depth() == CV_32F ? FLT_EPSILON : DBL_EPSILON)*1000;
@@ -1733,7 +1733,7 @@ void Core_SolveTest::get_test_array_types_and_sizes( int test_case_idx, vector<v
RNG& rng = ts->get_rng();
int bits = cvtest::randInt(rng);
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
CvSize in_sz = sizes[INPUT][0];
CvSize in_sz = cvSize(sizes[INPUT][0]);
if( in_sz.width > in_sz.height )
in_sz = cvSize(in_sz.height, in_sz.width);
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
@@ -1813,14 +1813,14 @@ void Core_SolveTest::prepare_to_validation( int )
Mat& temp1 = test_mat[TEMP][1];
cvtest::convert(input, temp1, temp1.type());
dst = Scalar::all(0);
CvMat _temp1 = temp1;
CvMat _temp1 = cvMat(temp1);
double det = cvTsLU( &_temp1, 0, 0 );
dst0 = Scalar::all(det != 0);
return;
}
double threshold = (input.type() == CV_32F ? FLT_EPSILON : DBL_EPSILON)*1000;
CvMat _input = input;
CvMat _input = cvMat(input);
double ratio = 0, det = cvTsSVDet( &_input, &ratio );
if( det < threshold || ratio < threshold )
{
@@ -2105,7 +2105,7 @@ void Core_SVBkSbTest::get_test_array_types_and_sizes( int test_case_idx, vector<
int bits = cvtest::randInt(rng);
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
int min_size, i, m, n;
CvSize b_size;
cv::Size b_size;
min_size = MIN( sizes[INPUT][0].width, sizes[INPUT][0].height );
@@ -2122,7 +2122,7 @@ void Core_SVBkSbTest::get_test_array_types_and_sizes( int test_case_idx, vector<
n = sizes[INPUT][0].width;
sizes[INPUT][1] = Size(0,0);
b_size = Size(m,m);
b_size = cvSize(m, m);
if( have_b )
{
sizes[INPUT][1].height = sizes[INPUT][0].height;
@@ -2174,7 +2174,7 @@ int Core_SVBkSbTest::prepare_test_case( int test_case_idx )
cvtest::copy( temp, input );
}
CvMat _input = input;
CvMat _input = cvMat(input);
cvSVD( &_input, test_array[TEMP][0], test_array[TEMP][1], test_array[TEMP][2], flags );
}
@@ -2210,7 +2210,7 @@ void Core_SVBkSbTest::prepare_to_validation( int )
Size w_size = compact ? Size(min_size,min_size) : Size(m,n);
Mat& w = test_mat[TEMP][0];
Mat wdb( w_size.height, w_size.width, CV_64FC1 );
CvMat _w = w, _wdb = wdb;
CvMat _w = cvMat(w), _wdb = cvMat(wdb);
// use exactly the same threshold as in icvSVD... ,
// so the changes in the library and here should be synchronized.
double threshold = cv::sum(w)[0]*(DBL_EPSILON*2);//(is_float ? FLT_EPSILON*10 : DBL_EPSILON*2);
+1 -1
View File
@@ -970,7 +970,7 @@ bool CV_OperationsTest::operations1()
Size sz(10, 20);
if (sz.area() != 200) throw test_excep();
if (sz.width != 10 || sz.height != 20) throw test_excep();
if (((CvSize)sz).width != 10 || ((CvSize)sz).height != 20) throw test_excep();
if (cvSize(sz).width != 10 || cvSize(sz).height != 20) throw test_excep();
Vec<double, 5> v5d(1, 1, 1, 1, 1);
Vec<double, 6> v6d(1, 1, 1, 1, 1, 1);