Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenCV找不到视频设备_Opencv - Fatal编程技术网

OpenCV找不到视频设备

OpenCV找不到视频设备,opencv,Opencv,我无法在Ubuntu 11.04中使用网络摄像头作为OpenCV 2.3.1的输入设备,此代码在windows上运行良好: #include "cv.h" #include "highgui.h" #include <stdio.h> // A Simple Camera Capture Framework int main() { CvCapture* capture = cvCaptureFromCAM(-1); if( !capture ) { fprint

我无法在Ubuntu 11.04中使用网络摄像头作为OpenCV 2.3.1的输入设备,此代码在windows上运行良好:

#include "cv.h"
#include "highgui.h"
#include <stdio.h>

// A Simple Camera Capture Framework
int main() {

  CvCapture* capture = cvCaptureFromCAM(-1);
  if( !capture ) {
    fprintf( stderr, "ERROR: capture is NULL \n" );
    getchar();
    return -1;
  }

  // Create a window in which the captured images will be presented
  cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );

  // Show the image captured from the camera in the window and repeat
  while( 1 ) {

    // Get one frame
    IplImage* frame = cvQueryFrame( capture );
    if( !frame ) {
      fprintf( stderr, "ERROR: frame is null...\n" );
      getchar();
      break;
    }

    cvShowImage( "mywindow", frame );
    // Do not release the frame!

    //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
    //remove higher bits using AND operator
    if( (cvWaitKey(10) & 255) == 27 ) break;
  }

  // Release the capture device housekeeping
  cvReleaseCapture( &capture );
  cvDestroyWindow( "mywindow" );
  return 0;
}
#包括“cv.h”
#包括“highgui.h”
#包括
//一个简单的摄像机捕获框架
int main(){
CvCapture*capture=cvCaptureFromCAM(-1);
如果(!捕获){
fprintf(stderr,“错误:捕获为空\n”);
getchar();
返回-1;
}
//创建一个显示捕获图像的窗口
cvNamedWindow(“mywindow”,CV_WINDOW_AUTOSIZE);
//在窗口中显示从相机捕获的图像,然后重复
而(1){
//得到一帧
IplImage*frame=cvQueryFrame(捕获);
如果(!帧){
fprintf(stderr,“错误:帧为空…\n”);
getchar();
打破
}
cvShowImage(“我的窗口”,框架);
//不要松开框架!
//如果按下ESC键,则在OpenCV 0.9.7(linux版本)下的键=0x10001B,
//使用AND运算符删除高位
如果((cvWaitKey(10)&255)==27)中断;
}
//释放捕获设备
cvReleaseCapture(&capture);
CvWindow(“mywindow”);
返回0;
}

它返回“ERROR:capture is NULL”

我找到了解决方案,我需要安装
libv4l-0
libv4l-dev
,然后用
USE_V4L=ON
编译OpenCV

我的网络摄像头是/dev/video0你能用另一个V4L应用程序(例如Camorama)捕获帧吗?只是为了确保您安装了所有需要的要求,并且cam实际上得到了支持。是的,我可以,Camorama工作正常