作为标题,我无法使用以下代码在 python 中使用 VideoCapture 读取视频:
v = 'C:\\test.mp4'
import cv2
cap = cv2.VideoCapture(v)
if cap.isOpened():
print "Finally"
else:
print "BOOM"
BOOM 总是被打印出来。叹
而在 VS11 中,以下代码有效:
#include "stdafx.h"
#include <opencv2\highgui\highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
string v = "C:\\test.mp4";
VideoCapture cap;
cap.open(v);
if (cap.isOpened()) {
cout << "Yes!" << endl;
} else {
cout << "BOOM" << endl;
}
return 0;
}
我确实意识到SO中有一个数字解决方案,但对我没有任何作用。我在 C:\Python27 和 C:\Python27\DLLs 以及 PATH 中有以下 dll
- opencv_ffmpeg.dll
- opencv_ffmpeg_64.dll
- opencv_ffmpeg_245_64.dll
- opencv_ffmpeg_245.dll
我不知道什么还没有做。
请帮我。非常感谢。