OpenCV VideoCapture无法在Python中阅读视频,但在VS11中却无法读取视频 [英] OpenCV VideoCapture cannot read video in Python but able in VS11

查看:198
本文介绍了OpenCV VideoCapture无法在Python中阅读视频,但在VS11中却无法读取视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题,我无法使用以下代码在python中使用VideoCapture来阅读视频:

  v ='C :\\test.mp4'
import cv2
cap = cv2.VideoCapture(v)
如果cap.isOpened():
打印最后
其他:
打印BOOM

BOOM始终被打印。



而在VS11中,以下代码正常工作:

  #includestdafx.h

#include< opencv2\highgui\highgui.hpp>
#include< iostream>

使用命名空间cv;
使用命名空间std;

int main(int argc,char * argv [])
{
string v =C:\\test.mp4;
VideoCapture cap;
cap.open(v);
if(cap.isOpened()){
cout<<< 是! << 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



我不知道还没有做。



请帮助我。非常感谢你。

解决方案

我已经通过从这个下载链接这个答案。



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


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 is always being printed. sigh

Whereas in VS11, the following code works:

#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;
}

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:\Python27\DLLs, 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.

Please help me. Thank you very much.

解决方案

I have solved the problem by installing the binaries from this download link provided by this answer.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