mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-13 02:02:48 +03:00
bring the FrameManager interface in line with its implementation
The abstract get() still had a timeout_ms signature from an older implementation and frame_times() wasn't declared, though capture and detect are typed against the interface. get() also didn't say how long the array it returns stays valid.
This commit is contained in:
+22
-2
@@ -990,7 +990,13 @@ class FrameManager(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get(self, name: str, timeout_ms: int = 0):
|
||||
def get(
|
||||
self, name: str, shape: tuple[int, ...], frame_time: float | None = None
|
||||
) -> np.ndarray | None:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def frame_times(self, camera: str) -> np.ndarray | None:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@@ -1099,8 +1105,22 @@ class SharedMemoryFrameManager(FrameManager):
|
||||
)
|
||||
|
||||
def get(
|
||||
self, name: str, shape, frame_time: float | None = None
|
||||
self, name: str, shape: tuple[int, ...], frame_time: float | None = None
|
||||
) -> np.ndarray | None:
|
||||
"""Map a frame slot as an array without copying it.
|
||||
|
||||
The array points into shared memory, so it is only valid until the next
|
||||
close(), delete(), or get() of the same name. Copy it to keep it longer.
|
||||
|
||||
Args:
|
||||
name: Slot name, such as front_door_frame3
|
||||
shape: Array shape, which must match the slot's size
|
||||
frame_time: Time of the frame the caller was told is in the slot
|
||||
|
||||
Returns:
|
||||
The frame, or None when the slot is missing, the wrong size, or holds
|
||||
a different frame than frame_time
|
||||
"""
|
||||
if frame_time is not None and not self._holds(name, frame_time):
|
||||
# a mapping left over from a same-size recreate of the camera
|
||||
# looks the same as a lapped slot, so reopen by name once
|
||||
|
||||
Reference in New Issue
Block a user