I\'m trying to use cv::setMouseCallback in my c++ project. I just don\'t get it. let that I habe a class Stuff how can tell this class you got a frame and run the cv::se
you must declare a mouse handler as static inside your class. For instance, I have a dragger
with a member mouser
, that I want to be called. I declare an helper static void mouser
, that cast the void* received and calls the member:
class dragger {
void mouser(int event, int x, int y) {
current_img = original_img.clone();
Point P(x, y);
...
}
static void mouser(int event, int x, int y, int, void* this_) {
static_cast(this_)->mouser(event, x, y);
}
and instance in dragger
constructor in this way
dragger(string w, Mat m) :
window_id(w), status(0), original_img(m), /*black(0, 0, 0),*/ K(5, 5)
{
...
setMouseCallback(w, mouser, this);
}
...
}