moved some old stuff to the legacy module; merge "compat_c.h" headers and moved to the legacy as well. moved implementation of many non-critical/obsolete inline functions and methods to .cpp to improve Opencv build time

This commit is contained in:
Vadim Pisarevsky
2010-11-26 17:58:20 +00:00
parent fbdb4f4ab5
commit 54ef4c08c2
32 changed files with 1661 additions and 1289 deletions

View File

@@ -0,0 +1,948 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_VIDEOSURVEILLANCE_H__
#define __OPENCV_VIDEOSURVEILLANCE_H__
/* Turn off the functionality until cvaux/src/Makefile.am gets updated: */
//#if _MSC_VER >= 1200
#include "opencv2/core/core_c.h"
#include <stdio.h>
#if _MSC_VER >= 1200 || defined __BORLANDC__
#define cv_stricmp stricmp
#define cv_strnicmp strnicmp
#if defined WINCE
#define strdup _strdup
#define stricmp _stricmp
#endif
#elif defined __GNUC__
#define cv_stricmp strcasecmp
#define cv_strnicmp strncasecmp
#else
#error Do not know how to make case-insensitive string comparison on this platform
#endif
//struct DefParam;
struct CvDefParam
{
struct CvDefParam* next;
char* pName;
char* pComment;
double* pDouble;
double Double;
float* pFloat;
float Float;
int* pInt;
int Int;
char** pStr;
char* Str;
};
class CV_EXPORTS CvVSModule
{
private: /* Internal data: */
CvDefParam* m_pParamList;
char* m_pModuleTypeName;
char* m_pModuleName;
char* m_pNickName;
protected:
int m_Wnd;
public: /* Constructor and destructor: */
CvVSModule();
virtual ~CvVSModule();
private: /* Internal functions: */
void FreeParam(CvDefParam** pp);
CvDefParam* NewParam(const char* name);
CvDefParam* GetParamPtr(int index);
CvDefParam* GetParamPtr(const char* name);
protected: /* INTERNAL INTERFACE */
int IsParam(const char* name);
void AddParam(const char* name, double* pAddr);
void AddParam(const char* name, float* pAddr);
void AddParam(const char* name, int* pAddr);
void AddParam(const char* name, const char** pAddr);
void AddParam(const char* name);
void CommentParam(const char* name, const char* pComment);
void SetTypeName(const char* name);
void SetModuleName(const char* name);
void DelParam(const char* name);
public: /* EXTERNAL INTERFACE */
const char* GetParamName(int index);
const char* GetParamComment(const char* name);
double GetParam(const char* name);
const char* GetParamStr(const char* name);
void SetParam(const char* name, double val);
void SetParamStr(const char* name, const char* str);
void TransferParamsFromChild(CvVSModule* pM, const char* prefix = NULL);
void TransferParamsToChild(CvVSModule* pM, char* prefix = NULL);
virtual void ParamUpdate();
const char* GetTypeName();
int IsModuleTypeName(const char* name);
char* GetModuleName();
int IsModuleName(const char* name);
void SetNickName(const char* pStr);
const char* GetNickName();
virtual void SaveState(CvFileStorage*);
virtual void LoadState(CvFileStorage*, CvFileNode*);
virtual void Release() = 0;
};/* CvVMModule */
CV_EXPORTS void cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num=1);
CV_EXPORTS void cvReadStructByName(CvFileStorage* fs, CvFileNode* node, const char* name, void* addr, const char* desc);
/* FOREGROUND DETECTOR INTERFACE */
class CV_EXPORTS CvFGDetector : public CvVSModule
{
public:
CvFGDetector();
virtual IplImage* GetMask() = 0;
/* Process current image: */
virtual void Process(IplImage* pImg) = 0;
/* Release foreground detector: */
virtual void Release() = 0;
};
CV_EXPORTS void cvReleaseFGDetector(CvFGDetector** ppT );
CV_EXPORTS CvFGDetector* cvCreateFGDetectorBase(int type, void *param);
/* BLOB STRUCTURE*/
struct CvBlob
{
float x,y; /* blob position */
float w,h; /* blob sizes */
int ID; /* blob ID */
};
inline CvBlob cvBlob(float x,float y, float w, float h)
{
CvBlob B = {x,y,w,h,0};
return B;
}
#define CV_BLOB_MINW 5
#define CV_BLOB_MINH 5
#define CV_BLOB_ID(pB) (((CvBlob*)(pB))->ID)
#define CV_BLOB_CENTER(pB) cvPoint2D32f(((CvBlob*)(pB))->x,((CvBlob*)(pB))->y)
#define CV_BLOB_X(pB) (((CvBlob*)(pB))->x)
#define CV_BLOB_Y(pB) (((CvBlob*)(pB))->y)
#define CV_BLOB_WX(pB) (((CvBlob*)(pB))->w)
#define CV_BLOB_WY(pB) (((CvBlob*)(pB))->h)
#define CV_BLOB_RX(pB) (0.5f*CV_BLOB_WX(pB))
#define CV_BLOB_RY(pB) (0.5f*CV_BLOB_WY(pB))
#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)))
/* END BLOB STRUCTURE*/
/* simple BLOBLIST */
class CV_EXPORTS CvBlobSeq
{
public:
CvBlobSeq(int BlobSize = sizeof(CvBlob))
{
m_pMem = cvCreateMemStorage();
m_pSeq = cvCreateSeq(0,sizeof(CvSeq),BlobSize,m_pMem);
strcpy(m_pElemFormat,"ffffi");
}
virtual ~CvBlobSeq()
{
cvReleaseMemStorage(&m_pMem);
};
virtual CvBlob* GetBlob(int BlobIndex)
{
return (CvBlob*)cvGetSeqElem(m_pSeq,BlobIndex);
};
virtual CvBlob* GetBlobByID(int BlobID)
{
int i;
for(i=0; i<m_pSeq->total; ++i)
if(BlobID == CV_BLOB_ID(GetBlob(i)))
return GetBlob(i);
return NULL;
};
virtual void DelBlob(int BlobIndex)
{
cvSeqRemove(m_pSeq,BlobIndex);
};
virtual void DelBlobByID(int BlobID)
{
int i;
for(i=0; i<m_pSeq->total; ++i)
{
if(BlobID == CV_BLOB_ID(GetBlob(i)))
{
DelBlob(i);
return;
}
}
};
virtual void Clear()
{
cvClearSeq(m_pSeq);
};
virtual void AddBlob(CvBlob* pB)
{
cvSeqPush(m_pSeq,pB);
};
virtual int GetBlobNum()
{
return m_pSeq->total;
};
virtual void Write(CvFileStorage* fs, const char* name)
{
const char* attr[] = {"dt",m_pElemFormat,NULL};
if(fs)
{
cvWrite(fs,name,m_pSeq,cvAttrList(attr,NULL));
}
}
virtual void Load(CvFileStorage* fs, CvFileNode* node)
{
if(fs==NULL) return;
CvSeq* pSeq = (CvSeq*)cvRead(fs, node);
if(pSeq)
{
int i;
cvClearSeq(m_pSeq);
for(i=0;i<pSeq->total;++i)
{
void* pB = cvGetSeqElem( pSeq, i );
cvSeqPush( m_pSeq, pB );
}
}
}
void AddFormat(const char* str){strcat(m_pElemFormat,str);}
protected:
CvMemStorage* m_pMem;
CvSeq* m_pSeq;
char m_pElemFormat[1024];
};
/* simple BLOBLIST */
/* simple TRACKLIST */
struct CvBlobTrack
{
int TrackID;
int StartFrame;
CvBlobSeq* pBlobSeq;
};
class CV_EXPORTS CvBlobTrackSeq
{
public:
CvBlobTrackSeq(int TrackSize = sizeof(CvBlobTrack));
virtual ~CvBlobTrackSeq();
virtual CvBlobTrack* GetBlobTrack(int TrackIndex);
virtual CvBlobTrack* GetBlobTrackByID(int TrackID);
virtual void DelBlobTrack(int TrackIndex);
virtual void DelBlobTrackByID(int TrackID);
virtual void Clear();
virtual void AddBlobTrack(int TrackID, int StartFrame = 0);
virtual int GetBlobTrackNum();
protected:
CvMemStorage* m_pMem;
CvSeq* m_pSeq;
};
/* simple TRACKLIST */
/* BLOB DETECTOR INTERFACE */
class CV_EXPORTS CvBlobDetector: public CvVSModule
{
public:
CvBlobDetector(){SetTypeName("BlobDetector");};
/* Try to detect new blob entrance based on foreground mask. */
/* pFGMask - image of foreground mask */
/* pNewBlob - pointer to CvBlob structure which will be filled if new blob entrance detected */
/* pOldBlobList - pointer to blob list which already exist on image */
virtual int DetectNewBlob(IplImage* pImg, IplImage* pImgFG, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList) = 0;
/* release blob detector */
virtual void Release()=0;
};
/* Release any blob detector: */
CV_EXPORTS void cvReleaseBlobDetector(CvBlobDetector** ppBD);
/* Declarations of constructors of implemented modules: */
CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorSimple();
CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorCC();
struct CV_EXPORTS CvDetectedBlob : public CvBlob
{
float response;
};
CV_INLINE CvDetectedBlob cvDetectedBlob( float x, float y, float w, float h, int ID = 0, float response = 0.0F )
{
CvDetectedBlob b;
b.x = x; b.y = y; b.w = w; b.h = h; b.ID = ID; b.response = response;
return b;
}
class CV_EXPORTS CvObjectDetector
{
public:
CvObjectDetector( const char* /*detector_file_name*/ = 0 );
~CvObjectDetector();
/*
* Release the current detector and load new detector from file
* (if detector_file_name is not 0)
* Return true on success:
*/
bool Load( const char* /*detector_file_name*/ = 0 );
/* Return min detector window size: */
CvSize GetMinWindowSize() const;
/* Return max border: */
int GetMaxBorderSize() const;
/*
* Detect the object on the image and push the detected
* blobs into <detected_blob_seq> which must be the sequence of <CvDetectedBlob>s
*/
void Detect( const CvArr* /*img*/, /* out */ CvBlobSeq* /*detected_blob_seq*/ = 0 );
protected:
class CvObjectDetectorImpl* impl;
};
CV_INLINE CvRect cvRectIntersection( const CvRect r1, const CvRect r2 )
{
CvRect r = cvRect( MAX(r1.x, r2.x), MAX(r1.y, r2.y), 0, 0 );
r.width = MIN(r1.x + r1.width, r2.x + r2.width) - r.x;
r.height = MIN(r1.y + r1.height, r2.y + r2.height) - r.y;
return r;
}
/*
* CvImageDrawer
*
* Draw on an image the specified ROIs from the source image and
* given blobs as ellipses or rectangles:
*/
struct CvDrawShape
{
enum {RECT, ELLIPSE} shape;
CvScalar color;
};
/*extern const CvDrawShape icv_shape[] =
{
{ CvDrawShape::ELLIPSE, CV_RGB(255,0,0) },
{ CvDrawShape::ELLIPSE, CV_RGB(0,255,0) },
{ CvDrawShape::ELLIPSE, CV_RGB(0,0,255) },
{ CvDrawShape::ELLIPSE, CV_RGB(255,255,0) },
{ CvDrawShape::ELLIPSE, CV_RGB(0,255,255) },
{ CvDrawShape::ELLIPSE, CV_RGB(255,0,255) }
};*/
class CV_EXPORTS CvImageDrawer
{
public:
CvImageDrawer() : m_image(0) {}
~CvImageDrawer() { cvReleaseImage( &m_image ); }
void SetShapes( const CvDrawShape* shapes, int num );
/* <blob_seq> must be the sequence of <CvDetectedBlob>s */
IplImage* Draw( const CvArr* src, CvBlobSeq* blob_seq = 0, const CvSeq* roi_seq = 0 );
IplImage* GetImage() { return m_image; }
protected:
//static const int MAX_SHAPES = sizeof(icv_shape) / sizeof(icv_shape[0]);;
IplImage* m_image;
CvDrawShape m_shape[16];
};
/* Trajectory generation module: */
class CV_EXPORTS CvBlobTrackGen: public CvVSModule
{
public:
CvBlobTrackGen(){SetTypeName("BlobTrackGen");};
virtual void SetFileName(char* pFileName) = 0;
virtual void AddBlob(CvBlob* pBlob) = 0;
virtual void Process(IplImage* pImg = NULL, IplImage* pFG = NULL) = 0;
virtual void Release() = 0;
};
inline void cvReleaseBlobTrackGen(CvBlobTrackGen** pBTGen)
{
if(*pBTGen)(*pBTGen)->Release();
*pBTGen = 0;
}
/* Declarations of constructors of implemented modules: */
CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGen1();
CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGenYML();
/* BLOB TRACKER INTERFACE */
class CV_EXPORTS CvBlobTracker: public CvVSModule
{
public:
CvBlobTracker();
/* Add new blob to track it and assign to this blob personal ID */
/* pBlob - pointer to structure with blob parameters (ID is ignored)*/
/* pImg - current image */
/* pImgFG - current foreground mask */
/* Return pointer to new added blob: */
virtual CvBlob* AddBlob(CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG = NULL ) = 0;
/* Return number of currently tracked blobs: */
virtual int GetBlobNum() = 0;
/* Return pointer to specified by index blob: */
virtual CvBlob* GetBlob(int BlobIndex) = 0;
/* Delete blob by its index: */
virtual void DelBlob(int BlobIndex) = 0;
/* Process current image and track all existed blobs: */
virtual void Process(IplImage* pImg, IplImage* pImgFG = NULL) = 0;
/* Release blob tracker: */
virtual void Release() = 0;
/* Process one blob (for multi hypothesis tracing): */
virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
/* Get confidence/wieght/probability (0-1) for blob: */
virtual double GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL);
virtual void UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
/* Update all blob models: */
virtual void Update(IplImage* pImg, IplImage* pImgFG = NULL);
/* Return pointer to blob by its unique ID: */
virtual int GetBlobIndexByID(int BlobID);
/* Return pointer to blob by its unique ID: */
virtual CvBlob* GetBlobByID(int BlobID);
/* Delete blob by its ID: */
virtual void DelBlobByID(int 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);
/* =============== MULTI HYPOTHESIS INTERFACE ================== */
/* Return number of position hyposetis of currently tracked blob: */
virtual int GetBlobHypNum(int /*BlobIdx*/);
/* Return pointer to specified blob hypothesis by index blob: */
virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/);
/* Set new parameters for specified (by index) blob hyp
* (can be called several times for each hyp ):
*/
virtual void SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/);
};
CV_EXPORTS void cvReleaseBlobTracker(CvBlobTracker**ppT );
/* 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;
/* Non-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 */
/* Declarations of constructors of implemented modules: */
/* Some declarations 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 declarations for specific Likelihood tracker: */
struct CvBlobTrackerParamLH
{
int HistType; /* see Prob.h */
int ScaleAfter;
};
/* Without scale optimization: */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHR(CvBlobTrackerParamLH* /*param*/ = NULL);
/* With 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 mean-shift particle filter collion-resolver: */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCCMSPF();
/* Blob tracker that integrates meanshift and connected components: */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFG();
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFGS();
/* Meanshift without connected-components */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS();
/* Particle filtering via Bhattacharya coefficient, which */
/* is roughly the dot-product of two probability densities. */
/* See: Real-Time Tracking of Non-Rigid Objects using Mean Shift */
/* Comanicius, Ramesh, Meer, 2000, 8p */
/* http://citeseer.ist.psu.edu/321441.html */
CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSPF();
/* =========== tracker integrators trackers =============*/
/* Integrator based on Particle Filtering method: */
//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPF();
/* Rule based integrator: */
//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIRB();
/* Integrator based on data fusion using particle filtering: */
//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPFDF();
/* Trajectory postprocessing module: */
class CV_EXPORTS CvBlobTrackPostProc: public CvVSModule
{
public:
CvBlobTrackPostProc(){SetTypeName("BlobTrackPostProc");};
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:
CvBlobTrackPostProcOne(){SetTypeName("BlobTrackPostOne");};
virtual CvBlob* Process(CvBlob* pBlob) = 0;
virtual void Release() = 0;
};
/* Create blob tracking post processing module based on simle module: */
CV_EXPORTS CvBlobTrackPostProc* cvCreateBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)());
/* Declarations 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:
CvBlobTrackPredictor(){SetTypeName("BlobTrackPredictor");};
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:
CvBlobTrackAnalysis(){SetTypeName("BlobTrackAnalysis");};
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 const 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:
CvBlobTrackFVGen(){SetTypeName("BlobTrackFVGen");};
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; /* Returns pointer to FV, if return 0 then FV not created */
virtual float* GetFVVar(){return NULL;}; /* Returns pointer to array of variation of values of FV, if returns 0 then FVVar does not exist. */
virtual float* GetFVMin() = 0; /* Returns pointer to array of minimal values of FV, if returns 0 then FVrange does not exist */
virtual float* GetFVMax() = 0; /* Returns pointer to array of maximal values of FV, if returns 0 then FVrange does 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 tracking post processing module based on simle module: */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)());
/* Declarations of constructors of implemented modules: */
/* Based on histogram analysis of 2D FV (x,y): */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistP();
/* Based on histogram analysis of 4D FV (x,y,vx,vy): */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPV();
/* Based on histogram analysis of 5D FV (x,y,vx,vy,state): */
CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPVS();
/* Based on histogram 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();
/* Analyzer based on reation Road and height map: */
//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysis3DRoadMap();
/* Analyzer that makes OR decision using set of analyzers: */
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:
CvBlobTrackerAuto(){SetTypeName("BlobTrackerAuto");};
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 const 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 */
/* Constructor functions and data for specific BlobTRackerAuto modules: */
/* Parameters of blobtracker auto ver1: */
struct CvBlobTrackerAutoParam1
{
int FGTrainFrames; /* Number of frames needed for FG (foreground) detector to train. */
CvFGDetector* pFG; /* FGDetector module. If this field is NULL the Process FG mask is used. */
CvBlobDetector* pBD; /* Selected blob detector module. */
/* If this field is NULL default blobdetector module will be created. */
CvBlobTracker* pBT; /* Selected blob tracking module. */
/* If this field is NULL default blobtracker module will be created. */
CvBlobTrackGen* pBTGen; /* Selected blob trajectory generator. */
/* If this field is NULL no generator is used. */
CvBlobTrackPostProc* pBTPP; /* Selected blob trajectory postprocessing module. */
/* If this field is NULL no postprocessing is done. */
int UsePPData;
CvBlobTrackAnalysis* pBTA; /* Selected blob trajectory analysis module. */
/* If this field is NULL no track analysis is done. */
};
/* 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);*/
/* Constructor 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 type definitions: */
#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, CvRNG* 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);
/* Generate 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 existing 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 final 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. */

