簡體   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