opencv立体相机错误

时间:2015-09-20 02:42:12

标签: c++ opencv

我在一个立体相机项目中工作我有两个相机5megapixels每一个我连接我的笔记本电脑并运行我的代码,但当我运行它我得到此错误libv4l2: error turning on stream: No space left on device im linux os我的c ++ opencv代码有任何想法如何解决它我尝试了其他代码我发现它在网络但仍然给我同样的错误

#include <opencv2/opencv.hpp>

int main()
{
cv::VideoCapture cap1(1);
cv::VideoCapture cap2(2);

if(!cap1.isOpened())
{
  std::cout << "Cannot open the video cam [1]" << std::endl;
  return -1;
}

if(!cap2.isOpened())
{
  std::cout << "Cannot open the video cam [2]" << std::endl;
  return -1;
}

cap1.set(CV_CAP_PROP_FPS, 15);
cap2.set(CV_CAP_PROP_FPS, 15);

// Values taken from output of Version 1 and used to setup the exact same parameters with the exact same values!
cap1.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap1.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
cap2.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 480);    

cv::namedWindow("cam[1]",CV_WINDOW_AUTOSIZE);
cv::namedWindow("cam[2]",CV_WINDOW_AUTOSIZE);

while(1)    
{    
  cv::Mat frame1, frame2;    
  bool bSuccess1 = cap1.read(frame1);    
  bool bSuccess2 = cap2.read(frame2);

  if (!bSuccess1)
  {
    std::cout << "Cannot read a frame from video stream [1]" << std::endl;
    break;
  }

  if (!bSuccess2)
  {
    std::cout << "Cannot read a frame from video stream [2]" << std::endl;
    break;
  }

  cv::imshow("cam[1]", frame1);
  cv::imshow("cam[2]", frame2);

  if(cv::waitKey(30) == 27)
  {
    std::cout << "ESC key is pressed by user" << std::endl;
    break;
  }
}

    return 0;
}

0 个答案:

没有答案