Ask Your Question
1

cvSetMouseCallback function pointer WinForms

asked 2012-10-16 06:57:06 -0600

updated 2012-10-17 01:42:24 -0600

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-10-16 07:18:43 -0600

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);
edit flag offensive delete link more

Comments

Can you please elaborate this ?

ShirishRanoji gravatar imageShirishRanoji ( 2018-02-18 23:30:40 -0600 )edit
1

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

ShirishRanoji gravatar imageShirishRanoji ( 2018-02-18 23:45:07 -0600 )edit

Question Tools

Stats

Asked: 2012-10-16 06:57:06 -0600

Seen: 1,768 times

Last updated: Oct 17 '12