c ++向量问题; 通过参考传递东西

Jam*_*les 2 c++ pointers reference vector temporary

所以我检查了我的指针,我真的不确定这里出了什么问题.我通过引用修改它们的函数传递2个向量向量.这是功能:

bool imageToTips( Mat& img,
  vector<vector<int> > & fingertips,
  vector<vector<Point> > & hand,
  double epsilon,
  double theta){
      //code 
}
Run Code Online (Sandbox Code Playgroud)

这就是所谓的地方:

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
}
Run Code Online (Sandbox Code Playgroud)

错误:

/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> > > > > (*)()'
Run Code Online (Sandbox Code Playgroud)

我已经尝试制作矢量指针但它没有用.我想我在某个地方或某个地方使用临时变量......这里有什么问题?

ken*_*ytm 6

您不需要()默认构造变量,否则您将定义一个函数.

vector<vector<int> >  fingertips;
vector<vector<Point> >  hands;
//                           ^ loose the ()s
Run Code Online (Sandbox Code Playgroud)