View File

@@ -0,0 +1,605 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright( C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
//(including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort(including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
/*
A few macros and definitions for backward compatibility
with the previous versions of OpenCV. They are obsolete and
are likely to be removed in future. To check whether your code
uses any of these, define CV_NO_BACKWARD_COMPATIBILITY before
including cv.h.
*/
#ifndef __OPENCV_COMPAT_HPP__
#define __OPENCV_COMPAT_HPP__
#include <math.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int CvMatType;
typedef int CvDisMaskType;
typedef CvMat CvMatArray;
typedef int CvThreshType;
typedef int CvAdaptiveThreshMethod;
typedef int CvCompareMethod;
typedef int CvFontFace;
typedef int CvPolyApproxMethod;
typedef int CvContoursMatchMethod;
typedef int CvContourTreesMatchMethod;
typedef int CvCoeffType;
typedef int CvRodriguesType;
typedef int CvElementShape;
typedef int CvMorphOp;
typedef int CvTemplMatchMethod;
typedef CvPoint2D64f CvPoint2D64d;
typedef CvPoint3D64f CvPoint3D64d;
enum
{
CV_MAT32F = CV_32FC1,
CV_MAT3x1_32F = CV_32FC1,
CV_MAT4x1_32F = CV_32FC1,
CV_MAT3x3_32F = CV_32FC1,
CV_MAT4x4_32F = CV_32FC1,
CV_MAT64D = CV_64FC1,
CV_MAT3x1_64D = CV_64FC1,
CV_MAT4x1_64D = CV_64FC1,
CV_MAT3x3_64D = CV_64FC1,
CV_MAT4x4_64D = CV_64FC1
};
enum
{
IPL_GAUSSIAN_5x5 = 7
};
typedef CvBox2D CvBox2D32f;
/* allocation/deallocation macros */
#define cvCreateImageData cvCreateData
#define cvReleaseImageData cvReleaseData
#define cvSetImageData cvSetData
#define cvGetImageRawData cvGetRawData
#define cvmAlloc cvCreateData
#define cvmFree cvReleaseData
#define cvmAllocArray cvCreateData
#define cvmFreeArray cvReleaseData
#define cvIntegralImage cvIntegral
#define cvMatchContours cvMatchShapes
CV_EXPORTS CvMat cvMatArray( int rows, int cols, int type,
int count, void* data CV_DEFAULT(0));
#define cvUpdateMHIByTime cvUpdateMotionHistory
#define cvAccMask cvAcc
#define cvSquareAccMask cvSquareAcc
#define cvMultiplyAccMask cvMultiplyAcc
#define cvRunningAvgMask(imgY, imgU, mask, alpha) cvRunningAvg(imgY, imgU, alpha, mask)
#define cvSetHistThresh cvSetHistBinRanges
#define cvCalcHistMask(img, mask, hist, doNotClear) cvCalcHist(img, hist, doNotClear, mask)
CV_EXPORTS double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0));
CV_EXPORTS double cvSumPixels( const CvArr* image );
CV_EXPORTS void cvMean_StdDev( const CvArr* image, double* mean, double* sdv,
const CvArr* mask CV_DEFAULT(0));
CV_EXPORTS void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst );
CV_EXPORTS void cvFillImage( CvArr* mat, double color );
#define cvCvtPixToPlane cvSplit
#define cvCvtPlaneToPix cvMerge
typedef struct CvRandState
{
CvRNG state; /* RNG state (the current seed and carry)*/
int disttype; /* distribution type */
CvScalar param[2]; /* parameters of RNG */
} CvRandState;
/* Changes RNG range while preserving RNG state */
CV_EXPORTS void cvRandSetRange( CvRandState* state, double param1,
double param2, int index CV_DEFAULT(-1));
CV_EXPORTS void cvRandInit( CvRandState* state, double param1,
double param2, int seed,
int disttype CV_DEFAULT(CV_RAND_UNI));
/* Fills array with random numbers */
CV_EXPORTS void cvRand( CvRandState* state, CvArr* arr );
#define cvRandNext( _state ) cvRandInt( &(_state)->state )
CV_EXPORTS void cvbRand( CvRandState* state, float* dst, int len );
CV_EXPORTS void cvbCartToPolar( const float* y, const float* x,
float* magnitude, float* angle, int len );
CV_EXPORTS void cvbFastArctan( const float* y, const float* x, float* angle, int len );
CV_EXPORTS void cvbSqrt( const float* x, float* y, int len );
CV_EXPORTS void cvbInvSqrt( const float* x, float* y, int len );
CV_EXPORTS void cvbReciprocal( const float* x, float* y, int len );
CV_EXPORTS void cvbFastExp( const float* x, double* y, int len );
CV_EXPORTS void cvbFastLog( const double* x, float* y, int len );
CV_EXPORTS CvRect cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0));
CV_EXPORTS double cvPseudoInverse( const CvArr* src, CvArr* dst );
#define cvPseudoInv cvPseudoInverse
#define cvContourMoments( contour, moments ) cvMoments( contour, moments, 0 )
#define cvGetPtrAt cvPtr2D
#define cvGetAt cvGet2D
#define cvSetAt(arr,val,y,x) cvSet2D((arr),(y),(x),(val))
#define cvMeanMask cvMean
#define cvMean_StdDevMask(img,mask,mean,sdv) cvMean_StdDev(img,mean,sdv,mask)
#define cvNormMask(imgA,imgB,mask,normType) cvNorm(imgA,imgB,normType,mask)
#define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \
cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask)
#define cvRemoveMemoryManager cvSetMemoryManager
#define cvmSetZero( mat ) cvSetZero( mat )
#define cvmSetIdentity( mat ) cvSetIdentity( mat )
#define cvmAdd( src1, src2, dst ) cvAdd( src1, src2, dst, 0 )
#define cvmSub( src1, src2, dst ) cvSub( src1, src2, dst, 0 )
#define cvmCopy( src, dst ) cvCopy( src, dst, 0 )
#define cvmMul( src1, src2, dst ) cvMatMulAdd( src1, src2, 0, dst )
#define cvmTranspose( src, dst ) cvT( src, dst )
#define cvmInvert( src, dst ) cvInv( src, dst )
#define cvmMahalanobis(vec1, vec2, mat) cvMahalanobis( vec1, vec2, mat )
#define cvmDotProduct( vec1, vec2 ) cvDotProduct( vec1, vec2 )
#define cvmCrossProduct(vec1, vec2,dst) cvCrossProduct( vec1, vec2, dst )
#define cvmTrace( mat ) (cvTrace( mat )).val[0]
#define cvmMulTransposed( src, dst, order ) cvMulTransposed( src, dst, order )
#define cvmEigenVV( mat, evec, eval, eps) cvEigenVV( mat, evec, eval, eps )
#define cvmDet( mat ) cvDet( mat )
#define cvmScale( src, dst, scale ) cvScale( src, dst, scale )
#define cvCopyImage( src, dst ) cvCopy( src, dst, 0 )
#define cvReleaseMatHeader cvReleaseMat
/* Calculates exact convex hull of 2d point set */
CV_EXPORTS void cvConvexHull( CvPoint* points, int num_points,
CvRect* bound_rect,
int orientation, int* hull, int* hullsize );
CV_EXPORTS void cvMinAreaRect( CvPoint* points, int n,
int left, int bottom,
int right, int top,
CvPoint2D32f* anchor,
CvPoint2D32f* vect1,
CvPoint2D32f* vect2 );
typedef int CvDisType;
typedef int CvChainApproxMethod;
typedef int CvContourRetrievalMode;
CV_EXPORTS void cvFitLine3D( CvPoint3D32f* points, int count, int dist,
void *param, float reps, float aeps, float* line );
/* Fits a line into set of 2d points in a robust way (M-estimator technique) */
CV_EXPORTS void cvFitLine2D( CvPoint2D32f* points, int count, int dist,
void *param, float reps, float aeps, float* line );
CV_EXPORTS void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box );
/* Projects 2d points to one of standard coordinate planes
(i.e. removes one of coordinates) */
CV_EXPORTS void cvProject3D( CvPoint3D32f* points3D, int count,
CvPoint2D32f* points2D,
int xIndx CV_DEFAULT(0),
int yIndx CV_DEFAULT(1));
/* Retrieves value of the particular bin
of x-dimensional (x=1,2,3,...) histogram */
#define cvQueryHistValue_1D( hist, idx0 ) \
((float)cvGetReal1D( (hist)->bins, (idx0)))
#define cvQueryHistValue_2D( hist, idx0, idx1 ) \
((float)cvGetReal2D( (hist)->bins, (idx0), (idx1)))
#define cvQueryHistValue_3D( hist, idx0, idx1, idx2 ) \
((float)cvGetReal3D( (hist)->bins, (idx0), (idx1), (idx2)))
#define cvQueryHistValue_nD( hist, idx ) \
((float)cvGetRealND( (hist)->bins, (idx)))
/* Returns pointer to the particular bin of x-dimesional histogram.
For sparse histogram the bin is created if it didn't exist before */
#define cvGetHistValue_1D( hist, idx0 ) \
((float*)cvPtr1D( (hist)->bins, (idx0), 0))
#define cvGetHistValue_2D( hist, idx0, idx1 ) \
((float*)cvPtr2D( (hist)->bins, (idx0), (idx1), 0))
#define cvGetHistValue_3D( hist, idx0, idx1, idx2 ) \
((float*)cvPtr3D( (hist)->bins, (idx0), (idx1), (idx2), 0))
#define cvGetHistValue_nD( hist, idx ) \
((float*)cvPtrND( (hist)->bins, (idx), 0))
#define CV_IS_SET_ELEM_EXISTS CV_IS_SET_ELEM
CV_EXPORTS int cvHoughLines( CvArr* image, double rho,
double theta, int threshold,
float* lines, int linesNumber );
CV_EXPORTS int cvHoughLinesP( CvArr* image, double rho,
double theta, int threshold,
int lineLength, int lineGap,
int* lines, int linesNumber );
CV_EXPORTS int cvHoughLinesSDiv( CvArr* image, double rho, int srn,
double theta, int stn, int threshold,
float* lines, int linesNumber );
CV_EXPORTS float cvCalcEMD( const float* signature1, int size1,
const float* signature2, int size2,
int dims, int dist_type CV_DEFAULT(CV_DIST_L2),
CvDistanceFunction dist_func CV_DEFAULT(0),
float* lower_bound CV_DEFAULT(0),
void* user_param CV_DEFAULT(0));
CV_EXPORTS void cvKMeans( int num_clusters, float** samples,
int num_samples, int vec_size,
CvTermCriteria termcrit, int* cluster_idx );
CV_EXPORTS void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
CvGraphVtx* vtx CV_DEFAULT(NULL),
int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
CV_EXPORTS void cvEndScanGraph( CvGraphScanner* scanner );
/* old drawing functions */
CV_EXPORTS void cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2,
double color, int scale CV_DEFAULT(0));
CV_EXPORTS void cvCircleAA( CvArr* img, CvPoint center, int radius,
double color, int scale CV_DEFAULT(0) );
CV_EXPORTS void cvEllipseAA( CvArr* img, CvPoint center, CvSize axes,
double angle, double start_angle,
double end_angle, double color,
int scale CV_DEFAULT(0) );
CV_EXPORTS void cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours,
int is_closed, double color, int scale CV_DEFAULT(0) );
/****************************************************************************************\
* Pixel Access Macros *
\****************************************************************************************/
typedef struct _CvPixelPosition8u
{
uchar* currline; /* pointer to the start of the current pixel line */
uchar* topline; /* pointer to the start of the top pixel line */
uchar* bottomline; /* pointer to the start of the first line */
/* which is below the image */
int x; /* current x coordinate ( in pixels ) */
int width; /* width of the image ( in pixels ) */
int height; /* height of the image ( in pixels ) */
int step; /* distance between lines ( in elements of single */
/* plane ) */
int step_arr[3]; /* array: ( 0, -step, step ). It is used for */
/* vertical moving */
} CvPixelPosition8u;
/* this structure differs from the above only in data type */
typedef struct _CvPixelPosition8s
{
schar* currline;
schar* topline;
schar* bottomline;
int x;
int width;
int height;
int step;
int step_arr[3];
} CvPixelPosition8s;
/* this structure differs from the CvPixelPosition8u only in data type */
typedef struct _CvPixelPosition32f
{
float* currline;
float* topline;
float* bottomline;
int x;
int width;
int height;
int step;
int step_arr[3];
} CvPixelPosition32f;
/* Initialize one of the CvPixelPosition structures. */
/* pos - initialized structure */
/* origin - pointer to the left-top corner of the ROI */
/* step - width of the whole image in bytes */
/* roi - width & height of the ROI */
/* x, y - initial position */
#define CV_INIT_PIXEL_POS(pos, origin, _step, roi, _x, _y, orientation) \
( \
(pos).step = (_step)/sizeof((pos).currline[0]) * (orientation ? -1 : 1), \
(pos).width = (roi).width, \
(pos).height = (roi).height, \
(pos).bottomline = (origin) + (pos).step*(pos).height, \
(pos).topline = (origin) - (pos).step, \
(pos).step_arr[0] = 0, \
(pos).step_arr[1] = -(pos).step, \
(pos).step_arr[2] = (pos).step, \
(pos).x = (_x), \
(pos).currline = (origin) + (pos).step*(_y) )
/* Move to specified point ( absolute shift ) */
/* pos - position structure */
/* x, y - coordinates of the new position */
/* cs - number of the image channels */
#define CV_MOVE_TO( pos, _x, _y, cs ) \
((pos).currline = (_y) >= 0 && (_y) < (pos).height ? (pos).topline + ((_y)+1)*(pos).step : 0, \
(pos).x = (_x) >= 0 && (_x) < (pos).width ? (_x) : 0, (pos).currline + (_x) * (cs) )
/* Get current coordinates */
/* pos - position structure */
/* x, y - coordinates of the new position */
/* cs - number of the image channels */
#define CV_GET_CURRENT( pos, cs ) ((pos).currline + (pos).x * (cs))
/* Move by one pixel relatively to current position */
/* pos - position structure */
/* cs - number of the image channels */
/* left */
#define CV_MOVE_LEFT( pos, cs ) \
( --(pos).x >= 0 ? (pos).currline + (pos).x*(cs) : 0 )
/* right */
#define CV_MOVE_RIGHT( pos, cs ) \
( ++(pos).x < (pos).width ? (pos).currline + (pos).x*(cs) : 0 )
/* up */
#define CV_MOVE_UP( pos, cs ) \
(((pos).currline -= (pos).step) != (pos).topline ? (pos).currline + (pos).x*(cs) : 0 )
/* down */
#define CV_MOVE_DOWN( pos, cs ) \
(((pos).currline += (pos).step) != (pos).bottomline ? (pos).currline + (pos).x*(cs) : 0 )
/* left up */
#define CV_MOVE_LU( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_UP(pos, cs))
/* right up */
#define CV_MOVE_RU( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_UP(pos, cs))
/* left down */
#define CV_MOVE_LD( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_DOWN(pos, cs))
/* right down */
#define CV_MOVE_RD( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_DOWN(pos, cs))
/* Move by one pixel relatively to current position with wrapping when the position */
/* achieves image boundary */
/* pos - position structure */
/* cs - number of the image channels */
/* left */
#define CV_MOVE_LEFT_WRAP( pos, cs ) \
((pos).currline + ( --(pos).x >= 0 ? (pos).x : ((pos).x = (pos).width-1))*(cs))
/* right */
#define CV_MOVE_RIGHT_WRAP( pos, cs ) \
((pos).currline + ( ++(pos).x < (pos).width ? (pos).x : ((pos).x = 0))*(cs) )
/* up */
#define CV_MOVE_UP_WRAP( pos, cs ) \
((((pos).currline -= (pos).step) != (pos).topline ? \
(pos).currline : ((pos).currline = (pos).bottomline - (pos).step)) + (pos).x*(cs) )
/* down */
#define CV_MOVE_DOWN_WRAP( pos, cs ) \
((((pos).currline += (pos).step) != (pos).bottomline ? \
(pos).currline : ((pos).currline = (pos).topline + (pos).step)) + (pos).x*(cs) )
/* left up */
#define CV_MOVE_LU_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs))
/* right up */
#define CV_MOVE_RU_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs))
/* left down */
#define CV_MOVE_LD_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
/* right down */
#define CV_MOVE_RD_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
/* Numeric constants which used for moving in arbitrary direction */
enum
{
CV_SHIFT_NONE = 2,
CV_SHIFT_LEFT = 1,
CV_SHIFT_RIGHT = 3,
CV_SHIFT_UP = 6,
CV_SHIFT_DOWN = 10,
CV_SHIFT_LU = 5,
CV_SHIFT_RU = 7,
CV_SHIFT_LD = 9,
CV_SHIFT_RD = 11
};
/* Move by one pixel in specified direction */
/* pos - position structure */
/* shift - direction ( it's value must be one of the CV_SHIFT_Ö constants ) */
/* cs - number of the image channels */
#define CV_MOVE_PARAM( pos, shift, cs ) \
( (pos).currline += (pos).step_arr[(shift)>>2], (pos).x += ((shift)&3)-2, \
((pos).currline != (pos).topline && (pos).currline != (pos).bottomline && \
(pos).x >= 0 && (pos).x < (pos).width) ? (pos).currline + (pos).x*(cs) : 0 )
/* Move by one pixel in specified direction with wrapping when the */
/* position achieves image boundary */
/* pos - position structure */
/* shift - direction ( it's value must be one of the CV_SHIFT_Ö constants ) */
/* cs - number of the image channels */
#define CV_MOVE_PARAM_WRAP( pos, shift, cs ) \
( (pos).currline += (pos).step_arr[(shift)>>2], \
(pos).currline = ((pos).currline == (pos).topline ? \
(pos).bottomline - (pos).step : \
(pos).currline == (pos).bottomline ? \
(pos).topline + (pos).step : (pos).currline), \
\
(pos).x += ((shift)&3)-2, \
(pos).x = ((pos).x < 0 ? (pos).width-1 : (pos).x >= (pos).width ? 0 : (pos).x), \
\
(pos).currline + (pos).x*(cs) )
typedef float* CvVect32f;
typedef float* CvMatr32f;
typedef double* CvVect64d;
typedef double* CvMatr64d;
CV_EXPORTS void cvUnDistortOnce( const CvArr* src, CvArr* dst,
const float* intrinsic_matrix,
const float* distortion_coeffs,
int interpolate );
/* the two functions below have quite hackerish implementations, use with care
(or, which is better, switch to cvUndistortInitMap and cvRemap instead */
CV_EXPORTS void cvUnDistortInit( const CvArr* src,
CvArr* undistortion_map,
const float* A, const float* k,
int interpolate );
CV_EXPORTS void cvUnDistort( const CvArr* src, CvArr* dst,
const CvArr* undistortion_map,
int interpolate );
/* Find fundamental matrix */
CV_EXPORTS void cvFindFundamentalMatrix( int* points1, int* points2,
int numpoints, int method, float* matrix );
CV_EXPORTS int cvFindChessBoardCornerGuesses( const void* arr, void* thresharr,
CvMemStorage* storage,
CvSize pattern_size, CvPoint2D32f * corners,
int *corner_count );
/* Calibrates camera using multiple views of calibration pattern */
CV_EXPORTS void cvCalibrateCamera( int image_count, int* _point_counts,
CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points,
float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors,
float* _rotation_matrices, int flags );
CV_EXPORTS void cvCalibrateCamera_64d( int image_count, int* _point_counts,
CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points,
double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors,
double* _rotation_matrices, int flags );
/* Find 3d position of object given intrinsic camera parameters,
3d model of the object and projection of the object into view plane */
CV_EXPORTS void cvFindExtrinsicCameraParams( int point_count,
CvSize image_size, CvPoint2D32f* _image_points,
CvPoint3D32f* _object_points, float* focal_length,
CvPoint2D32f principal_point, float* _distortion_coeffs,
float* _rotation_vector, float* _translation_vector );
/* Variant of the previous function that takes double-precision parameters */
CV_EXPORTS void cvFindExtrinsicCameraParams_64d( int point_count,
CvSize image_size, CvPoint2D64f* _image_points,
CvPoint3D64f* _object_points, double* focal_length,
CvPoint2D64f principal_point, double* _distortion_coeffs,
double* _rotation_vector, double* _translation_vector );
/* Rodrigues transform */
enum
{
CV_RODRIGUES_M2V = 0,
CV_RODRIGUES_V2M = 1
};
/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */
CV_EXPORTS void cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector,
CvMat* jacobian, int conv_type );
/* Does reprojection of 3d object points to the view plane */
CV_EXPORTS void cvProjectPoints( int point_count, CvPoint3D64f* _object_points,
double* _rotation_vector, double* _translation_vector,
double* focal_length, CvPoint2D64f principal_point,
double* _distortion, CvPoint2D64f* _image_points,
double* _deriv_points_rotation_matrix,
double* _deriv_points_translation_vect,
double* _deriv_points_focal,
double* _deriv_points_principal_point,
double* _deriv_points_distortion_coeffs );
/* Simpler version of the previous function */
CV_EXPORTS void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points,
double* _rotation_matrix, double* _translation_vector,
double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points );
#define cvMake2DPoints cvConvertPointsHomogeneous
#define cvMake3DPoints cvConvertPointsHomogeneous
#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform
#define cvConvertPointsHomogenious cvConvertPointsHomogeneous
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -579,17 +579,17 @@ CVAPI(int) icvCompute3DPoint( double alpha,double betta,
CvStereoLineCoeff* coeffs,
CvPoint3D64f* point);
CVAPI(int) icvCreateConvertMatrVect( CvMatr64d rotMatr1,
CvMatr64d transVect1,
CvMatr64d rotMatr2,
CvMatr64d transVect2,
CvMatr64d convRotMatr,
CvMatr64d convTransVect);
CVAPI(int) icvCreateConvertMatrVect( double* rotMatr1,
double* transVect1,
double* rotMatr2,
double* transVect2,
double* convRotMatr,
double* convTransVect);
CVAPI(int) icvConvertPointSystem(CvPoint3D64f M2,
CvPoint3D64f* M1,
CvMatr64d rotMatr,
CvMatr64d transVect
double* rotMatr,
double* transVect
);
CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera);
@@ -615,17 +615,17 @@ CVAPI(int) icvComCoeffForLine( CvPoint2D64f point1,
CvPoint2D64f point2,
CvPoint2D64f point3,
CvPoint2D64f point4,
CvMatr64d camMatr1,
CvMatr64d rotMatr1,
CvMatr64d transVect1,
CvMatr64d camMatr2,
CvMatr64d rotMatr2,
CvMatr64d transVect2,
double* camMatr1,
double* rotMatr1,
double* transVect1,
double* camMatr2,
double* rotMatr2,
double* transVect2,
CvStereoLineCoeff* coeffs,
int* needSwapCameras);
CVAPI(int) icvGetDirectionForPoint( CvPoint2D64f point,
CvMatr64d camMatr,
double* camMatr,
CvPoint3D64f* direct);
CVAPI(int) icvGetCrossLines(CvPoint3D64f point11,CvPoint3D64f point12,
@@ -638,15 +638,15 @@ CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64f pointA,
double gamma,
CvStereoLineCoeff* coeffs);
/*CVAPI(int) icvComputeFundMatrEpipoles ( CvMatr64d camMatr1,
CvMatr64d rotMatr1,
CvVect64d transVect1,
CvMatr64d camMatr2,
CvMatr64d rotMatr2,
CvVect64d transVect2,
/*CVAPI(int) icvComputeFundMatrEpipoles ( double* camMatr1,
double* rotMatr1,
double* transVect1,
double* camMatr2,
double* rotMatr2,
double* transVect2,
CvPoint2D64f* epipole1,
CvPoint2D64f* epipole2,
CvMatr64d fundMatr);*/
double* fundMatr);*/
CVAPI(int) icvGetAngleLine( CvPoint2D64f startPoint, CvSize imageSize,CvPoint2D64f *point1,CvPoint2D64f *point2);
@@ -656,24 +656,24 @@ CVAPI(void) icvGetCoefForPiece( CvPoint2D64f p_start,CvPoint2D64f p_end,
/*CVAPI(void) icvGetCommonArea( CvSize imageSize,
CvPoint2D64f epipole1,CvPoint2D64f epipole2,
CvMatr64d fundMatr,
CvVect64d coeff11,CvVect64d coeff12,
CvVect64d coeff21,CvVect64d coeff22,
double* fundMatr,
double* coeff11,double* coeff12,
double* coeff21,double* coeff22,
int* result);*/
CVAPI(void) icvComputeeInfiniteProject1(CvMatr64d rotMatr,
CvMatr64d camMatr1,
CvMatr64d camMatr2,
CVAPI(void) icvComputeeInfiniteProject1(double* rotMatr,
double* camMatr1,
double* camMatr2,
CvPoint2D32f point1,
CvPoint2D32f *point2);
CVAPI(void) icvComputeeInfiniteProject2(CvMatr64d rotMatr,
CvMatr64d camMatr1,
CvMatr64d camMatr2,
CVAPI(void) icvComputeeInfiniteProject2(double* rotMatr,
double* camMatr1,
double* camMatr2,
CvPoint2D32f* point1,
CvPoint2D32f point2);
CVAPI(void) icvGetCrossDirectDirect( CvVect64d direct1,CvVect64d direct2,
CVAPI(void) icvGetCrossDirectDirect( double* direct1,double* direct2,
CvPoint2D64f *cross,int* result);
CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64f p_start,CvPoint2D64f p_end,
@@ -693,20 +693,20 @@ CVAPI(void) icvGetCrossRectDirect( CvSize imageSize,
int* result);
CVAPI(void) icvProjectPointToImage( CvPoint3D64f point,
CvMatr64d camMatr,CvMatr64d rotMatr,CvVect64d transVect,
double* camMatr,double* rotMatr,double* transVect,
CvPoint2D64f* projPoint);
CVAPI(void) icvGetQuadsTransform( CvSize imageSize,
CvMatr64d camMatr1,
CvMatr64d rotMatr1,
CvVect64d transVect1,
CvMatr64d camMatr2,
CvMatr64d rotMatr2,
CvVect64d transVect2,
double* camMatr1,
double* rotMatr1,
double* transVect1,
double* camMatr2,
double* rotMatr2,
double* transVect2,
CvSize* warpSize,
double quad1[4][2],
double quad2[4][2],
CvMatr64d fundMatr,
double* fundMatr,
CvPoint3D64f* epipole1,
CvPoint3D64f* epipole2
);
@@ -715,7 +715,7 @@ CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera);
CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera);
CVAPI(void) icvGetCutPiece( CvVect64d areaLineCoef1,CvVect64d areaLineCoef2,
CVAPI(void) icvGetCutPiece( double* areaLineCoef1,double* areaLineCoef2,
CvPoint2D64f epipole,
CvSize imageSize,
CvPoint2D64f* point11,CvPoint2D64f* point12,
@@ -726,14 +726,14 @@ CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64f basePoint,
CvPoint2D64f point1,CvPoint2D64f point2,
CvPoint2D64f* midPoint);
CVAPI(void) icvGetNormalDirect(CvVect64d direct,CvPoint2D64f point,CvVect64d normDirect);
CVAPI(void) icvGetNormalDirect(double* direct,CvPoint2D64f point,double* normDirect);
CVAPI(double) icvGetVect(CvPoint2D64f basePoint,CvPoint2D64f point1,CvPoint2D64f point2);
CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,CvVect64d lineCoeff,
CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,double* lineCoeff,
CvPoint2D64f* projectPoint);
CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,CvVect64d lineCoef,double*dist);
CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,double* lineCoef,double*dist);
CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst,
int desired_depth, int desired_num_channels );
@@ -1096,6 +1096,11 @@ CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4
/*************************** View Morphing Functions ************************/
typedef struct CvMatrix3
{
float m[3][3];
} CvMatrix3;
/* The order of the function corresponds to the order they should appear in
the view morphing pipeline */