5
我无法在Ubuntu 11.04使用网络摄像头作为输入设备的OpenCV 2.3.1,该代码工作正常的Windows:OpenCV中找不到视频设备
#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;
}
它返回“ERROR:捕捉NULL”
我的摄像头是/ dev/video0 – Maysam
您可以用另一个V4L应用程序(例如Camorama)捕获帧吗?只是为了确保您已经安装了所有需要的要求,并且实际上支持了凸轮。 –
是的,我可以,Camorama工作正常 – Maysam