OpenCV VideoCapture 无法在 Python 中读取视频,但可以在 VS11 中读取 [英] OpenCV VideoCapture cannot read video in Python but able in VS11
问题描述
作为标题,我无法使用以下代码在 python 中使用 VideoCapture 读取视频:
As title, I am not able to read video using VideoCapture in python with the following code:
v = 'C:\test.mp4'
import cv2
cap = cv2.VideoCapture(v)
if cap.isOpened():
print "Finally"
else:
print "BOOM"
BOOM 一直在打印.叹息
BOOM is always being printed. sigh
而在 VS11 中,以下代码有效:
Whereas in VS11, the following code works:
#include "stdafx.h"
#include <opencv2highguihighgui.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:Python27DLLs 以及 PATH 中有以下 dll
I do realize there's a number solution in SO, but nothing works for me. I have the following dlls in C:Python27 and C:Python27DLLs, as well as in PATH
- opencv_ffmpeg.dll
- opencv_ffmpeg_64.dll
- opencv_ffmpeg_245_64.dll
- opencv_ffmpeg_245.dll
我不知道还有什么没有做.
I have no more idea what have not done.
请帮帮我.非常感谢.
推荐答案
I have solved the problem by installing the binaries from this download link provided by this answer.
它将所有 opencv DLL 复制到 C:Python27(或其他文件).但我不明白为什么它不能更早地工作,因为我已经将这些 DLL 包含在我的 PATH 中
It copied all opencv DLLs to C:Python27 (or maybe other files). But I don't understand why it wouldn't work earlier as I have already included those DLLs into my PATH
这篇关于OpenCV VideoCapture 无法在 Python 中读取视频,但可以在 VS11 中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!