LBP train_cascade number of features

asked 2016-09-05 12:24:22 -0500

zvone gravatar image

When I train my classifier using opencv_traincascade by using local binary pattern (LBP), I get this written on console :

Number of unique features given windowSize [50,28] : 51408

How is this number calculated? I found code on GitHub, but did not manage to understand it :

void CvLBPEvaluator::generateFeatures()
{
    int offset = winSize.width + 1;
    for( int x = 0; x < winSize.width; x++ )
        for( int y = 0; y < winSize.height; y++ )
            for( int w = 1; w <= winSize.width / 3; w++ )
                for( int h = 1; h <= winSize.height / 3; h++ )
                    if ( (x+3*w <= winSize.width) && (y+3*h <= winSize.height) )
                         features.push_back( Feature(offset, x, y, w, h ) );
    numFeatures = (int)features.size();
}
edit retag flag offensive close merge delete

Comments

Basically it tells you how many unique LBP feature locations are calculated for a single window given the window size.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-09 06:50:20 -0500 )edit

Yeah, I know that, but don't understand this piece of code. For example, why are winSize.width and winSize.height divided by 3?

zvone gravatar imagezvone ( 2016-09-10 06:00:39 -0500 )edit

That is mathematics to respect the LBP features grid ... if you need even more detail, take paper and pen, and start writing down the whole process on a sample image.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-12 04:04:16 -0500 )edit