Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello, I am not sure I understand well your problem, but I will give you an example on how I deal with this:

void Manager::init(){
  ...//code
  cv::setMouseCallback( "SELECT BOX", onMouse, &tinfo1 );    
  ...//code
}

void Manager::onMouse( int event, int x, int y, int , void* p ){
    trackerinfo* info = (trackerinfo*) p;
    switch ( event ){
    case cv::EVENT_LBUTTONDOWN:
    //set origin of the bounding box
    info->startSelection = true;
    info->bbox.x = x;
    info->bbox.y = y;
    break;
        ... /*other events...*/
    }
}

So, as you can see, you can use information that is modified inside the "onMouse" event method by passing a pointer to your data (In the example a "trackerinfo" object). As the callback expects a (void*) you have to apply proper casting for your own data types. You can also see that there is no inconvenient on using a class method as callback. Is this what you are looking for?