diff options
author | Antoine Villeret <avilleret@users.sourceforge.net> | 2013-10-08 10:13:50 +0000 |
---|---|---|
committer | Antoine Villeret <avilleret@users.sourceforge.net> | 2013-10-08 10:13:50 +0000 |
commit | 85bce3dd5d03302a34206b8205da0f5aa6489241 (patch) | |
tree | 1fe38913f3c910019672b963486ac2b2ba9195ea /blobtrack.cpp | |
parent | 0dc9321bdf97b1327d37c11af62b0e0aeb06ab14 (diff) |
delete unneeded source
svn path=/trunk/externals/pix_opencv/; revision=17217
Diffstat (limited to 'blobtrack.cpp')
-rw-r--r-- | blobtrack.cpp | 247 |
1 files changed, 0 insertions, 247 deletions
diff --git a/blobtrack.cpp b/blobtrack.cpp deleted file mode 100644 index 5015034..0000000 --- a/blobtrack.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * OpenCV 2.3 - blobtrack_sample.cpp ported to Gem by Antoine Villeret - 2012 -*/ - -#include "blobtrack.h" - -/* List of Blob Trajectory ANALYSIS modules: */ -/*================= END MODULES DECRIPTION ===================================*/ - -/* Run pipeline on all frames: */ -int RunBlobTrackingAuto( CvCapture* pCap, CvBlobTrackerAuto* pTracker,char* fgavi_name = NULL, char* btavi_name = NULL ) -{ - int OneFrameProcess = 0; - int key; - int FrameNum = 0; - CvVideoWriter* pFGAvi = NULL; - CvVideoWriter* pBTAvi = NULL; - - //cvNamedWindow( "FG", 0 ); - - /* Main loop: */ - for( FrameNum=0; pCap && (key=cvWaitKey(OneFrameProcess?0:1))!=27; - FrameNum++) - { /* Main loop: */ - IplImage* pImg = NULL; - IplImage* pMask = NULL; - - if(key!=-1) - { - OneFrameProcess = 1; - if(key=='r')OneFrameProcess = 0; - } - - pImg = cvQueryFrame(pCap); - if(pImg == NULL) break; - - - /* Process: */ - pTracker->Process(pImg, pMask); - - if(fgavi_name) - if(pTracker->GetFGMask()) - { /* Debug FG: */ - IplImage* pFG = pTracker->GetFGMask(); - CvSize S = cvSize(pFG->width,pFG->height); - static IplImage* pI = NULL; - - if(pI==NULL)pI = cvCreateImage(S,pFG->depth,3); - cvCvtColor( pFG, pI, CV_GRAY2BGR ); - - if(fgavi_name) - { /* Save fg to avi file: */ - if(pFGAvi==NULL) - { - pFGAvi=cvCreateVideoWriter( - fgavi_name, - CV_FOURCC('x','v','i','d'), - 25, - S ); - } - cvWriteFrame( pFGAvi, pI ); - } - - if(pTracker->GetBlobNum()>0) - { /* Draw detected blobs: */ - int i; - for(i=pTracker->GetBlobNum();i>0;i--) - { - CvBlob* pB = pTracker->GetBlob(i-1); - CvPoint p = cvPointFrom32f(CV_BLOB_CENTER(pB)); - CvSize s = cvSize(MAX(1,cvRound(CV_BLOB_RX(pB))), MAX(1,cvRound(CV_BLOB_RY(pB)))); - int c = cvRound(255*pTracker->GetState(CV_BLOB_ID(pB))); - cvEllipse( pI, - p, - s, - 0, 0, 360, - CV_RGB(c,255-c,0), cvRound(1+(3*c)/255) ); - } /* Next blob: */; - } - - cvNamedWindow( "FG",0); - cvShowImage( "FG",pI); - } /* Debug FG. */ - - - /* Draw debug info: */ - if(pImg) - { /* Draw all information about test sequence: */ - char str[1024]; - int line_type = CV_AA; // Change it to 8 to see non-antialiased graphics. - CvFont font; - int i; - IplImage* pI = cvCloneImage(pImg); - - cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, 0.7, 0.7, 0, 1, line_type ); - - for(i=pTracker->GetBlobNum(); i>0; i--) - { - CvSize TextSize; - CvBlob* pB = pTracker->GetBlob(i-1); - CvPoint p = cvPoint(cvRound(pB->x*256),cvRound(pB->y*256)); - CvSize s = cvSize(MAX(1,cvRound(CV_BLOB_RX(pB)*256)), MAX(1,cvRound(CV_BLOB_RY(pB)*256))); - int c = cvRound(255*pTracker->GetState(CV_BLOB_ID(pB))); - - cvEllipse( pI, - p, - s, - 0, 0, 360, - CV_RGB(c,255-c,0), cvRound(1+(3*0)/255), CV_AA, 8 ); - - p.x >>= 8; - p.y >>= 8; - s.width >>= 8; - s.height >>= 8; - sprintf(str,"%03d",CV_BLOB_ID(pB)); - cvGetTextSize( str, &font, &TextSize, NULL ); - p.y -= s.height; - cvPutText( pI, str, p, &font, CV_RGB(0,255,255)); - { - const char* pS = pTracker->GetStateDesc(CV_BLOB_ID(pB)); - - if(pS) - { - char* pStr = strdup(pS); - char* pStrFree = pStr; - - while (pStr && strlen(pStr) > 0) - { - char* str_next = strchr(pStr,'\n'); - - if(str_next) - { - str_next[0] = 0; - str_next++; - } - - p.y += TextSize.height+1; - cvPutText( pI, pStr, p, &font, CV_RGB(0,255,255)); - pStr = str_next; - } - free(pStrFree); - } - } - - } /* Next blob. */; - - cvNamedWindow( "Tracking", 0); - cvShowImage( "Tracking",pI ); - - if(btavi_name && pI) - { /* Save to avi file: */ - CvSize S = cvSize(pI->width,pI->height); - if(pBTAvi==NULL) - { - pBTAvi=cvCreateVideoWriter( - btavi_name, - CV_FOURCC('x','v','i','d'), - 25, - S ); - } - cvWriteFrame( pBTAvi, pI ); - } - - cvReleaseImage(&pI); - } /* Draw all information about test sequence. */ - } /* Main loop. */ - - if(pFGAvi)cvReleaseVideoWriter( &pFGAvi ); - if(pBTAvi)cvReleaseVideoWriter( &pBTAvi ); - return 0; -} /* RunBlobTrackingAuto */ - -/* Read parameters from command line - * and transfer to specified module: - */ -void set_params(int argc, char* argv[], CvVSModule* pM, const char* prefix, const char* module) -{ - int prefix_len = strlen(prefix); - int i; - for(i=0; i<argc; ++i) - { - int j; - char* ptr_eq = NULL; - int cmd_param_len=0; - char* cmd = argv[i]; - if(MY_STRNICMP(prefix,cmd,prefix_len)!=0) continue; - cmd += prefix_len; - if(cmd[0]!=':')continue; - cmd++; - - ptr_eq = strchr(cmd,'='); - if(ptr_eq)cmd_param_len = ptr_eq-cmd; - - for(j=0; ; ++j) - { - int param_len; - const char* param = pM->GetParamName(j); - if(param==NULL) break; - param_len = strlen(param); - if(cmd_param_len!=param_len) continue; - if(MY_STRNICMP(param,cmd,param_len)!=0) continue; - cmd+=param_len; - if(cmd[0]!='=')continue; - cmd++; - pM->SetParamStr(param,cmd); - printf("%s:%s param set to %g\n",module,param,pM->GetParam(param)); - } - } - - pM->ParamUpdate(); - -} /* set_params */ - -/* Print all parameter values for given module: */ -void print_params(CvVSModule* pM, const char* module, const char* log_name) -{ - FILE* log = log_name?fopen(log_name,"at"):NULL; - int i; - if(pM->GetParamName(0) == NULL ) return; - - - printf("%s(%s) module parameters:\n",module,pM->GetNickName()); - if(log) - fprintf(log,"%s(%s) module parameters:\n",module,pM->GetNickName()); - - for (i=0; ; ++i) - { - const char* param = pM->GetParamName(i); - const char* str = param?pM->GetParamStr(param):NULL; - if(param == NULL)break; - if(str) - { - printf(" %s: %s\n",param,str); - if(log) - fprintf(log," %s: %s\n",param,str); - } - else - { - printf(" %s: %g\n",param,pM->GetParam(param)); - if(log) - fprintf(log," %s: %g\n",param,pM->GetParam(param)); - } - } - - if(log) fclose(log); - -} /* print_params */ |