Libcamera migration#953
Draft
newtonick wants to merge 2 commits into
Draft
Conversation
…mera; requirements-raspi.txt no longer needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to SeedSigner/seedsigner-os#114. Should be tested with and merged with this SeedSigner OS PR ideally.
Problem or Issue being addressed
SeedSigner's camera code depends on
picamera, which only drives the legacy Broadcom/MMAL camera stack. That stack is Buster-only and has been deprecated for years, which is a big part of why manual dev builds are still stuck on Debian 10.picameraalso drags innumpyas a transitive dependency purely for frame buffer handling. The picamera stack is also closed source and no longer maintained.Solution
Replace
picamerawith the nativelibcamerapython bindings and dropnumpyentirely.The old
pivideostream.pyis replaced by a newcamera_stream.pywith three pieces:LibcameraVideoStreamdrives the QR scanning feed. It hands grayscale frames straight to pyzbar, with a separate RGBA path for the live preview.LibcameraStillCapturehandles single-frame capture. It locks auto-exposure/AWB at their converged values to reproduce the old picamerashutter_speed/awb_gainsfreeze.rgba_buffer_to_imageconverts a raw libcamera buffer into a PIL image without numpy.camera.pyis reworked to drive these classes, and the background import warmup now preloadslibcamerainstead of numpy.I also rewrote
raspberry_pi_os_build_instructions.md. It now splits into Part 1 (libcamera on Debian 13 "Trixie", for currentdev), Part 2 (legacy picamera on Buster, for v0.8.7 and earlier), and Part 3 (config shared by both).requirements-raspi.txtis removed since it is no longer needed.Additional Information
The libcamera bindings behave differently from picamera in a few spots worth flagging for reviewers: methods raise on error rather than returning status, and YUV420 buffers come back with stride padding that has to be handled when building images. Code after v0.8.7 will not run on Buster (no libcamera module), and v0.8.7 and earlier will not run on Trixie (no legacy picamera), which is why the build doc keeps both paths.
Screenshots
No UI screens changed. This is a hardware/camera plumbing change, so there is nothing new to show.
Testing information
It'll be very important to perform regression testing. I want to make sure the QR scanning and New Seed from Camera all work as well or better before merging.
This pull request is categorized as a:
Checklist
I ran
pytestlocallyI included screenshots of any new or modified screens
Should be part of the PR description above.
I added or updated tests
Any new or altered functionality should be covered in a unit test. Any new or updated sequences require FlowTests.
I tested this PR hands-on on the following platform(s):
I have reviewed these notes: