c++ - imshow() function freezes -


i developing video analytic algorithms using opencv. however, after process frame , want display on window, hangs @ imshow() function. have searched issue online still cannot find problem! here code using multithread , opencv:

void cfeatureextraction::extract(){     boost::thread opflowthread, bgsthread;     while (m_nrun){         imgptr frame_ptr;         m_pqueue->wait_and_pop(frame_ptr);         mat frame1, frame2;          (*frame_ptr).copyto(frame1);         (*frame_ptr).copyto(frame2);          opflowthread = boost::thread(&copflow::op_flow, m_palgo,frame1);         bgsthread = boost::thread(&cbgsub::bgsub, m_pbgs, frame2);         opflowthread.join();         bgsthread.join();     } } 

and inside op_flow , bgsub function, using imshow() , cvwaitkey() together! keeps hanging whole program. if question still not clear you, pls feel free ask me more detail. here detail code of calling imshow():

cfarnebackalgo::cfarnebackalgo() : copflow() {     namedwindow("optical flow"); }  cfarnebackalgo::~cfarnebackalgo() {     destroywindow("optical flow"); }  int cfarnebackalgo::op_flow(mat frame) {    mat flow;    cvtcolor(frame, gray, color_bgr2gray);    if (prevgray.data)    {        calcopticalflowfarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);         (int y = 0; y < frame.rows; y += 8)            (int x = 0; x < frame.cols; x += 8){            const point2f& fxy = flow.at<point2f>(y, x);            line(frame, point(x, y), point(cvround(x + fxy.x), cvround(y + fxy.y)),    scalar(0, 255, 0));            circle(frame, point(x, y), 2, scalar(0, 255, 0), -1);            }        if (frame.data == null){            cout << "no img!" << endl;            exit(0);        }        imshow("optical flow", frame);        waitkey(50);    }    std::swap(prevgray, gray);    return 0; } 

if put namedwindow() in op_flow(), working. if put in constructor, it's not working , freezes. knows why?


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -