Picamera2 support for LabThings-FastAPI
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file labthings_picamera2-0.0.1.dev1.tar.gz
.
File metadata
- Download URL: labthings_picamera2-0.0.1.dev1.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3deb371dd6d7833ccb451b5581bfda1c823cb0e8fb4eda9ee98aa56d819df0df |
|
MD5 | ac081f17f749f1fb481f5a2e47eeae01 |
|
BLAKE2b-256 | b93d6336a7f531dcba7841a3d9584c0da4ca2e76cc1b2968b80ddb22a916a61f |
Provenance
The following attestation bundles were made for labthings_picamera2-0.0.1.dev1.tar.gz
:
Publisher:
publish.yml
on labthings/labthings-picamera2
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
labthings_picamera2-0.0.1.dev1.tar.gz
- Subject digest:
3deb371dd6d7833ccb451b5581bfda1c823cb0e8fb4eda9ee98aa56d819df0df
- Sigstore transparency entry: 149125694
- Sigstore integration time:
- Predicate type:
File details
Details for the file labthings_picamera2-0.0.1.dev1-py3-none-any.whl
.
File metadata
- Download URL: labthings_picamera2-0.0.1.dev1-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 113b9d0b02905994d26cbbae9191d76a4464081d029ae2596673c068b419801c |
|
MD5 | ac23d49d9c7bb681872628ec14417f6c |
|
BLAKE2b-256 | 75a41a8f493ba5585f79c153019e709e3f11356aa5c2c6fe9e074d5fb5e84f00 |
Provenance
The following attestation bundles were made for labthings_picamera2-0.0.1.dev1-py3-none-any.whl
:
Publisher:
publish.yml
on labthings/labthings-picamera2
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
labthings_picamera2-0.0.1.dev1-py3-none-any.whl
- Subject digest:
113b9d0b02905994d26cbbae9191d76a4464081d029ae2596673c068b419801c
- Sigstore transparency entry: 149125695
- Sigstore integration time:
- Predicate type: