Utilisation de MACRO pour simuler une classe abstract.
Bonjour,
J'ai trouver dans la librarie openCV une déclaration qui me parait interessante car elle represente une sort de classe abstraite:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
struct CvBGStatModel;
typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model );
typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model );
#define CV_BG_STAT_MODEL_FIELDS() \
int type; /*type of BG model*/ \
CvReleaseBGStatModel release; \
CvUpdateBGStatModel update; \
IplImage* background; /*8UC3 reference background image*/ \
IplImage* foreground; /*8UC1 foreground image*/
typedef struct CvBGStatModel
{
CV_BG_STAT_MODEL_FIELDS();
}
CvBGStatModel; |
Puis les pseudo classes fille sont definie ainsi:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
typedef struct CvFGDStatModel
{
CV_BG_STAT_MODEL_FIELDS();
IplImage* prev_frame;
CvFGDStatModelParams params;
}
CvFGDStatModel;
typedef struct CvGaussBGModel
{
CV_BG_STAT_MODEL_FIELDS();
CvGaussBGStatModelParams params;
CvGaussBGPoint* g_point;
int countFrames;
}
CvGaussBGModel; |
Puis dans le code il utilise CvBGStatModel pour appeler les functions qui regarde le type et donc apres appel leur fonction specialisée.
Cependant je ne comprend pas vraiment le #define CV_BG_STAT_MODEL_FIELDS() ...
Et surtout je ne comprend pas du tout comment marche les functions
typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model );
typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model );
Si qqun pourrait m'aider!
Le code se trouver actuellement sur http://opencvlibrary.svn.sourceforge...34&view=markup
Merci