我想使用相機並對輸入流執行圖像處理,但是當程序執行時會出現一個窗口,詢問'Capture Source',之後'OK'或'Apply'什麼也沒有發生。OpenCV 2.2無法打開相機
但是,如果我使用視頻文件而不是相機,程序運行得很好。
下面是代碼:
int MainWindow::on_CameraOpen_triggered()
{
// programming done in Qt and using Opencv 2.2.
// all the variables are defined & declared in private of header file
// there is no compilation error
// return type of the function is 'int'
// Following program works fine if name of video file is mentioned
// instead of '0' is the line below
VideoCapture capture(0);
if(!capture.isOpened())
return 1;
bool stop(false);
double rate = capture.get(CV_CAP_PROP_FPS);
namedWindow("Extracted Frame");
int delayVideo = 1000/rate;
while(!stop)
{
if(!capture.read(frame))
{
break;
}
imshow("Extracted frame", frame);
if(waitKey(delayVideo)>=0)
{
stop = true;
}
}
capture.release();
}
我試圖以去除在下面的鏈接糾正錯誤: https://code.ros.org/trac/opencv/changeset/4400
https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/highgui/src/precomp.hpp?rev=4400
拍照效果上的gtalk等拍照軟件精。
請建議/指導可以做些什麼。
非常感謝。
問候, DBS
嗨,你可以解釋一下/澄清在你提到的代碼中的'// ...'部分應該有什麼w.r.t.在我的代碼在後。我從未在2.2之前使用過任何版本的opencv – DBS