【发布时间】:2011-05-22 21:30:28
【问题描述】:
所以我检查了我的指针,我真的不确定这里出了什么问题。我通过引用修改它们的函数来传递 2 个向量向量。函数如下:
bool imageToTips( Mat& img,
vector<vector<int> > & fingertips,
vector<vector<Point> > & hand,
double epsilon,
double theta){
//code
}
这就是它的名字:
Mat depth = _depth;
Mat image = depth.clone();
Mat decon = depth.clone();
vector<vector<int> > fingertips();
vector<vector<Point> > hands();
double epsilon = 50;
double theta = 30;
if (fs::imageToTips(decon, fingertips, hands, epsilon, theta))
{
drawContours(image, hands, -1, Scalar(255,0,0,0));
imshow("KinectFingerProcessing", image);
//more code
}
错误:
/FingerLocator2/main.cpp:47: error: invalid initialization of non-const reference of type 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&' from a temporary of type 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > (*)()'
/FingerLocator2/main.cpp:49: error: invalid initialization of reference of type 'const std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > >&' from expression of type 'std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > > (*)()'
我试过制作矢量指针,但没有奏效。我想我在某处或某处使用了临时变量……这里有什么问题?
【问题讨论】:
-
哈哈,最常见的问题之一,但很难搜索...
-
@Xeo:除非你知道如何搜索 Most Vexing Parse(或者你的意思是,在代码中?一些编译器会帮助你 -Wall 或类似的)
-
@sehe:如果你知道最棘手的解析,你就不会遇到这个问题,甚至不会问这个问题。 ;)
标签: c++ pointers vector reference temporary