错误:'varName'未在此范围中声明 [英] error: 'varName' was not declared in this scope
问题描述
我想在我的图像中找到更大的轮廓(使用opencv和C ++)。我已经读过这个线程:
在OpenCV中查找轮廓?和绘制最大的元素连接使用areaContours(OpenCV)但我得到错误: 'varName'没有在这个范围内声明,这意味着编译器认为我还没有声明这个变量对吗?所以我的代码片段:
I want to find the biggerst contour in my image (with opencv and C++). I have been read this thread: Finding Contours in OpenCV? and Draw the biggest element conncted using areaContours (OpenCV ) but I got error: 'varName' was not declared in this scope, which mean compiler think I haven't been declare that variable right? So this snippet of my code:
threshold(Img, Img, t, 255, CV_THRESH_BINARY_INV);
vector<vector<Point>> varName;
findContours(Img, varName, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
我遇到此错误:
D:\OpencvWorkspace\....|50|error: 'varName' was not declared in this scope|
第50行是此代码:
vector<vector<Point>> varName;
我的问题。为什么编译器问这个变量没有声明在行声明那个变量。
My question. Why compiler ask this variable haven't declare at the line I declare that variable. could someone help me?
推荐答案
您使用了一个pre c ++ 11标准编译器(如您的意见)。较老的标准有一个问题,让解析器消除在嵌套模板类型说明符中使用的一对闭包括号>>
,从 operator> ;>()
。因此,你必须在它们之间写一个空格:
You have used a pre c++11 standard compiler (as proven in your comment). The older standard had a problem letting the parser disambiguate a pair of closing angle brackets >>
used in a nested template type specifier, from the operator>>()
. Thus you had to write a space between them:
vector<vector<Point> > varName;
// ^ Note the space
这篇关于错误:'varName'未在此范围中声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!