Skip to main content

labthings-picamera2

A LabThings-FastAPI Thing for working with picamera2

This package defines a Thing using labthings-fastapi that exposes an HTTP interface to the Raspberry Pi camera, using picamera2. This includes autogenerated OpenAPI documentation viewed with a built-in Swagger/Redocly page at /docs/, and a Web of Things compliant Thing Description at the camera's root (usually /camera/).

Installation

For this to work you should be on a 32-bit version of Bullseye or Bookworm os with python v3.9 or 3.11.

It's usually best to install in a virtual environment, but note that you should use

python -m venv .venv --system-site-packages

as the picamera2 package and its dependencies are not all installable using pip.

The package is on PyPI and can be installed using

pip install labthings-picamera2

You will also need to separately install the server with:

pip install labthings-fastapi[server]

If you want to edit labthings-picamera2 then you can clone this repository. Move to the directory and run

pip install -e .

Usage

You can start the server using:

labthings-server --json '{"things":{"/camera/":"labthings_picamera2.thing:StreamingPiCamera2"}}'

This assumes you have labthings[server]>=0.0.6 installed.

You may then point a web browser at http://localhost:5000/camera or http://localhost:5000/docs/.

It's also possible to control it from Python, if you have labthings-fastapi installed (note that if you're using a separate machine or separate environment for the client, if you don't add [server] it won't install the rather heavy server dependencies like starlette.)

To connect, run:

from labthings_fastapi.client import ThingClient
from PIL import Image

cam = ThingClient.from_url("http://localhost:5000/camera/")
blob = cam.capture_jpeg()
image = Image.open(blob.open())

All of the properties and actions described in the Thing Description should be present as Python properties and methods - currently the types and docstrings don't propagate to the client object, this is planned for the future but isn't reality yet.

Metadata

Release files for labthings-picamera2 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labthings-picamera2 0.0.2
File Size Uploaded Provenance Actions
labthings_picamera2-0.0.2.tar.gz 32.8 kB With provenance Details for labthings_picamera2-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for labthings-picamera2 0.0.2
File Interpreter ABI Platform Actions
labthings_picamera2-0.0.2-py3-none-any.whl Python 3 none any Details for labthings_picamera2-0.0.2-py3-none-any.whl

Total release size: 63.8 kB

Release files / labthings_picamera2-0.0.2.tar.gz

Download URL labthings_picamera2-0.0.2.tar.gz
Size 32.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f288527bd6d8cb079e4e5c40cc2341041f0033e36fa4ba617a6b1a3ba4c6546d
BLAKE2b-256 checksum
How to use checksums
1cf6cf64f7643f80d92bd674a6fcd3e5ca9182e59da9f9fe1057d7d7725e4b62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2025.

Transparency log

Release files / labthings_picamera2-0.0.2-py3-none-any.whl

Download URL labthings_picamera2-0.0.2-py3-none-any.whl
Size 31.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cdd19ef93b755333001c3dbea1651f720c7274d9e730b9bb4bd7c7adcabf524
BLAKE2b-256 checksum
How to use checksums
ae0e48a4bfe79415ade3ee386888bb8bf8baff8979c157f5cf8b66998deda0fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2025.

Transparency log

Security for labthings-picamera2 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for labthings_picamera2-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page