【问题标题】:OpenCV VideoCapture cannot read video in Python but able in VS11OpenCV VideoCapture 无法在 Python 中读取视频,但可以在 VS11 中读取
【发布时间】:2013-04-28 18:50:36
【问题描述】:

作为标题,我无法通过以下代码在 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

我不知道还有什么没做。

请帮助我。非常感谢。

【问题讨论】:

    标签: python opencv ffmpeg


    【解决方案1】:

    我已经通过安装download link 提供的this 答案中的二进制文件解决了这个问题。

    它将所有 opencv DLL 复制到 C:\Python27(或者可能是其他文件)。但我不明白为什么它不能更早地工作,因为我已经将这些 DLL 包含在我的 PATH 中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-16
      • 2018-02-27
      • 1970-01-01
      • 2020-02-12
      • 2019-05-18
      • 2014-04-30
      • 1970-01-01
      • 2018-04-23
      相关资源
      最近更新 更多