繁体   English   中英

OpenCV VideoCapture无法在Python中读取视频,但在VS11中可以

[英]OpenCV VideoCapture cannot read video in Python but able in VS11

作为标题,我无法使用以下代码在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 \\ DLL以及PATH中都有以下dll

  • opencv_ffmpeg.dll
  • opencv_ffmpeg_64.dll
  • opencv_ffmpeg_245_64.dll
  • opencv_ffmpeg_245.dll

我不知道还没做什么。

请帮我。 非常感谢你。

我已经通过安装答案提供的下载链接中的二进制文件解决了该问题。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM