As the title suggest, I\'m having some trouble implementing OpenCV\'s mouseCallback function in a class based C++ structure. Allow me to explain. I have defined a class called B
Since a member function takes a this
pointer, you will need a static wrapper function. Typically, you use the param
parameter to be the address of the object that the member function belongs to, so you end up with something like this:
...
static void mouseCallback(int event, int x, int y, int flags, void *param);
void doMouseCallback(int event, int x, int y, int flags);
And then inside the mouseCallback
:
void BriskMatching::mouseCallback(int event, int x, int y, int flags, void *param)
{
BriskMatching *self = static_cast(param);
self->doMouseCallback(event, x, y, flags);
}