|
发表于 2012-11-12 17:13:11
|
显示全部楼层
opencv排错总结
你好,我是一个新手菜鸟。最近在跑代码例子的时候老是遇到这么个问题,求助啊!
1>d:\\opencv\\opencv2.2\\include\\opencv2\\flann\\logger.h(66): warning C4996: \'fopen\': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\\vs2010\\vc\\include\\stdio.h(234) : 参见“fopen”的声明
1>d:\\documents\\visual studio 2010\\projects\\test\\test\\test.cpp(21): error C2146: 语法错误: 缺少“;”(在标识符“filter”的前面)
1>d:\\documents\\visual studio 2010\\projects\\test\\test\\test.cpp(21): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\\documents\\visual studio 2010\\projects\\test\\test\\test.cpp(21): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>
我点击错误,所指的为CvFilter为无法识别的标示符,这究竟是什么错误?
完整代码例子如下:
#include "StdAfx.h"
#include "cv.h"
#include "highgui.h"
#include <math.h>
IplImage* image[2] = { 0, 0 }, *image0 = 0, *image1 = 0;
CvSize size;
int w0, h0,i;
int threshold1, threshold2;
int l,level = 4;
int sthreshold1, sthreshold2;
int l_comp;
int block_size = 1000;
float parameter;
double threshold;
double rezult, min_rezult;
CvFilter filter = CV_GAUSSIAN_5x5;
CvConnectedComp *cur_comp, min_comp;
CvSeq *comp;
CvMemStorage *storage;
CvPoint pt1, pt2;
void ON_SEGMENT(int a)
{
cvPyrSegmentation(image0, image1, storage, &comp,
level, threshold1+1, threshold2+1);
/*l_comp = comp->total;
i = 0;
min_comp.value = cvScalarAll(0);
while(i<l_comp)
{
cur_comp = (CvConnectedComp*)cvGetSeqElem ( comp, i );
if(fabs(255- min_comp.value.val[0])>
fabs(255- cur_comp->value.val[0]) &&
fabs(min_comp.value.val[1])>
fabs(cur_comp->value.val[1]) &&
fabs(min_comp.value.val[2])>
fabs(cur_comp->value.val[2]) )
min_comp = *cur_comp;
i++;
}*/
cvShowImage("Segmentation", image1);
}
int main( int argc, char** argv )
{
char* filename = argc == 2 ? argv[1] : (char*)"fruits.jpg";
if( (image[0] = cvLoadImage( filename, 1)) == 0 )
return -1;
cvNamedWindow("Source", 0);
cvShowImage("Source", image[0]);
cvNamedWindow("Segmentation", 0);
storage = cvCreateMemStorage ( block_size );
image[0]->width &= -(1<<level);
image[0]->height &= -(1<<level);
image0 = cvCloneImage( image[0] );
image1 = cvCloneImage( image[0] );
// 对彩色图像进行分割
l = 1;
threshold1 =255;
threshold2 =30;
ON_SEGMENT(1);
sthreshold1 = cvCreateTrackbar("Threshold1", "Segmentation", &threshold1, 255,
ON_SEGMENT);
sthreshold2 = cvCreateTrackbar("Threshold2", "Segmentation", &threshold2, 255,
ON_SEGMENT);
cvShowImage("Segmentation", image1);
cvWaitKey(0);
cvDestroyWindow("Segmentation");
cvDestroyWindow("Source");
cvReleaseMemStorage(&storage );
cvReleaseImage(&image[0]);
cvReleaseImage(&image0);
cvReleaseImage(&image1);
return 0;
} |
|