- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
每次我使用 VideoCapture 尝试访问视频文件中的帧时,返回值 (ret
) 都是 false。请参阅下面的示例代码:
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 guide和 this long issue在 Github 上。此外,我阅读了一些涉及移动 ffmpeg dll 文件的解决方案,但那只是在 Windows 的情况下。
有什么想法吗?因为我肯定用完了。
最佳答案
供将来引用:使用 pip 安装 opencv 不适用于 ffmpeg。
Q: Why I can’t open video files on GNU/Linux distribution X or on macOS?
A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries are not compiled against it. The purpose of these packages is to provide as easy as possible installation experience for OpenCV Python bindings and they should work directly out-of-the-box. Adding FFmpeg as an additional dependency without a “universal” FFmpeg build (e.g. LGPL licensed build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future.
解决方案:
关于python - VideoCapture 在 Python OPENCV [Linux] 中总是返回 False,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43176029/
我几乎阅读了所有关于这个主题的问题,但我没有解决它。我正在研究 Linux/Mint。我试图用 opencv 打开我的网络摄像头(或任何无关紧要的视频)并从视频中读取一帧。我写了这段代码: impor
我正在尝试使用 C++ 和 OpenCV 来使用我的网络摄像头,但我遇到了这个错误 (...):Images.cpp:(.text+0x27): undefined reference to cv::
我已经在禁用 GPU 的情况下编译了 caffe,然后 cp caffe/build/Makefile openpose/Makefile.conf 运行 make all -j 6 得到这些错误:
我正在运行以下代码: import numpy as np import cv2 import os count = 0 cap = cv2.VideoCapture("/home/simon/PRO
我有一个问题似乎是由 OpenCV 3.xx 引起的 - 该问题在 OpenCV 2.xx 中没有体现 问题是读取视频文件。我的代码设置如下: >#include >#include >#incl
这可能是一个愚蠢的问题,但我真的无法弄清楚。 首先:抱歉标题含糊不清,我不太确定如何用几句话来描述我的问题。 我在 MS Visual Studio、C++ 中使用 OpenCV 2.4.3。我正在使
我正在使用 webrtc 示例代码从我的 Android 设备流式传输到网页。示例代码不具备切换摄像头的功能。我试图解决它,但失败了。该示例使用 VideoCapturerAndroid 类,我发现切
我正在尝试打开视频并将其写入某个位置: #include #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp
我是论坛的新手。几周前我开始将 Opencv 与 Java 结合使用。在我的程序中,我使用 videocapture 从 avi 文件中读取帧。昨天我注意到,在我的程序的不同运行中,从文件读取的第 n
我已经使用工作线程实时获取最新帧,代码如下。但是在我的代码中,有一个问题。该帧一直是第一帧,它没有更新。结果,第一帧做了remap(),remap result frame做了下一个循环remap .
根据这个article的回答这是指将单个图像组合成4面的方式。从那里开始,我想从仅使用单个视频更改为使用 4 个视频作为输入。 这是我的代码,它使用单个视频作为输入 import cv2 import
import numpy as np import cv2 cap = cv2.VideoCapture(0) fourcc = cv2.cv.CV_FOURCC(*'XVID') out = cv2
我正在尝试对 OpenCV 的 VideoCapture 类进行“包装”,但无法使其正常工作,我的代码如下: #include "opencv2/opencv.hpp" #include "openc
我可以在 VLC 中打开一个流,但在 OpenCV 中我无法捕获帧。 (Python 2.7、OpenCV 3.4.3 二进制分发版 x86、Windows 10)。我一直在关注本指南:https:/
我有几个 avi 文件,我试图逐帧读取这些文件。我使用 opencv 3.1.0 来读取帧: import cv2 cap = cv2.VideoCapture(file_path) 然后我只读了 c
该代码显示正确的图像,但是在图像“帧”播放后显示错误消息。所以我无法获得“res”图像 它只显示“无对象文件”错误消息。 我应该修复哪一部分才能使其正常工作? import cv2 import nu
我有一台装有2个Nvidia RTX GPU的机器。 主要任务是解码来自IP摄像机的h264视频,并使用GPU 将原始帧编码为JPEG 。 我通过以下方式从源代码构建了opencv + cuda: c
import cv2 import sys cpt=0 vidStream=cv2.videoCapture(0) while True: ret,frame=vidStream.read()
我一直试图找到一种方法来异步检查以查看我使用videocapture拍摄的下一帧相机是否准备就绪。 我遇到了waitAny(),它被描述为“等待VideoCapture的就绪帧”。 在OpenCV文档
定义类很新,我遇到了在自制类中定义 VideoCapture 对象的问题。请参阅下面的代码。 我尝试创建一个包含有关视频文件的所有信息的类。所以我初始化了 videoCapture 对象。哪个工作正常
我是一名优秀的程序员,十分优秀!