Ask Your Question
1

cvSetMouseCallback function pointer WinForms

asked Oct 16 '12

updated Oct 17 '12

Kirill Kornyakov gravatar image

I got a function

void on_mouse(int event, int x, int y, int flag, void *param)
{
   //mouse functionality here
}

Then the function detectPositives() does the following command inside

cvSetMouseCallback(window_name, on_mouse, NULL);

And it doesn't seem to work using the function name as function pointer, which works perfectly in a CLI application, but not in this WinForm application header file.

Error message = error C3867: 'ObjectDetectionGUI::Form1::on_mouse': function call 
missing argument list; use '&ObjectDetectionGUI::Form1::on_mouse' to create a pointer 
to member

Anyone could help?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
5

answered Oct 16 '12

Vladislav Vinogradov gravatar image

You can't pass non-static function to cvSetMouseCallback. If you want to call method of some class in this callback, you can write wrapper-callback:

void on_mouse_wrapper(int event, int x, int y, int flag, void *param)
{
    ObjectDetectionGUI* thiz = (ObjectDetectionGUI*) param;
    thiz->on_mouse(...);
}

cvSetMouseCallback(window_name, on_mouse_wrapper, this);
Preview: (hide)

Comments

Can you please elaborate this ?

ShirishRanoji gravatar imageShirishRanoji (Feb 19 '18)edit
1

This I have used and found the same error. Did not work for me.

ShirishRanoji gravatar imageShirishRanoji (Feb 19 '18)edit

Question Tools

Stats

Asked: Oct 16 '12

Seen: 1,844 times

Last updated: Oct 17 '12