⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 haarfeatures.h

📁 MultiBoost 是c++实现的多类adaboost酸法。与传统的adaboost算法主要解决二类分类问题不同
💻 H
📖 第 1 页 / 共 2 页
字号:
   /**   * The type of access for the configurations.   * @see eAccessType   * @date 27/12/2005   */   eAccessType _accessType;    vector<nor_utils::Rect> _precomputedConfigs; //!< The precomputed sizes and locations of the features.   /**   * The list of the configurations that have already been used when the access type is   * AT_RANDOM_SAMPLE.   * @see moveToNextConfig   * @see eAccessType   * @date 27/12/2005   */   vector<char> _visitedConfigs;   /**   * Keep the number of configurations that have already been used when the access type   * is AT_RANDOM_SAMPLE.   * @see moveToNextConfig   * @see eAccessType   * @date 4/1/2006   */   size_t       _numVisited;   /**   * The iterator of the current position in the list of configurations.   * @remark Used only with "full search".   * @see getNextFeature   * @date 3/12/2005   */   vector<nor_utils::Rect>::const_iterator _configIt;   /**   * Convert the vector of all the examples (in integral image format) into   * a vector of features outputs, using the current configuration.   * The pair represent the original index of the example, where the second   * element is the feature's output. This method statically call the derived   * method to avoid the virtual calling.   * @param intImages The vector with the examples to be converted.   * @param haarData The returned vector of features outputs.   * @see fillHaarData.   * @date 27/12/2005   */   template <typename TDeriv>   void _fillHaarData( const vector< int* >& intImages, // input                        vector< pair<int, int> >& haarData ) // output   {      int i;      vector< int* >::const_iterator iiIt;      const vector< int* >::const_iterator iiEnd = intImages.end();      vector< pair<int, int> >::iterator hIt;      const nor_utils::Rect& currConfig = getCurrentConfig();      for (iiIt = intImages.begin(), hIt = haarData.begin(), i = 0;           iiIt != iiEnd; ++iiIt, ++hIt, ++i)      {         hIt->first = i;         hIt->second = static_cast<TDeriv&>(*this).getValue(*iiIt, currConfig);      }   }};// ------------------------------------------------------------------------------/*** Type "2 Blocs Horizontal" feature.\verbatim For white: 1      2     +-----++-----+  | [W] ||  B  | 3+-----4+-----+        ^-- xHalfPos For black:        1      2  +-----++-----+  |  W  || [B] |  +-----3+-----4         ^-- xHalfPos\endverbatim* (W = White, B = Black)* The formula is: 4+1 - (2+3)* @date 27/12/2005*/class HaarFeature_2H : public HaarFeature{public:   /**   * The constructor. Defines the name, type and shape of the feature.   * @param shortName The short name of the feature.   * @date 27/12/2005   */   HaarFeature_2H(const string& shortName)       : HaarFeature(2, 1, shortName, "2 Blocs Horizontal", FEATURE_2H_RECT) {}   /**   * Returns itself as object.   * @remark It uses the trick described in http://www.parashift.com/c++-faq-lite/serialization.html#faq-36.8   * for the auto-registering classes.   * @see FeaturesRegs   * @date 27/12/2005   */   HaarFeature* create()    { return new HaarFeature_2H(_shortName); }   /**   * Transform the example in integral image format, into the scalar   * output of the feature.   * @param pIntImage The array with the integral image data of the single example.   * @param r The configuration that will be used to compute the value of the   * feature.   * @date 27/12/2005   */   virtual int getValue(const int* pIntImage, const nor_utils::Rect& r);};// ------------------------------------------------------------------------------/*** Type "2 Blocs Vertical" feature.\verbatim For white:   1        2    +-------+    |  [W]  |   3+-------4    |   B   |    +-------+ For black:    +-------+   1|   W   2    +-------+    |  [B]  |   3+-------4\endverbatim* (W = White, B = Black)* The formula is: 4+1 - (2+3)* @date 27/12/2005*/class HaarFeature_2V : public HaarFeature{public:   /**   * The constructor. Defines the name, type and shape of the feature.   * @param shortName The short name of the feature.   * @date 27/12/2005   */   HaarFeature_2V(const string& shortName)       : HaarFeature(1, 2, shortName, "2 Blocs Vertical", FEATURE_2V_RECT) {}   /**   * Returns itself as object.   * @remark It uses the trick described in http://www.parashift.com/c++-faq-lite/serialization.html#faq-36.8   * for the auto-registering classes.   * @see FeaturesRegs   * @date 27/12/2005   */   HaarFeature* create()    { return new HaarFeature_2V(_shortName); }   /**   * Transform the example in integral image format, into the scalar   * output of the feature.   * @param pIntImage The array with the integral image data of the single example.   * @param r The configuration that will be used to compute the value of the   * feature.   * @date 27/12/2005   */   virtual int getValue(const int* pIntImage, const nor_utils::Rect& r);};// ------------------------------------------------------------------------------/*** Type "3 Blocs Horizontal" feature.\verbatim For white left:   1      2    +-----+-----+-----+    | [W] |  B  |  W  |   3+-----4-----+-----+ For black:         1      2    +-----+-----+-----+    |  W  | [B] |  W  |    +----3+-----4-----+ For white right:               1      2    +-----+-----+-----+    |  W  |  B  | [W] |    +-----+----3+-----4\endverbatim* (W = White, B = Black)* The formula is: 4+1 - (2+3)* @date 27/12/2005*/class HaarFeature_3H : public HaarFeature{public:   /**   * The constructor. Defines the name, type and shape of the feature.   * @param shortName The short name of the feature.   * @date 27/12/2005   */   HaarFeature_3H(const string& shortName)       : HaarFeature(3, 1, shortName, "3 Blocs Horizontal", FEATURE_3H_RECT) {}   /**   * Returns itself as object.   * @remark It uses the trick described in http://www.parashift.com/c++-faq-lite/serialization.html#faq-36.8   * for the auto-registering classes.   * @see FeaturesRegs   * @date 27/12/2005   */   HaarFeature* create()    { return new HaarFeature_3H(_shortName); }   /**   * Transform the example in integral image format, into the scalar   * output of the feature.   * @param pIntImage The array with the integral image data of the single example.   * @param r The configuration that will be used to compute the value of the   * feature.   * @date 27/12/2005   */   virtual int getValue(const int* pIntImage, const nor_utils::Rect& r);};// ------------------------------------------------------------------------------/*** Type "3 Blocs Vertical" feature.\verbatim For white top               For white bottom  1      2       For black    +-----+        +-----+        +-----+   | [W] |       1|  W  2        |  W  |  3+-----4        +-----+        +-----+   |  B  |        | [B] |       1| [B] 2   +-----+       3+-----4        +-----+   |  W  |        |  W  |        |  W  |   +-----+        +-----+       3+-----4\endverbatim* (W = White, B = Black)* The formula is: 4+1 - (2+3)* @date 27/12/2005*/class HaarFeature_3V : public HaarFeature{public:   /**   * The constructor. Defines the name, type and shape of the feature.   * @param shortName The short name of the feature.   * @date 27/12/2005   */   HaarFeature_3V(const string& shortName)       : HaarFeature(1, 3, shortName, "3 Blocs Vertical", FEATURE_3V_RECT) {}   /**   * Returns itself as object.   * @remark It uses the trick described in http://www.parashift.com/c++-faq-lite/serialization.html#faq-36.8   * for the auto-registering classes.   * @see FeaturesRegs   * @date 27/12/2005   */   HaarFeature* create()    { return new HaarFeature_3V(_shortName); }   /**   * Transform the example in integral image format, into the scalar   * output of the feature.   * @param pIntImage The array with the integral image data of the single example.   * @param r The configuration that will be used to compute the value of the   * feature.   * @date 27/12/2005   */   virtual int getValue(const int* pIntImage, const nor_utils::Rect& r);};// ------------------------------------------------------------------------------/*** Type "4 Blocs Square" feature.\verbatim For white top-left:     For black top-right:   1      2                     1      2    +-----+-----+          +-----+-----+    | [W] |  B  |          |  W  | [B] |   3+-----4-----+          +----3+-----4    |  B  |  W  |          |  B  |  W  |    +-----+-----+          +-----+-----+ For black bottom-left:  For white bottom-right:               +-----+-----+          +-----+-----+   1|  W  2  B  |          |  W 1|  B  2    +-----+-----+          +-----+-----+    | [B] |  W  |          |  B  | [W] |   3+-----4-----+          +----3+-----4\endverbatim* (W = White, B = Black)* The formula is: 4+1 - (2+3)* @date 27/12/2005*/class HaarFeature_4SQ : public HaarFeature{public:   /**   * The constructor. Defines the name, type and shape of the feature.   * @param shortName The short name of the feature.   * @date 27/12/2005   */   HaarFeature_4SQ(const string& shortName)       : HaarFeature(2, 2, shortName, "4 Blocs Square", FEATURE_4SQUARE_RECT) {}   /**   * Returns itself as object.   * @remark It uses the trick described in http://www.parashift.com/c++-faq-lite/serialization.html#faq-36.8   * for the auto-registering classes.   * @see FeaturesRegs   * @date 27/12/2005   */   HaarFeature* create()    { return new HaarFeature_4SQ(_shortName); }   /**   * Transform the example in integral image format, into the scalar   * output of the feature.   * @param pIntImage The array with the integral image data of the single example.   * @param r The configuration that will be used to compute the value of the   * feature.   * @date 27/12/2005   */   virtual int getValue(const int* pIntImage, const nor_utils::Rect& r);};// ------------------------------------------------------------------------------// ------------------------------------------------------------------------------/*** The macro that \b must be declared by all the Derived classes that can be used* as Haar-like features.* @see HaarFeature::FeaturesRegs*/#define REGISTER_HAAR_FEATURE(SHORTNAME, X) \struct RegisterHF_##X \{ RegisterHF_##X() { HaarFeature::RegisteredFeatures().addFeature(#SHORTNAME, new X(#SHORTNAME)); } }; \        static RegisterHF_##X rHF_##X;// ------------------------------------------------------------------------------} // end of namespace Multiboost#endif // __HAAR_FEATURES_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -