⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cvvidsurv.hpp

📁 Simple ellipse fitting example on C++Builder6 + OpenCV1.0.
💻 HPP
📖 第 1 页 / 共 3 页
字号:
    virtual void    DelBlobByID(int BlobID){DelBlob(GetBlobIndexByID(BlobID));};
    /* Set new parameters for specified (by index) blob */
    virtual void    SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/){};
    /* Set new parameters for specified (by ID) blob */
    virtual void    SetBlobByID(int BlobID, CvBlob* pBlob)
    {
        SetBlob(GetBlobIndexByID(BlobID),pBlob);
    };

    /*  ===============  MULTI HYPOTHESIS INTERFACE ==================  */
    /* return number of position hyposetis of currently tracked blob */
    virtual int     GetBlobHypNum(int /*BlobIdx*/){return 1;};
    /* return pointer to specified blob hypothesis by index blob */
    virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/){return GetBlob(BlobIndex);};
    /* Set new parameters for specified (by index) blob hyp (can be called several times for each hyp )*/
    virtual void    SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/){};
};
inline void cvReleaseBlobTracker(CvBlobTracker**ppT )
{
    ppT[0]->Release();
    ppT[0] = 0;
}
/* BLOB TRACKER INTERFACE */

/*BLOB TRACKER ONE INTERFACE */
class CV_EXPORTS CvBlobTrackerOne:public CvVSModule
{
public:
    virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
    virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
    virtual void Release() =  0;
    /*not required methods */
    virtual void SkipProcess(CvBlob* /*pBlobPrev*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
    virtual void Update(CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
    virtual void SetCollision(int /*CollisionFlag*/){}; /* call in case of blob collision situation*/
    virtual double GetConfidence(CvBlob* /*pBlob*/, IplImage* /*pImg*/,
                                 IplImage* /*pImgFG*/ = NULL, IplImage* /*pImgUnusedReg*/ = NULL)
    {
        return 1;
    };
};
inline void cvReleaseBlobTrackerOne(CvBlobTrackerOne **ppT )
{
    ppT[0]->Release();
    ppT[0] = 0;
}
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerList(CvBlobTrackerOne* (*create)());
/*BLOB TRACKER ONE INTERFACE */

/* declaration of constructors of implemented modules */

/* some declaration for specific MeanShift tracker */
#define PROFILE_EPANECHNIKOV    0
#define PROFILE_DOG             1
struct CvBlobTrackerParamMS
{
    int     noOfSigBits;
    int     appearance_profile;
    int     meanshift_profile;
    float   sigma;
};

CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1(CvBlobTrackerParamMS* param);
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS2(CvBlobTrackerParamMS* param);
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1ByList();

/* some declaration for specific Liklyhood tracker */
struct CvBlobTrackerParamLH
{
    int     HistType; /* see Prob.h */
    int     ScaleAfter;
};

/* no scale optimization */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHR(CvBlobTrackerParamLH* /*param*/ = NULL);
/* scale optimization */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHRS(CvBlobTrackerParamLH* /*param*/ = NULL);

/* simple blob tracker based on connected component tracking */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCC();
/* connected component tracking and MSPF resolver for collision */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCCMSPF();
/* blob tracker that integrate MS and CC */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFG();
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFGS();
/* MS without CC */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS();
/* particle filtering using bahata... coefficient */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSPF();

/* =========== tracker integrators trackers =============*/
/* integrator based on Partical Filtering method */
//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPF();
/* rule based integrator */
//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIRB();
/* integrator based on data fusion used particle filtering */
//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPFDF();




/* Trajectory postprocessing module */
class CV_EXPORTS CvBlobTrackPostProc: public CvVSModule
{
public:
    virtual void    AddBlob(CvBlob* pBlob) = 0;
    virtual void    Process() = 0;
    virtual int     GetBlobNum() = 0;
    virtual CvBlob* GetBlob(int index) = 0;
    virtual void    Release() = 0;

    /* additional functionality */
    virtual CvBlob* GetBlobByID(int BlobID)
    {
        int i;
        for(i=GetBlobNum();i>0;i--)
        {
            CvBlob* pB=GetBlob(i-1);
            if(pB->ID==BlobID) return pB;
        }
        return NULL;
    };
};

