Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok, I stepped through the source code and found the error.

 for( i = 0; i < sample_count; i++ )
{
    int idx = map ? map[i] : i;
    assert( (unsigned)idx < (unsigned)sample_all );
    if( r_type == CV_32SC1 )
        dst[i] = srci[idx*r_step];
    else
    {
        float rf = srcfl[idx*r_step];
        int ri = cvRound(rf);
        if( ri != rf )
        {
            char buf[100];
            sprintf( buf, "response #%d is not integral", idx );
            CV_ERROR( CV_StsBadArg, buf );
        }
        dst[i] = ri;
    }
    response_ptr[i] = dst + i;
}

What I find kind of strange is that they get a float value float rf = srcfl[idx*r_step], then round it to an int and then compare the int and the float. I mean, float and int comparison in general is not good. Im not sure if this is a bug or supposed to be like that. If your training_label_matrix was of type CV_32SC1 you wouldnt have that issue, but I dont know if thats even useful. Im not familiar with machine learning.