great. my hypothesis now is that frames queue up, filling all available RAM.
I predict that this will also OOM:
import time
import cv2
stream = cv2.VideoCapture('v4l2src ! video/x-bayer, format=bggr, width=640, height=480 ! bayer2rgb ! videoconvert ! appsink')
assert stream.isOpened()
while True:
rv, frame = stream.read()
if not rv: break
time.sleep(1) # a second
if my prediction is correct, you’ll have to either reduce the frame rate from your video source, or discard some frames, or decouple reading and processing by the use of threads.