cvEvalCARTClassifier结构体的内容在cvboost.cpp文件里面,具体内容如下:
CV_BOOST_IMPL float cvEvalCARTClassifier( CvClassifier* classifier, CvMat* sample ) { CV_FUNCNAME( "cvEvalCARTClassifier" ); int idx = 0; __BEGIN__; CV_ASSERT( classifier != NULL ); CV_ASSERT( sample != NULL ); CV_ASSERT( CV_MAT_TYPE( sample->type ) == CV_32FC1 ); CV_ASSERT( sample->rows == 1 || sample->cols == 1 ); if( sample->rows == 1 ) { do { if( (CV_MAT_ELEM( (*sample), float, 0, ((CvCARTClassifier*) classifier)->compidx[idx] )) < ((CvCARTClassifier*) classifier)->threshold[idx] ) { idx = ((CvCARTClassifier*) classifier)->left[idx]; } else { idx = ((CvCARTClassifier*) classifier)->right[idx]; } } while( idx > 0 ); } else { do { if( (CV_MAT_ELEM( (*sample), float, ((CvCARTClassifier*) classifier)->compidx[idx], 0 )) < ((CvCARTClassifier*) classifier)->threshold[idx] ) { idx = ((CvCARTClassifier*) classifier)->left[idx]; } else { idx = ((CvCARTClassifier*) classifier)->right[idx]; } } while( idx > 0 ); } __END__; return ((CvCARTClassifier*) classifier)->val[-idx]; }
时间: 2024-11-29 07:14:30