Starting docstring on the same lines as the quotations
This commit is contained in:
parent
be6a6ca6fe
commit
35d47fe3ed
28 changed files with 92 additions and 214 deletions
|
|
@ -43,8 +43,7 @@ class NoImageInMemoryError(RuntimeError):
|
|||
|
||||
|
||||
class CameraMemoryBuffer:
|
||||
"""
|
||||
A class that holds images in memory. The images are by default PIL images.
|
||||
"""A class that holds images in memory. The images are by default PIL images.
|
||||
|
||||
However subclasses of BaseCamera can use this class to store other object types
|
||||
"""
|
||||
|
|
@ -62,8 +61,7 @@ class CameraMemoryBuffer:
|
|||
def add_image(
|
||||
self, image: Any, metadata: Optional[dict] = None, buffer_max: int = 1
|
||||
) -> int:
|
||||
"""
|
||||
Add an image to the Memory buffer
|
||||
"""Add an image to the Memory buffer
|
||||
|
||||
This will add an image to the memory buffer. By default the buffer will
|
||||
be cleared. To allow saving multiple images the buffer_max must be set
|
||||
|
|
@ -85,8 +83,7 @@ class CameraMemoryBuffer:
|
|||
def get_image(
|
||||
self, buffer_id: Optional[int] = None, remove: bool = True
|
||||
) -> tuple[Any, Optional[dict]]:
|
||||
"""
|
||||
Return the image with the given id.
|
||||
"""Return the image with the given id.
|
||||
|
||||
If no id is given the most recent image is returned. However, the
|
||||
buffer is also cleared, otherwise it would be possible to accidentally
|
||||
|
|
@ -117,14 +114,11 @@ class CameraMemoryBuffer:
|
|||
) from e
|
||||
|
||||
def clear(self):
|
||||
"""
|
||||
Clear all images from memory
|
||||
"""
|
||||
"""Clear all images from memory"""
|
||||
self._storage.clear()
|
||||
|
||||
def _create_space(self, buffer_max: int) -> None:
|
||||
"""
|
||||
Create space to add an image.
|
||||
"""Create space to add an image.
|
||||
|
||||
:param buffer_max: The maximum number of images that should be in the buffer
|
||||
once another images is added.
|
||||
|
|
@ -170,8 +164,7 @@ class BaseCamera(lt.Thing):
|
|||
)
|
||||
|
||||
def kill_mjpeg_streams(self):
|
||||
"""
|
||||
Kill the streams now as the server is shutting down.
|
||||
"""Kill the streams now as the server is shutting down.
|
||||
|
||||
This is called when uvicorn gets the a shutdown signal. As this is called from
|
||||
the event loop it cannot interact with the our ThingProperties or run
|
||||
|
|
@ -293,8 +286,7 @@ class BaseCamera(lt.Thing):
|
|||
metadata_getter: lt.deps.GetThingStates,
|
||||
buffer_max: int = 1,
|
||||
) -> None:
|
||||
"""
|
||||
Capture an image to memory. This can be saved later with ``save_from_memory``
|
||||
"""Capture an image to memory. This can be saved later with ``save_from_memory``
|
||||
|
||||
Note that only one image is held in memory so this will overwrite any image
|
||||
in memory.
|
||||
|
|
@ -319,8 +311,7 @@ class BaseCamera(lt.Thing):
|
|||
save_resolution: Optional[Tuple[int, int]] = None,
|
||||
buffer_id: Optional[int] = None,
|
||||
) -> None:
|
||||
"""
|
||||
Save an image that has been captured to memory.
|
||||
"""Save an image that has been captured to memory.
|
||||
|
||||
:param jpeg_path: The path to save the file to
|
||||
:param logger: This should be injected automatically by Labthings FastAPI
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ class PicameraStreamOutput(Output):
|
|||
|
||||
|
||||
class SensorMode(BaseModel):
|
||||
"""
|
||||
A Pydantic model holding all the information about a specific
|
||||
"""A Pydantic model holding all the information about a specific
|
||||
sensor mode as reported by the PiCamera.
|
||||
"""
|
||||
|
||||
|
|
@ -77,8 +76,7 @@ class SensorMode(BaseModel):
|
|||
|
||||
|
||||
class SensorModeSelector(BaseModel):
|
||||
"""
|
||||
A Pydantic model holding the two values needed to select a PiCamera
|
||||
"""A Pydantic model holding the two values needed to select a PiCamera
|
||||
Sensor mode. The output size and the bit depth.
|
||||
|
||||
This is a Pydantic modell so that it can be saved to the disk.
|
||||
|
|
@ -89,8 +87,7 @@ class SensorModeSelector(BaseModel):
|
|||
|
||||
|
||||
class LensShading(BaseModel):
|
||||
"""
|
||||
A Pydantic model holding the lens shading tables.
|
||||
"""A Pydantic model holding the lens shading tables.
|
||||
|
||||
PiCamera needs three numpy arrays for lens shading correction. Each array is
|
||||
(12, 16) in size. The arrays are luminance, red-difference chroma (Cr), and
|
||||
|
|
@ -363,8 +360,7 @@ class StreamingPiCamera2(BaseCamera):
|
|||
def start_streaming(
|
||||
self, main_resolution: tuple[int, int] = (820, 616), buffer_count: int = 6
|
||||
) -> None:
|
||||
"""
|
||||
Start the MJPEG stream. This is where persistent controls are sent to camera.
|
||||
"""Start the MJPEG stream. This is where persistent controls are sent to camera.
|
||||
|
||||
Sets the camera resolutions based on input parameters, and sets the low-res
|
||||
resolution to (320, 240). Note: (320, 240) is a standard from the Pi Camera
|
||||
|
|
@ -434,9 +430,7 @@ class StreamingPiCamera2(BaseCamera):
|
|||
|
||||
@lt.thing_action
|
||||
def stop_streaming(self, stop_web_stream: bool = True) -> None:
|
||||
"""
|
||||
Stop the MJPEG stream
|
||||
"""
|
||||
"""Stop the MJPEG stream"""
|
||||
with self._streaming_picamera() as picam:
|
||||
try:
|
||||
picam.stop_recording() # This should also stop the extra lores encoder
|
||||
|
|
@ -679,8 +673,7 @@ class StreamingPiCamera2(BaseCamera):
|
|||
|
||||
@lt.thing_action
|
||||
def reset_ccm(self):
|
||||
"""
|
||||
Overwrite the colour correction matrix in camera tuning with default values.
|
||||
"""Overwrite the colour correction matrix in camera tuning with default values.
|
||||
|
||||
These values are from the Raspberry Pi Camera Algorithm and Tuning Guide, page
|
||||
45.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
"""
|
||||
Functions to set up a Raspberry Pi Camera v2 for scientific use
|
||||
"""Functions to set up a Raspberry Pi Camera v2 for scientific use
|
||||
|
||||
This module provides slower, simpler functions to set the
|
||||
gain, exposure, and white balance of a Raspberry Pi camera, using
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue