Size and framerate
Posted: Mon May 30, 2022 11:03 pm
I'm trying to capture high resolution frames from the Stereopi, reading the output of raspividyuv as suggested in this medium post. However, the framerate is terribly slow at 3264 x 1024 (1632 x 1024 per side). This is the code I'm running:
The execution line is
And the output is
As you can see, the code doesn't do anything with the images, not even using cv2.imshow()
Is this the correct approach to getting such big images? I wasn't even able to use Picamera with such resolution. I know you also can use the mmal api directly, but I wasn't able to find any examples of that.
Code: Select all
import sys
import numpy as np
import cv2
import time
height = 1024
width = 1632 * 2
n_channels = 3
n_frames = 10
t0 = time.time()
for _ in range(n_frames):
start_time = time.time()
bytes = sys.stdin.buffer.read(width * height * n_channels)
frame = np.frombuffer(bytes, dtype=np.uint8, count=width * height * n_channels).reshape(height, width, n_channels)
left_frame = frame[:, :width // 2]
right_frame = frame[:, width // 2:]
print("--- %s seconds ---" % (time.time() - start_time))
dt = time.time() - t0
print("Framerate is %f" % (n_frames / dt))
The execution line is
Code: Select all
raspividyuv -3d sbs --rgb -w 3264 -h 1024 -fps 20 -t 0 -n -o - | python main.py
And the output is
Code: Select all
--- 0.08326101303100586 seconds ---
--- 0.09539151191711426 seconds ---
--- 0.09400773048400879 seconds ---
--- 0.09419560432434082 seconds ---
--- 0.09409403800964355 seconds ---
--- 0.09410309791564941 seconds ---
--- 0.09404730796813965 seconds ---
--- 0.09309720993041992 seconds ---
--- 0.09331631660461426 seconds ---
--- 0.0949711799621582 seconds ---
Framerate is 10.729000
Is this the correct approach to getting such big images? I wasn't even able to use Picamera with such resolution. I know you also can use the mmal api directly, but I wasn't able to find any examples of that.