2

所以我检查了我的指针,我真的不确定这里出了什么问题。我通过引用修改它们的函数来传递 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> > > > > (*)()'

我试过制作矢量指针,但没有奏效。我想我在某处或某处使用临时变量……这里有什么问题?

4

2 回答 2

6

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

vector<vector<int> >  fingertips;
vector<vector<Point> >  hands;
//                           ^ loose the ()s
于 2011-05-22T21:36:31.350 回答
2

你应该像这样初始化向量,没有'()':

vector<vector<int> >  fingertips;
vector<vector<Point> >  hands;
于 2011-05-22T21:36:56.650 回答