Ask Your Question

Revision history [back]

how to release camera when application is running

I thought when i==20 it will release the camera but the process is still holding the camera. How can I release it. I am sure cvQueryFrame is playing some role for not releasing the camera.

main( int argc, char* argv[] ) { int i=1; CvCapture* capture = NULL; capture = cvCreateCameraCapture( 0 );

IplImage *frames = cvQueryFrame(capture);

while(1) {      
    if (i==20)
        cvReleaseCapture ( &capture );

    char c = cvWaitKey(33);
    if( c == 27 ) break;
    i++;
}
return 0;

}

how to release camera when application is running

I thought when i==20 it will release the camera but the process is still holding the camera. How can I release it. I am sure cvQueryFrame is playing some role for not releasing the camera.

main( int argc, char* argv[] ) {
int i=1;
CvCapture* capture = NULL;
capture = cvCreateCameraCapture( 0 );

);
 IplImage *frames = cvQueryFrame(capture);
 while(1) {
 if (i==20)
  cvReleaseCapture ( &capture );
 char c = cvWaitKey(33);
  if( c == 27 ) break;
 i++;
 }
 return 0;

}

}