OpenCV找不到视频设备
我无法在Ubuntu 11.04中使用网络摄像头作为OpenCV 2.3.1的输入设备,此代码在windows上运行良好: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
#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工作正常