Ask Your Question

LBP model training using traincascade

asked 2013-02-28 08:10:39 -0600


I am trying to create several new models for objects using the LBP approach so that I could use it inside of the ViolaJones framework to detect other elements than faces.

So far I have succesfully created the vector of possitive samples, and started the training (using traincascade algorithm) with following specific parameters: numPos 35 numNeg 100 numStages 20 featureType LBP -w 36 -h 47 -minHitRate 0.995 -MaxFalseAlarmRate 0.5

It went pretty good until level 15, then each stage took a lot more time to train, which is logical as far as I see it. However, for the moment it seems to gotten stuck at level 17.

Since the algorithm only creates the final XML file after processing all stages, I was wondering if there is any way to create a temporary XML detection model based solely on the first 16 in between xml files? I could not seem to find any guidance on the internet for this problem.


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-02-28 09:54:27 -0600

berak gravatar image

updated 2013-02-28 09:58:49 -0600

oh, given you're talking about train_cascades, ad you stopped it after training 15 stages you can

  1. restart it with like -numStages 20 (if you want to continue the calculation ), or
  2. restart it with -numStages 15 to generate the cascade file for the existing 15 stages
edit flag offensive delete link more


Exactly what I was just going to post, but thanks for the advice nevertheless. Just finded it out for myself. Seems that the training wasn't stuck, stage 17 just reached the desired leaf false alarm rate. Just need to be more patient in these cases :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-02-28 09:56:50 -0600 )edit

answered 2013-02-28 09:40:54 -0600

I went a bit deeper in my search and found the following code, reffered to by this tutorial. It is for the HAAR like classifiers to create intermediate files:

#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <ctype.h>
#include <stdio.h>

static void help(void)
    printf("\n This sample demonstrates cascade's convertation \n"
    "./convert_cascade --size=\"<width>x<height>\"<convertation size> \n"
    "                   input_cascade_path \n"
    "                   output_cascade_filename\n"
    "Example: \n"
    "./convert_cascade --size=640x480 ../../opencv/data/haarcascades/haarcascade_eye.xml ../../opencv/data/haarcascades/test_cascade.xml \n"

int main( int argc, char** argv )
    const char* size_opt = "--size=";
    char comment[1024];
    CvHaarClassifierCascade* cascade = 0;
    CvSize size;


    if( argc != 4 || strncmp( argv[1], size_opt, strlen(size_opt) ) != 0 )
        return -1;

    sscanf( argv[1], "--size=%ux%u", &size.width, &size.height );
    cascade = cvLoadHaarClassifierCascade( argv[2], size );

    if( !cascade )
        fprintf( stderr, "Input cascade could not be found/opened\n" );
        return -1;

    sprintf( comment, "Automatically converted from %s, window size = %dx%d", argv[2], size.width, size.height );
    cvSave( argv[3], cascade, 0, comment, cvAttrList(0,0) );
    return 0;

#ifdef _EiC

However, even when creating a partial HAAR like model, this doesnt work. I use following command:

convert_cascade.exe -size="36x47" tempFolder output.xml

It says that the input cascade could not be found. However, the tutorial, which is referred to alot, does suggest that this should work. Anyone knows what could be the problem.

edit flag offensive delete link more

Question Tools


Asked: 2013-02-28 08:10:39 -0600

Seen: 2,490 times

Last updated: Feb 28 '13