Lines Matching refs:model
69 static void CV_CDECL icvReleaseFGDStatModel( CvFGDStatModel** model );
71 CvFGDStatModel* model );
192 CvFGDStatModel* model = *_model;
193 if( model->pixel_stat )
195 cvFree( &model->pixel_stat[0].ctable );
196 cvFree( &model->pixel_stat[0].cctable );
197 cvFree( &model->pixel_stat );
200 cvReleaseImage( &model->Ftd );
201 cvReleaseImage( &model->Fbd );
202 cvReleaseImage( &model->foreground );
203 cvReleaseImage( &model->background );
204 cvReleaseImage( &model->prev_frame );
205 cvReleaseMemStorage(&model->storage);
324 // Function cvUpdateFGDStatModel updates statistical model and returns number of foreground regions
329 icvUpdateFGDStatModel( IplImage* curr_frame, CvFGDStatModel* model )
331 int mask_step = model->Ftd->widthStep;
333 IplImage* prev_frame = model->prev_frame;
336 int deltaC = cvRound(model->params.delta * 256 / model->params.Lc);
337 int deltaCC = cvRound(model->params.delta * 256 / model->params.Lcc);
341 cvClearMemStorage(model->storage);
342 cvZero(model->foreground);
351 cvChangeDetection( prev_frame, curr_frame, model->Ftd );
352 cvChangeDetection( model->background, curr_frame, model->Fbd );
354 for( i = 0; i < model->Ftd->height; i++ )
356 for( j = 0; j < model->Ftd->width; j++ )
358 if( ((uchar*)model->Fbd->imageData)[i*mask_step+j] || ((uchar*)model->Ftd->imageData)[i*mask_step+j] )
364 CvBGPixelStat* stat = model->pixel_stat + i * model->Ftd->width + j;
375 if( ((uchar*)model->Ftd->imageData)[i*mask_step+j] )
384 for( k = 0; PV_CC(k) > model->params.alpha2 && k < model->params.N1cc; k++ )
404 for( k = 0; PV_C(k) > model->params.alpha2 && k < model->params.N1c; k++ )
419 ((uchar*)model->foreground->imageData)[i*mask_step+j] = (uchar)(val*255);
429 if( model->params.perform_morphing ){
430 cvMorphologyEx( model->foreground, model->foreground, 0, 0, CV_MOP_OPEN, model->params.perform_morphing );
431 cvMorphologyEx( model->foreground, model->foreground, 0, 0, CV_MOP_CLOSE, model->params.perform_morphing );
435 if( model->params.minArea > 0 || model->params.is_obj_without_holes ){
439 cvFindContours( model->foreground, model->storage, &first_seq, sizeof(CvContour), CV_RETR_LIST );
443 if( cnt->rect.width * cnt->rect.height < model->params.minArea ||
444 (model->params.is_obj_without_holes && CV_IS_SEQ_HOLE(seq)) )
464 model->foreground_regions = first_seq;
465 cvZero(model->foreground);
466 cvDrawContours(model->foreground, first_seq, CV_RGB(0, 0, 255), CV_RGB(0, 0, 255), 10, -1);
470 model->foreground_regions = NULL;
474 if( ((float)FG_pixels_count/(model->Ftd->width*model->Ftd->height)) > CV_BGFG_FGD_BG_UPDATE_TRESH )
476 for( i = 0; i < model->Ftd->height; i++ )
477 for( j = 0; j < model->Ftd->width; j++ )
479 CvBGPixelStat* stat = model->pixel_stat + i * model->Ftd->width + j;
485 // Update background model:
486 for( i = 0; i < model->Ftd->height; i++ )
488 for( j = 0; j < model->Ftd->width; j++ )
490 CvBGPixelStat* stat = model->pixel_stat + i * model->Ftd->width + j;
497 if( ((uchar*)model->Ftd->imageData)[i*mask_step+j] || !stat->is_trained_dyn_model )
499 float alpha = stat->is_trained_dyn_model ? model->params.alpha2 : model->params.alpha3;
505 if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
511 for(k = 0; PV_CC(k) && k < model->params.N2cc; k++ )
543 indx = model->params.N2cc - 1;
556 if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
582 for(k = 0; PV_CC(k) && k < model->params.N1cc; k++ )
587 if( sum1 > model->params.T ) stat->is_trained_dyn_model = 1;
591 if( diff > model->params.T )
595 for( k = 0; PV_CC(k) && k < model->params.N1cc; k++ )
605 if( !((uchar*)model->Ftd->imageData)[i*mask_step+j] )
607 float alpha = stat->is_trained_st_model ? model->params.alpha2 : model->params.alpha3;
613 if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
619 for( k = 0; k < model->params.N2c; k++ )
647 indx = model->params.N2c - 1;
658 if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
683 for( k = 0; PV_C(k) && k < model->params.N1c; k++ )
689 if( sum1 > model->params.T ) stat->is_trained_st_model = 1;
692 if( diff > model->params.T )
696 for( k = 0; PV_C(k) && k < model->params.N1c; k++ )
705 if( !((uchar*)model->foreground->imageData)[i*mask_step+j])
707 uchar* ptr = ((uchar*)model->background->imageData) + i*model->background->widthStep+j*3;
709 if( !((uchar*)model->Ftd->imageData)[i*mask_step+j] &&
710 !((uchar*)model->Fbd->imageData)[i*mask_step+j] )
715 int a = cvRound(ptr[l]*(1 - model->params.alpha1) + model->params.alpha1*curr_data[l]);
717 //((uchar*)model->background->imageData)[i*model->background->widthStep+j*3+l]*=(1 - model->params.alpha1);
718 //((uchar*)model->background->imageData)[i*model->background->widthStep+j*3+l] += model->params.alpha1*curr_data[l];
726 //((uchar*)model->background->imageData)[i*model->background->widthStep+j*3+l] = curr_data[l];
735 cvCopy( curr_frame, model->prev_frame );