VideoCapture在Python OPENCV中始终返回False [Linux] [英] VideoCapture always returns False in Python OPENCV [Linux]

查看:581
本文介绍了VideoCapture在Python OPENCV中始终返回False [Linux]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我使用VideoCapture尝试从视频文件访问帧时,返回值(ret)为false.请参见下面的示例代码:

Every time that I use VideoCapture trying to access the frames from a video file, the return value (ret) is false. See the sample code below:

cap = cv2.VideoCapture('asd.mkv')
    vid = []
    while True:
        ret, img = cap.read()
        if not ret: # Always happens
            break
        vid.append(cv2.resize(img, (171, 128)))

我已经尝试使用谷歌搜索找到的所有东西,包括 OpenCV指南并在Github上此长期问题.另外,我阅读了一些涉及移动ffmpeg dll文件的解决方案,但这仅适用于Windows.

I have already tried absolutely everything I could find today by googling, including the OpenCV guide and this long issue on Github. Also, I read some solutions involving moving ffmpeg dll files, but that only was in the case of Windows.

有什么想法吗?因为我有足够的精力用光了它们.

Any ideas? Because I defenitely ran out of them.

推荐答案

问题出在我的IDE(Visual Studio代码)以及安装OpenCV时与bin文件的关联中……我很糟糕. 指南运行正常.

The problem was at my IDE (Visual Studio Code) and the association with bin files when installing OpenCV... my bad. This guide worked flawlessly.

这篇关于VideoCapture在Python OPENCV中始终返回False [Linux]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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