Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You pass pointer to local variable part into cv::setMouseCallback. This variable will be destroyed in the end of gettingROI function. And in mouseHandler you will get bad pointer. Make part variable a class member:

class Mainthread
{
    cv::Mat m_part;
public :
     static void mouseHandler(int event,int x,int y, int flags,void* param);
     void gettingROI();    
};
void MainThread::gettingROI()
{
    m_part = stream.getframe();
    name = "roi";
    cv::imshow(name, m_part);
    cv::setMouseCallback(name, mouseHandler, &m_part);
}