Ask Your Question

Revision history [back]

What you basically do is creating a void* to the image, then inside your handler you do

void onMouse(int event, int x, int y, int flags, void* param)
{
    Mat src;
    src = *((Mat*)param);

   ...

and in source code you do

setMouseCallback("source", onMouse, &src);

What you basically do is creating a void* to the image, then inside your handler you do

void onMouse(int event, int x, int y, int flags, void* param)
{
    Mat src;
    src = *((Mat*)param);

   ...

and in source code you do

setMouseCallback("source", onMouse, &src);

or if you really do not care about copies and optimized code, just make a global Mat element and address it from everywhere. Thats how the tutorials do it.