错误错误 C3861:"cvPyrSegmentation":找不到标识符
Error error C3861: 'cvPyrSegmentation': identifier not found
你能帮我吗???执行以下代码时出错。我是一个使用OpenCV的新手。我的老师是谷歌先生,你们是这方面的专家。
IntelliSense:标识符"cvPyrSegmentation"未定义
错误错误C3861:"cvPyrSegmentation":找不到标识符
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include <stdio.h>
static void help(void)
{
printf("nThis program present the function of pyramid segmentation which is
cvcvPyrSegmentation()n""we can controlled the value of threshold by creating
the taskbarn""Usage :n");
}
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;
int filter = CV_GAUSSIAN_5x5;
CvConnectedComp *cur_comp, min_comp;
CvSeq *comp;
CvMemStorage *storage;
CvPoint pt1, pt2;
static void START_SEGMENT(int a)
{
(void) a;
cvPyrSegmentation (image0, image1, storage, &comp, level, threshold1+1,
threshold2+1);
cvShowImage("Segmentation", image1);
}
int main( int argc, char** argv )
{
char* filename;
help();
filename = argc == 2 ? argv[1] : (char*)"C:/Users/acer/Documents/Visual Studio
2012/Projects/me2.jpg";
if( (image[0] = cvLoadImage( filename, 1)) == 0 )
{
help();
printf("Cannot load fileimage - %sn", filename);
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] );
// segmentation of the color image
l = 1;
threshold1 =255;
threshold2 =30;
START_SEGMENT(1);
sthreshold1 = cvCreateTrackbar("Threshold1", "Segmentation", &threshold1, 255,
START_SEGMENT);
sthreshold2 = cvCreateTrackbar("Threshold2", "Segmentation", &threshold2, 255,
START_SEGMENT);
cvShowImage("Segmentation", image1);
cvWaitKey(0);
cvDestroyWindow("Segmentation");
cvDestroyWindow("Source");
cvReleaseMemStorage(&storage );
cvReleaseImage(&image[0]);
cvReleaseImage(&image0);
cvReleaseImage(&image1);
return 0;
}
#ifdef _EiC
main(1,"pyramid_segmentation.c");
#endif
从外观上看,您没有包含正确的标题。
#include <opencv2/imgproc/imgproc_c.hpp>
编译器无法理解命令cvPyrSegmentation
的含义。您的解决方案是:
-
这个特定的函数实际上并不存在,而且您读错了文档(我在官方API中找不到这个函数)。
-
您可能缺少一个头文件。回到你所遵循的任何一个例子,并按照他们所展示的方式重做。如果你没有遵循一个例子,找一个;这几乎总是解决问题的最佳方法。
-
您可能缺少一些必须传递给编译器的标志。如果你熟悉使用库,你就会知道我的意思。如果您不熟悉在C中使用库,请先查找如何使用非常简单的库。我建议GMP。
如果你找不到一个例子,请留下评论,我一找到就会编辑一个。
在函数cvPyrSessionation所在的位置添加#include<cvaux.h>
。
附言:所有文件都包括在内,以保证。。。
#include<cv.h>
#include <cvaux.h>
#include <opencvcxcore.hpp>
#include <opencv.hpp>
#include <nonfree.hpp>
#include <core/core.hpp>
#include <imgproc/imgproc.hpp>
#include <imgproc/imgproc_c.h>
#include <highgui.h>
您需要:1) 首先包括legacy.hpp(通常在opencv2/legacy/legate.hpp上)
2) 确保legacy.hpp在链接器输入的"附加依赖项"中(我假设您使用的是visual C++)
相关文章:
- 设置 Visual Studio for MPI: 找不到标识符错误
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- C++:枚举:错误:应使用标识符而不是"}"
- 我的代码中有错误,未声明的标识符
- 错误:在 C++ 'std'使用未声明的标识符
- 从子类访问模板类成员时出现"找不到标识符"错误
- 为什么更改包含 psapi.h 的顺序会产生编译错误?(标识符 BOOL 未定义)
- 未声明的标识符错误,但变量定义正确 (?)
- C++ 多态构造函数错误;标识符未定义
- 虚幻引擎4:UShape组件给出错误"标识符未定义"。我能做什么?
- 如何修复可视化工作室中的"C2061语法错误标识符"堆栈?
- C++结构错误 - 错误 C2061:语法错误:标识符
- 在给定的代码中获取错误(标识符未定义)
- 视觉 在调用它时用 c++ 创建一个方法后,我得到的错误标识符未找到
- C++Visual Studio类错误标识符字符串未定义
- C++错误C2061:语法错误:标识符
- 智能感知错误标识符"emlrtStack"未定义
- 错误:标识符未在c++中定义
- Visual Studio错误:语法错误:标识符
- 错误 C2061:语法错误:标识符,但已包含头文件