资源描述:
《opencv码本(codebook)背景模型》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、//结构体定义typedefstructCvBGCodeBookElem{structCvBGCodeBookElem*next;inttLastUpdate;intstale;ucharboxMin[3];ucharboxMax[3];ucharlearnMin[3];ucharlearnMax[3];}CvBGCodeBookElem;typedefstructCvBGCodeBookModel{CvSizesize;intt;ucharcbBounds[3];ucharmodMin[3];ucharmod
2、Max[3];CvBGCodeBookElem**cbmap;CvMemStorage*storage;CvBGCodeBookElem*freeList;}CvBGCodeBookModel;CvBGCodeBookModel*cvCreateBGCodeBookModel(){CvBGCodeBookModel*model=(CvBGCodeBookModel*)cvAlloc(sizeof(*model));memset(model,0,sizeof(*model));model->cbBounds[0]
3、=model->cbBounds[1]=model->cbBounds[2]=10;model->modMin[0]=3;model->modMax[0]=10;model->modMin[1]=model->modMin[2]=1;model->modMax[1]=model->modMax[2]=1;model->storage=cvCreateMemStorage();returnmodel;}voidcvReleaseBGCodeBookModel(CvBGCodeBookModel**model){i
4、f(model&&*model){cvReleaseMemStorage(&(*model)->storage);memset(*model,0,sizeof(**model));otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWes
5、tNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecret
6、ary,MinistersandcvFree(model);}}staticucharsatTab8u[768];#undefSAT_8U#defineSAT_8U(x)satTab8u[(x)+255]staticvoidicvInitSatTab(){staticintinitialized=0;if(!initialized){for(inti=0;i<768;i++){intv=i-255;satTab8u[i]=(uchar)(v<0?0:v>255?255:v);}initialized=1;}}v
7、oidcvBGCodeBookUpdate(CvBGCodeBookModel*model,constCvArr*_image,CvRectroi=cvRect(0,0,0,0),constCvArr*_mask=0){CV_FUNCNAME("cvBGCodeBookUpdate");__BEGIN__;CvMatstub,*image=cvGetMat(_image,&stub);CvMatmstub,*mask=_mask?cvGetMat(_mask,&mstub):0;inti,x,y,T;intnb
8、locks;ucharcb0,cb1,cb2;CvBGCodeBookElem*freeList;CV_ASSERT(model&&CV_MAT_TYPE(image->type)==CV_8UC3&&(!mask
9、
10、(CV_IS_MASK_ARR(mask)&&CV_ARE_SIZES_EQ(image,mask))));if(roi.x==0&&roi.y==0&&roi.widt