adaptation between old video capture card and new version opencv

asked 2016-03-10 04:40:12 -0600

Sheng Liu gravatar image

updated 2016-03-10 04:43:19 -0600

My boss let me write a simple monitoring program which could record video only when people appear. But the equipment we have, outdated commputer and three simulation video cameras with a capture card, are both bought many years ago. I don't know how to use opencv(2.4.12) to play video from old capture card(connect PC via USB). All methods I tried are failed. My code is as follows:

CvCapture *capture1 = cvCreateCameraCapture(0);
    IplImage* img1;
        cvNamedWindow("a", CV_WINDOW_AUTOSIZE);
        while (1)
        {
            img1 = cvQueryFrame(capture1);
            if (!img1)break;            
            cvShowImage("a", img1); 
                }

The result of it is " ERROR:SampleCB() - buffer sizes do not match". Someone said if add " CV_CAP_DSHOW", " videoinput" mode woud be used. However, the code doesnot work well.

 CvCapture *capture1 = cvCreateCameraCapture(CV_CAP_DSHOW);
        IplImage* img1;
            cvNamedWindow("a", CV_WINDOW_AUTOSIZE);
            while (1)
            {
                img1 = cvQueryFrame(capture1);
                if (!img1)break;            
                cvShowImage("a", img1); 
    }

The result is still " ERROR:SampleCB() - buffer sizes do not match". How to solve the adaption problem? Please give me some help. Thanks!

edit retag flag offensive close merge delete