簡體   English   中英

作為向量<2f>進行轉換

[英]Casting as a vector<2f>

我正在使用OpenCV的highgui包括能夠在我的圖像上獲得鼠標點擊位置。 我已經定義了一個向量<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));

    }
}

我的編譯器在param上給了我一個錯誤並說錯誤:Expression必須有類類型。 任何人都可以建議如何投射為矢量結構? 或者我做錯了什么?

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

應該:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM