Lines Matching refs:cascade
128 CvHaarClassifierCascade* cascade = 0;
134 int block_size = sizeof(*cascade) + stage_count*sizeof(*cascade->stage_classifier);
139 CV_CALL( cascade = (CvHaarClassifierCascade*)cvAlloc( block_size ));
140 memset( cascade, 0, block_size );
142 cascade->stage_classifier = (CvHaarStageClassifier*)(cascade + 1);
143 cascade->flags = CV_HAAR_MAGIC_VAL;
144 cascade->count = stage_count;
148 return cascade;
156 CvHidHaarClassifierCascade* cascade = *_cascade;
157 if( cascade->ipp_stages && icvHaarClassifierFree_32f_p )
160 for( i = 0; i < cascade->count; i++ )
162 if( cascade->ipp_stages[i] )
163 icvHaarClassifierFree_32f_p( cascade->ipp_stages[i] );
166 cvFree( &cascade->ipp_stages );
171 /* create more efficient internal representation of haar classifier cascade */
173 icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
196 if( !CV_IS_HAAR_CLASSIFIER(cascade) )
197 CV_ERROR( !cascade ? CV_StsNullPtr : CV_StsBadArg, "Invalid classifier pointer" );
199 if( cascade->hid_cascade )
202 if( !cascade->stage_classifier )
205 if( cascade->count <= 0 )
206 CV_ERROR( CV_StsOutOfRange, "Negative number of cascade stages" );
208 orig_window_size = cascade->orig_window_size;
211 internal representation of the classifier cascade */
212 for( i = 0; i < cascade->count; i++ )
214 CvHaarStageClassifier* stage_classifier = cascade->stage_classifier + i;
252 "the reference (original) cascade window", k, j, i );
261 // this is an upper boundary for the whole hidden cascade size
263 sizeof(CvHidHaarStageClassifier)*cascade->count +
272 out->count = cascade->count;
274 haar_classifier_ptr = (CvHidHaarClassifier*)(out->stage_classifier + cascade->count);
282 for( i = 0; i < cascade->count; i++ )
284 CvHaarStageClassifier* stage_classifier = cascade->stage_classifier + i;
347 int ipp_datasize = cascade->count*sizeof(out->ipp_stages[0]);
361 for( i = 0; i < cascade->count; i++ )
363 CvHaarStageClassifier* stage_classifier = cascade->stage_classifier + i;
388 if( i < cascade->count )
398 cascade->hid_cascade = out;
441 CvHidHaarClassifierCascade* cascade;
470 cascade = _cascade->hid_cascade;
472 if( cascade->has_tilted_features )
486 cascade->tilted = *tilted;
493 cascade->sum = *sum;
494 cascade->sqsum = *sqsum;
500 cascade->inv_window_area = weight_scale;
502 cascade->p0 = sum_elem_ptr(*sum, equ_rect.y, equ_rect.x);
503 cascade->p1 = sum_elem_ptr(*sum, equ_rect.y, equ_rect.x + equ_rect.width );
504 cascade->p2 = sum_elem_ptr(*sum, equ_rect.y + equ_rect.height, equ_rect.x );
505 cascade->p3 = sum_elem_ptr(*sum, equ_rect.y + equ_rect.height,
508 cascade->pq0 = sqsum_elem_ptr(*sqsum, equ_rect.y, equ_rect.x);
509 cascade->pq1 = sqsum_elem_ptr(*sqsum, equ_rect.y, equ_rect.x + equ_rect.width );
510 cascade->pq2 = sqsum_elem_ptr(*sqsum, equ_rect.y + equ_rect.height, equ_rect.x );
511 cascade->pq3 = sqsum_elem_ptr(*sqsum, equ_rect.y + equ_rect.height,
524 for( j = 0; j < cascade->stage_classifier[i].count; j++ )
526 for( l = 0; l < cascade->stage_classifier[i].classifier[j].count; l++ )
531 cascade->stage_classifier[i].classifier + j; */
533 &cascade->stage_classifier[i].classifier[j].node[l].feature;
700 CvHidHaarClassifierCascade* cascade;
703 CV_ERROR( !_cascade ? CV_StsNullPtr : CV_StsBadArg, "Invalid cascade pointer" );
705 cascade = _cascade->hid_cascade;
706 if( !cascade )
707 CV_ERROR( CV_StsNullPtr, "Hidden cascade has not been created.\n"
711 pt.x + _cascade->real_window_size.width >= cascade->sum.width-2 ||
712 pt.y + _cascade->real_window_size.height >= cascade->sum.height-2 )
715 p_offset = pt.y * (cascade->sum.step/sizeof(sumtype)) + pt.x;
716 pq_offset = pt.y * (cascade->sqsum.step/sizeof(sqsumtype)) + pt.x;
717 mean = calc_sum(*cascade,p_offset)*cascade->inv_window_area;
718 variance_norm_factor = cascade->pq0[pq_offset] - cascade->pq1[pq_offset] -
719 cascade->pq2[pq_offset] + cascade->pq3[pq_offset];
720 variance_norm_factor = variance_norm_factor*cascade->inv_window_area - mean*mean;
726 if( cascade->is_tree )
732 ptr = cascade->stage_classifier;
760 else if( cascade->is_stump_based )
762 for( i = start_stage; i < cascade->count; i++ )
766 if( cascade->stage_classifier[i].two_rects )
768 for( j = 0; j < cascade->stage_classifier[i].count; j++ )
770 CvHidHaarClassifier* classifier = cascade->stage_classifier[i].classifier + j;
784 for( j = 0; j < cascade->stage_classifier[i].count; j++ )
786 CvHidHaarClassifier* classifier = cascade->stage_classifier[i].classifier + j;
802 if( stage_sum < cascade->stage_classifier[i].threshold )
811 for( i = start_stage; i < cascade->count; i++ )
815 for( j = 0; j < cascade->stage_classifier[i].count; j++ )
818 cascade->stage_classifier[i].classifier + j,
822 if( stage_sum < cascade->stage_classifier[i].threshold )
857 CvHaarClassifierCascade* cascade,
883 if( !CV_IS_HAAR_CLASSIFIER(cascade) )
884 CV_ERROR( !cascade ? CV_StsNullPtr : CV_StsBadArg, "Invalid classifier cascade" );
904 if( !cascade->hid_cascade )
905 CV_CALL( icvCreateHidHaarClassifierCascade(cascade) );
907 if( cascade->hid_cascade->has_tilted_features )
937 CvSize win_size0 = cascade->orig_window_size;
938 int use_ipp = cascade->hid_cascade->ipp_stages != 0 &&
991 cvSetImagesForHaarClassifierCascade( cascade, &sum1, &sqsum1, 0, 1. );
1036 for( j = 0; j < cascade->count; j++ )
1042 cascade->hid_cascade->stage_classifier[j].threshold,
1043 cascade->hid_cascade->ipp_stages[j]) < 0 )
1058 cvRunHaarClassifierCascade( cascade, cvPoint(x,y), 0 ) > 0;
1103 if( (unsigned)split_stage >= (unsigned)cascade->count ||
1104 cascade->hid_cascade->is_tree )
1106 split_stage = cascade->count;
1111 factor*cascade->orig_window_size.width < img->cols - 10 &&
1112 factor*cascade->orig_window_size.height < img->rows - 10;
1128 CvSize win_size = { cvRound( cascade->orig_window_size.width * factor ),
1129 cvRound( cascade->orig_window_size.height * factor )};
1145 cvSetImagesForHaarClassifierCascade( cascade, sum, sqsum, tilted, factor );
1180 cascade->hid_cascade->count = split_stage;
1215 result = cvRunHaarClassifierCascade( cascade, cvPoint(ix,iy), 0 );
1231 int result = cvRunHaarClassifierCascade( cascade, cvPoint(ix,iy),
1246 stage_offset = cascade->hid_cascade->count;
1247 cascade->hid_cascade->count = cascade->count;
1539 CvHaarClassifierCascade* cascade = icvCreateHaarClassifierCascade(n);
1540 cascade->orig_window_size = orig_window_size;
1557 cascade->stage_classifier[i].count = count;
1558 cascade->stage_classifier[i].classifier =
1559 (CvHaarClassifier*)cvAlloc( count*sizeof(cascade->stage_classifier[i].classifier[0]));
1563 CvHaarClassifier* classifier = cascade->stage_classifier[i].classifier + j;
1624 cascade->stage_classifier[i].threshold = threshold;
1634 cascade->stage_classifier[i].parent = parent;
1635 cascade->stage_classifier[i].next = next;
1636 cascade->stage_classifier[i].child = -1;
1638 if( parent != -1 && cascade->stage_classifier[parent].child == -1 )
1640 cascade->stage_classifier[parent].child = i;
1644 return cascade;
1655 CvHaarClassifierCascade *cascade = 0;
1687 CV_CALL( cascade = (CvHaarClassifierCascade*)cvLoad( directory ));
1714 cascade = icvLoadCascadeCART( input_cascade, n, orig_window_size );
1722 cvReleaseHaarClassifierCascade( &cascade );
1724 return cascade;
1734 CvHaarClassifierCascade* cascade = *_cascade;
1736 for( i = 0; i < cascade->count; i++ )
1738 for( j = 0; j < cascade->stage_classifier[i].count; j++ )
1739 cvFree( &cascade->stage_classifier[i].classifier[j].haar_feature );
1740 cvFree( &cascade->stage_classifier[i].classifier );
1742 icvReleaseHidHaarClassifierCascade( &cascade->hid_cascade );
1778 CvHaarClassifierCascade* cascade = NULL;
1798 CV_CALL( cascade = icvCreateHaarClassifierCascade(n) );
1807 cascade->orig_window_size.width = fn->data.i;
1811 cascade->orig_window_size.height = fn->data.i;
1835 CV_CALL( cascade->stage_classifier[i].classifier =
1837 * sizeof( cascade->stage_classifier[i].classifier[0] ) ) );
1840 cascade->stage_classifier[i].classifier[j].haar_feature = NULL;
1842 cascade->stage_classifier[i].count = trees_fn->data.seq->total;
1852 classifier = &cascade->stage_classifier[i].classifier[j];
1938 || r.x + fn->data.i > cascade->orig_window_size.width )
1948 || r.y + fn->data.i > cascade->orig_window_size.height )
2088 cascade->stage_classifier[i].threshold = (float) fn->data.f;
2095 || fn->data.i < -1 || fn->data.i >= cascade->count )
2103 || fn->data.i < -1 || fn->data.i >= cascade->count )
2110 cascade->stage_classifier[i].parent = parent;
2111 cascade->stage_classifier[i].next = next;
2112 cascade->stage_classifier[i].child = -1;
2114 if( parent != -1 && cascade->stage_classifier[parent].child == -1 )
2116 cascade->stage_classifier[parent].child = i;
2126 cvReleaseHaarClassifierCascade( &cascade );
2127 cascade = NULL;
2130 return cascade;
2143 const CvHaarClassifierCascade* cascade = (const CvHaarClassifierCascade*) struct_ptr;
2150 CV_CALL( cvWriteInt( fs, NULL, cascade->orig_window_size.width ) );
2151 CV_CALL( cvWriteInt( fs, NULL, cascade->orig_window_size.height ) );
2155 for( i = 0; i < cascade->count; ++i )
2163 for( j = 0; j < cascade->stage_classifier[i].count; ++j )
2165 CvHaarClassifier* tree = &cascade->stage_classifier[i].classifier[j];
2234 cascade->stage_classifier[i].threshold) );
2237 cascade->stage_classifier[i].parent ) );
2239 cascade->stage_classifier[i].next ) );
2253 CvHaarClassifierCascade* cascade = NULL;
2264 CV_CALL( cascade = icvCreateHaarClassifierCascade(n) );
2265 cascade->orig_window_size = cascade_src->orig_window_size;
2269 cascade->stage_classifier[i].parent = cascade_src->stage_classifier[i].parent;
2270 cascade->stage_classifier[i].next = cascade_src->stage_classifier[i].next;
2271 cascade->stage_classifier[i].child = cascade_src->stage_classifier[i].child;
2272 cascade->stage_classifier[i].threshold = cascade_src->stage_classifier[i].threshold;
2274 cascade->stage_classifier[i].count = 0;
2275 CV_CALL( cascade->stage_classifier[i].classifier =
2277 * sizeof( cascade->stage_classifier[i].classifier[0] ) ) );
2279 cascade->stage_classifier[i].count = cascade_src->stage_classifier[i].count;
2281 for( j = 0; j < cascade->stage_classifier[i].count; ++j )
2283 cascade->stage_classifier[i].classifier[j].haar_feature = NULL;
2286 for( j = 0; j < cascade->stage_classifier[i].count; ++j )
2291 &cascade->stage_classifier[i].classifier[j];
2319 return cascade;