inline void cvReleaseBlobTrackPostProc(CvBlobTrackPostProc** pBTPP)
{
    if(pBTPP == NULL) return;
    if(*pBTPP)(*pBTPP)->Release();
    *pBTPP = 0;
}

/* Trajectory generation module */
class CV_EXPORTS CvBlobTrackPostProcOne: public CvVSModule
{
public:
    virtual CvBlob* Process(CvBlob* pBlob) = 0;
    virtual void    Release() = 0;
};
/* create blob traking post processing module based on simle module */
CV_EXPORTS CvBlobTrackPostProc* cvCreateBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)());


/* declaration of constructors of implemented modules */
CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcKalman();
CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverRect();
CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverExp();


/* PREDICTORS */
/* blob PREDICTOR */
class CvBlobTrackPredictor: public CvVSModule
{
public:
    virtual CvBlob* Predict() = 0;
    virtual void    Update(CvBlob* pBlob) = 0;
    virtual void    Release() = 0;
};
CV_EXPORTS CvBlobTrackPredictor* cvCreateModuleBlobTrackPredictKalman();



/* Trajectory analyser module */
class CV_EXPORTS CvBlobTrackAnalysis: public CvVSModule
{
public:
    virtual void    AddBlob(CvBlob* pBlob) = 0;
    virtual void    Process(IplImage* pImg, IplImage* pFG) = 0;
    virtual float   GetState(int BlobID) = 0;
    /* return 0 if trajectory is normal
       return >0 if trajectory abnormal */
    virtual char*   GetStateDesc(int /*BlobID*/){return NULL;};
    virtual void    SetFileName(char* /*DataBaseName*/){};
    virtual void    Release() = 0;
};


inline void cvReleaseBlobTrackAnalysis(CvBlobTrackAnalysis** pBTPP)
{
    if(pBTPP == NULL) return;
    if(*pBTPP)(*pBTPP)->Release();
    *pBTPP = 0;
}

/* feature vector generation module */
class CV_EXPORTS CvBlobTrackFVGen : public CvVSModule
{
public:
    virtual void    AddBlob(CvBlob* pBlob) = 0;
    virtual void    Process(IplImage* pImg, IplImage* pFG) = 0;
    virtual void    Release() = 0;
    virtual int     GetFVSize() = 0;
    virtual int     GetFVNum() = 0;
    virtual float*  GetFV(int index, int* pFVID) = 0; /* pointer to FV, if return 0 then FV does not created */
    virtual float*  GetFVVar(){return NULL;}; /* returned pointer to array of variation of values of FV, if return 0 then FVVar is not exist */
    virtual float*  GetFVMin() = 0; /* returned pointer to array of minimal values of FV, if return 0 then FVrange is not exist */
    virtual float*  GetFVMax() = 0; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
};


/* Trajectory Analyser module */
class CV_EXPORTS CvBlobTrackAnalysisOne
{
public:
    virtual ~CvBlobTrackAnalysisOne() {};
    virtual int     Process(CvBlob* pBlob, IplImage* pImg, IplImage* pFG) = 0;
    /* return 0 if trajectory is normal
       return >0 if trajectory abnormal */
    virtual void    Release() = 0;
};

/* create blob traking post processing module based on simle module */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)());

/* declaration of constructors of implemented modules */
/* based on histogramm analysis of 2D FV (x,y)*/
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistP();
/* based on histogramm analysis of 4D FV (x,y,vx,vy)*/
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPV();
/* based on histogramm analysis of 5D FV (x,y,vx,vy,state)*/
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPVS();
/* based on histogramm analysis of 4D FV (startpos,stoppos)*/
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistSS();

/* based on SVM classifier analysis of 2D FV (x,y)*/
//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMP();
/* based on SVM classifier analysis of 4D FV (x,y,vx,vy)*/
//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPV();
/* based on SVM classifier analysis of 5D FV (x,y,vx,vy,state)*/
//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPVS();
/* based on SVM classifier analysis of 4D FV (startpos,stoppos)*/
//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMSS();

/* track analysis based on distance between tracks */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisTrackDist();

/* analizer based on reation Road and height map*/
//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysis3DRoadMap();

/* analizer that make OR desicion using set of analizers */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisIOR();

