Commit ad146e5a authored by Alexander Alekhin's avatar Alexander Alekhin

core: remove constructors from C API structures

POD structures can't have constructors.
parent 66d15e89
This diff is collapsed.
...@@ -4,20 +4,24 @@ ...@@ -4,20 +4,24 @@
// glue // 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; int i, d = m.dims;
for( i = 0; i < d; i++ ) for( i = 0; i < d; i++ )
dim[i].step = (int)m.step[i]; self.dim[i].step = (int)m.step[i];
type |= m.flags & cv::Mat::CONTINUOUS_FLAG; 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 ); CV_Assert( m.dims <= 2 );
cvInitImageHeader(this, m.size(), cvIplDepth(m.flags), m.channels()); cvInitImageHeader(&self, cvSize(m.size()), cvIplDepth(m.flags), m.channels());
cvSetData(this, m.data, (int)m.step[0]); cvSetData(&self, m.data, (int)m.step[0]);
return self;
} }
namespace cv { namespace cv {
......
...@@ -410,7 +410,7 @@ typedef struct CvMoments ...@@ -410,7 +410,7 @@ typedef struct CvMoments
double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /**< central moments */ double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /**< central moments */
double inv_sqrt_m00; /**< m00 != 0 ? 1/sqrt(m00) : 0 */ double inv_sqrt_m00; /**< m00 != 0 ? 1/sqrt(m00) : 0 */
#ifdef __cplusplus #if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvMoments(){} CvMoments(){}
CvMoments(const cv::Moments& m) CvMoments(const cv::Moments& m)
{ {
...@@ -430,6 +430,36 @@ typedef struct CvMoments ...@@ -430,6 +430,36 @@ typedef struct CvMoments
} }
CvMoments; CvMoments;
#ifdef __cplusplus
} // extern "C"
CV_INLINE CvMoments cvMoments()
{
#if !defined(CV__ENABLE_C_API_CTORS)
CvMoments self = CV_STRUCT_INITIALIZER; return self;
#else
return CvMoments();
#endif
}
CV_INLINE CvMoments cvMoments(const cv::Moments& m)
{
#if !defined(CV__ENABLE_C_API_CTORS)
double am00 = std::abs(m.m00);
CvMoments self = {
m.m00, m.m10, m.m01, m.m20, m.m11, m.m02, m.m30, m.m21, m.m12, m.m03,
m.mu20, m.mu11, m.mu02, m.mu30, m.mu21, m.mu12, m.mu03,
am00 > DBL_EPSILON ? 1./std::sqrt(am00) : 0
};
return self;
#else
return CvMoments(m);
#endif
}
extern "C" {
#endif // __cplusplus
/** Hu invariants */ /** Hu invariants */
typedef struct CvHuMoments typedef struct CvHuMoments
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment