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.