OpenCV + python-从视频文件中获取帧 [英] OpenCV + python -- grab frames from a video file

查看:615
本文介绍了OpenCV + python-从视频文件中获取帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法使用OpenCV捕获文件中的帧-我已经在Ubuntu上从源代码编译了所有必要的先决条件,具体取决于:

I can't seem to capture frames from a file using OpenCV -- I've compiled from source on Ubuntu with all the necessary prereqs according to: http://opencv.willowgarage.com/wiki/InstallGuide%20%3A%20Debian

#!/usr/bin/env python

import cv
import sys

files = sys.argv[1:]

for f in files:
    capture = cv.CaptureFromFile(f)
    print capture

    print cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH)
    print cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT)

    for i in xrange(10000):
        frame = cv.QueryFrame(capture)
        if frame:
            print frame

输出:

ubuntu@local:~/opencv$ ./test.py bbb.avi 
<Capture 0xa37b130>
0.0
0.0

框架始终为无...

我已经使用以下方法将视频文件转码为i420格式:

I've transcoded a video file to i420 format using:

mencoder $1 -nosound -ovc raw -vf format=i420 -o $2

有什么想法吗?

推荐答案

您没有安装gstreamer-ffmpeggsteamer-pythongsteamer-python-devel软件包.我安装了所有三个.并解决了完全相同的问题.

You don't have the gstreamer-ffmpeg or gsteamer-python or gsteamer-python-devel packages installed. I installed all three of them. and the exact same problem was resolved.

这篇关于OpenCV + python-从视频文件中获取帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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