Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCapture will fail after open it many (about 99xx) times #12920

Open
stonechao opened this issue Oct 24, 2018 · 1 comment
Open

VideoCapture will fail after open it many (about 99xx) times #12920

stonechao opened this issue Oct 24, 2018 · 1 comment

Comments

@stonechao
Copy link

stonechao commented Oct 24, 2018

System information
  • OpenCV => 2.4.13.6
  • Operating System / Platform => windows7 64bit, windows10
  • Compiler => VS2015
  • WebCam => USB webcam
Detailed description

I found that open videocapture will fail when I did it many times.
It always failed around the 99xx times.

The testing code is quite simple as the following.
I show image when loop > 9900 since it will be easier to tell if the webcam still alive.

Is it an known issue or I did something wrong?
Thanks for comments.

Steps to reproduce
int main()
{
   Mat image;
   VideoCapture cap;      

   int i = 0;
   for (i = 0; i < 11000; i++)
   {			
   	cap.open(0);          
   	if (cap.isOpened())  
   	{
   		printf("open ok at:%d\n", i);

   		if (i > 9900) //read and show image after loop 9900
   		{
   			cap >> image;        
   			imshow("Webcam live", image);
   			waitKey(100);												
   		}
   	}
   	else
   	{
   		printf("open fail at:%d\n", i);
   	}

   }

   return 0;

}
@mshabunin
Copy link
Contributor

OpenCV 2.4.x is very old and will not be fixed anyway. Could you please try and reproduce your issue with OpenCV 4.5.5 (or 4.x branch)? Also post more information about your OpenCV build configuration.

Hint: set environment variables OPENCV_VIDEOIO_DEBUG=1 and OPENCV_LOG_LEVEL=debug to capture more information around the moment of failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants