diff --git a/apps/haartraining/_cvcommon.h b/apps/haartraining/_cvcommon.h index 2155117feb..1c4bad52d0 100644 --- a/apps/haartraining/_cvcommon.h +++ b/apps/haartraining/_cvcommon.h @@ -43,7 +43,6 @@ #define __CVCOMMON_H_ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "cxcore.h" #include "cv.h" diff --git a/apps/haartraining/performance.cpp b/apps/haartraining/performance.cpp index 0620f21a1b..a95e4d4c46 100644 --- a/apps/haartraining/performance.cpp +++ b/apps/haartraining/performance.cpp @@ -45,7 +45,6 @@ * Measure performance of classifier */ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "cv.h" #include "highgui.h" diff --git a/apps/traincascade/HOGfeatures.cpp b/apps/traincascade/HOGfeatures.cpp index eaf4bd7960..b4ae56d373 100644 --- a/apps/traincascade/HOGfeatures.cpp +++ b/apps/traincascade/HOGfeatures.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "HOGfeatures.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/boost.cpp b/apps/traincascade/boost.cpp index 0486bda4f5..a3cf90b7c4 100644 --- a/apps/traincascade/boost.cpp +++ b/apps/traincascade/boost.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "boost.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/cascadeclassifier.cpp b/apps/traincascade/cascadeclassifier.cpp index f6752da0c9..3983a614fd 100644 --- a/apps/traincascade/cascadeclassifier.cpp +++ b/apps/traincascade/cascadeclassifier.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "cascadeclassifier.h" #include diff --git a/apps/traincascade/features.cpp b/apps/traincascade/features.cpp index 4aebc80940..7f0c0a7079 100644 --- a/apps/traincascade/features.cpp +++ b/apps/traincascade/features.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "traincascade_features.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/haarfeatures.cpp b/apps/traincascade/haarfeatures.cpp index 59f1fd4ca7..40af47d42c 100644 --- a/apps/traincascade/haarfeatures.cpp +++ b/apps/traincascade/haarfeatures.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "haarfeatures.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/imagestorage.cpp b/apps/traincascade/imagestorage.cpp index e7922a9afc..53fddcc0da 100644 --- a/apps/traincascade/imagestorage.cpp +++ b/apps/traincascade/imagestorage.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "cv.h" #include "imagestorage.h" diff --git a/apps/traincascade/lbpfeatures.cpp b/apps/traincascade/lbpfeatures.cpp index 5e23d9e461..eb15b5ae87 100644 --- a/apps/traincascade/lbpfeatures.cpp +++ b/apps/traincascade/lbpfeatures.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "lbpfeatures.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/traincascade.cpp b/apps/traincascade/traincascade.cpp index c85046e6b7..7b8fcddd84 100644 --- a/apps/traincascade/traincascade.cpp +++ b/apps/traincascade/traincascade.cpp @@ -1,5 +1,4 @@ #include "opencv2/core.hpp" -#include "opencv2/core/internal.hpp" #include "cv.h" #include "cascadeclassifier.h" diff --git a/include/opencv/cv.h b/include/opencv/cv.h index 4b98ff3fbd..d239643b84 100644 --- a/include/opencv/cv.h +++ b/include/opencv/cv.h @@ -61,8 +61,6 @@ //CV_WARNING("This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module") #include "opencv2/core/core_c.h" -#include "opencv2/core.hpp" -#include "opencv2/core/utility.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" @@ -76,9 +74,5 @@ #define CV_IMPL extern "C" #endif //CV_IMPL -#if defined(__cplusplus) -#include "opencv2/core/internal.hpp" -#endif //__cplusplus - #endif // __OPENCV_OLD_CV_H_ diff --git a/include/opencv/cv.hpp b/include/opencv/cv.hpp index 37b523b31c..6654dea562 100644 --- a/include/opencv/cv.hpp +++ b/include/opencv/cv.hpp @@ -47,6 +47,7 @@ //#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module" //#endif -#include +#include "cv.h" +#include "opencv2/core.hpp" #endif diff --git a/include/opencv/cvaux.h b/include/opencv/cvaux.h index 52d4f0b648..62c91dab4b 100644 --- a/include/opencv/cvaux.h +++ b/include/opencv/cvaux.h @@ -47,7 +47,6 @@ //#endif #include "opencv2/core/core_c.h" -#include "opencv2/core.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgproc.hpp" #include "opencv2/video.hpp" diff --git a/include/opencv/cvaux.hpp b/include/opencv/cvaux.hpp index 952210b0be..b0e60a3038 100644 --- a/include/opencv/cvaux.hpp +++ b/include/opencv/cvaux.hpp @@ -46,6 +46,7 @@ //#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module" //#endif -#include +#include "cvaux.h" +#include "opencv2/core/utility.hpp" #endif diff --git a/include/opencv/cxcore.h b/include/opencv/cxcore.h index 9be80ae96f..0982bd7508 100644 --- a/include/opencv/cxcore.h +++ b/include/opencv/cxcore.h @@ -48,6 +48,5 @@ //#endif #include "opencv2/core/core_c.h" -#include "opencv2/core.hpp" #endif diff --git a/include/opencv/cxcore.hpp b/include/opencv/cxcore.hpp index 033b36556c..9af4ac7460 100644 --- a/include/opencv/cxcore.hpp +++ b/include/opencv/cxcore.hpp @@ -47,6 +47,7 @@ //#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module" //#endif -#include +#include "cxcore.h" +#include "opencv2/core.hpp" #endif diff --git a/include/opencv/highgui.h b/include/opencv/highgui.h index 56874e7383..229436a75a 100644 --- a/include/opencv/highgui.h +++ b/include/opencv/highgui.h @@ -43,7 +43,6 @@ #define __OPENCV_OLD_HIGHGUI_H__ #include "opencv2/core/core_c.h" -#include "opencv2/core.hpp" #include "opencv2/highgui/highgui_c.h" #include "opencv2/highgui.hpp" diff --git a/include/opencv/ml.h b/include/opencv/ml.h index ac21f3c219..d8e967f81b 100644 --- a/include/opencv/ml.h +++ b/include/opencv/ml.h @@ -42,7 +42,6 @@ #define __OPENCV_OLD_ML_H__ #include "opencv2/core/core_c.h" -#include "opencv2/core.hpp" #include "opencv2/ml.hpp" #endif diff --git a/include/opencv2/opencv.hpp b/include/opencv2/opencv.hpp index f9c15df3d4..403858cc75 100644 --- a/include/opencv2/opencv.hpp +++ b/include/opencv2/opencv.hpp @@ -43,10 +43,8 @@ #ifndef __OPENCV_ALL_HPP__ #define __OPENCV_ALL_HPP__ -#include "opencv2/core/core_c.h" #include "opencv2/core.hpp" #include "opencv2/flann/miniflann.hpp" -#include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgproc.hpp" #include "opencv2/photo.hpp" #include "opencv2/video.hpp" @@ -54,7 +52,6 @@ #include "opencv2/objdetect.hpp" #include "opencv2/calib3d.hpp" #include "opencv2/ml.hpp" -#include "opencv2/highgui/highgui_c.h" #include "opencv2/highgui.hpp" #include "opencv2/contrib.hpp" diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 79fb8892a9..f3c7e8262c 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -44,7 +44,10 @@ #ifndef __OPENCV_CALIB3D_HPP__ #define __OPENCV_CALIB3D_HPP__ -#include "opencv2/core.hpp" +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif +#include "opencv2/core/core_c.h" #include "opencv2/features2d.hpp" #ifdef __cplusplus diff --git a/modules/calib3d/test/test_undistort.cpp b/modules/calib3d/test/test_undistort.cpp index 8823e1d517..8484aa4731 100644 --- a/modules/calib3d/test/test_undistort.cpp +++ b/modules/calib3d/test/test_undistort.cpp @@ -491,7 +491,7 @@ void CV_UndistortPointsTest::distortPoints(const CvMat* _src, CvMat* _dst, const __P = cvCreateMat(3,4,CV_64F); if (matP) { - cvTsConvert(matP,__P); + cvtest::convert(cvarrToMat(matP), cvarrToMat(__P), -1); } else { @@ -500,7 +500,7 @@ void CV_UndistortPointsTest::distortPoints(const CvMat* _src, CvMat* _dst, const __P->data.db[4] = 1; __P->data.db[8] = 1; } - CvMat* __R = cvCreateMat(3,3,CV_64F);; + CvMat* __R = cvCreateMat(3,3,CV_64F); if (matR) { cvCopy(matR,__R); @@ -847,10 +847,10 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/ CvMat _input3 = test_mat[INPUT][3]; CvMat _input4 = test_mat[INPUT][4]; - cvTsConvert(&_input1,&_camera); - cvTsConvert(&_input2,&_distort); - cvTsConvert(&_input3,&_rot); - cvTsConvert(&_input4,&_new_cam); + cvtest::convert(cvarrToMat(&_input1), cvarrToMat(&_camera), -1); + cvtest::convert(cvarrToMat(&_input2), cvarrToMat(&_distort), -1); + cvtest::convert(cvarrToMat(&_input3), cvarrToMat(&_rot), -1); + cvtest::convert(cvarrToMat(&_input4), cvarrToMat(&_new_cam), -1); //Applying precalculated undistort rectify map if (!useCPlus) @@ -876,7 +876,7 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/ zero_distortion ? 0 : &_distort, zero_R ? 0 : &_rot, zero_new_cam ? &_camera : &_new_cam); //cvTsDistortPoints(&_points,&ref_points,&_camera,&_distort,&_rot,&_new_cam); CvMat dst = test_mat[REF_OUTPUT][0]; - cvTsConvert(&ref_points,&dst); + cvtest::convert(cvarrToMat(&ref_points), cvarrToMat(&dst), -1); cvtest::copy(test_mat[INPUT][0],test_mat[OUTPUT][0]); diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index c533dd5ccd..f5aca80b4c 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -46,21 +46,25 @@ #ifndef __OPENCV_CORE_HPP__ #define __OPENCV_CORE_HPP__ +#ifndef __cplusplus +# error core.hpp header must be compiled as C++ +#endif + #include "opencv2/core/cvdef.h" #include "opencv2/core/version.hpp" -#ifdef __cplusplus +// Used by FileStorage +typedef struct CvFileStorage CvFileStorage; +struct CvFileNode; +struct CvSeq; +struct CvSeqBlock; + #include "opencv2/core/base.hpp" #include "opencv2/core/cvstd.hpp" #include "opencv2/core/traits.hpp" #include "opencv2/core/matx.hpp" #include "opencv2/core/types.hpp" #include "opencv2/core/mat.hpp" -#endif - -#include "opencv2/core/types_c.h" - -#ifdef __cplusplus #ifndef SKIP_INCLUDES #include @@ -215,11 +219,6 @@ CV_EXPORTS BinaryFunc getCopyMaskFunc(size_t esz); //! swaps two matrices CV_EXPORTS void swap(Mat& a, Mat& b); -//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. -CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); -//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage -CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); - //! adds one matrix to another (dst = src1 + src2) CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1); @@ -1583,9 +1582,21 @@ public: FileNodeIterator& readRaw( const String& fmt, uchar* vec, size_t maxCount=(size_t)INT_MAX ); + struct SeqReader + { + int header_size; + CvSeq* seq; /* sequence, beign read */ + CvSeqBlock* block; /* current block */ + schar* ptr; /* pointer to element be read next */ + schar* block_min; /* pointer to the beginning of block */ + schar* block_max; /* pointer to the end of block */ + int delta_index;/* = seq->first->start_index */ + schar* prev_elem; /* pointer to previous element */ + }; + const CvFileStorage* fs; const CvFileNode* container; - CvSeqReader reader; + SeqReader reader; size_t remaining; }; @@ -1873,10 +1884,6 @@ template<> struct ParamType #include "opencv2/core/operations.hpp" #include "opencv2/core/mat.inl.hpp" - #include "opencv2/core/cvstd.inl.hpp" -#endif // __cplusplus - - #endif /*__OPENCV_CORE_HPP__*/ diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 65376be219..ec96932e30 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -44,6 +44,10 @@ #ifndef __OPENCV_CORE_BASE_HPP__ #define __OPENCV_CORE_BASE_HPP__ +#ifndef __cplusplus +# error base.hpp header must be compiled as C++ +#endif + #include #include "opencv2/core/cvdef.h" diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index b7ddbf368c..2ae1d6176f 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -1842,12 +1842,32 @@ struct CV_EXPORTS CvType static CvTypeInfo* last; }; -#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" namespace cv { -//// specializied implementations of Ptr::delete_obj() for classic OpenCV types +/////////////////////////////////////////// glue /////////////////////////////////////////// + +//! converts array (CvMat or IplImage) to cv::Mat +CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, + bool allowND=true, int coiMode=0, + AutoBuffer* buf=0); + +static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) +{ + return cvarrToMat(arr, copyData, true, coiMode); +} + + +//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. +CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); +//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage +CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); + + + +//////// specializied implementations of Ptr::delete_obj() for classic OpenCV types //////// template<> CV_EXPORTS void Ptr::delete_obj(); template<> CV_EXPORTS void Ptr::delete_obj(); diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index bc247a535d..141424f52a 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -335,6 +335,14 @@ typedef signed char schar; # include #endif +#ifndef MIN +# define MIN(a,b) ((a) > (b) ? (b) : (a)) +#endif + +#ifndef MAX +# define MAX(a,b) ((a) < (b) ? (b) : (a)) +#endif + #ifdef HAVE_TEGRA_OPTIMIZATION # include "tegra_round.hpp" #endif diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index b1a3facce0..45ada54874 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -44,6 +44,10 @@ #ifndef __OPENCV_CORE_MAT_HPP__ #define __OPENCV_CORE_MAT_HPP__ +#ifndef __cplusplus +# error mat.hpp header must be compiled as C++ +#endif + #include "opencv2/core/matx.hpp" #include "opencv2/core/types.hpp" diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 83b0dbc8a6..f68efb01cc 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -43,13 +43,15 @@ #ifndef __OPENCV_CORE_MATRIX_OPERATIONS_HPP__ #define __OPENCV_CORE_MATRIX_OPERATIONS_HPP__ +#ifndef __cplusplus +# error mat.inl.hpp header must be compiled as C++ +#endif + #ifndef SKIP_INCLUDES #include #include #endif // SKIP_INCLUDES -#ifdef __cplusplus - namespace cv { @@ -2588,4 +2590,3 @@ SparseMatIterator_<_Tp>::operator ++(int) } #endif -#endif diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index 53c55c8901..7dddd8f9c1 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -44,6 +44,10 @@ #ifndef __OPENCV_CORE_MATX_HPP__ #define __OPENCV_CORE_MATX_HPP__ +#ifndef __cplusplus +# error matx.hpp header must be compiled as C++ +#endif + #include "opencv2/core/cvdef.h" #include "opencv2/core/base.hpp" #include "opencv2/core/traits.hpp" diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 82d1f49c33..88bdc54798 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -43,14 +43,16 @@ #ifndef __OPENCV_CORE_OPERATIONS_HPP__ #define __OPENCV_CORE_OPERATIONS_HPP__ +#ifndef __cplusplus +# error operations.hpp header must be compiled as C++ +#endif + #ifndef SKIP_INCLUDES #include #include #endif // SKIP_INCLUDES -#ifdef __cplusplus - #include #ifdef _MSC_VER @@ -330,8 +332,8 @@ public: dst[i] = src[i]; } - operator CvMat() const - { return cvMat((int)size(), 1, type(), (void*)hdr.data); } + // operator CvMat() const + // { return cvMat((int)size(), 1, type(), (void*)hdr.data); } _Tp& operator [] (size_t i) { CV_DbgAssert( i < size() ); return hdr.data[i]; } const _Tp& operator [] (size_t i) const { CV_DbgAssert( i < size() ); return hdr.data[i]; } @@ -453,7 +455,7 @@ inline RNG::RNG() { state = 0xffffffff; } inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; } inline unsigned RNG::next() { - state = (uint64)(unsigned)state*CV_RNG_COEFF + (unsigned)(state >> 32); + state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32); return (unsigned)state; } @@ -597,14 +599,14 @@ public: template inline void write(FileStorage& fs, const String& name, const Point_<_Tp>& pt ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, pt.x); write(fs, pt.y); } template inline void write(FileStorage& fs, const String& name, const Point3_<_Tp>& pt ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, pt.x); write(fs, pt.y); write(fs, pt.z); @@ -612,21 +614,21 @@ template inline void write(FileStorage& fs, const String& name, co template inline void write(FileStorage& fs, const String& name, const Size_<_Tp>& sz ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, sz.width); write(fs, sz.height); } template inline void write(FileStorage& fs, const String& name, const Complex<_Tp>& c ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, c.re); write(fs, c.im); } template inline void write(FileStorage& fs, const String& name, const Rect_<_Tp>& r ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, r.x); write(fs, r.y); write(fs, r.width); @@ -635,14 +637,14 @@ template inline void write(FileStorage& fs, const String& name, co template inline void write(FileStorage& fs, const String& name, const Vec<_Tp, cn>& v ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); for(int i = 0; i < cn; i++) write(fs, v.val[i]); } template inline void write(FileStorage& fs, const String& name, const Scalar_<_Tp>& s ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, s.val[0]); write(fs, s.val[1]); write(fs, s.val[2]); @@ -651,7 +653,7 @@ template inline void write(FileStorage& fs, const String& name, co inline void write(FileStorage& fs, const String& name, const Range& r ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); + WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); write(fs, r.start); write(fs, r.end); } @@ -691,7 +693,7 @@ template static inline void write( FileStorage& fs, const std::vec template static inline void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec ) { - WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0)); + WriteStructContext ws(fs, name, FileNode::SEQ+(DataType<_Tp>::fmt != 0 ? FileNode::FLOW : 0)); write(fs, vec); } @@ -703,7 +705,7 @@ template static inline FileStorage& operator << (FileStorage& fs, if( !fs.isOpened() ) return fs; if( fs.state == FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP ) - CV_Error( CV_StsError, "No element name has been given" ); + CV_Error( Error::StsError, "No element name has been given" ); write( fs, fs.elname, value ); if( fs.state & FileStorage::INSIDE_MAP ) fs.state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP; @@ -724,7 +726,6 @@ inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node) inline FileNode::FileNode(const FileNode& _node) : fs(_node.fs), node(_node.node) {} -inline int FileNode::type() const { return !node ? NONE : (node->tag & TYPE_MASK); } inline bool FileNode::empty() const { return node == 0; } inline bool FileNode::isNone() const { return type() == NONE; } inline bool FileNode::isSeq() const { return type() == SEQ; } @@ -732,23 +733,19 @@ inline bool FileNode::isMap() const { return type() == MAP; } inline bool FileNode::isInt() const { return type() == INT; } inline bool FileNode::isReal() const { return type() == REAL; } inline bool FileNode::isString() const { return type() == STR; } -inline bool FileNode::isNamed() const { return !node ? false : (node->tag & NAMED) != 0; } -inline size_t FileNode::size() const -{ - int t = type(); - return t == MAP ? (size_t)((CvSet*)node->data.map)->active_count : - t == SEQ ? (size_t)node->data.seq->total : (size_t)!isNone(); -} inline CvFileNode* FileNode::operator *() { return (CvFileNode*)node; } inline const CvFileNode* FileNode::operator* () const { return node; } -static inline void read(const FileNode& node, int& value, int default_value) -{ - value = !node.node ? default_value : - CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : - CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff; -} +CV_EXPORTS void read(const FileNode& node, int& value, int default_value); +CV_EXPORTS void read(const FileNode& node, float& value, float default_value); +CV_EXPORTS void read(const FileNode& node, double& value, double default_value); +CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value); +CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat=SparseMat() ); +CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() ); + +CV_EXPORTS void read(const FileNode& node, std::vector& keypoints); +CV_EXPORTS void write(FileStorage& fs, const String& objname, const std::vector& keypoints); static inline void read(const FileNode& node, bool& value, bool default_value) { @@ -780,31 +777,6 @@ static inline void read(const FileNode& node, short& value, short default_value) value = saturate_cast(temp); } -static inline void read(const FileNode& node, float& value, float default_value) -{ - value = !node.node ? default_value : - CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i : - CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f; -} - -static inline void read(const FileNode& node, double& value, double default_value) -{ - value = !node.node ? default_value : - CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i : - CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300; -} - -static inline void read(const FileNode& node, String& value, const String& default_value) -{ - value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String(); -} - -CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() ); -CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat=SparseMat() ); - -CV_EXPORTS void read(const FileNode& node, std::vector& keypoints); -CV_EXPORTS void write(FileStorage& fs, const String& objname, const std::vector& keypoints); - inline FileNode::operator int() const { int value; @@ -1022,7 +994,7 @@ partition( const std::vector<_Tp>& _vec, std::vector& labels, nodes[root2][RANK] += rank == rank2; root = root2; } - assert( nodes[root][PARENT] < 0 ); + CV_Assert( nodes[root][PARENT] < 0 ); int k = j, parent; @@ -1224,7 +1196,7 @@ inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) { Ptr algo_ptr = value. template ptr(); if (algo_ptr.empty()) { - CV_Error( CV_StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); + CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); } info()->set(this, _name, ParamType::type, &algo_ptr); } @@ -1240,7 +1212,7 @@ inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value) { Ptr algo_ptr = value. template ptr(); if (algo_ptr.empty()) { - CV_Error( CV_StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); + CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); } info()->set(this, _name, ParamType::type, &algo_ptr); } @@ -1289,5 +1261,4 @@ template inline void AlgorithmInfo::addParam(Algorithm& algo, cons # pragma warning(pop) #endif -#endif // __cplusplus #endif diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 1d7f1a2bee..5111f36322 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -44,6 +44,10 @@ #ifndef __OPENCV_CORE_TYPES_HPP__ #define __OPENCV_CORE_TYPES_HPP__ +#ifndef __cplusplus +# error types.hpp header must be compiled as C++ +#endif + #include #include #include diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index b2f157cd77..352e000d4a 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -93,8 +93,7 @@ #endif #ifdef __cplusplus -# include "opencv2/core/types.hpp" -# include "opencv2/core/mat.hpp" +# include "opencv2/core.hpp" #endif /* CvArr* is used to pass arbitrary @@ -182,14 +181,6 @@ enum { #define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t)) -#ifndef MIN -# define MIN(a,b) ((a) > (b) ? (b) : (a)) -#endif - -#ifndef MAX -# define MAX(a,b) ((a) < (b) ? (b) : (a)) -#endif - /* min & max without jumps */ #define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1))) @@ -426,6 +417,7 @@ typedef struct CvMat #ifdef __cplusplus CvMat() {} + CvMat(const CvMat& m) { memcpy(this, &m, sizeof(CvMat));} CvMat(const cv::Mat& m); #endif @@ -1465,12 +1457,15 @@ CvSeqWriter; int delta_index;/* = seq->first->start_index */ \ schar* prev_elem; /* pointer to previous element */ - +#ifdef __cplusplus +typedef cv::FileNodeIterator::SeqReader CvSeqReader; +#else typedef struct CvSeqReader { CV_SEQ_READER_FIELDS() } CvSeqReader; +#endif /****************************************************************************************/ /* Operations on sequences */ diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 269730673e..d421e7a05d 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -44,6 +44,10 @@ #ifndef __OPENCV_CORE_UTILITY_H__ #define __OPENCV_CORE_UTILITY_H__ +#ifndef __cplusplus +# error utility.hpp header must be compiled as C++ +#endif + #include "opencv2/core.hpp" namespace cv @@ -126,7 +130,7 @@ protected: */ CV_EXPORTS bool setBreakOnError(bool flag); -typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name, +extern "C" typedef int (*ErrorCallback)( int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata ); @@ -144,7 +148,7 @@ typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name, CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0); CV_EXPORTS String format( const char* fmt, ... ); -CV_EXPORTS String tempfile( const char* suffix CV_DEFAULT(0)); +CV_EXPORTS String tempfile( const char* suffix = 0); CV_EXPORTS void glob(String pattern, std::vector& result, bool recursive = false); CV_EXPORTS void setNumThreads(int nthreads); CV_EXPORTS int getNumThreads(); @@ -443,17 +447,6 @@ template inline AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const { return ptr; } -// TODO: move them to core_c.h -//! converts array (CvMat or IplImage) to cv::Mat -CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, - bool allowND=true, int coiMode=0, - AutoBuffer* buf=0); - -static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) -{ - return cvarrToMat(arr, copyData, true, coiMode); -} - #ifndef OPENCV_NOSTL template<> inline std::string CommandLineParser::get(int index, bool space_delete) const { diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 2f5523d3ed..85bc02d1d7 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -5553,6 +5553,42 @@ void read(const FileNode& node, std::vector& keypoints) } } +int FileNode::type() const { return !node ? NONE : (node->tag & TYPE_MASK); } +bool FileNode::isNamed() const { return !node ? false : (node->tag & NAMED) != 0; } + +size_t FileNode::size() const +{ + int t = type(); + return t == MAP ? (size_t)((CvSet*)node->data.map)->active_count : + t == SEQ ? (size_t)node->data.seq->total : (size_t)!isNone(); +} + +void read(const FileNode& node, int& value, int default_value) +{ + value = !node.node ? default_value : + CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : + CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff; +} + +void read(const FileNode& node, float& value, float default_value) +{ + value = !node.node ? default_value : + CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i : + CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f; +} + +void read(const FileNode& node, double& value, double default_value) +{ + value = !node.node ? default_value : + CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i : + CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300; +} + +void read(const FileNode& node, String& value, const String& default_value) +{ + value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String(); +} + } /* End of file. */ diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 533ba22cf4..76758712cf 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -47,7 +47,6 @@ #include "cvconfig.h" #endif -#include "opencv2/core.hpp" #include "opencv2/core/utility.hpp" #include "opencv2/core/core_c.h" #include "opencv2/core/internal.hpp" diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index a3a8fe2f70..071bea6aa9 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -43,10 +43,10 @@ #ifndef __OPENCV_FEATURES_2D_HPP__ #define __OPENCV_FEATURES_2D_HPP__ -#include "opencv2/core.hpp" #include "opencv2/flann/miniflann.hpp" #ifdef __cplusplus +#include "opencv2/core.hpp" #include namespace cv diff --git a/modules/highgui/include/opencv2/highgui.hpp b/modules/highgui/include/opencv2/highgui.hpp index ecec175f6d..19fed92960 100644 --- a/modules/highgui/include/opencv2/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui.hpp @@ -43,10 +43,10 @@ #ifndef __OPENCV_HIGHGUI_HPP__ #define __OPENCV_HIGHGUI_HPP__ -#include "opencv2/core.hpp" #include "opencv2/highgui/highgui_c.h" #ifdef __cplusplus +#include "opencv2/core.hpp" struct CvCapture; struct CvVideoWriter; diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 10a5d53c65..8747a30116 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -43,11 +43,12 @@ #ifndef __OPENCV_IMGPROC_HPP__ #define __OPENCV_IMGPROC_HPP__ -#include "opencv2/core.hpp" #include "opencv2/imgproc/types_c.h" #ifdef __cplusplus +#include "opencv2/core.hpp" + /*! \namespace cv Namespace where all the C++ OpenCV functionality resides */ diff --git a/modules/imgproc/test/test_floodfill.cpp b/modules/imgproc/test/test_floodfill.cpp index 558aa322b6..07e0bcbc4e 100644 --- a/modules/imgproc/test/test_floodfill.cpp +++ b/modules/imgproc/test/test_floodfill.cpp @@ -259,16 +259,17 @@ cvTsFloodFill( CvMat* _img, CvPoint seed_pt, CvScalar new_val, if( CV_MAT_DEPTH(_img->type) == CV_8U || CV_MAT_DEPTH(_img->type) == CV_32S ) { tmp = cvCreateMat( rows, cols, CV_MAKETYPE(CV_32F,CV_MAT_CN(_img->type)) ); - cvTsConvert(_img, tmp); + cvtest::convert(cvarrToMat(_img), cvarrToMat(tmp), -1); } mask = cvCreateMat( rows + 2, cols + 2, CV_16UC1 ); if( _mask ) - cvTsConvert( _mask, mask ); + cvtest::convert(cvarrToMat(_mask), cvarrToMat(mask), -1); else { - cvTsZero( mask ); + Mat m_mask = cvarrToMat(mask); + cvtest::set( m_mask, Scalar::all(0), Mat() ); cvRectangle( mask, cvPoint(0,0), cvPoint(mask->cols-1,mask->rows-1), Scalar::all(1.), 1, 8, 0 ); } @@ -481,7 +482,7 @@ _exit_: if( tmp != _img ) { if( !mask_only ) - cvTsConvert(tmp, _img); + cvtest::convert(cvarrToMat(tmp), cvarrToMat(_img), -1); cvReleaseMat( &tmp ); } diff --git a/modules/java/generator/src/cpp/features2d_manual.hpp b/modules/java/generator/src/cpp/features2d_manual.hpp index d735d9e228..a51b1eaa30 100644 --- a/modules/java/generator/src/cpp/features2d_manual.hpp +++ b/modules/java/generator/src/cpp/features2d_manual.hpp @@ -137,7 +137,7 @@ public: name = name + "BRISK"; break; default: - CV_Error( CV_StsBadArg, "Specified feature detector type is not supported." ); + CV_Error( Error::StsBadArg, "Specified feature detector type is not supported." ); break; } @@ -231,7 +231,7 @@ public: name = "BruteForce-SL2"; break; default: - CV_Error( CV_StsBadArg, "Specified descriptor matcher type is not supported." ); + CV_Error( Error::StsBadArg, "Specified descriptor matcher type is not supported." ); break; } @@ -323,7 +323,7 @@ public: name = name + "FREAK"; break; default: - CV_Error( CV_StsBadArg, "Specified descriptor extractor type is not supported." ); + CV_Error( Error::StsBadArg, "Specified descriptor extractor type is not supported." ); break; } @@ -412,7 +412,7 @@ public: name = "FERN"; break; default: - CV_Error( CV_StsBadArg, "Specified generic descriptor matcher type is not supported." ); + CV_Error( Error::StsBadArg, "Specified generic descriptor matcher type is not supported." ); break; } diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index 5c1591a7e3..7a334f2649 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -41,7 +41,11 @@ #ifndef __OPENCV_ML_HPP__ #define __OPENCV_ML_HPP__ -#include "opencv2/core.hpp" +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif + +#include "opencv2/core/core_c.h" #include #ifdef __cplusplus diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index c2ba8cedf6..50bfd05bd9 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -43,7 +43,10 @@ #ifndef __OPENCV_OBJDETECT_HPP__ #define __OPENCV_OBJDETECT_HPP__ -#include "opencv2/core.hpp" +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif +#include "opencv2/core/core_c.h" #ifdef __cplusplus #include diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index e2735da3e0..9e9bcb39cc 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -94,7 +94,7 @@ CV_EXPORTS void add(const Mat& a, double alpha, const Mat& b, double beta, CV_EXPORTS void multiply(const Mat& a, const Mat& b, Mat& c, double alpha=1); CV_EXPORTS void divide(const Mat& a, const Mat& b, Mat& c, double alpha=1); -CV_EXPORTS void convert(const Mat& src, Mat& dst, int dtype, double alpha=1, double beta=0); +CV_EXPORTS void convert(const Mat& src, cv::OutputArray dst, int dtype, double alpha=1, double beta=0); CV_EXPORTS void copy(const Mat& src, Mat& dst, const Mat& mask=Mat(), bool invertMask=false); CV_EXPORTS void set(Mat& dst, const Scalar& gamma, const Mat& mask=Mat()); @@ -111,9 +111,9 @@ CV_EXPORTS void patchZeros( Mat& mat, double level ); CV_EXPORTS void transpose(const Mat& src, Mat& dst); CV_EXPORTS void erode(const Mat& src, Mat& dst, const Mat& _kernel, Point anchor=Point(-1,-1), - int borderType=IPL_BORDER_CONSTANT, const Scalar& borderValue=Scalar()); + int borderType=0, const Scalar& borderValue=Scalar()); CV_EXPORTS void dilate(const Mat& src, Mat& dst, const Mat& _kernel, Point anchor=Point(-1,-1), - int borderType=IPL_BORDER_CONSTANT, const Scalar& borderValue=Scalar()); + int borderType=0, const Scalar& borderValue=Scalar()); CV_EXPORTS void filter2D(const Mat& src, Mat& dst, int ddepth, const Mat& kernel, Point anchor, double delta, int borderType, const Scalar& borderValue=Scalar()); @@ -541,18 +541,6 @@ CV_EXPORTS void smoothBorder(Mat& img, const Scalar& color, int delta = 3); } //namespace cvtest -// fills c with zeros -CV_EXPORTS void cvTsZero( CvMat* c, const CvMat* mask=0 ); - -// copies a to b (whole matrix or only the selected region) -CV_EXPORTS void cvTsCopy( const CvMat* a, CvMat* b, const CvMat* mask=0 ); - -// converts one array to another -CV_EXPORTS void cvTsConvert( const CvMat* src, CvMat* dst ); - -CV_EXPORTS void cvTsGEMM( const CvMat* a, const CvMat* b, double alpha, - const CvMat* c, double beta, CvMat* d, int flags ); - #define CV_TEST_MAIN(resourcesubdir) \ int main(int argc, char **argv) \ { \ diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index 7208484293..b797447691 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -272,10 +272,13 @@ convertTo(const _Tp* src, void* dst, int dtype, size_t total, double alpha, doub } } -void convert(const Mat& src, Mat& dst, int dtype, double alpha, double beta) +void convert(const Mat& src, cv::OutputArray _dst, int dtype, double alpha, double beta) { + if (dtype < 0) dtype = _dst.depth(); + dtype = CV_MAKETYPE(CV_MAT_DEPTH(dtype), src.channels()); - dst.create(src.dims, &src.size[0], dtype); + _dst.create(src.dims, &src.size[0], dtype); + Mat dst = _dst.getMat(); if( alpha == 0 ) { set( dst, Scalar::all(beta) ); @@ -2935,15 +2938,3 @@ MatComparator::operator()(const char* expr1, const char* expr2, } } - -void cvTsConvert( const CvMat* src, CvMat* dst ) -{ - Mat _src = cvarrToMat(src), _dst = cvarrToMat(dst); - cvtest::convert(_src, _dst, _dst.depth()); -} - -void cvTsZero( CvMat* dst, const CvMat* mask ) -{ - Mat _dst = cvarrToMat(dst), _mask = mask ? cvarrToMat(mask) : Mat(); - cvtest::set(_dst, Scalar::all(0), _mask); -} diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp index 01f80c2de5..dbccfae748 100644 --- a/modules/video/include/opencv2/video/tracking.hpp +++ b/modules/video/include/opencv2/video/tracking.hpp @@ -43,7 +43,9 @@ #ifndef __OPENCV_TRACKING_HPP__ #define __OPENCV_TRACKING_HPP__ -#include "opencv2/core.hpp" +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif #include "opencv2/imgproc.hpp" #ifdef __cplusplus diff --git a/samples/cpp/detection_based_tracker_sample.cpp b/samples/cpp/detection_based_tracker_sample.cpp index 2b9eef1a94..50dffea569 100644 --- a/samples/cpp/detection_based_tracker_sample.cpp +++ b/samples/cpp/detection_based_tracker_sample.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include diff --git a/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp b/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp index 58cb1961e5..dfb13bdf64 100644 --- a/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp +++ b/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp @@ -4,7 +4,7 @@ #include #include #include -#include " +#include using namespace cv; // The new C++ interface API is inside this namespace. Import it. using namespace std;