Reading Video File Slow on Raspberry Pi

asked 2015-03-14 16:46:21 -0600

Rookie25 gravatar image

Hi,

I'm having performance problems reading video files using OpenCV and Python on a Raspberry Pi. I get around 2 fps. That is just reading the frames, doing nothing else. I have absolutely no problem reading from the camera module. The video I'm trying to read is a .h264 file recorded using the camera module.

Here is my test code:

import numpy as np
import cv2

try:
    cap = cv2.VideoCapture('/home/pi/test.h264')
except:
    print 'Could not open video file'

i=0
while True:
    ret, frame = cap.read()
    i+=1
    print 'frame ', i

I can play the video fine with omxplayer so it's not a limitation of the Raspberry Pi itself.

Using Python 2.7.3 & OpenCV 2.4.11. Feels like something is wrong somewhere?

edit retag flag offensive close merge delete

Comments

As Python is a performance killer I would go with C++ for better results.

Kozuch gravatar imageKozuch ( 2015-04-24 15:27:38 -0600 )edit