Users of the Raspberry Pi camera - and we know you’re out there, we’ve covered a few of the best projects made with one - rejoice. There's a new Python camera library on the horizon, and a preview release has just been made available to those brave enough to compile it themselves.
PiCamera2 is a replacement for the PiCamera library that was deprecated during the transition of Raspberry Pi OS to Debian Bullseye late last year and won’t be supported in the future. PiCamera was a third-party community effort led by Dave Jones, built on a proprietary Broadcom camera stack, while the new library has been made in-house and is more open, though the announcement doesn’t go as far as calling it open-source.
The preview release, compatible with all models of Raspberry Pi camera, including the HQ camera, is available from GitHub, and is very much a work in progress. Right now it is missing some important features, or they are not working as intended. What you can do, however, includes starting, configuring, and setting the parameters of the camera, receiving multiple image streams, opening preview windows, capturing full-resolution images as JPEGs or PNGs, or as numpy arrays ready for image analysis.
What it can’t do right now is record video. The team is still working on this application of the Pi’s built-in h.264 encoder, but it remains a “few weeks away”.
If you want to try it out, there are a few hoops waiting for you to jump through. You can’t install it using a package manager, so you’ll have to build it from source, and you’ll need a special version of the libcamera library too. For casual users it’s better to wait, but for those of us on the bleeding edge we can dive in and compile our own.
And if you’re the former rather than the latter, you can console yourself with the readme.md file, which warns in big letters that there will be bugs and problems, and that things are likely to change significantly and without warning. The new library is such a departure from the original PiCamera that backward compatibility isn’t possible, and things like the blur and denoise image effects are no longer available. These will need to be re-implemented on the Pi’s Arm cores, and anyone relying on them is recommended to look elsewhere for equivalent functionality.