我有一个使用openCV的C ++程序来打开摄像头。
执行此操作的行如下:
cout<<"camera initializing\n";
VideoSettings cam(camNum + CAP_V4L);
cout<<"camera initialized\n";
cout<<"Ch3ck c4m3ra is 0p3n3d\n";
if ( !cam.isOpened())
{
cout << "Could not open reference " << sourceReference << endl;
return -1;
}
我编译了程序,它运行没有问题。
但是,有时我想在Ubuntu18.04上使用相同的cam两次启动相同的程序(其id作为bash参数传递)。 启动第二个打开同一凸轮的实例时出现的错误是:
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Device or resource busy
VIDEOIO ERROR: V4L: can't open camera by index 0
当然,由于cam.isOpened()
尚未验证,因此代码正在停止。
可以多次启动OSX上相同的程序(删除CAP_V4L
)。
为什么行为不同?是否有任何简单的解决方法在Ubuntu上具有相同的行为?