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