Next we will start to parse the Haar Feature Extraction Algorithm:
In this algorithm, Haar features are divided into six sub-features. The code and analysis are as follows:
The sub-Calculation of the six Haar feature descriptions is as follows. Next we will analyze the application of the Haar feature:
// Generate Haar feature vector 192 dimension 32*6 = 192 dimension void haarfeatures: generatesystematic () {float X [] = {0.2f, 0.4f, 0.6f, 0.8f }; float y [] = {0.2f, 0.4f, 0.6f, 0.8f}; float s [] = {0.2f, 0.4f}; For (INT Iy = 0; Iy <4; ++ Iy) // obtain the number in X [], the window coefficient {for (int ix = 0; ix <4; ++ IX) // obtain the number in Y, window coefficient {for (Int Is = 0; is <2; ++ is) // returns the number in S, window coefficient {floatrect R (X [ix]-s [is]/2, Y [Iy]-s [is]/2, s [is], s [is]); // obtains the window size. A total of 32 for (INT it = 0; it <6; ++ it) // It is the sub-type of Haar feature description (6 in total) {m_features.push_back (haarfeature (R, It) ;}}}} void haarfeatures :: updatefeaturevector (const sample & S) {for (INT I = 0; I <m_featurecount; ++ I) {// normalize m_featvec [I] = m_features [I]. eval (s );}}