OPENCV多相机处理问题

OpenCV Multi-camera handling issue

本文关键字:处理问题 相机 OPENCV      更新时间:2023-10-16

1)我在使用OpenCV(更新的Kubuntu Linux)处理两个Logitech C310摄像机时会遇到此错误

vidioc_streamon:设备上没有剩余的空间

整个错误日志如下

**IDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument**
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
**libv4l2: error turning on stream: No space left on device**
**VIDIOC_STREAMON: No space left on device**
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /home/rjdp/Computer_Vision/0_Installers/OpenCV-2.4.2/modules/core/src/array.cpp, line 2482
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/rjdp/Computer_Vision/0_Installers/OpenCV-2.4.2/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

2)仅在处理两个摄像机,即使在默认低RES 640x480时也会发生。我仍然试图将代码中的分辨率降低到320x240,这也不起作用。

3)我在这里搜索了许多其他帖子&在其他网站上。这告诉我没有足够的USB凸轮带宽可用。因此,我试图将一个凸轮插入前方USB&一个在后侧也失败了:(

我的问题是:

是否可以解决此问题BandWith/Memory&运行两个或 OpenCV 2.4.2 ?? OpenCV使用 ffmpeg 处理I/O的更多摄像机,我可以使用一些ffmpeg命令告诉我的相机硬件,以使用 comprateds mpeg进行输入流模式而不是频率消耗正常模式。

代码如下:

#include "opencv2/opencv.hpp"
#include <stdio.h>
using namespace cv;
int main(int, char**)
{
    VideoCapture cap01(0); // open the default camera
    cap01.set(CV_CAP_PROP_FRAME_WIDTH,320);
    cap01.set(CV_CAP_PROP_FRAME_HEIGHT,240);
    //sleep(1);
    if(!cap01.isOpened())  // check if we succeeded
        return -1;
    namedWindow("Camera01",1);
    VideoCapture cap02(1); // open the default camera
    cap02.set(CV_CAP_PROP_FRAME_WIDTH,320);
    cap02.set(CV_CAP_PROP_FRAME_HEIGHT,240);
   if(!cap02.isOpened())  // check if we succeeded
        return -1;
    namedWindow("Camera02",1);
    for(;;)
    {
        Mat frame, frame_1;
        //Mat frame02;
        cap02 >> frame;
        imshow("Camera01", frame);
        if(waitKey(30) >= 0) break;
        Mat frame_1;
        cap02 >> frame_1; 
        imshow("Camera02", frame_1);
        if(waitKey(30) >= 0) break;
    }
    return 0;
}

使用pci USB扩展卡对我解决了相同的问题,因为网络摄像头会在USB总线上使用所有可用的bandwith。使用PCI USB扩展卡为您提供第二个USB总线,您可以连接第二个网络摄像头