Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Try this

    CvCapture *capture1 = cvCaptureFromCAM(0);
    if( !capture1 ) return 1; 
    cvNamedWindow("Video1");
    while(true) 
    {
        //grab and retrieve each frames of the video sequentially 
        IplImage* frame1 = cvQueryFrame( capture1 );

        cvShowImage( "Video1", frame1 );

        //wait for 40 milliseconds
        int c = cvWaitKey(40);

        //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27) 
        if((char)c==27 ) break;
    }
}

Hope this works for you , and the code which you paste in comment kindly paste it in your question , so that every one can better understand what your trying to do

Try this

    CvCapture *capture1 = cvCaptureFromCAM(0);
    if( !capture1 ) return 1; 
    cvNamedWindow("Video1");
    while(true) 
    {
        //grab and retrieve each frames of the video sequentially 
        IplImage* frame1 = cvQueryFrame( capture1 );

        cvShowImage( "Video1", frame1 );

        //wait for 40 milliseconds
        int c = cvWaitKey(40);

        //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27) 
        if((char)c==27 ) break;
    }
}

Hope this works for you , and the code which you paste in comment kindly paste it in your question , so that every one can better understand what your trying to do

In c++ format you can get the answer from here answer