1

我正在使用 OpenCV 的 highgui include 来获取图像上的鼠标点击位置。我已经定义了一个 vector<2f> 我想存储已点击的点,但不幸的是,我认为我做错了什么:

void on_mouse(int mouseEvent, int x, int y, int flags, void* param)
{
    if( mouseEvent == CV_EVENT_LBUTTONDOWN) {

        printf("Clicked image at (%d,%d)\n", x, y);

        (vector<Point2f>*)param.push_back(Point2f(x,y));

    }
}

我的编译器在参数上给了我一个错误并说错误:表达式必须具有类类型。谁能建议如何将其转换为矢量结构?或者我做错了什么?

4

1 回答 1

4
    (vector<Point2f>*)param.push_back(Point2f(x,y));

应该:

    reinterpret_cast<vector<Point2f>*>(param)->push_back(Point2f(x,y));
于 2012-11-29T21:01:46.993 回答