Package: picamera2
Picamera2Picamera2is currently available here as a beta release. This means there may still be some issues and bugs which we shall work on fixing, and where users identify particularly useful features we may still consider implementing them. Mostly we shall be working on bugs, stability, support, examples and documentation, as well as keeping up with ongoinglibcameradevelopment. There will also be quite a strong presumptionagainstmaking signficant code changes unless it seems absolutely necessary, especially any that break existing behaviour or APIs.Picamera2is the libcamera-based replacement forPicamerawhich was a Python interface to the Raspberry Pi's legacy camera stack.Picamera2also presents an easy to use Python API.You can finddocumentation herewhich should help you to get started.There are also many examples in theexamplesfolder of this repository, and some furtherQtapplication examples in theappsfolder.InstallationPicamera2is only supported on Raspberry Pi OS Bullseye (or later) images, both 32 and 64-bit. As of September 2022,Picamera2is pre-installed on images downloaded from Raspberry Pi. It works on all Raspberry Pi boards right down to the Pi Zero, although performance in some areas may be worse on less powerful devices.Picamera2isnotsupported on:Images based on Buster or earlier releases.Raspberry Pi OS Legacy images.Bullseye (or later) images where the legacy camera stack has been re-enabled.On Raspberry Pi OS images,Picamera2is now installed with all the GUI (QtandOpenGL) dependencies. On Raspberry Pi OS Lite, it is installed without the GUI dependencies, although preview images can still be displayed using DRM/KMS. If these users wish to use the additional X-Windows GUI features, they will need to runsudo apt install -y python3-pyqt5 python3-opengl(No changes are required toPicamera2itself.)Installation usingaptaptis the recommended way of installing and updatingPicamera2.IfPicamera2is already installed, you can update it withsudo apt install -y python3-picamera2, or as part of a full system update (for example,sudo apt upgrade).IfPicamera2is not already installed, then your image is presumably older and you should start withsudo apt update
sudo apt upgradeIf you have installedPicamera2previously usingpip, then you should also uninstall this (pip3 uninstall picamera2).Thereafter, you can installPicamera2withall the GUI (QtandOpenGL) dependencies usingsudo apt install -y python3-picamera2If you donotwant the GUI dependencies, usesudo apt install -y python3-picamera2 --no-install-recommendsInstallation usingpipThis is no longer the recommended way to installPicamera2. However, if you want to do so you can usesudo apt install -y python3-libcamera python3-kms++
sudo apt install -y python3-pyqt5 python3-prctl libatlas-base-dev ffmpeg python3-pip
pip3 install numpy --upgrade
pip3 install picamera2[gui]which will installPicamera2with all the GUI (QtandOpenGL) dependencies. If you do not want these, please usesudo apt install -y python3-libcamera python3-kms++
sudo apt install -y python3-prctl libatlas-base-dev ffmpeg libopenjp2-7 python3-pip
pip3 install numpy --upgrade
pip3 install picamera2ContributingPlease note that the "main" branch of this repository corresponds to the currently released version ofPicamera2so that the examples there can be referred to by users. Development for forthcoming releases happens on the "next" branch.We are happy to receive pull requests (normally for the "next" branch) that will fix bugs, add features and generally improve the code. Pull requests should be:Restricted to one change or feature each. Please try to avoid "drive-by fixes" especially in a larger set of changes, as it can make them harder to review.The commit history should consist of a number of commits that are as easy to review as possible. In particular this means:Where one commit is fixing errors in an earlier commit in the set, please simply merge them.Where a commit is reverting a commit from earlier in the set, please remove the commit entirely.Please avoid adding merge commits or any other unnecessary commits.The commit message should have a short single line at the top which is nonetheless as descriptive as possible. After that we encourage more lines explaining in a little more detail exactly what has been done.In general, we don't need to see all the trials, errors and bug-fixes that went into this change, we only want to understand how it works now!Try to ensure that the automated tests are working after all the commits in the set. This avoids other developers going back to an arbitrary earlier commit and finding that things don't work. There can be occasions when other problems cause test failures beyond our control, so we'll just have to remain alert to these and work around them as best we can.Where changes are likely to be more involved, or may change public APIs, authors should start a discussion with us first so that we can agree a good way forward.Before submitting a pull request, please ensure that all the automated tests are passing. They can be run using thetools/run_testsscript. Please usetools/run_tests --helpfor more information.Any documentation should be updated accordingly. New examples and tests should be included wherever possible. Also consider making an entry in the change log.The author of the pull request needs to agree that they are donating the work to this project and to Raspberry Pi Ltd., so that we can continue to distribute it as open source to all our users. To indicate your agreement to this, we would ask that you finish commit messages with a blank line followed bySigned-off-by: Your Name <your.email@your.domain>.We'd like to conform to the common PythonPEP 8coding style wherever possible. To facilitate this we would recommend using our pre-commit hook, which can be installed by doing the following in the root of the repository:pip3 install pre-commit
pre-commit installThis will install flake8 in a venv and will perform linting of changes prior to committing.Thank you!