From a89299acb2db7fcbfc3aa6b3506fb5755182ac67 Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Fri, 7 Dec 2012 18:26:09 +0400 Subject: [PATCH] store result to xml. --- apps/sft/include/sft/config.hpp | 7 +++++++ apps/sft/include/sft/octave.hpp | 1 + apps/sft/octave.cpp | 5 +++++ apps/sft/sft.cpp | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/sft/include/sft/config.hpp b/apps/sft/include/sft/config.hpp index 6e512be..d0ede66 100644 --- a/apps/sft/include/sft/config.hpp +++ b/apps/sft/include/sft/config.hpp @@ -73,6 +73,13 @@ struct Config cvRound(modelWinSize.width * octave), cvRound(modelWinSize.height * octave)); } + string resPath(ivector::const_iterator it) const + { + char s[65]; + sprintf(s, "%d", *it); + return std::string(cascadeName) + s + ".xml"; + } + // Paths to a rescaled data string trainPath; string testPath; diff --git a/apps/sft/include/sft/octave.hpp b/apps/sft/include/sft/octave.hpp index e03c29e..08c258b 100644 --- a/apps/sft/include/sft/octave.hpp +++ b/apps/sft/include/sft/octave.hpp @@ -129,6 +129,7 @@ public: virtual ~Octave(); virtual bool train(const Dataset& dataset, const FeaturePool& pool, int weaks, int treeDepth); + virtual void write( CvFileStorage* fs, string name) const; int logScale; diff --git a/apps/sft/octave.cpp b/apps/sft/octave.cpp index e90504f..4cb301e 100644 --- a/apps/sft/octave.cpp +++ b/apps/sft/octave.cpp @@ -297,6 +297,11 @@ bool sft::Octave::train(const Dataset& dataset, const FeaturePool& pool, int wea } +void sft::Octave::write( CvFileStorage* fs, string name) const +{ + CvBoost::write(fs, name.c_str()); +} + // ========= FeaturePool ========= // sft::FeaturePool::FeaturePool(cv::Size m, int n) : model(m), nfeatures(n) { diff --git a/apps/sft/sft.cpp b/apps/sft/sft.cpp index 6ea3513..c68a24a 100644 --- a/apps/sft/sft.cpp +++ b/apps/sft/sft.cpp @@ -46,6 +46,8 @@ #include #include +#include + int main(int argc, char** argv) { using namespace sft; @@ -128,7 +130,10 @@ int main(int argc, char** argv) if (boost.train(dataset, pool, cfg.weaks, cfg.treeDepth)) { std::cout << "Octave " << *it << " was successfully trained..." << std::endl; - // strong.push_back(octave); + CvFileStorage* fout = cvOpenFileStorage(cfg.resPath(it).c_str(), 0, CV_STORAGE_WRITE); + boost.write(fout, cfg.cascadeName); + // strong.push_back(octave); + cvReleaseFileStorage( &fout); } } -- 2.7.4