|
|
|
@ -44,6 +44,27 @@ |
|
|
|
|
#ifndef OPENCV_CORE_TYPES_H |
|
|
|
|
#define OPENCV_CORE_TYPES_H |
|
|
|
|
|
|
|
|
|
#define CV__ENABLE_C_API_CTORS // enable C API ctors (must be removed)
|
|
|
|
|
|
|
|
|
|
//#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 +306,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 +320,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 +353,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 +492,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 +558,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 +568,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 +669,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 +702,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 +735,7 @@ CvMatND; |
|
|
|
|
|
|
|
|
|
struct CvSet; |
|
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
CV_EXPORTS |
|
|
|
|
#endif |
|
|
|
|
CvSparseMat |
|
|
|
|
typedef struct CvSparseMat |
|
|
|
|
{ |
|
|
|
|
int type; |
|
|
|
|
int dims; |
|
|
|
@ -703,13 +750,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 +843,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 +869,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 +913,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 +944,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 +970,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 +1012,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 +1024,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 +1042,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 +1057,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 +1083,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 +1137,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 +1167,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 +1193,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 +1244,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 +1273,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 +1329,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 +1351,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 +1375,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 +1399,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 +1459,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 +1516,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. */ |
|
|
|
|