Move the sources to trunk
[opencv] / cvaux / include / cvvidsurv.hpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42
43 #ifndef __CVVIDEOSURVEILLANCE_H__
44 #define __CVVIDEOSURVEILLANCE_H__
45
46 /* turn off the functionality until cvaux/src/Makefile.am gets updated */
47 //#if _MSC_VER >= 1200
48
49 #include <stdio.h>
50
51 #if _MSC_VER >= 1200 || defined __BORLANDC__
52 #define cv_stricmp stricmp
53 #define cv_strnicmp strnicmp
54 #elif defined __GNUC__
55 #define cv_stricmp strcasecmp
56 #define cv_strnicmp strncasecmp
57 #else
58 #error Do not know how to make case-insensitive string comparison on this platform
59 #endif
60
61 //struct DefParam;
62 struct CvDefParam
63 {
64     struct CvDefParam*    next;
65     char*               pName;
66     char*               pComment;
67     double*             pDouble;
68     double              Double;
69     float*              pFloat;
70     float               Float;
71     int*                pInt;
72     int                 Int;
73     char**              pStr;
74     char*               Str;
75 };
76
77 class CV_EXPORTS CvVSModule
78 {
79 private: /* internal data */
80     CvDefParam*   m_pParamList;
81     char*       m_pModuleTypeName;
82     char*       m_pModuleName;
83     char*       m_pNickName;
84 protected:
85     int         m_Wnd;
86 public: /* constructor and destructor */
87     CvVSModule()
88     {
89         m_pNickName = NULL;
90         m_pParamList = NULL;
91         m_pModuleTypeName = NULL;
92         m_pModuleName = NULL;
93         m_Wnd = 0;
94         AddParam("DebugWnd",&m_Wnd);
95     }
96     virtual ~CvVSModule()
97     {
98         CvDefParam* p = m_pParamList;
99         for(;p;)
100         {
101             CvDefParam* pf = p;
102             p=p->next;
103             FreeParam(&pf);
104         }
105         m_pParamList=NULL;
106         if(m_pModuleTypeName)free(m_pModuleTypeName);
107         if(m_pModuleName)free(m_pModuleName);
108     }
109 private: /* internal functions */
110     void    FreeParam(CvDefParam** pp)
111     {
112         CvDefParam* p = pp[0];
113         if(p->Str)free(p->Str);
114         if(p->pName)free(p->pName);
115         if(p->pComment)free(p->pComment);
116         cvFree((void**)pp);
117     }
118     CvDefParam* NewParam(char* name)
119     {
120         CvDefParam* pNew = (CvDefParam*)cvAlloc(sizeof(CvDefParam));
121         memset(pNew,0,sizeof(CvDefParam));
122         pNew->pName = strdup(name);
123         if(m_pParamList==NULL)
124         {
125             m_pParamList = pNew;
126         }
127         else
128         {
129             CvDefParam* p = m_pParamList;
130             for(;p->next;p=p->next);
131             p->next = pNew;
132         }
133         return pNew;
134     };
135
136     CvDefParam* GetParamPtr(int index)
137     {
138         CvDefParam* p = m_pParamList;
139         for(;index>0 && p;index--,p=p->next);
140         return p;
141     }
142     CvDefParam* GetParamPtr(char* name)
143     {
144         CvDefParam* p = m_pParamList;
145         for(;p;p=p->next)
146         {
147             if(cv_stricmp(p->pName,name)==0) break;
148         }
149         return p;
150     }
151 protected: /* INTERNAL INTERFACE */
152     int  IsParam(char* name)
153     {
154         return GetParamPtr(name)?1:0;
155     };
156     void AddParam(char* name, double* pAddr)
157     {
158         NewParam(name)->pDouble = pAddr;
159     };
160     void AddParam(char* name, float* pAddr)
161     {
162         NewParam(name)->pFloat=pAddr;
163     };
164     void AddParam(char* name, int* pAddr)
165     {
166         NewParam(name)->pInt=pAddr;
167     };
168     void AddParam(char* name, char** pAddr)
169     {
170         CvDefParam* pP = NewParam(name);
171         char* p = pAddr?pAddr[0]:NULL;
172         pP->pStr = pAddr?pAddr:&(pP->Str);
173         if(p)
174         {
175             pP->Str = strdup(p);
176             pP->pStr[0] = pP->Str;
177         }
178     };
179     void AddParam(char* name)
180     {
181         CvDefParam* p = NewParam(name);
182         p->pDouble = &p->Double;
183     };
184     void CommentParam(char* name, char* pComment)
185     {
186         CvDefParam* p = GetParamPtr(name);
187         if(p)p->pComment = pComment ? strdup(pComment) : 0;
188     };
189     void SetTypeName(char* name){m_pModuleTypeName = strdup(name);}
190     void SetModuleName(char* name){m_pModuleName = strdup(name);}
191     void DelParam(char* name)
192     {
193         CvDefParam* p = m_pParamList;
194         CvDefParam* pPrev = NULL;
195         for(;p;p=p->next)
196         {
197             if(cv_stricmp(p->pName,name)==0) break;
198             pPrev = p;
199         }
200         if(p)
201         {
202             if(pPrev)
203             {
204                 pPrev->next = p->next;
205             }
206             else
207             {
208                 m_pParamList = p->next;
209             }
210             FreeParam(&p);
211         }
212     }/* DelParam */
213
214 public: /* EXTERNAL INTERFACE */
215     char* GetParamName(int index)
216     {
217         CvDefParam* p = GetParamPtr(index);
218         return p?p->pName:NULL;
219     }
220     char* GetParamComment(char* name)
221     {
222         CvDefParam* p = GetParamPtr(name);
223         if(p && p->pComment) return p->pComment;
224         return NULL;
225     }
226     double GetParam(char* name)
227     {
228         CvDefParam* p = GetParamPtr(name);
229         if(p)
230         {
231             if(p->pDouble) return p->pDouble[0];
232             if(p->pFloat) return p->pFloat[0];
233             if(p->pInt) return p->pInt[0];
234         }
235         return 0;
236     };
237
238     char* GetParamStr(char* name)
239     {
240         CvDefParam* p = GetParamPtr(name);
241         return p?p->Str:NULL;
242     }
243     void   SetParam(char* name, double val)
244     {
245         CvDefParam* p = m_pParamList;
246         for(;p;p=p->next)
247         {
248             if(cv_stricmp(p->pName,name) != 0) continue;
249             if(p->pDouble)p->pDouble[0] = val;
250             if(p->pFloat)p->pFloat[0] = (float)val;
251             if(p->pInt)p->pInt[0] = cvRound(val);
252         }
253     }
254     void   SetParamStr(char* name, char* str)
255     {
256         CvDefParam* p = m_pParamList;
257         for(;p;p=p->next)
258         {
259             if(cv_stricmp(p->pName,name) != 0) continue;
260             if(p->pStr)
261             {
262                 if(p->Str)free(p->Str);
263                 p->Str = NULL;
264                 if(str)p->Str = strdup(str);
265                 p->pStr[0] = p->Str;
266             }
267         }
268         /* convert to double and set */
269         if(str)SetParam(name,atof(str));
270     }
271     void TransferParamsFromChild(CvVSModule* pM, char* prefix = NULL)
272     {
273         char    tmp[1024];
274         char*   FN = NULL;
275         int i;
276         for(i=0;;++i)
277         {
278             char* N = pM->GetParamName(i);
279             if(N == NULL) break;
280             FN = N;
281             if(prefix)
282             {
283                 strcpy(tmp,prefix);
284                 strcat(tmp,"_");
285                 FN = strcat(tmp,N);
286             }
287
288             if(!IsParam(FN))
289             {
290                 if(pM->GetParamStr(N))
291                 {
292                     AddParam(FN,(char**)NULL);
293                 }
294                 else
295                 {
296                     AddParam(FN);
297                 }
298             }
299             if(pM->GetParamStr(N))
300             {
301                 char* val = pM->GetParamStr(N);
302                 SetParamStr(FN,val);
303             }
304             else
305             {
306                 double val = pM->GetParam(N);
307                 SetParam(FN,val);
308             }
309             CommentParam(FN, pM->GetParamComment(N));
310         }/* transfer next param */
311     }/* Transfer params */
312
313     void TransferParamsToChild(CvVSModule* pM, char* prefix = NULL)
314     {
315         char    tmp[1024];
316         int i;
317         for(i=0;;++i)
318         {
319             char* N = pM->GetParamName(i);
320             if(N == NULL) break;
321             if(prefix)
322             {
323                 strcpy(tmp,prefix);
324                 strcat(tmp,"_");
325                 strcat(tmp,N);
326             }
327             else
328             {
329                 strcpy(tmp,N);
330             }
331
332             if(IsParam(tmp))
333             {
334                 if(GetParamStr(tmp))
335                     pM->SetParamStr(N,GetParamStr(tmp));
336                 else
337                     pM->SetParam(N,GetParam(tmp));
338             }
339         }/* transfer next param */
340         pM->ParamUpdate();
341     }/* Transfer params */
342
343     virtual void ParamUpdate(){};
344     char*   GetTypeName()
345     {
346         return m_pModuleTypeName;
347     }
348     int     IsModuleTypeName(char* name)
349     {
350         return m_pModuleTypeName?(cv_stricmp(m_pModuleTypeName,name)==0):0;
351     }
352     char*   GetModuleName()
353     {
354         return m_pModuleName;
355     }
356     int     IsModuleName(char* name)
357     {
358         return m_pModuleName?(cv_stricmp(m_pModuleName,name)==0):0;
359     }
360     void SetNickName(char* pStr)
361     {
362
363         if(m_pNickName)
364             free(m_pNickName);
365         m_pNickName = NULL;
366         if(pStr)
367             m_pNickName = strdup(pStr);
368     }
369     char* GetNickName()
370     {
371         return m_pNickName ? m_pNickName : (char *)"unknown";
372     }
373     virtual void SaveState(CvFileStorage*){};
374     virtual void LoadState(CvFileStorage*, CvFileNode*){};
375
376     virtual void Release() = 0;
377 };/* CvVMModule */
378 void inline cvWriteStruct(CvFileStorage* fs, char* name, void* addr, char* desc, int num=1)
379 {
380     cvStartWriteStruct(fs,name,CV_NODE_SEQ|CV_NODE_FLOW);
381     cvWriteRawData(fs,addr,num,desc);
382     cvEndWriteStruct(fs);
383 }
384 void inline cvReadStructByName(CvFileStorage* fs, CvFileNode* node, char* name, void* addr, char* desc)
385 {
386     CvFileNode* pSeqNode = cvGetFileNodeByName(fs, node, name);
387     if(pSeqNode==NULL)
388     {
389         printf("WARNING!!! Can't read structure %s\n",name);
390     }
391     else
392     {
393         if(CV_NODE_IS_SEQ(pSeqNode->tag))
394         {
395             cvReadRawData( fs, pSeqNode, addr, desc );
396         }
397         else
398         {
399             printf("WARNING!!! Structure %s is not sequence and can not be read\n",name);
400         }
401     }
402 }
403
404
405 /* FOREGROUND DETECTOR INTERFACE */
406 class CV_EXPORTS CvFGDetector: public CvVSModule
407 {
408 public:
409     virtual IplImage* GetMask() = 0;
410     /* process current image */
411     virtual void    Process(IplImage* pImg) = 0;
412     /* release foreground detector */
413     virtual void    Release() = 0;
414 };
415 inline void cvReleaseFGDetector(CvFGDetector** ppT )
416 {
417     ppT[0]->Release();
418     ppT[0] = 0;
419 }
420 /* FOREGROUND DETECTOR INTERFACE */
421
422 CV_EXPORTS CvFGDetector* cvCreateFGDetectorBase(int type, void *param);
423
424
425 /* BLOB STRUCTURE*/
426 struct CvBlob
427 {
428     float   x,y; /* blob position   */
429     float   w,h; /* blob sizes      */
430     int     ID;  /* blbo ID         */     
431 };
432
433 inline CvBlob cvBlob(float x,float y, float w, float h)
434 {
435     CvBlob B = {x,y,w,h,0}; 
436     return B;
437 }
438 #define CV_BLOB_MINW 5
439 #define CV_BLOB_MINH 5
440 #define CV_BLOB_ID(pB) (((CvBlob*)(pB))->ID)
441 #define CV_BLOB_CENTER(pB) cvPoint2D32f(((CvBlob*)(pB))->x,((CvBlob*)(pB))->y)
442 #define CV_BLOB_X(pB) (((CvBlob*)(pB))->x)
443 #define CV_BLOB_Y(pB) (((CvBlob*)(pB))->y)
444 #define CV_BLOB_WX(pB) (((CvBlob*)(pB))->w)
445 #define CV_BLOB_WY(pB) (((CvBlob*)(pB))->h)
446 #define CV_BLOB_RX(pB) (0.5f*CV_BLOB_WX(pB))
447 #define CV_BLOB_RY(pB) (0.5f*CV_BLOB_WY(pB))
448 #define CV_BLOB_RECT(pB) cvRect(cvRound(((CvBlob*)(pB))->x-CV_BLOB_RX(pB)),cvRound(((CvBlob*)(pB))->y-CV_BLOB_RY(pB)),cvRound(CV_BLOB_WX(pB)),cvRound(CV_BLOB_WY(pB)))
449 /* END BLOB STRUCTURE*/
450
451
452 /* simple BLOBLIST */
453 class CV_EXPORTS CvBlobSeq
454 {
455 public:
456     CvBlobSeq(int BlobSize = sizeof(CvBlob))
457     {
458         m_pMem = cvCreateMemStorage();
459         m_pSeq = cvCreateSeq(0,sizeof(CvSeq),BlobSize,m_pMem);
460         strcpy(m_pElemFormat,"ffffi");
461     }
462     virtual ~CvBlobSeq()
463     { 
464         cvReleaseMemStorage(&m_pMem);
465     };
466     virtual CvBlob* GetBlob(int BlobIndex)
467     {
468         return (CvBlob*)cvGetSeqElem(m_pSeq,BlobIndex);
469     };
470     virtual CvBlob* GetBlobByID(int BlobID)
471     {
472         int i;
473         for(i=0;i<m_pSeq->total;++i)
474             if(BlobID == CV_BLOB_ID(GetBlob(i)))
475                 return GetBlob(i);
476         return NULL;
477     };
478     virtual void DelBlob(int BlobIndex)
479     {
480         cvSeqRemove(m_pSeq,BlobIndex);
481     };
482     virtual void DelBlobByID(int BlobID)
483     {
484         int i;
485         for(i=0;i<m_pSeq->total;++i)
486         {
487             if(BlobID == CV_BLOB_ID(GetBlob(i)))
488             {
489                 DelBlob(i);
490                 return;
491             }
492         }
493     };
494     virtual void Clear()
495     {
496         cvClearSeq(m_pSeq);
497     };
498     virtual void AddBlob(CvBlob* pB)
499     {
500         cvSeqPush(m_pSeq,pB);
501     };
502     virtual int GetBlobNum()
503     {
504         return m_pSeq->total;
505     };
506     virtual void Write(CvFileStorage* fs, char* name)
507     {
508         char*  attr[] = {"dt",m_pElemFormat,NULL};
509         if(fs)
510         {
511             cvWrite(fs,name,m_pSeq,cvAttrList((const char**)attr,NULL));
512         }
513     }
514     virtual void Load(CvFileStorage* fs, CvFileNode* node)
515     {
516         if(fs==NULL) return;
517         CvSeq* pSeq = (CvSeq*)cvRead(fs, node);
518         if(pSeq)
519         {
520             int i;
521             cvClearSeq(m_pSeq);
522             for(i=0;i<pSeq->total;++i)
523             {
524                 void* pB = cvGetSeqElem( pSeq, i );
525                 cvSeqPush( m_pSeq, pB );
526             }
527         }
528     }
529     void AddFormat(char* str){strcat(m_pElemFormat,str);}
530 protected:
531     CvMemStorage*   m_pMem;
532     CvSeq*          m_pSeq;
533     char            m_pElemFormat[1024];
534 };
535 /* simple BLOBLIST */
536
537
538 /* simple TRACKLIST */
539 struct CvBlobTrack
540 {
541     int         TrackID;
542     int         StartFrame;
543     CvBlobSeq*  pBlobSeq;
544 };
545
546 class CV_EXPORTS CvBlobTrackSeq
547 {
548 public:
549     CvBlobTrackSeq(int TrackSize = sizeof(CvBlobTrack))
550     {
551         m_pMem = cvCreateMemStorage();
552         m_pSeq = cvCreateSeq(0,sizeof(CvSeq),TrackSize,m_pMem);
553     }
554     virtual ~CvBlobTrackSeq()
555     { 
556         Clear();
557         cvReleaseMemStorage(&m_pMem);
558     };
559     virtual CvBlobTrack* GetBlobTrack(int TrackIndex)
560     {
561         return (CvBlobTrack*)cvGetSeqElem(m_pSeq,TrackIndex);
562     };
563     virtual CvBlobTrack* GetBlobTrackByID(int TrackID)
564     {
565         int i;
566         for(i=0;i<m_pSeq->total;++i)
567         {
568             CvBlobTrack* pP = GetBlobTrack(i);
569             if(pP && pP->TrackID == TrackID)
570                 return pP;
571         }
572         return NULL;
573     };
574     virtual void DelBlobTrack(int TrackIndex)
575     {
576         CvBlobTrack* pP = GetBlobTrack(TrackIndex);
577         if(pP && pP->pBlobSeq) delete pP->pBlobSeq;
578         cvSeqRemove(m_pSeq,TrackIndex);
579     };
580     virtual void DelBlobTrackByID(int TrackID)
581     {
582         int i;
583         for(i=0;i<m_pSeq->total;++i)
584         {
585             CvBlobTrack* pP = GetBlobTrack(i);
586             if(TrackID == pP->TrackID)
587             {
588                 DelBlobTrack(i);
589                 return;
590             }
591         }
592     };
593     virtual void Clear()
594     {
595         int i;
596         for(i=GetBlobTrackNum();i>0;i--)
597         {
598             DelBlobTrack(i-1);
599         }
600         cvClearSeq(m_pSeq);
601     };
602     virtual void AddBlobTrack(int TrackID, int StartFrame = 0)
603     {
604         CvBlobTrack N;
605         N.TrackID = TrackID;
606         N.StartFrame = StartFrame;
607         N.pBlobSeq = new CvBlobSeq;
608         cvSeqPush(m_pSeq,&N);
609     };
610     virtual int GetBlobTrackNum()
611     {
612         return m_pSeq->total;
613     };
614 protected:
615     CvMemStorage*   m_pMem;
616     CvSeq*          m_pSeq;
617 };
618
619 /* simple TRACKLIST */
620
621
622 /* BLOB DETECTOR INTERFACE */
623 class CV_EXPORTS CvBlobDetector: public CvVSModule
624 {
625 public:
626     /* try to detect new blob entrance based on foreground mask */
627     /* pFGMask - image of foreground mask */
628     /* pNewBlob - pointer to CvBlob structure which will bew filled if new blob entrance detected */
629     /* pOldBlobList - pointer to blob list which already exist on image */
630     virtual int DetectNewBlob(IplImage* pImg, IplImage* pImgFG, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList) = 0;
631     /* release blob detector */
632     virtual void Release()=0;
633 };
634 /* release any blob detector*/
635 inline void cvReleaseBlobDetector(CvBlobDetector** ppBD)
636 {
637     ppBD[0]->Release();
638     ppBD[0] = NULL;
639 }
640 /* END BLOB DETECTOR INTERFACE */
641
642 /* declaration of constructors of implemented modules */
643 CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorSimple();
644 CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorCC();
645
646
647 struct CV_EXPORTS CvDetectedBlob : public CvBlob
648 {
649     float response;
650 };
651
652 CV_INLINE CvDetectedBlob cvDetectedBlob( float x, float y, float w, float h, int ID = 0, float response = 0.0F )
653 {
654     CvDetectedBlob b;
655     b.x = x; b.y = y; b.w = w; b.h = h; b.ID = ID; b.response = response;
656     return b;
657 }
658
659
660 class CV_EXPORTS CvObjectDetector
661 {
662 public:
663     CvObjectDetector( const char* /*detector_file_name*/ = 0 ) {};
664     
665     ~CvObjectDetector() {};
666
667     /*
668      * Releases the current detector and loads new detector from file
669      * (if detector_file_name is not 0)
670      * Returns true on success
671      */
672     bool Load( const char* /*detector_file_name*/ = 0 ) { return false; }
673
674     /* Returns min detector window size */
675     CvSize GetMinWindowSize() const { return cvSize(0,0); }
676     
677     /* Returns max border */
678     int GetMaxBorderSize() const { return 0; }
679
680     /*
681      * Detects the objects on the image and pushes the detected
682      * blobs into <detected_blob_seq> which must be the sequence of <CvDetectedBlob>s
683      */
684     void Detect( const CvArr* /*img*/, /* out */ CvBlobSeq* /*detected_blob_seq*/ = 0 ) {};
685
686 protected:
687     class CvObjectDetectorImpl* impl;
688 };
689
690
691 CV_INLINE CvRect cvRectIntersection( const CvRect r1, const CvRect r2 )
692 {
693     CvRect r = cvRect( MAX(r1.x, r2.x), MAX(r1.y, r2.y), 0, 0 );
694
695     r.width  = MIN(r1.x + r1.width, r2.x + r2.width) - r.x;
696     r.height = MIN(r1.y + r1.height, r2.y + r2.height) - r.y;
697
698     return r;
699 }
700
701
702 /*
703  * CvImageDrawer
704  *
705  * Draws on an image the specified ROIs from the source image and
706  * given blobs as ellipses or rectangles
707  */
708
709 struct CvDrawShape
710 {
711     enum {RECT, ELLIPSE} shape;
712     CvScalar color;
713 };
714
715 /*extern const CvDrawShape icv_shape[] =
716 {
717     { CvDrawShape::ELLIPSE, CV_RGB(255,0,0) },
718     { CvDrawShape::ELLIPSE, CV_RGB(0,255,0) },
719     { CvDrawShape::ELLIPSE, CV_RGB(0,0,255) },
720     { CvDrawShape::ELLIPSE, CV_RGB(255,255,0) },
721     { CvDrawShape::ELLIPSE, CV_RGB(0,255,255) },
722     { CvDrawShape::ELLIPSE, CV_RGB(255,0,255) }
723 };*/
724
725 class CV_EXPORTS CvImageDrawer
726 {
727 public:
728     CvImageDrawer() : m_image(0) {}
729     ~CvImageDrawer() { cvReleaseImage( &m_image ); }
730     void SetShapes( const CvDrawShape* shapes, int num );
731     /* <blob_seq> must be the sequence of <CvDetectedBlob>s */
732     IplImage* Draw( const CvArr* src, CvBlobSeq* blob_seq = 0, const CvSeq* roi_seq = 0 );
733     IplImage* GetImage() { return m_image; }
734 protected:
735     //static const int MAX_SHAPES = sizeof(icv_shape) / sizeof(icv_shape[0]);;
736
737     IplImage* m_image;    
738     CvDrawShape m_shape[16];
739 };
740
741
742
743 /* Trajectory generation module */
744 class CV_EXPORTS CvBlobTrackGen: public CvVSModule
745 {
746 public:
747     virtual void    SetFileName(char* pFileName) = 0;
748     virtual void    AddBlob(CvBlob* pBlob) = 0;
749     virtual void    Process(IplImage* pImg = NULL, IplImage* pFG = NULL) = 0;
750     virtual void    Release() = 0;
751 };
752
753 inline void cvReleaseBlobTrackGen(CvBlobTrackGen** pBTGen)
754 {
755     if(*pBTGen)(*pBTGen)->Release();
756     *pBTGen = 0;
757 }
758
759 /* declaration of constructors of implemented modules */
760 CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGen1();
761 CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGenYML();
762
763
764
765 /* BLOB TRACKER INTERFACE */
766 class CV_EXPORTS CvBlobTracker: public CvVSModule
767 {
768 public:
769     CvBlobTracker(){SetTypeName("BlobTracker");};
770     /* Add new blob to track it and assign to this blob personal ID */
771     /* pBlob - pinter to structure with blob parameters (ID is ignored)*/
772     /* pImg - current image */
773     /* pImgFG - current foreground mask */
774     /* return pointer to new added blob */
775     virtual CvBlob* AddBlob(CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG = NULL ) = 0;
776     /* return number of currently tracked blobs */
777     virtual int     GetBlobNum() = 0;
778     /* return pointer to specified by index blob */
779     virtual CvBlob* GetBlob(int BlobIndex) = 0;
780     
781     /* delete blob by its index */
782     virtual void    DelBlob(int BlobIndex) = 0;
783     /* process current image and track all existed blobs */
784     virtual void    Process(IplImage* pImg, IplImage* pImgFG = NULL) = 0;
785     /* release blob tracker */
786     virtual void    Release() = 0;
787
788
789     /* Process on blob (for multi hypothesis tracing) */
790     virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL)
791     {
792         CvBlob* pB;
793         int ID = 0;
794         assert(pBlob);
795         //pBlob->ID;
796         pB = GetBlob(BlobIndex);
797         if(pB)
798             pBlob[0] = pB[0];
799         pBlob->ID = ID;
800     };
801     /* get confidence/wieght/probability (0-1) for blob */
802     virtual double  GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL)
803     {
804         return 1;
805     };
806     virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL)
807     {
808         int     b,bN = pBlobList->GetBlobNum();
809         double  W = 1;
810         for(b=0;b<bN;++b)
811         {
812             CvBlob* pB = pBlobList->GetBlob(b);
813             int     BI = GetBlobIndexByID(pB->ID);
814             W *= GetConfidence(BI,pB,pImg,pImgFG);
815         }
816         return W;
817     };
818     virtual void UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
819     /* update all blob models */
820     virtual void Update(IplImage* pImg, IplImage* pImgFG = NULL)
821     {
822         int i;
823         for(i=GetBlobNum();i>0;i--)
824         {
825             CvBlob* pB=GetBlob(i-1);
826             UpdateBlob(i-1, pB, pImg, pImgFG);
827         }
828
829     };
830
831     /* return pinter to blob by its unique ID */
832     virtual int     GetBlobIndexByID(int BlobID)
833     {
834         int i;
835         for(i=GetBlobNum();i>0;i--)
836         {
837             CvBlob* pB=GetBlob(i-1);
838             if(CV_BLOB_ID(pB) == BlobID) return i-1;
839         }
840         return -1;
841     };
842     /* return pinter to blob by its unique ID */
843     virtual CvBlob* GetBlobByID(int BlobID){return GetBlob(GetBlobIndexByID(BlobID));};
844     /* delete blob by its ID */
845     virtual void    DelBlobByID(int BlobID){DelBlob(GetBlobIndexByID(BlobID));};
846     /* Set new parameters for specified (by index) blob */
847     virtual void    SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/){};
848     /* Set new parameters for specified (by ID) blob */
849     virtual void    SetBlobByID(int BlobID, CvBlob* pBlob)
850     {
851         SetBlob(GetBlobIndexByID(BlobID),pBlob);
852     };
853
854     /*  ===============  MULTI HYPOTHESIS INTERFACE ==================  */
855     /* return number of position hyposetis of currently tracked blob */
856     virtual int     GetBlobHypNum(int /*BlobIdx*/){return 1;};
857     /* return pointer to specified blob hypothesis by index blob */
858     virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/){return GetBlob(BlobIndex);};
859     /* Set new parameters for specified (by index) blob hyp (can be called several times for each hyp )*/
860     virtual void    SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/){};
861 };
862 inline void cvReleaseBlobTracker(CvBlobTracker**ppT )
863 {
864     ppT[0]->Release();
865     ppT[0] = 0;
866 }
867 /* BLOB TRACKER INTERFACE */
868
869 /*BLOB TRACKER ONE INTERFACE */
870 class CV_EXPORTS CvBlobTrackerOne:public CvVSModule
871 {
872 public:
873     virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
874     virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
875     virtual void Release() =  0;
876     /*not required methods */
877     virtual void SkipProcess(CvBlob* /*pBlobPrev*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
878     virtual void Update(CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
879     virtual void SetCollision(int /*CollisionFlag*/){}; /* call in case of blob collision situation*/
880     virtual double GetConfidence(CvBlob* /*pBlob*/, IplImage* /*pImg*/,
881                                  IplImage* /*pImgFG*/ = NULL, IplImage* /*pImgUnusedReg*/ = NULL)
882     {
883         return 1;
884     };
885 };
886 inline void cvReleaseBlobTrackerOne(CvBlobTrackerOne **ppT )
887 {
888     ppT[0]->Release();
889     ppT[0] = 0;
890 }
891 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerList(CvBlobTrackerOne* (*create)());
892 /*BLOB TRACKER ONE INTERFACE */
893
894 /* declaration of constructors of implemented modules */
895
896 /* some declaration for specific MeanShift tracker */
897 #define PROFILE_EPANECHNIKOV    0
898 #define PROFILE_DOG             1
899 struct CvBlobTrackerParamMS
900 {
901     int     noOfSigBits;
902     int     appearance_profile;
903     int     meanshift_profile;
904     float   sigma;
905 };
906
907 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1(CvBlobTrackerParamMS* param);
908 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS2(CvBlobTrackerParamMS* param);
909 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1ByList();
910
911 /* some declaration for specific Liklyhood tracker */
912 struct CvBlobTrackerParamLH
913 {
914     int     HistType; /* see Prob.h */
915     int     ScaleAfter;
916 };
917
918 /* no scale optimization */
919 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHR(CvBlobTrackerParamLH* /*param*/ = NULL);
920 /* scale optimization */
921 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHRS(CvBlobTrackerParamLH* /*param*/ = NULL);
922
923 /* simple blob tracker based on connected component tracking */
924 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCC();
925 /* connected component tracking and MSPF resolver for collision */
926 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCCMSPF();
927 /* blob tracker that integrate MS and CC */
928 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFG();
929 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFGS();
930 /* MS without CC */
931 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS();
932 /* particle filtering using bahata... coefficient */
933 CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSPF();
934
935 /* =========== tracker integrators trackers =============*/
936 /* integrator based on Partical Filtering method */
937 //CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPF();
938 /* rule based integrator */
939 //CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIRB();
940 /* integrator based on data fusion used particle filtering */
941 //CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPFDF();
942
943
944
945
946 /* Trajectory postprocessing module */
947 class CV_EXPORTS CvBlobTrackPostProc: public CvVSModule
948 {
949 public:
950     virtual void    AddBlob(CvBlob* pBlob) = 0;
951     virtual void    Process() = 0;
952     virtual int     GetBlobNum() = 0;
953     virtual CvBlob* GetBlob(int index) = 0;
954     virtual void    Release() = 0;
955
956     /* additional functionality */
957     virtual CvBlob* GetBlobByID(int BlobID)
958     {
959         int i;
960         for(i=GetBlobNum();i>0;i--)
961         {
962             CvBlob* pB=GetBlob(i-1);
963             if(pB->ID==BlobID) return pB;
964         }
965         return NULL;
966     };
967 };
968
969 inline void cvReleaseBlobTrackPostProc(CvBlobTrackPostProc** pBTPP)
970 {
971     if(pBTPP == NULL) return;
972     if(*pBTPP)(*pBTPP)->Release();
973     *pBTPP = 0;
974 }
975
976 /* Trajectory generation module */
977 class CV_EXPORTS CvBlobTrackPostProcOne: public CvVSModule
978 {
979 public:
980     virtual CvBlob* Process(CvBlob* pBlob) = 0;
981     virtual void    Release() = 0;
982 };
983 /* create blob traking post processing module based on simle module */
984 CV_EXPORTS CvBlobTrackPostProc* cvCreateBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)());
985
986
987 /* declaration of constructors of implemented modules */
988 CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcKalman();
989 CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverRect();
990 CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverExp();
991
992
993 /* PREDICTORS */
994 /* blob PREDICTOR */
995 class CvBlobTrackPredictor: public CvVSModule
996 {
997 public:
998     virtual CvBlob* Predict() = 0;
999     virtual void    Update(CvBlob* pBlob) = 0;
1000     virtual void    Release() = 0;
1001 };
1002 CV_EXPORTS CvBlobTrackPredictor* cvCreateModuleBlobTrackPredictKalman();
1003
1004
1005
1006 /* Trajectory analyser module */
1007 class CV_EXPORTS CvBlobTrackAnalysis: public CvVSModule
1008 {
1009 public:
1010     virtual void    AddBlob(CvBlob* pBlob) = 0;
1011     virtual void    Process(IplImage* pImg, IplImage* pFG) = 0;
1012     virtual float   GetState(int BlobID) = 0;
1013     /* return 0 if trajectory is normal
1014        return >0 if trajectory abnormal */
1015     virtual char*   GetStateDesc(int /*BlobID*/){return NULL;};
1016     virtual void    SetFileName(char* /*DataBaseName*/){};
1017     virtual void    Release() = 0;
1018 };
1019
1020
1021 inline void cvReleaseBlobTrackAnalysis(CvBlobTrackAnalysis** pBTPP)
1022 {
1023     if(pBTPP == NULL) return;
1024     if(*pBTPP)(*pBTPP)->Release();
1025     *pBTPP = 0;
1026 }
1027
1028 /* feature vector generation module */
1029 class CV_EXPORTS CvBlobTrackFVGen : public CvVSModule
1030 {
1031 public:
1032     virtual void    AddBlob(CvBlob* pBlob) = 0;
1033     virtual void    Process(IplImage* pImg, IplImage* pFG) = 0;
1034     virtual void    Release() = 0;
1035     virtual int     GetFVSize() = 0;
1036     virtual int     GetFVNum() = 0;
1037     virtual float*  GetFV(int index, int* pFVID) = 0; /* pointer to FV, if return 0 then FV does not created */
1038     virtual float*  GetFVVar(){return NULL;}; /* returned pointer to array of variation of values of FV, if return 0 then FVVar is not exist */
1039     virtual float*  GetFVMin() = 0; /* returned pointer to array of minimal values of FV, if return 0 then FVrange is not exist */
1040     virtual float*  GetFVMax() = 0; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
1041 };
1042
1043
1044 /* Trajectory Analyser module */
1045 class CV_EXPORTS CvBlobTrackAnalysisOne
1046 {
1047 public:
1048     virtual ~CvBlobTrackAnalysisOne() {};
1049     virtual int     Process(CvBlob* pBlob, IplImage* pImg, IplImage* pFG) = 0;
1050     /* return 0 if trajectory is normal
1051        return >0 if trajectory abnormal */
1052     virtual void    Release() = 0;
1053 };
1054
1055 /* create blob traking post processing module based on simle module */
1056 CV_EXPORTS CvBlobTrackAnalysis* cvCreateBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)());
1057
1058 /* declaration of constructors of implemented modules */
1059 /* based on histogramm analysis of 2D FV (x,y)*/
1060 CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistP();
1061 /* based on histogramm analysis of 4D FV (x,y,vx,vy)*/
1062 CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPV();
1063 /* based on histogramm analysis of 5D FV (x,y,vx,vy,state)*/
1064 CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPVS();
1065 /* based on histogramm analysis of 4D FV (startpos,stoppos)*/
1066 CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistSS();
1067
1068 /* based on SVM classifier analysis of 2D FV (x,y)*/
1069 //CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMP();
1070 /* based on SVM classifier analysis of 4D FV (x,y,vx,vy)*/
1071 //CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPV();
1072 /* based on SVM classifier analysis of 5D FV (x,y,vx,vy,state)*/
1073 //CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPVS();
1074 /* based on SVM classifier analysis of 4D FV (startpos,stoppos)*/
1075 //CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMSS();
1076
1077 /* track analysis based on distance between tracks */
1078 CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisTrackDist();
1079
1080 /* analizer based on reation Road and height map*/
1081 //CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysis3DRoadMap();
1082
1083 /* analizer that make OR desicion using set of analizers */
1084 CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisIOR();
1085
1086 /* estimator of human height */
1087 class CV_EXPORTS CvBlobTrackAnalysisHeight: public CvBlobTrackAnalysis
1088 {
1089 public:
1090     virtual double  GetHeight(CvBlob* pB) = 0;
1091 }; 
1092 //CV_EXPORTS CvBlobTrackAnalysisHeight* cvCreateModuleBlobTrackAnalysisHeightScale();
1093
1094
1095
1096 /* AUTO BLOB TRACKER INTERFACE - pipeline of 3 modules */
1097 class CV_EXPORTS CvBlobTrackerAuto: public CvVSModule
1098 {
1099 public:
1100     virtual void        Process(IplImage* pImg, IplImage* pMask = NULL) = 0;
1101     virtual CvBlob*     GetBlob(int index) = 0;
1102     virtual CvBlob*     GetBlobByID(int ID) = 0;
1103     virtual int         GetBlobNum() = 0;
1104     virtual IplImage*   GetFGMask(){return NULL;};
1105     virtual float       GetState(int BlobID) = 0;
1106     virtual char*       GetStateDesc(int BlobID) = 0;
1107     /* return 0 if trajectory is normal
1108        return >0 if trajectory abnormal */
1109     virtual void    Release() = 0;
1110 };
1111 inline void cvReleaseBlobTrackerAuto(CvBlobTrackerAuto** ppT)
1112 {
1113     ppT[0]->Release();
1114     ppT[0] = 0;
1115 }
1116 /* END AUTO BLOB TRACKER INTERFACE */
1117
1118
1119 /* creation function and data for specific BlobTRackerAuto modules */
1120 /* parameters of blobtracker auto ver1 */
1121 struct CvBlobTrackerAutoParam1
1122 {
1123     int                     FGTrainFrames; /* number of frames are needed for FG detector to train */
1124     CvFGDetector*           pFG; /* FGDetector module, if this filed is NULL the Process FG mask is used */
1125     CvBlobDetector*         pBD; /* existed blob detector module
1126                                 if this filed is NULL default blobdetector module will be created */
1127     CvBlobTracker*          pBT; /* existed blob tracking module
1128                                 if this filed is NULL default blobtracker module will be created */
1129     CvBlobTrackGen*         pBTGen; /* existed blob trajectory generator,
1130                                 if this filed is NULL no any generator is used */
1131     CvBlobTrackPostProc*    pBTPP; /* existed blob trajectory postprocessing module
1132                                 if this filed is NULL no any postprocessing is used */
1133     int                     UsePPData;
1134     CvBlobTrackAnalysis*    pBTA; /* existed blob trajectory analysis module */
1135                                   /* if this filed is NULL no any analysis is made */
1136 };
1137
1138 /* create blob tracker auto ver1 */
1139 CV_EXPORTS CvBlobTrackerAuto* cvCreateBlobTrackerAuto1(CvBlobTrackerAutoParam1* param = NULL);
1140
1141 /* simple loader for many auto trackers by its type  */
1142 inline CvBlobTrackerAuto* cvCreateBlobTrackerAuto(int type, void* param)
1143 {
1144     if(type == 0) return cvCreateBlobTrackerAuto1((CvBlobTrackerAutoParam1*)param);
1145     return 0;
1146 }
1147
1148
1149
1150 struct CvTracksTimePos
1151 {
1152     int len1,len2;
1153     int beg1,beg2;
1154     int end1,end2;
1155     int comLen; //common length for two tracks
1156     int shift1,shift2;
1157 };
1158
1159 /*CV_EXPORTS int cvCompareTracks( CvBlobTrackSeq *groundTruth,
1160                    CvBlobTrackSeq *result,
1161                    FILE *file);*/
1162
1163
1164 /*  Create functions  */
1165
1166 CV_EXPORTS void cvCreateTracks_One(CvBlobTrackSeq *TS);
1167 CV_EXPORTS void cvCreateTracks_Same(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2);
1168 CV_EXPORTS void cvCreateTracks_AreaErr(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2, int addW, int addH);
1169
1170
1171 /* HIST API */
1172 class CV_EXPORTS CvProb
1173 {
1174 public:
1175     virtual ~CvProb() {};
1176     /* calculate probability value */ 
1177     virtual double Value(int* /*comp*/, int /*x*/ = 0, int /*y*/ = 0){return -1;};
1178     /* update histograpp Pnew = (1-W)*Pold + W*Padd*/
1179     /* W weight of new added prob */
1180     /* comps - matrix of new fetature vectors used to update prob */
1181     virtual void AddFeature(float W, int* comps, int x =0, int y = 0) = 0;
1182     virtual void Scale(float factor = 0, int x = -1, int y = -1) = 0;
1183     virtual void Release() = 0;
1184 };
1185 inline void cvReleaseProb(CvProb** ppProb){ppProb[0]->Release();ppProb[0]=NULL;}
1186 /* HIST API */
1187
1188 /* some Prob */
1189 CV_EXPORTS CvProb* cvCreateProbS(int dim, CvSize size, int sample_num);
1190 CV_EXPORTS CvProb* cvCreateProbMG(int dim, CvSize size, int sample_num);
1191 CV_EXPORTS CvProb* cvCreateProbMG2(int dim, CvSize size, int sample_num);
1192 CV_EXPORTS CvProb* cvCreateProbHist(int dim, CvSize size);
1193
1194 #define CV_BT_HIST_TYPE_S     0
1195 #define CV_BT_HIST_TYPE_MG    1
1196 #define CV_BT_HIST_TYPE_MG2   2
1197 #define CV_BT_HIST_TYPE_H     3
1198 inline CvProb* cvCreateProb(int type, int dim, CvSize size = cvSize(1,1), void* /*param*/ = NULL)
1199 {
1200     if(type == CV_BT_HIST_TYPE_S) return cvCreateProbS(dim, size, -1);
1201     if(type == CV_BT_HIST_TYPE_MG) return cvCreateProbMG(dim, size, -1);
1202     if(type == CV_BT_HIST_TYPE_MG2) return cvCreateProbMG2(dim, size, -1);
1203     if(type == CV_BT_HIST_TYPE_H) return cvCreateProbHist(dim, size);
1204     return NULL;
1205 }
1206
1207
1208
1209 /* noise types defenition */
1210 #define CV_NOISE_NONE               0
1211 #define CV_NOISE_GAUSSIAN           1
1212 #define CV_NOISE_UNIFORM            2
1213 #define CV_NOISE_SPECKLE            3
1214 #define CV_NOISE_SALT_AND_PEPPER    4
1215 /* Add some noise to image */
1216 /* pImg - (input) image without noise */
1217 /* pImg - (output) image with noise */
1218 /* noise_type - type of added noise */
1219 /*  CV_NOISE_GAUSSIAN - pImg += n , n - is gaussian noise with Ampl standart deviation */
1220 /*  CV_NOISE_UNIFORM - pImg += n , n - is uniform noise with Ampl standart deviation */
1221 /*  CV_NOISE_SPECKLE - pImg += n*pImg , n - is gaussian noise with Ampl standart deviation */
1222 /*  CV_NOISE_SALT_AND_PAPPER - pImg = pImg with blacked and whited pixels, 
1223             Ampl is density of brocken pixels (0-there are not broken pixels, 1 - all pixels are broken)*/
1224 /* Ampl - "amplitude" of noise */                                
1225 CV_EXPORTS void cvAddNoise(IplImage* pImg, int noise_type, double Ampl, CvRandState* rnd_state = NULL);
1226
1227 /*================== GENERATOR OF TEST VIDEO SEQUENCE ===================== */
1228 typedef void CvTestSeq;
1229
1230 /* pConfigfile - name of file (yml or xml) with description of test sequence */
1231 /* videos - array of names of test videos described in "pConfigfile" file */
1232 /* numvideos - size of "videos" array */
1233 CV_EXPORTS CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float Scale = 1, int noise_type = CV_NOISE_NONE, double noise_ampl = 0);
1234 CV_EXPORTS void cvReleaseTestSeq(CvTestSeq** ppTestSeq);
1235
1236 /* generete next frame from test video seq and return pointer to it */
1237 CV_EXPORTS IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq);
1238 /* return pointer to current foreground mask */
1239 CV_EXPORTS IplImage* cvTestSeqGetFGMask(CvTestSeq* pTestSeq);
1240 /* return pointer to current image */
1241 CV_EXPORTS IplImage* cvTestSeqGetImage(CvTestSeq* pTestSeq);
1242 /* return frame size of result test video */
1243 CV_EXPORTS CvSize cvTestSeqGetImageSize(CvTestSeq* pTestSeq);
1244 /* return number of frames result test video */
1245 CV_EXPORTS int cvTestSeqFrameNum(CvTestSeq* pTestSeq);
1246
1247 /* return number of existed objects 
1248  this is general number of any objects. 
1249 for example number of trajectories may be equal or less than returned value*/
1250 CV_EXPORTS int cvTestSeqGetObjectNum(CvTestSeq* pTestSeq);
1251
1252 /* return 0 if there is not position for current defined on current frame */
1253 /* return 1 if there is object position and pPos was filled */
1254 CV_EXPORTS int cvTestSeqGetObjectPos(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pPos);
1255 CV_EXPORTS int cvTestSeqGetObjectSize(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pSize);
1256
1257 /* add noise to finile image */
1258 CV_EXPORTS void cvTestSeqAddNoise(CvTestSeq* pTestSeq, int noise_type = CV_NOISE_NONE, double noise_ampl = 0);
1259 /* add Intensity variation */
1260 CV_EXPORTS void cvTestSeqAddIntensityVariation(CvTestSeq* pTestSeq, float DI_per_frame, float MinI, float MaxI);
1261 CV_EXPORTS void cvTestSeqSetFrame(CvTestSeq* pTestSeq, int n);
1262
1263 #endif
1264
1265 /* End of file. */