2013-10-20 35 views
0

我最近重新安装Ubuntu - 12.04。我正在使用摄像头为OpenCV中的程序拍摄视频。它不适用于我的摄像头,但同一段代码适用于我的朋友。 我的摄像头和奶酪一起工作。 的一块我使用的代码是:网络摄像头不工作在Ubuntu 12.04,与奶酪,不为OpenCV

#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/core/core.hpp" 
#include "opencv2/imgproc/imgproc_c.h" 
#include <opencv2/imgproc/imgproc.hpp> 
#include <iostream> 
#include <stdio.h> 
#include <stdlib.h> 
#include <math.h> 
#define heightBirdEyeView 1000 
#define widthBirdEyeView 1000 //earlier was 300 300 
#define _USE_MATH_DEFINES 

//public class VideoCapture; 
using namespace cv;   
using namespace std; 

int main(int argc, char** argv) 
{ 
VideoCapture cap(0); // open the default camera 

if(!cap.isOpened()) 
{ // check if we succeeded 
cout<<"cam not open"<<endl; 
return -1;} 

cout<<"yay"<<endl; 

Mat frame; 
while(1) 
{ 
cap >> frame; 

imshow("frame", frame); 

if(waitKey(30) >= 27) 
break; 
} 

return 0;} 

出了什么问题?

回答

0

v4l2或v4l可能会丢失,请检查您的输出结果。它应该有很高的问题。

+0

我有v4l和v4l2。任何类型的外部摄像头也不会被检测到。 –