From 16dd09ccfc5faf6686f19f628afd39a6671477c3 Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Thu, 25 Oct 2012 12:22:54 +0400 Subject: [PATCH] move scale related parameters to SoftCascade constructor --- .../include/opencv2/objdetect/objdetect.hpp | 17 ++++++++++------- modules/objdetect/src/softcascade.cpp | 9 +++++---- modules/objdetect/test/test_softcascade.cpp | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index 85084a90c..53b2b1107 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -510,19 +510,18 @@ public: }; //! An empty cascade will be created. - SoftCascade(); + //! Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed. + //! Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed. + //! Param scales is a number of scales from minScale to maxScale. + SoftCascade( const float minScale = 0.4f, const float maxScale = 5.f, const int scales = 55); //! Cascade will be created for scales from minScale to maxScale. //! Param fs is a serialized sacsade. - //! Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed. - //! Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed. - SoftCascade( const cv::FileStorage& fs, const float minScale = 0.4f, const float maxScale = 5.f); + SoftCascade( const cv::FileStorage& fs); //! cascade will be loaded. The previous cascade will be destroyed. //! Param fs is a serialized sacsade. - //! Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed. - //! Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed. - bool read( const cv::FileStorage& fs, const float minScale = 0.4f, const float maxScale = 5.f); + bool read( const cv::FileStorage& fs); virtual ~SoftCascade(); @@ -545,6 +544,10 @@ protected: private: struct Filds; Filds* filds; + + float minScale; + float maxScale; + int scales; }; class CV_EXPORTS IntegralChannels diff --git a/modules/objdetect/src/softcascade.cpp b/modules/objdetect/src/softcascade.cpp index 7c735b21d..4cf72e3cd 100644 --- a/modules/objdetect/src/softcascade.cpp +++ b/modules/objdetect/src/softcascade.cpp @@ -497,18 +497,19 @@ struct cv::SoftCascade::Filds } }; -cv::SoftCascade::SoftCascade() : filds(0) {} +cv::SoftCascade::SoftCascade(const float mins, const float maxs, const int nsc) +: filds(0), minScale(mins), maxScale(maxs), scales(nsc) {} -cv::SoftCascade::SoftCascade(const cv::FileStorage& fs, const float minScale, const float maxScale) : filds(0) +cv::SoftCascade::SoftCascade(const cv::FileStorage& fs) : filds(0) { - read(fs, minScale, maxScale); + read(fs); } cv::SoftCascade::~SoftCascade() { delete filds; } -bool cv::SoftCascade::read( const cv::FileStorage& fs, const float minScale, const float maxScale) +bool cv::SoftCascade::read( const cv::FileStorage& fs) { if (!fs.isOpened()) return false; diff --git a/modules/objdetect/test/test_softcascade.cpp b/modules/objdetect/test/test_softcascade.cpp index b75db7371..aa72a9719 100644 --- a/modules/objdetect/test/test_softcascade.cpp +++ b/modules/objdetect/test/test_softcascade.cpp @@ -92,4 +92,5 @@ TEST(SoftCascade, detect) total++; } std::cout << "detected: " << (int)objects.size() << std::endl; + ASSERT_EQ((int)objects.size(), 1501); } \ No newline at end of file