Add typehints and docstrings as suggested in review
This commit is contained in:
parent
0933ece63a
commit
ce5b5b781c
2 changed files with 13 additions and 4 deletions
|
|
@ -76,7 +76,9 @@ class BaseCamera(Thing):
|
||||||
self._memory_metadata = None
|
self._memory_metadata = None
|
||||||
|
|
||||||
@thing_action
|
@thing_action
|
||||||
def start_streaming(self, main_resolution, buffer_count) -> None:
|
def start_streaming(
|
||||||
|
self, main_resolution: tuple[int, int], buffer_count: int
|
||||||
|
) -> None:
|
||||||
"""Start (or stop and restart) the camera with the given resolution
|
"""Start (or stop and restart) the camera with the given resolution
|
||||||
for the main stream, and buffer_count number of images in the buffer"""
|
for the main stream, and buffer_count number of images in the buffer"""
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
|
|
@ -132,7 +134,11 @@ class BaseCamera(Thing):
|
||||||
return JPEGBlob.from_bytes(frame)
|
return JPEGBlob.from_bytes(frame)
|
||||||
|
|
||||||
@thing_action
|
@thing_action
|
||||||
def capture_image(self, stream_name, wait):
|
def capture_image(
|
||||||
|
self,
|
||||||
|
stream_name: Literal["main", "lores", "raw"],
|
||||||
|
wait: Optional[float],
|
||||||
|
) -> None:
|
||||||
"""Capture a PIL image from stream stream_name with timeout wait"""
|
"""Capture a PIL image from stream stream_name with timeout wait"""
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"CameraThings must define their own capture_image method"
|
"CameraThings must define their own capture_image method"
|
||||||
|
|
@ -211,7 +217,10 @@ class BaseCamera(Thing):
|
||||||
) -> Image:
|
) -> Image:
|
||||||
"""Capture an image in memory and return it with metadata
|
"""Capture an image in memory and return it with metadata
|
||||||
CaptureError raised if the capture fails for any reason
|
CaptureError raised if the capture fails for any reason
|
||||||
returns tuple with PIL Image, and dict of metadata
|
returns tuple with PIL Image, and dict of metadata.
|
||||||
|
|
||||||
|
This robust capturing method attempts to capture the image five times
|
||||||
|
each time with a 5 second timeout set.
|
||||||
"""
|
"""
|
||||||
for capture_attempts in range(5):
|
for capture_attempts in range(5):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
self,
|
self,
|
||||||
stream_name: Literal["main", "lores", "raw"] = "main",
|
stream_name: Literal["main", "lores", "raw"] = "main",
|
||||||
wait: Optional[float] = 0.9,
|
wait: Optional[float] = 0.9,
|
||||||
):
|
) -> None:
|
||||||
"""Acquire one image from the camera.
|
"""Acquire one image from the camera.
|
||||||
|
|
||||||
Return it as a PIL Image
|
Return it as a PIL Image
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue