I have a Pi 4 with the High Quality Camera. I'm trying to capture raw frames with Picamera2 using the camera's 2028x1520 2x2 binning mode.
I'm using camera.sensor_modes[2]
, which says it has a maximum FPS of 40.
{'format': SRGGB12_CSI2P, 'unpacked': 'SRGGB12', 'bit_depth': 12, 'size': (2028, 1520), 'fps': 40.01, 'crop_limits': (0, 0, 4056, 3040), 'exposure_limits': (60, 674181621, None)}
Here's my test code. It captures and discards 100 frames and calculates the FPS.
from picamera2 import Picamera2
import time
# Configure camera for 2028x1520 mode
camera = Picamera2()
config = camera.create_preview_configuration({"size": (2028, 1520)}, raw = camera.sensor_modes[2])
camera.configure(config)
# Start camera
camera.start()
time.sleep(1)
# Capture 100 frames and calculate FPS
startTime = time.time()
for i in range(100):
camera.capture_array("raw")
print(1 / (time.time() - startTime) * 100)
I ran it a few times and got values between 15.11 and 15.12 FPS. I think the actual framerate is exactly 15 FPS, but the first frame is already buffered and is returned instantly. It being so close to 15 FPS makes me think the problem lies in a camera configuration issue, not Picamera2 dropping frames.
How can I capture frames at the full 40 FPS?
(I know the micro SD card isn't capable of saving raw frames at 40 FPS. I plan to capture for a few seconds into RAM, then write it slowly to the micro SD card).