tags:

views:

124

answers:

1

Sorry for the confusing title, but it basically says it all. Here's the structures I'm using (found in OpenCV) :

struct CV_EXPORTS CvRTParams : public CvDTreeParams
{
    bool calc_var_importance;
    int nactive_vars;
    CvTermCriteria term_crit;

    CvRTParams() : CvDTreeParams( 5, 10, 0, false, 10, 0, false, false, 0 ),
        calc_var_importance(false), nactive_vars(0)
    {
        term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 50, 0.1 );
    }
}

and

typedef struct CvTermCriteria
{
    int    type;
    int    max_iter;
    double epsilon;
}
CvTermCriteria;

CV_INLINE  CvTermCriteria  cvTermCriteria( int type, int max_iter, double epsilon )
{
    CvTermCriteria t;

    t.type = type;
    t.max_iter = max_iter;
    t.epsilon = (float)epsilon;

    return t;
}

Now, I initialize a CvRTParams structure and set values for its members :

 CvRTParams params;
 params.max_depth = 8;
 params.min_sample_count = 10;
 params.regression_accuracy = 0;
 params.use_surrogates = false;
 params.max_categories = 10;
 params.priors = priors;
 params.calc_var_importance = true;
 params.nactive_vars = 9;
 params.term_crit.max_iter = 33;
 params.term_crit.epsilon = 0.1;
 params.term_crit.type = 3;

Then call a function of an object, taking params in as a parameter :

CvRTrees* rt = new CvRTrees;
rt->train(t, CV_ROW_SAMPLE, r, 0, 0, var_type, 0, params);

What happens now ? Values of...

params.term_crit.max_iter
params.term_crit.epsilon
params.term_crit.type

have changed ! They are no longer 33, 0.1 and 3, but something along the lines of 3, 7.05541e-313 and 4, and this, for the whole duration of the CvRtrees::train() function...

A: 

By the time I finished writing this question I found the answer. So I figured I'd post anyway if someone comes across the same problem. The code itself wasn't wrong (or at least, it wasn't completely wrong). However I am using MacOS X and apple-gcc on a ppc processor (G5). I was using the -fast flag for optimization. Removing the -fast flag (leaving only -O3) solved the problem.

Can you close the post ?
Romain Hippeau
If that's done by clicking on the check icon to turn it green, I can only do so in two days (because I answered my own question, I suppose).
reminder it has been two days - please close question.
Romain Hippeau
Have been taking some time off from work. Done. Sorry for the delay.