如何将向量传递给c ++

时间:2017-07-17 12:41:38

标签: c++ opencv

我正在使用带c ++的opencv并在图像上标记点。我想在main函数中返回这些点。我正在使用该功能来标记点。

int n=4;
int TOTAL_POINTS=n;
Point pt;
vector<Point> capturePoint = vector<Point>();

void CallBackFunc(int event, int x, int y, int flags, void* param)
{
    //Mat& image= *(Mat*) param;

    if (event == CV_EVENT_LBUTTONDOWN){
        pt.x = x;
        pt.y = y;
        cout << "Point" << TOTAL_POINTS + 1 - n << "(" << x << "," << y << ")" << endl;
        capturePoint.push_back(pt);
        n--;
        //circle(mouseDetector::workingMat,pt,2,Scalar(0,0,255), 5);
        if(n==0){
           cvDestroyAllWindows();
        }
    }
}

我从main称为

setMouseCallback("Display window", CallBackFunc, (void*)&FrameMat);

如何在capturePoint函数中获取main向量值?

1 个答案:

答案 0 :(得分:0)

我得到了解决方案。我已将其全局声明,然后其值也可在main中使用。