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