add the type_id to the old save format

This commit is contained in:
Kevin Hughes 2016-12-17 13:54:55 -05:00
parent 85e01f3ffe
commit 0d32bec5c3
No known key found for this signature in database
GPG Key ID: 47531019ABDAFEE7

View File

@ -412,6 +412,7 @@ bool CvCascadeClassifier::readStages( const FileNode &node)
}
// For old Haar Classifier file saving
#define ICV_HAAR_TYPE_ID "opencv-haar-classifier"
#define ICV_HAAR_SIZE_NAME "size"
#define ICV_HAAR_STAGES_NAME "stages"
#define ICV_HAAR_TREES_NAME "trees"
@ -434,11 +435,12 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
if ( !fs.isOpened() )
return;
fs << FileStorage::getDefaultObjectName(filename) << "{";
fs << FileStorage::getDefaultObjectName(filename);
if ( !baseFormat )
{
Mat featureMap;
getUsedFeaturesIdxMap( featureMap );
fs << "{";
writeParams( fs );
fs << CC_STAGE_NUM << (int)stageClassifiers.size();
writeStages( fs, featureMap );
@ -450,6 +452,7 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
CvSeq* weak;
if ( cascadeParams.featureType != CvFeatureParams::HAAR )
CV_Error( CV_StsBadFunc, "old file format is used for Haar-like features only");
fs << "{:" ICV_HAAR_TYPE_ID;
fs << ICV_HAAR_SIZE_NAME << "[:" << cascadeParams.winSize.width <<
cascadeParams.winSize.height << "]";
fs << ICV_HAAR_STAGES_NAME << "[";