目标跟踪之:blob_tracking 跟踪代码中文注释

opencv自带的跟踪代码位置:opencv\samples\c\blobtrack_sample.cpp
[cpp]  view plain copy
  1. #include "cvaux.h"  
  2. #include "highgui.h"  
  3. #include <stdio.h>  
  4.   
  5. /* select the correct function for doing case insensitive string comparaison */  
  6. #ifdef WIN32  
  7.   #define MY_STRNICMP strnicmp  
  8.   #define MY_STRICMP stricmp  
  9. #else  
  10.   #define MY_STRNICMP strncasecmp  
  11.   #define MY_STRICMP strcasecmp  
  12. #endif  
  13.   
  14. /* list of FG DETECTION modules */ /* FG(前景)检测模块的列表 */  
  15. static CvFGDetector* cvCreateFGDetector0(){ return cvCreateFGDetectorBase(CV_BG_MODEL_FGD, NULL);}  
  16. static CvFGDetector* cvCreateFGDetector0Simple(){ return cvCreateFGDetectorBase(CV_BG_MODEL_FGD_SIMPLE, NULL);}  
  17. static CvFGDetector* cvCreateFGDetector1(){ return cvCreateFGDetectorBase(CV_BG_MODEL_MOG, NULL);}  
  18. typedef struct DefModule_FGDetector  
  19. {  
  20.     CvFGDetector* (*create)();  
  21.     char* nickname;  
  22.     char* description;  
  23. } DefModule_FGDetector;  
  24. DefModule_FGDetector FGDetector_Modules[] =  
  25. {  
  26.     {cvCreateFGDetector0,"FG_0","Foreground Object Detection from Videos Containing Complex Background. ACM MM2003."},  
  27.     {cvCreateFGDetector0Simple,"FG_0S","Simplyfied version of FG_0"},  
  28.     {cvCreateFGDetector1,"FG_1","Adaptive background mixture models for real-time tracking. CVPR1999"},// 高斯混合模型运动目标检测  
  29.     {NULL,NULL,NULL}  
  30. };  
  31.   
  32. /* list of BLOB DETECTION modules */ /* BLOB检测模块的列表 */  
  33. typedef struct DefModule_BlobDetector  
  34. {  
  35.     CvBlobDetector* (*create)();  
  36.     char* nickname;  
  37.     char* description;  
  38. } DefModule_BlobDetector;  
  39. DefModule_BlobDetector BlobDetector_Modules[] =  
  40. {  
  41.     //{cvCreateBlobDetectorCC,"BD_CC","Detect new blob by tracking CC of FG mask"},  
  42.     {cvCreateBlobDetectorSimple,"BD_Simple","Detect new blob by uniform moving of connected components of FG mask"},  
  43.     {NULL,NULL,NULL}  
  44. };  
  45.   
  46. /* list of BLOB TRACKING modules */ /* BLOB跟踪模块的列表 */  
  47. typedef struct DefModule_BlobTracker  
  48. {  
  49.     CvBlobTracker* (*create)();  
  50.     char* nickname;  
  51.     char* description;  
  52. } DefModule_BlobTracker;  
  53. DefModule_BlobTracker BlobTracker_Modules[] =  
  54. {  
  55.     //{cvCreateBlobTrackerCCMSPF,"CCMSPF","connected component tracking and MSPF resolver for collision"},  
  56.     //{cvCreateBlobTrackerCC,"CC","Simple connected component tracking"},  
  57.     //{cvCreateBlobTrackerMS,"MS","Mean shift algorithm "},  
  58.     //{cvCreateBlobTrackerMSFG,"MSFG","Mean shift algorithm with FG mask using"},  
  59.     {cvCreateBlobTrackerMSPF,"MSPF","Particle filtering based on MS weight"},  
  60.     {NULL,NULL,NULL}  
  61. };  
  62.   
  63. /* list of BLOB TRAJECTORY GENERATION modules */ /* BLOB轨迹生成模块的列表 */  
  64. typedef struct DefModule_BlobTrackGen  
  65. {  
  66.     CvBlobTrackGen* (*create)();  
  67.     char* nickname;  
  68.     char* description;  
  69. } DefModule_BlobTrackGen;  
  70. DefModule_BlobTrackGen BlobTrackGen_Modules[] =  
  71. {  
  72.     {cvCreateModuleBlobTrackGenYML,"YML","Generate track record in YML format as synthetic video data"},  
  73.     {cvCreateModuleBlobTrackGen1,"RawTracks","Generate raw track record (x,y,sx,sy),()... in each line"},  
  74.     {NULL,NULL,NULL}  
  75. };  
  76.   
  77. /* list of BLOB TRAJECTORY POST PROCESSING modules */ /* BLOB轨迹后处理模块的列表 */  
  78. typedef struct DefModule_BlobTrackPostProc  
  79. {  
  80.     CvBlobTrackPostProc* (*create)();  
  81.     char* nickname;  
  82.     char* description;  
  83. } DefModule_BlobTrackPostProc;  
  84. DefModule_BlobTrackPostProc BlobTrackPostProc_Modules[] =  
  85. {  
  86.     {cvCreateModuleBlobTrackPostProcKalman,"Kalman","Kalman filtering of blob position and size"},  
  87.     {NULL,"None","No post processing filter"},  
  88. //    {cvCreateModuleBlobTrackPostProcTimeAverRect,"TimeAverRect","Average by time using rectangle window"},  
  89. //    {cvCreateModuleBlobTrackPostProcTimeAverExp,"TimeAverExp","Average by time using exponential window"},  
  90.     {NULL,NULL,NULL}  
  91. };  
  92.   
  93. /* list of BLOB TRAJECTORY ANALYSIS modules */ /* BLOB轨迹分析模块的列表 */  
  94. CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisDetector();  
  95.   
  96. typedef struct DefModule_BlobTrackAnalysis  
  97. {  
  98.     CvBlobTrackAnalysis* (*create)();  
  99.     char* nickname;  
  100.     char* description;  
  101. } DefModule_BlobTrackAnalysis;  
  102. DefModule_BlobTrackAnalysis BlobTrackAnalysis_Modules[] =  
  103. {  
  104.     {cvCreateModuleBlobTrackAnalysisHistPVS,"HistPVS","Histogramm of 5D feture vector analysis (x,y,vx,vy,state)"},  
  105.     {NULL,"None","No trajectory analiser"},  
  106.     {cvCreateModuleBlobTrackAnalysisHistP,"HistP","Histogramm of 2D feture vector analysis (x,y)"},  
  107.     {cvCreateModuleBlobTrackAnalysisHistPV,"HistPV","Histogramm of 4D feture vector analysis (x,y,vx,vy)"},  
  108.     {cvCreateModuleBlobTrackAnalysisHistSS,"HistSS","Histogramm of 4D feture vector analysis (startpos,endpos)"},  
  109.     {cvCreateModuleBlobTrackAnalysisTrackDist,"TrackDist","Compare tracks directly"},  
  110.     {cvCreateModuleBlobTrackAnalysisIOR,"IOR","Integrator (by OR operation) of several analysers "},  
  111.     {NULL,NULL,NULL}  
  112. };  
  113. /* list of Blob Trajectory ANALYSIS modules */ /* BLOB轨迹分析模块的列表 */  
  114. /*================= END MODULES DECRIPTION ===================================*/  
  115.   
  116. /* run pipeline on all frames */  
  117. /* 运行传递途径上的所有帧 */  
  118. static int RunBlobTrackingAuto( CvCapture* pCap, CvBlobTrackerAuto* pTracker,char* fgavi_name = NULL, char* btavi_name = NULL )  
  119. {  
  120.     int                     OneFrameProcess = 0;  
  121.     int                     key;  
  122.     int                     FrameNum = 0;  
  123.     CvVideoWriter*          pFGAvi = NULL;  
  124.     CvVideoWriter*          pBTAvi = NULL;  
  125.   
  126.     //cvNamedWindow( "FG", 0 );  
  127.   
  128.     /* main cicle */  
  129.     for( FrameNum=0; pCap && (key=cvWaitKey(OneFrameProcess?0:2))!=27;  
  130.          FrameNum++)  
  131.     { /* main cicle */  
  132.         IplImage*   pImg = NULL;  
  133.         IplImage*   pMask = NULL;  
  134.   
  135.         if(key!=-1)  
  136.         {  
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值