编译cvaux错误的原因
平台vc6.0;
在debug模式下编译cvaux时会提示三个错误:
error C2039: 'foreground_regions' : is not a member of 'CvFGDStatModel'
error C2039: 'foreground_regions' : is not a member of 'CvFGDStatModel'
error C2039: 'foreground_regions' : is not a member of 'CvGaussBGModel'
error C2039: 'foreground_regions' : is not a member of 'CvFGDStatModel'
error C2039: 'foreground_regions' : is not a member of 'CvGaussBGModel'
在网上搜到的解决方法都是这样写的:
在cvaux.h文件中,
搜索关键字foreground_regions,
CvMemStorage* storage; /*storage for 揻oreground_regions?/ \
CvSeq* foreground_regions /*foreground object contours*/
改为如下形式:
CvMemStorage* storage; /*storage for foreground_regions*/ \
CvSeq* foreground_regions /*foreground object contours*/
CvMemStorage* storage; /*storage for 揻oreground_regions?/ \
CvSeq* foreground_regions /*foreground object contours*/
改为如下形式:
CvMemStorage* storage; /*storage for foreground_regions*/ \
CvSeq* foreground_regions /*foreground object contours*/
具体原因解释如下:首先foreground_regions 定义在这个宏里面:
#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*/ \
IplImage** layers; /*8UC3 reference background image, can be null */ \
int layer_count; /* can be zero */ \
CvMemStorage* storage; /*storage for 揻oreground_regions?*/ \
CvSeq* foreground_regions /*foreground object contours*/
int type; /*type of BG model*/ \
CvReleaseBGStatModel release; \
CvUpdateBGStatModel update; \
IplImage* background; /*8UC3 reference background image*/ \
IplImage* foreground; /*8UC1 foreground image*/ \
IplImage** layers; /*8UC3 reference background image, can be null */ \
int layer_count; /* can be zero */ \
CvMemStorage* storage; /*storage for 揻oreground_regions?*/ \
CvSeq* foreground_regions /*foreground object contours*/
“\”在这里代表续行的意思。并且注意前面定义的变量后面都有“;”号,而foreground_regions没有,因为它是这个定义的最后一项,因为宏定义末尾是不加‘;’号的。
另外要注意的是,千万不要在修改最后两行时写成这个样子:
CvMemStorage* storage; /*storage for 揻oreground_regions?*/ \
CvSeq* foreground_regions /*foreground object contours*/
即不能放入空行,因为这样一来foreground_regions就不属于宏定义中的一份了。而'CvFGDStatModel'和'CvGaussBGModel'中均包含了改宏,所以错误会照旧的。偶刚开始就犯了这个错误,还以为是各位高手犯错误了呢。呵呵