c++ - Having trouble creating a class based implementation of OpenCV's mouseCallback function -
as title suggest, i'm having trouble implementing opencv's mousecallback function in class based c++ structure. allow me explain. have defined class called briskmatching in have created member function named mousecallback correct parameters opencv requires (please see code snippet below).
**briskmatching.h** class briskmatching { public: briskmatching(); ~briskmatching(); public: void mousecallback(int event, int x, int y, int flags, void *param); };
this fine, problem arises when try set function designated mouse callback function through opencv's cv::setmousecallback
function.
in main function, create instance of briskmatching class called briskmatcher when comes time set mouse callback attempt so...
cv::setmousecallback("matches", briskmatching::mousecallback, &matchesimg);
unfortunately, throws error.
error 3 error c3867: 'briskmatching::mousecallback': function call missing argument list; use '&briskmatching::mousecallback' create pointer member c:\users\mobilef\documents\visual studio 2010\projects\opencv_objtracking\opencv_briskmatching\main.cpp 54 1 opencv_briskmatching
i rid of error declaring mousecallback function static
in briskmatching.h
whole whack of other errors since refer many non-static member variables in mousecallback function.
so question guys this. how should modify code able pass mousecallback function declared within briskmatching class cv::setmousecallback
function?
thanks in advanced!
since member function takes this
pointer, need static wrapper function. typically, use param
parameter address of object member function belongs to, end 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 inside mousecallback
:
void briskmatching::mousecallback(int event, int x, int y, int flags, void *param) { briskmatching *self = static_cast<briskmatching*>(param); self->domousecallback(event, x, y, flags); }
Comments
Post a Comment