Skip to main content

The libcamera-based Python interface to Raspberry Pi cameras, based on the original Picamera library

Project description

Picamera2


WARNING! Picamera2 is currently available here as an alpha release. This means there may still be some issues, but we're hoping for feedback that can lead to further improvements. Consequently the API cannot be expected to be completely stable, but nor will we be making changes to it without due consideration.

Picamera2 is the libcamera-based replacement for Picamera which was a Python interface to the Raspberry Pi's legacy camera stack. Picamera2 also presents an easy to use Python API.

You can find draft documentation here. This is currently incomplete but should help users to get started.

There are also many examples in the examples folder of this repository.

Installation

These instructions are for a fresh 32-bit Bullseye image running on a Pi 4B but should work on other platforms too.

All the necessary packages can now be installed via apt and pip3, so the following should suffice. Please run sudo apt update and sudo apt upgrade first if you have not done so for some time. Then:

sudo 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

Or If you don't want the GUI dependencies:

sudo 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
NOGUI=1 pip3 install picamera2

Contributing

Please note that the "main" branch of this repository corresponds to the currently released version of Picamera2 so 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 the tools/run_tests script. Please use tools/run_tests --help for 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 by Signed-off-by: Your Name <your.email@your.domain>.
  • We'd like to conform to the common Python PEP 8 coding style wherever possible. To facilitate this we would recommend putting
#!/bin/bash

exec git diff --cached | ./tools/checkstyle.py --staged

into your .git/hooks/pre-commit file. We note that there are some occasions when other formatting is actually better in which case please use that in spite of the style checker, but do note this in your pull request so that we understand.

Thank you!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picamera2-0.2.3.tar.gz (43.2 kB view details)

Uploaded Source

Built Distribution

picamera2-0.2.3-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file picamera2-0.2.3.tar.gz.

File metadata

  • Download URL: picamera2-0.2.3.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for picamera2-0.2.3.tar.gz
Algorithm Hash digest
SHA256 01c09dd5156109acfda4a2bc7e915fcb2347807452467f991b786305d1d61a25
MD5 988c2784a02c2b5acbd763b2418e75ab
BLAKE2b-256 2fb6e4998e5b17735026bed8bdf5bc1d900c6b35bb792d39774ff825da31f910

See more details on using hashes here.

File details

Details for the file picamera2-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: picamera2-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for picamera2-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0313fb50779ab2f48e45bf52dd9cbb1963c66fc8c900641d4be68df5c1edb44a
MD5 2e7bc143add731c4b7630c0bf991a3fb
BLAKE2b-256 10d6ebacd53f0952c21d7ca760dad795af71e660cb2c0e6c0af936f9cb9f958c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page