我剛剛安裝在我的Mac OSX與OpenCV的10.8.3,我有釀造安裝了它:OpenCV中不顯示在Mac OSX上的視頻
brew install opencv
版本爲2.4.3
>>> ls /usr/local/Cellar/opencv
2.4.3
我嘗試顯示視頻。格式爲.asf,編解碼器爲MJPG(我只能用VLC打開它,請參閱屏幕截圖)
幀數(如果在opencv中打印或在VLC中顯示)是相同的。
但是,如果我運行opencv程序只顯示第一幀。其他不是..爲什麼?
這是OpenCV的代碼
#include <iostream>
#include <string>
#include <sstream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main(int argc, char *argv[]) {
Mat frame;
int numframe = 0;
if (argc != 2) {
cout << "Not enough parameters" << endl;
return -1;
}
const string source = argv[1];
VideoCapture capture(source);
namedWindow("video", CV_WINDOW_AUTOSIZE);
if (!capture.isOpened()) {
cout << "Could not open " << source << endl;
return -1;
}
for(;;) {
capture >> frame;
numframe++;
if (frame.empty()) {
cout << "frame empty.." << endl;
break;
}
cout << numframe << endl;
imshow("video", frame);
}
return 0;
}
我怎麼看ffmpeg支持已經在?因爲我認爲這樣 – nkint
我發現你的問題已經解決了。但是,爲了將來的參考,您可以使用函數cv :: getBuildInformation()來獲得已編譯模塊的詳細信息。 – sansuiso