ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV's setMouseCallback does not support calling into non-static class member functions (http://docs.opencv.org/modules/highgui/doc/user_interface.html?highlight=setmousecallback#cv.SetMouseCallback).

A work around for this could be declaring a static method that calls into the non-static method:

Declaration:

class object_tracker
{    
public:
    ...
private:
    static void onMouseStatic( int event, int x, int y, int flags, void* that );
    void onMouse( int event, int x, int y, int flags );

Definition:

void object_tracker::onMouseStatic( int event, int x, int y, int flags, void* that )
{
    that->onMouse( event,  x, y, flags );
}

void object_tracker::onMouse( int event, int x, int y, int flags )
{
...
}

And add this rather than 0 if you want to the callback:

setMouseCallback( "CamShift Demo", object_tracker::onMouseStatic, this );