Problem with cvCaptureFromFile in thread!!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with cvCaptureFromFile in thread!!

putikorn@ymail.com
UINT runThread(LPVOID pParam){
       
        CvCapture* capture = cvCaptureFromFile("traffic.avi");
        cvNamedWindow("e");

        IplImage* frame;
        if(capture==NULL){
                AfxMessageBox(_T("End t1"));
                return 0;
        }
        while(TRUE){
                cout<<"t";
                if( cvGrabFrame(capture)){
                        frame = cvRetrieveFrame(capture);
                        if(frame){
                                cvShowImage("e",frame);
                        }
                }
                cvWaitKey(10);
                ::Sleep(10);
        }

    cvReleaseCapture( &capture );
    cvDestroyWindow("e");

        return 0;
}

while 2 thread run at the same time, thread which is the second thread
has problem because "capture" in the second thread is null.(Althought
capture from different file)
how can i fix this?