读分类器代码如opencv 所写
for( i = 0; i < cascade->count; i++ )
{
AeeHaarStageClassifier* stage_classifier = cascade->stage_classifier + i;
if( !stage_classifier->classifier ||
stage_classifier->count <= 0 )
{
sprintf( errorstr, "header of the stage classifier #%d is invalid "
"(has null pointers or non-positive classfier count)", i );
return 0;
}
max_count = MAX( max_count, stage_classifier->count );
total_classifiers += stage_classifier->count;
for( j = 0; j < stage_classifier->count; j++ )
{
AeeHaarClassifier* classifier = stage_classifier->classifier + j;
total_nodes += classifier->count;
for( l = 0; l < classifier->count; l++ )
{
for( k = 0; k < CV_HAAR_FEATURE_MAX; k++ )
{
if( classifier->haar_feature[l].rect[k].r.width )
{
CvRect r = classifier->haar_feature[l].rect[k].r;
int tilted = classifier->haar_feature[l].tilted;
has_tilted_features |= tilted != 0;
if( r.width < 0 || r.height < 0 || r.y < 0 ||
r.x + r.width > orig_window_size.width
||
(!tilted &&
(r.x < 0 || r.y + r.height > orig_window_size.height))
||
(tilted && (r.x - r.height < 0 ||
r.y + r.width + r.height > orig_window_size.height)))
{
sprintf( errorstr, "rectangle #%d of the classifier #%d of "
"the stage classifier #%d is not inside "
"the reference (original) cascade window", k, j, i );
return 0;
}
}
}
}
}
}
/*
2 //总数total_classifiers1//节点数total_nodes
2//rects 矩形数
8 19 6 6 0 -1 //&r.x, &r.y,&r.width, &r.height, &band, &(haar_feature.rect[k].weight) 说明分别为 矩形位置信息 和权值
11 19 3 6 0 2
haar_x2
3.213411e-003 0 -1
9.187203e-001 -9.739195e-001
1
2
3 21 8 3 0 -1
5 21 4 3 0 2
haar_x4
1.327998e-003 0 -1
7.252102e-001 -9.750153e-001
-2.487092e-001
12
-1
*/