Ask Your Question

Revision history [back]

Passing multiple parameters with the setMouseCallback function

Is it possible to do? As of know I am using the following to pass an image to the callback:

static void onMouse( int event, int x, int y, int, void* param)
{
    // Mount back the parameters
    Mat* ptrImage = (Mat*)param;

    //What to do when left button is pressed
    if( event != EVENT_LBUTTONDOWN ){
        // Draw the point on the image here!
        return;
    }
}

namedWindow("draw mask", WINDOW_AUTOSIZE);
setMouseCallback("draw mask", onMouse, (void*)&work_image);

But I would like to add a second pointer to a vector of points to keep storing them also, just don't know how to add multiple parameters. Anyone has any idea without creating global variables?

Passing multiple parameters with the setMouseCallback function

Is it possible to do? As of know I am using the following to pass an image to the callback:

static void onMouse( int event, int x, int y, int, void* param)
{
    // Mount back the parameters
    Mat* ptrImage = (Mat*)param;

    //What to do when left button is pressed
    if( event != EVENT_LBUTTONDOWN ){
        // Draw the point on the image here!
        return;
    }
}

namedWindow("draw mask", WINDOW_AUTOSIZE);
setMouseCallback("draw mask", onMouse, (void*)&work_image);

But I would like to add a second pointer to a vector of points to keep storing them also, just don't know how to add multiple parameters. Anyone has any idea without creating global variables?

Passing multiple parameters with the setMouseCallback function

Is it possible to do?

As of know I am using the following to pass an image to the callback:

static void onMouse( int event, int x, int y, int, void* param)
{
    // Mount back the parameters
    Mat* ptrImage = (Mat*)param;

    //What to do when left button is pressed
    if( event != EVENT_LBUTTONDOWN ){
        // Draw the point on the image here!
        return;
    }
}

namedWindow("draw mask", WINDOW_AUTOSIZE);
setMouseCallback("draw mask", onMouse, (void*)&work_image);

But I would like to add a second pointer to a vector of points to keep storing them also, just don't know how to add multiple parameters. Anyone has any idea without creating global variables?