Metadata-Version: 2.1
Name: labthings-picamera2
Version: 0.0.2.dev0
Summary: Picamera2 support for LabThings-FastAPI
Author-email: Richard Bowman <richard.bowman@cantab.net>
Project-URL: Homepage, https://github.com/rwb27/labthings-picamera2
Project-URL: Bug Tracker, https://github.com/rwb27/labthings-picamera2/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: picamera2~=0.3.12
Requires-Dist: labthings-fastapi>=0.0.7
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: pillow
Provides-Extra: dev
Requires-Dist: labthings-fastapi[dev,server]; extra == "dev"

# 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:

```python
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.

[labthings-fastapi]: https://github.com/labthings/labthings-fastapi/
