I want to display picamera's preview on fb1 in raspberry pi 4.
My environment is 64-bit aarch64 self compiled system. use vc4-fkms-v3d dtoverlay.
It seems that the preview image was direct draw on fb0 by GPU, someone suggest rpi-fbcp, but it can't be compile on rpi4 due to lack dispmanx api.
so I use python to implement a similar program, numpy.memmap open fb0, grab data, then write to fb1. it works and very fast! I can saw mouse point track was mirrored in realtime, even spinning gears of glxgear, but no luck with picamera's preview screen.
the picamera's preview was live in fb0 and overlay everything, I can mirror everything below it.
how to access the picamera's preview data? it shows on screen, but did not leave any footprint in fb0.
python code:
import numpy as np
fb0 = np.memmap('/dev/fb0', dtype='uint8',mode='r+', shape=(480,800,4))
fb1 = np.memmap('/dev/fb1', dtype='uint8',mode='r+', shape=(240,240,2))
img0 = fb0[0:240, 0:240]
img1 = BGRAtoBGR565(img0)
fb1[0:240,0:240] = img1
to produce preview image
from picamera import PiCamera
camera = PiCamera()
camera.start_preview(fullscreen=False,window=(0,0,240, 240))
I have tried python-mss, only grab image below preview screen too.
I have tested mmalobj follow the tutorial to draw a crosshair on preview, it's so lag and throws many exceptions.
picamera.exc.PiCameraMMALError: no buffers available: Resource temporarily unavailable; try again later
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 232, in 'calling callback function'
File "/home/pi/.local/lib/python3.7/site-packages/picamera/mmalobj.py", line 1227, in wrapper
self._pool.send_buffer(block=False)
File "/home/pi/.local/lib/python3.7/site-packages/picamera/mmalobj.py", line 1931, in send_buffer
super(MMALPortPool, self).send_buffer(port, block, timeout)
File "/home/pi/.local/lib/python3.7/site-packages/picamera/mmalobj.py", line 1881, in send_buffer
raise PiCameraMMALError(mmal.MMAL_EAGAIN, 'no buffers available')
It seems picamera's preview draws on screen directly and does not via /dev/fb0. I have found another project py-videocore6 which can access GPU memory, but I don't know where to grap video data.