/* estimator of human height */
class CV_EXPORTS CvBlobTrackAnalysisHeight: public CvBlobTrackAnalysis
{
public:
    virtual double  GetHeight(CvBlob* pB) = 0;
}; 
//CV_EXPORTS CvBlobTrackAnalysisHeight* cvCreateModuleBlobTrackAnalysisHeightScale();



/* AUTO BLOB TRACKER INTERFACE - pipeline of 3 modules */
class CV_EXPORTS CvBlobTrackerAuto: public CvVSModule
{
public:
    virtual void        Process(IplImage* pImg, IplImage* pMask = NULL) = 0;
    virtual CvBlob*     GetBlob(int index) = 0;
    virtual CvBlob*     GetBlobByID(int ID) = 0;
    virtual int         GetBlobNum() = 0;
    virtual IplImage*   GetFGMask(){return NULL;};
    virtual float       GetState(int BlobID) = 0;
    virtual char*       GetStateDesc(int BlobID) = 0;
    /* return 0 if trajectory is normal
       return >0 if trajectory abnormal */
    virtual void    Release() = 0;
};
inline void cvReleaseBlobTrackerAuto(CvBlobTrackerAuto** ppT)
{
    ppT[0]->Release();
    ppT[0] = 0;
}
/* END AUTO BLOB TRACKER INTERFACE */


/* creation function and data for specific BlobTRackerAuto modules */
/* parameters of blobtracker auto ver1 */
struct CvBlobTrackerAutoParam1
{
    int                     FGTrainFrames; /* number of frames are needed for FG detector to train */
    CvFGDetector*           pFG; /* FGDetector module, if this filed is NULL the Process FG mask is used */
    CvBlobDetector*         pBD; /* existed blob detector module
                                if this filed is NULL default blobdetector module will be created */
    CvBlobTracker*          pBT; /* existed blob tracking module
                                if this filed is NULL default blobtracker module will be created */
    CvBlobTrackGen*         pBTGen; /* existed blob trajectory generator,
                                if this filed is NULL no any generator is used */
    CvBlobTrackPostProc*    pBTPP; /* existed blob trajectory postprocessing module
                                if this filed is NULL no any postprocessing is used */
    int                     UsePPData;
    CvBlobTrackAnalysis*    pBTA; /* existed blob trajectory analysis module */
                                  /* if this filed is NULL no any analysis is made */
};

/* create blob tracker auto ver1 */
CV_EXPORTS CvBlobTrackerAuto* cvCreateBlobTrackerAuto1(CvBlobTrackerAutoParam1* param = NULL);

/* simple loader for many auto trackers by its type  */
inline CvBlobTrackerAuto* cvCreateBlobTrackerAuto(int type, void* param)
{
    if(type == 0) return cvCreateBlobTrackerAuto1((CvBlobTrackerAutoParam1*)param);
    return 0;
}



struct CvTracksTimePos
{
    int len1,len2;
    int beg1,beg2;
    int end1,end2;
    int comLen; //common length for two tracks
    int shift1,shift2;
};

/*CV_EXPORTS int cvCompareTracks( CvBlobTrackSeq *groundTruth,
                   CvBlobTrackSeq *result,
                   FILE *file);*/


/*  Create functions  */

CV_EXPORTS void cvCreateTracks_One(CvBlobTrackSeq *TS);
CV_EXPORTS void cvCreateTracks_Same(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2);
CV_EXPORTS void cvCreateTracks_AreaErr(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2, int addW, int addH);


/* HIST API */
class CV_EXPORTS CvProb
{
public:
    virtual ~CvProb() {};
    /* calculate probability value */ 
    virtual double Value(int* /*comp*/, int /*x*/ = 0, int /*y*/ = 0){return -1;};
    /* update histograpp Pnew = (1-W)*Pold + W*Padd*/
    /* W weight of new added prob */
    /* comps - matrix of new fetature vectors used to update prob */
    virtual void AddFeature(float W, int* comps, int x =0, int y = 0) = 0;
    virtual void Scale(float factor = 0, int x = -1, int y = -1) = 0;
    virtual void Release() = 0;
};
inline void cvReleaseProb(CvProb** ppProb){ppProb[0]->Release();ppProb[0]=NULL;}
/* HIST API */

/* some Prob */
CV_EXPORTS CvProb* cvCreateProbS(int dim, CvSize size, int sample_num);
CV_EXPORTS CvProb* cvCreateProbMG(int dim, CvSize size, int sample_num);
CV_EXPORTS CvProb* cvCreateProbMG2(int dim, CvSize size, int sample_num);
CV_EXPORTS CvProb* cvCreateProbHist(int dim, CvSize size);

