Skip to content

Commit

Permalink
add the type_id to the old save format
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhughes27 committed Dec 19, 2016
1 parent 85e01f3 commit 0d32bec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/traincascade/cascadeclassifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 );
Expand All @@ -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 << "[";
Expand Down

0 comments on commit 0d32bec

Please sign in to comment.