Commit 7193a73c authored by Andrey Kamaev's avatar Andrey Kamaev

Move FileStorage to separate header

parent 51706203
This diff is collapsed.
...@@ -449,6 +449,7 @@ class CV_EXPORTS Range; ...@@ -449,6 +449,7 @@ class CV_EXPORTS Range;
class CV_EXPORTS TermCriteria; class CV_EXPORTS TermCriteria;
class CV_EXPORTS KeyPoint; class CV_EXPORTS KeyPoint;
class CV_EXPORTS DMatch; class CV_EXPORTS DMatch;
class CV_EXPORTS RNG;
class CV_EXPORTS Mat; class CV_EXPORTS Mat;
class CV_EXPORTS MatExpr; class CV_EXPORTS MatExpr;
......
This diff is collapsed.
...@@ -188,6 +188,10 @@ static inline cv::Size cvGetMatSize( const CvMat* mat ) ...@@ -188,6 +188,10 @@ static inline cv::Size cvGetMatSize( const CvMat* mat )
return cv::Size(mat->cols, mat->rows); return cv::Size(mat->cols, mat->rows);
} }
namespace cv
{
CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int unroll_to = 0);
}
/****************************************************************************************\ /****************************************************************************************\
......
...@@ -1461,15 +1461,11 @@ CvSeqWriter; ...@@ -1461,15 +1461,11 @@ CvSeqWriter;
int delta_index;/* = seq->first->start_index */ \ int delta_index;/* = seq->first->start_index */ \
schar* prev_elem; /* pointer to previous element */ schar* prev_elem; /* pointer to previous element */
#ifdef __cplusplus
typedef cv::FileNodeIterator::SeqReader CvSeqReader;
#else
typedef struct CvSeqReader typedef struct CvSeqReader
{ {
CV_SEQ_READER_FIELDS() CV_SEQ_READER_FIELDS()
} }
CvSeqReader; CvSeqReader;
#endif
/****************************************************************************************/ /****************************************************************************************/
/* Operations on sequences */ /* Operations on sequences */
......
...@@ -423,7 +423,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const ...@@ -423,7 +423,7 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
cv::write(fs, pname, algo->get<std::vector<Mat> >(pname)); cv::write(fs, pname, algo->get<std::vector<Mat> >(pname));
else if( p.type == Param::ALGORITHM ) else if( p.type == Param::ALGORITHM )
{ {
WriteStructContext ws(fs, pname, CV_NODE_MAP); internal::WriteStructContext ws(fs, pname, CV_NODE_MAP);
Ptr<Algorithm> nestedAlgo = algo->get<Algorithm>(pname); Ptr<Algorithm> nestedAlgo = algo->get<Algorithm>(pname);
nestedAlgo->write(fs); nestedAlgo->write(fs);
} }
......
...@@ -5317,7 +5317,7 @@ FileNodeIterator::FileNodeIterator(const CvFileStorage* _fs, ...@@ -5317,7 +5317,7 @@ FileNodeIterator::FileNodeIterator(const CvFileStorage* _fs,
container = _node; container = _node;
if( !(_node->tag & FileNode::USER) && (node_type == FileNode::SEQ || node_type == FileNode::MAP) ) if( !(_node->tag & FileNode::USER) && (node_type == FileNode::SEQ || node_type == FileNode::MAP) )
{ {
cvStartReadSeq( _node->data.seq, &reader ); cvStartReadSeq( _node->data.seq, (CvSeqReader*)&reader );
remaining = FileNode(_fs, _node).size(); remaining = FileNode(_fs, _node).size();
} }
else else
...@@ -5350,7 +5350,12 @@ FileNodeIterator& FileNodeIterator::operator ++() ...@@ -5350,7 +5350,12 @@ FileNodeIterator& FileNodeIterator::operator ++()
if( remaining > 0 ) if( remaining > 0 )
{ {
if( reader.seq ) if( reader.seq )
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); {
if( ((reader).ptr += (((CvSeq*)reader.seq)->elem_size)) >= (reader).block_max )
{
cvChangeSeqBlock( (CvSeqReader*)&(reader), 1 );
}
}
remaining--; remaining--;
} }
return *this; return *this;
...@@ -5368,7 +5373,12 @@ FileNodeIterator& FileNodeIterator::operator --() ...@@ -5368,7 +5373,12 @@ FileNodeIterator& FileNodeIterator::operator --()
if( remaining < FileNode(fs, container).size() ) if( remaining < FileNode(fs, container).size() )
{ {
if( reader.seq ) if( reader.seq )
CV_PREV_SEQ_ELEM( reader.seq->elem_size, reader ); {
if( ((reader).ptr -= (((CvSeq*)reader.seq)->elem_size)) < (reader).block_min )
{
cvChangeSeqBlock( (CvSeqReader*)&(reader), -1 );
}
}
remaining++; remaining++;
} }
return *this; return *this;
...@@ -5394,7 +5404,7 @@ FileNodeIterator& FileNodeIterator::operator += (int ofs) ...@@ -5394,7 +5404,7 @@ FileNodeIterator& FileNodeIterator::operator += (int ofs)
} }
remaining -= ofs; remaining -= ofs;
if( reader.seq ) if( reader.seq )
cvSetSeqReaderPos( &reader, ofs, 1 ); cvSetSeqReaderPos( (CvSeqReader*)&reader, ofs, 1 );
return *this; return *this;
} }
...@@ -5415,7 +5425,7 @@ FileNodeIterator& FileNodeIterator::readRaw( const String& fmt, uchar* vec, size ...@@ -5415,7 +5425,7 @@ FileNodeIterator& FileNodeIterator::readRaw( const String& fmt, uchar* vec, size
if( reader.seq ) if( reader.seq )
{ {
cvReadRawDataSlice( fs, &reader, (int)count, vec, fmt.c_str() ); cvReadRawDataSlice( fs, (CvSeqReader*)&reader, (int)count, vec, fmt.c_str() );
remaining -= count*cn; remaining -= count*cn;
} }
else else
...@@ -5475,14 +5485,17 @@ void write( FileStorage& fs, const String& name, const SparseMat& value ) ...@@ -5475,14 +5485,17 @@ void write( FileStorage& fs, const String& name, const SparseMat& value )
} }
WriteStructContext::WriteStructContext(FileStorage& _fs, const String& name, internal::WriteStructContext::WriteStructContext(FileStorage& _fs,
int flags, const String& typeName) : fs(&_fs) const String& name, int flags, const String& typeName) : fs(&_fs)
{ {
cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags, cvStartWriteStruct(**fs, !name.empty() ? name.c_str() : 0, flags,
!typeName.empty() ? typeName.c_str() : 0); !typeName.empty() ? typeName.c_str() : 0);
} }
WriteStructContext::~WriteStructContext() { cvEndWriteStruct(**fs); } internal::WriteStructContext::~WriteStructContext()
{
cvEndWriteStruct(**fs);
}
void read( const FileNode& node, Mat& mat, const Mat& default_mat ) void read( const FileNode& node, Mat& mat, const Mat& default_mat )
...@@ -5524,7 +5537,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat ) ...@@ -5524,7 +5537,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat )
void write(FileStorage& fs, const String& objname, const std::vector<KeyPoint>& keypoints) void write(FileStorage& fs, const String& objname, const std::vector<KeyPoint>& keypoints)
{ {
WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW); internal::WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
int i, npoints = (int)keypoints.size(); int i, npoints = (int)keypoints.size();
for( i = 0; i < npoints; i++ ) for( i = 0; i < npoints; i++ )
......
...@@ -13,4 +13,6 @@ ...@@ -13,4 +13,6 @@
#include "opencv2/ts.hpp" #include "opencv2/ts.hpp"
#include "opencv2/core/core_c.h" #include "opencv2/core/core_c.h"
#include "opencv2/core/private.hpp"
#endif #endif
...@@ -619,7 +619,7 @@ void LDetector::read(const FileNode& objnode) ...@@ -619,7 +619,7 @@ void LDetector::read(const FileNode& objnode)
void LDetector::write(FileStorage& fs, const String& name) const void LDetector::write(FileStorage& fs, const String& name) const
{ {
WriteStructContext ws(fs, name, CV_NODE_MAP); internal::WriteStructContext ws(fs, name, CV_NODE_MAP);
fs << "radius" << radius fs << "radius" << radius
<< "threshold" << threshold << "threshold" << threshold
...@@ -709,7 +709,7 @@ FernClassifier::FernClassifier(const std::vector<std::vector<Point2f> >& points, ...@@ -709,7 +709,7 @@ FernClassifier::FernClassifier(const std::vector<std::vector<Point2f> >& points,
void FernClassifier::write(FileStorage& fs, const String& objname) const void FernClassifier::write(FileStorage& fs, const String& objname) const
{ {
WriteStructContext ws(fs, objname, CV_NODE_MAP); internal::WriteStructContext ws(fs, objname, CV_NODE_MAP);
cv::write(fs, "nstructs", nstructs); cv::write(fs, "nstructs", nstructs);
cv::write(fs, "struct-size", structSize); cv::write(fs, "struct-size", structSize);
...@@ -718,7 +718,7 @@ void FernClassifier::write(FileStorage& fs, const String& objname) const ...@@ -718,7 +718,7 @@ void FernClassifier::write(FileStorage& fs, const String& objname) const
cv::write(fs, "compression-method", compressionMethod); cv::write(fs, "compression-method", compressionMethod);
cv::write(fs, "patch-size", patchSize.width); cv::write(fs, "patch-size", patchSize.width);
{ {
WriteStructContext wsf(fs, "features", CV_NODE_SEQ + CV_NODE_FLOW); internal::WriteStructContext wsf(fs, "features", CV_NODE_SEQ + CV_NODE_FLOW);
int i, nfeatures = (int)features.size(); int i, nfeatures = (int)features.size();
for( i = 0; i < nfeatures; i++ ) for( i = 0; i < nfeatures; i++ )
{ {
...@@ -727,7 +727,7 @@ void FernClassifier::write(FileStorage& fs, const String& objname) const ...@@ -727,7 +727,7 @@ void FernClassifier::write(FileStorage& fs, const String& objname) const
} }
} }
{ {
WriteStructContext wsp(fs, "posteriors", CV_NODE_SEQ + CV_NODE_FLOW); internal::WriteStructContext wsp(fs, "posteriors", CV_NODE_SEQ + CV_NODE_FLOW);
cv::write(fs, posteriors); cv::write(fs, posteriors);
} }
} }
...@@ -1478,10 +1478,10 @@ void PlanarObjectDetector::read(const FileNode& node) ...@@ -1478,10 +1478,10 @@ void PlanarObjectDetector::read(const FileNode& node)
void PlanarObjectDetector::write(FileStorage& fs, const String& objname) const void PlanarObjectDetector::write(FileStorage& fs, const String& objname) const
{ {
WriteStructContext ws(fs, objname, CV_NODE_MAP); internal::WriteStructContext ws(fs, objname, CV_NODE_MAP);
{ {
WriteStructContext wsroi(fs, "model-roi", CV_NODE_SEQ + CV_NODE_FLOW); internal::WriteStructContext wsroi(fs, "model-roi", CV_NODE_SEQ + CV_NODE_FLOW);
cv::write(fs, modelROI.x); cv::write(fs, modelROI.x);
cv::write(fs, modelROI.y); cv::write(fs, modelROI.y);
cv::write(fs, modelROI.width); cv::write(fs, modelROI.width);
......
...@@ -24,7 +24,9 @@ ocv_module_include_directories( ...@@ -24,7 +24,9 @@ ocv_module_include_directories(
set(opencv_hdrs set(opencv_hdrs
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core.hpp" "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/types.hpp" "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/types.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/persistence.hpp"
"${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp" "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp"
"${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp" "${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp"
"${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp" "${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp"
......
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