#define CV_BT_HIST_TYPE_S     0
#define CV_BT_HIST_TYPE_MG    1
#define CV_BT_HIST_TYPE_MG2   2
#define CV_BT_HIST_TYPE_H     3
inline CvProb* cvCreateProb(int type, int dim, CvSize size = cvSize(1,1), void* /*param*/ = NULL)
{
    if(type == CV_BT_HIST_TYPE_S) return cvCreateProbS(dim, size, -1);
    if(type == CV_BT_HIST_TYPE_MG) return cvCreateProbMG(dim, size, -1);
    if(type == CV_BT_HIST_TYPE_MG2) return cvCreateProbMG2(dim, size, -1);
    if(type == CV_BT_HIST_TYPE_H) return cvCreateProbHist(dim, size);
    return NULL;
}



/* noise types defenition */
#define CV_NOISE_NONE               0
#define CV_NOISE_GAUSSIAN           1
#define CV_NOISE_UNIFORM            2
#define CV_NOISE_SPECKLE            3
#define CV_NOISE_SALT_AND_PEPPER    4
/* Add some noise to image */
/* pImg - (input) image without noise */
/* pImg - (output) image with noise */
/* noise_type - type of added noise */
/*  CV_NOISE_GAUSSIAN - pImg += n , n - is gaussian noise with Ampl standart deviation */
/*  CV_NOISE_UNIFORM - pImg += n , n - is uniform noise with Ampl standart deviation */
/*  CV_NOISE_SPECKLE - pImg += n*pImg , n - is gaussian noise with Ampl standart deviation */
/*  CV_NOISE_SALT_AND_PAPPER - pImg = pImg with blacked and whited pixels, 
            Ampl is density of brocken pixels (0-there are not broken pixels, 1 - all pixels are broken)*/
/* Ampl - "amplitude" of noise */                                
CV_EXPORTS void cvAddNoise(IplImage* pImg, int noise_type, double Ampl, CvRandState* rnd_state = NULL);

/*================== GENERATOR OF TEST VIDEO SEQUENCE ===================== */
typedef void CvTestSeq;

/* pConfigfile - name of file (yml or xml) with description of test sequence */
/* videos - array of names of test videos described in "pConfigfile" file */
/* numvideos - size of "videos" array */
CV_EXPORTS CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float Scale = 1, int noise_type = CV_NOISE_NONE, double noise_ampl = 0);
CV_EXPORTS void cvReleaseTestSeq(CvTestSeq** ppTestSeq);

/* generete next frame from test video seq and return pointer to it */
CV_EXPORTS IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq);
/* return pointer to current foreground mask */
CV_EXPORTS IplImage* cvTestSeqGetFGMask(CvTestSeq* pTestSeq);
/* return pointer to current image */
CV_EXPORTS IplImage* cvTestSeqGetImage(CvTestSeq* pTestSeq);
/* return frame size of result test video */
CV_EXPORTS CvSize cvTestSeqGetImageSize(CvTestSeq* pTestSeq);
/* return number of frames result test video */
CV_EXPORTS int cvTestSeqFrameNum(CvTestSeq* pTestSeq);

/* return number of existed objects 
 this is general number of any objects. 
for example number of trajectories may be equal or less than returned value*/
CV_EXPORTS int cvTestSeqGetObjectNum(CvTestSeq* pTestSeq);

/* return 0 if there is not position for current defined on current frame */
/* return 1 if there is object position and pPos was filled */
CV_EXPORTS int cvTestSeqGetObjectPos(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pPos);
CV_EXPORTS int cvTestSeqGetObjectSize(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pSize);

/* add noise to finile image */
CV_EXPORTS void cvTestSeqAddNoise(CvTestSeq* pTestSeq, int noise_type = CV_NOISE_NONE, double noise_ampl = 0);
/* add Intensity variation */
CV_EXPORTS void cvTestSeqAddIntensityVariation(CvTestSeq* pTestSeq, float DI_per_frame, float MinI, float MaxI);
CV_EXPORTS void cvTestSeqSetFrame(CvTestSeq* pTestSeq, int n);

#endif

/* End of file. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -