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 @@
// 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 {
......
......@@ -410,7 +410,7 @@ typedef struct CvMoments
double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /**< central moments */
double inv_sqrt_m00; /**< m00 != 0 ? 1/sqrt(m00) : 0 */
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvMoments(){}
CvMoments(const cv::Moments& m)
{
......@@ -430,6 +430,36 @@ typedef struct 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 */
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