opencv low fps on raspberry pi 4

asked 2020-02-15 16:45:19 -0500

mateusguilherme gravatar image

Hello

I have a raspberry pi 4 and a PiCamera and I'm trying to get video stream with python and opencv from PICamera and display it on the screen. With low resolutions (320x240) everything works fine, but with resolutions 800x600 .. 720p .. 1080p the fps is very low.

With the command raspvid ( raspivid -o - -t 0 -w 1920 -h 1080 -fps 30 -b 250000 ) the video stream displayed is perfect, in high resolution and practically in real time. Everything leads me to believe that there is enough hardware to process 1080p images at 30fps. Is there any limitation of cv2.imshow with raspberry?

my code:

from picamera import PiCamera
from picamera.array import PiRGBArray
from time import sleep
import cv2
import time

camera = PiCamera()
camera.resolution = (1280, 720)
camera.framerate = 32
rawCapture = PiRGBArray(camera, size=(1280, 720))
time.sleep(0.1)

for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
        image = frame.array
        cv2.imshow("Frame", image)
        key = cv2.waitKey(1) & 0xFF
        rawCapture.truncate(0)
        if key == ord("q"):
                break

any suggestion?

edit retag flag offensive close merge delete

Comments

twreese gravatar imagetwreese ( 2020-08-19 10:59:16 -0500 )edit