Device or resource busy
Hi there,
I'm trying to write a program that uses 2 cameras. In the first step I open the cameras on by one for configuration (which is left, right, not to use and so on). After that I open the left and right camera each in on thread. I close the configuration with:
destroyWindow(id);
cap.release();
The Problem is after the configuration I get the following massage when I try to open the capturing:
VIDEOIO ERROR: V4L/V4L2: VIDIOC_CROPCAP
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
VIDIOC_REQBUFS: Device or resource busy
VIDIOC_G_FMT: Bad file descriptor
Unable to stop the stream.: Device or resource busy
VIDIOC_G_FMT: Bad file descriptor
Another thing thats happening is that the camera window stays open for much to long. I put a sleep(60) after closing the video feed and the window stays open until the sleep is over. It's like the command is not even executed when the command is given.
Edit: Full Code in here: http://pastebin.com/MgYen8pL The important part is the main function and the registerCameras function.
please show more code. (impossible to guess, what you're doing now)
It's done, pastbin link is up.
the capture is already running in a thread of its own. (it's all async)
does it get better, if you skip the registerCameras() function ? (i don't see the reason for this anyway)
The 2 threads run fine if I don't use registerCameras(). I need to register them because I have 3 cameras and need to know which one is left or right.
again, the main code won't wait until your captures(from registerCameras()) properly close.
Yeah I thought so, but how do I close it properly?
it will get even worse, once you try to port to a different machine/os/capture_type.
And what do you suggest I do? No Threads? How do I properly close the video stream?
maybe: while( cap.isOpened() ) waitKey(20);
the complete VideoCapture interface is quite unable to handle multiple cameras effectively. This is a known issue but adapting the complete interface will indeed be one hell of a job.