Open earboxer opened 5 months ago
[after a good amount of tinkering,] I have a workable proof of concept running in bookworm:
config.txt
Edit your config.txt
file, adding the dtoverlay for your screen
dtoverlay=fbtft,st7789v,dc=25,cs=8,dc_pin=25,cs_pin=8,dc-gpios=25,height=240,width=240,cs-gpios=8
camera_auto_detect=1
)con2fbmap 1 1
, which will show your shell on that screen, but that's optional.Have this python script (you need picamera2, and python3-opencv)
#!/usr/bin/env python3
# For YUV420/YUYV to RGB, do
# sudo apt install python3-opencv
from picamera2 import Picamera2, Preview
from gpiozero import Button
import time
picam2 = Picamera2()
shutter = Button(24)
quitter = Button(23)
# probably could be optimized better...
camera_config = picam2.create_still_configuration(main={"size": (1920, 1080)}, lores={"size": (240, 240)}, display="lores")
# "fps":10.0 # TODO: howto set fps???
picam2.configure(camera_config)
#picam2.start_preview(Preview.QTGL)
#picam2.start_preview(Preview.DRM) # Failed to find...
picam2.start_preview(Preview.QT)
picam2.start()
num=0
while True:
shutter.wait_for_press()
now = time.localtime()
picam2.capture_file(
f"{now.tm_year}{now.tm_mon:02}{now.tm_mday:02}_{now.tm_hour:02}{now.tm_min:02}{now.tm_sec:02}_{num}.jpg"
)
num = num + 1
(there's some backstory about raspberry pi zero not having DRM support/GPU acceleration)
QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1 ./picamera.py
(this tells QT that you want it to render to the linuxfb at /dev/fb1)
But the latency and framerate are not horrible...
If you're having trouble setting up your fbtft overlay, use e.g. journalctl -t kernel --system -S 2024-04-19\ 21:00
on raspberry pi os to see kernel messages, which might include useful fbtft information.
Don't use raspberry pi OS 'lite' image. It will probably not connect to WiFi. (probably you want to start with the "Raspberry Pi OS with desktop", then uninstall/disable the desktop environment.)
Trying to use picamera on bookworm fails:
now that I have a raspberry pi camera, I'm getting this error, so I'm not completely sure how to set it up in bookworm.
(Presumably if I use some older version of raspberry pi OS, it will work?)