![](/img/trans.png)
[英]Webcam not working in Ubuntu 12.04, works with cheese, not for OpenCV
[英]OpenCV 2.4.3 camera capture not working on Ubuntu 12.04
我試圖在Ubuntu 12.04 LTS上使用openCV 2.4.3執行以下程序。 但我得到“相機未初始化為輸出”任何人都可以幫助我。
這是代碼:
include <iostream>
include "opencv2/imgproc/imgproc.hpp"
include "opencv2/highgui/highgui.hpp"
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap(1);
if (!cap.isOpened())
{
cout <<"Failed to initialize camera\n";
return 1;
}
namedWindow("CameraCapture");
Mat frame;
while (1)
{
cap>> frame;
imshow("cameraCapture",frame);
if (waitKey(30)>0)break;
}
destroyAllWindows();
return 0;
}
請幫我!
謝謝,Kushal
嘗試以下......
#include "iostream"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
CvCapture *webcam = cvCaptureFromCAM(-1);
IplImage *img = NULL;
while(true)
{
img = cvQueryFrame(webcam);
cvShowImage("TEST",img);
cvWaitKey(20);
}
return 0;
}
你檢查了默認的捕獲設備嗎? 默認情況下為0
VideoCapture cap(0);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.