0
我使用的是OpenCV 2.4.9和g ++。我也試過用python 2.7.8和python 3.4.1。OpenCV掛在讀取(),抓取()等從文件
這裏有一個簡單的例子:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char *argv[]) {
VideoCapture stream;
if (argc > 1) {
stream.open(argv[1]);
} else {
stream.open(0);
}
if (!stream.isOpened()) {
cout << "cannot open file";
}
while (true) {
Mat frame;
stream.read(frame);
imshow("preview", frame);
if (waitKey(30) >= 0)
break;
}
return 0;
}
這編譯:
g++ `pkg-config --libs opencv` -o test test.cpp
工作得很好用相機,但不能從文件的程序只是掛起讀取時。 python也是如此。有任何想法嗎?
文件的格式是什麼?如果是視頻文件,它會工作,但如果它是jpg/png文件,最好使用Imread api:http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video .html?highlight = imread#imread – 2015-03-25 06:38:04
我已經嘗試了avi(例如tree.avi,以及另一個)和m2ts。我懷疑這是不知何故gstreamer相關,而不是一個opencv問題。 – 2015-03-25 16:11:43