VideoCapture在Anaconda中不

VideoCapture在Anaconda中不

本文介绍了VideoCapture在Anaconda中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ubuntu 14.04,并安装了anaconda python.我使用了conda install opencv和conda install cv2来安装opencv.但是,我根本无法使用VideoCapture(我需要逐帧处理视频).我需要在项目的其余部分中使用anaconda.

I am using ubuntu 14.04, and have anaconda python installed. I used conda install opencv and conda install cv2 to install opencv. However I am unable to use the VideoCapture at all (I need to process videos frames by frames). I need to use anaconda for the rest of the project.

这是我的代码:

import cv2
import os
capture = cv2.VideoCapture('/home/Downloads/data/zfH2XdRcH14.mp4')
while not capture.isOpened():
    print 'noob'
while True:
    ret, frame = capture.read()
    cv2.imwrite('~/Downloads/data/pic.png',frame)
    cv2.imshow('Video', frame)
    count += 1
    print count

代码继续打印菜鸟.我已经多次检查了位置,这是正确的.我不知道问题是什么,我已经坚持了几个小时.

The code keeps printing noob. I have checked the location multiple times and it is correct. I have no clue what the issue is and I have been stuck on this for hours.

推荐答案

ffmpeg在默认的conda频道中不存在.

ffmpeg is not present in default conda channel.

您需要从conda-forge频道下载opencv,该频道包含最新和其他软件包以及用于视频处理的依赖项.请尝试以下操作:

You need to download opencv from conda-forge channel which contains latest and additional packages and dependencies for video processing. Try the following:

conda install -c conda-forge ffmpeg
conda install -c conda-forge opencv

此处-c告知要使用的通道.在我们的情况下,我们需要"conda-forge".

Here -c tells which channel to use. In our case we need 'conda-forge'.

这篇关于VideoCapture在Anaconda中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 17:28