我使用的是在Ubuntu 13.04(上宏碁C7 Chromebook)的OpenCV 2.4.6閱讀,我使用一個簡單的測試程序,看看我的攝像頭將與合作OpenCV的。它適用於奶酪和Skype,所以我知道攝像頭本身不是問題。OpenCV的VideoCapture不能從我的攝像頭在所有
這裏是我的代碼(編譯沒有任何錯誤):
#include "opencv2/opencv.hpp"
#include <stdio.h>
#include <stdlib.h>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
cv::VideoCapture cap;
if(argc > 1)
{
cap.open(string(argv[1]));
}
else
{
cap.open(CV_CAP_ANY);
}
if(!cap.isOpened())
{
printf("Error: could not load a camera or video.\n");
}
Mat frame;
namedWindow("video", 1);
for(;;)
{
waitKey(20);
cap >> frame;
if(!frame.data)
{
printf("Error: no frame data.\n");
break;
}
imshow("video", frame);
}
}
如果我不帶任何參數運行程序(因爲我希望它使用CV_CAP_ANY),我得到
Error: could not load a camera or video.
init done
opengl support available
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
Error: no frame data.
如果我指定/ dev/video0(我唯一的相機)作爲參數,我得到
demux_wavpack: (open_wv_file:127) open_wv_file: non-seekable inputs aren't supported yet.
(ERROR)icvOpenAVI_XINE(): Unable to open source '/dev/video0'
init done
opengl support available
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
GStreamer Plugin: Embedded video playback halted; module source reported: Could not read from resource.
Error: no frame data.
如果我指定路徑一個視頻文件作爲參數,它播放視頻就好了。
我很感激任何幫助。提前致謝!
哇。這在過去的一週裏讓我很難過,所以我很高興他們今天把它固定下來。非常感謝! – Jragon
不客氣;) – Poko
我剛剛完成刪除2.4.6和安裝2.4.6.1,我的代碼完美無瑕! – Jragon