fix(demo): stabilize visualizer bbox and mask rendering
Align bbox coordinate handling across primary and fallback paths, normalize Both-mode raw mask rendering, and tighten demo result typing to reduce runtime/display inconsistencies.
This commit is contained in:
+10
-9
@@ -7,7 +7,8 @@ Provides generator-based interfaces for video sources:
|
||||
"""
|
||||
|
||||
from collections.abc import AsyncIterator, Generator, Iterable
|
||||
from typing import TYPE_CHECKING, Protocol, cast
|
||||
from typing import Protocol, cast
|
||||
|
||||
import logging
|
||||
|
||||
import numpy as np
|
||||
@@ -17,15 +18,15 @@ logger = logging.getLogger(__name__)
|
||||
# Type alias for frame stream: (frame_array, metadata_dict)
|
||||
FrameStream = Iterable[tuple[np.ndarray, dict[str, object]]]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# Protocol for cv-mmap metadata to avoid direct import
|
||||
class _FrameMetadata(Protocol):
|
||||
frame_count: int
|
||||
timestamp_ns: int
|
||||
# Protocol for cv-mmap metadata (needed at runtime for nested function annotation)
|
||||
class _FrameMetadata(Protocol):
|
||||
frame_count: int
|
||||
timestamp_ns: int
|
||||
|
||||
# Protocol for cv-mmap client
|
||||
class _CvMmapClient(Protocol):
|
||||
def __aiter__(self) -> AsyncIterator[tuple[np.ndarray, _FrameMetadata]]: ...
|
||||
|
||||
# Protocol for cv-mmap client (needed at runtime for cast)
|
||||
class _CvMmapClient(Protocol):
|
||||
def __aiter__(self) -> AsyncIterator[tuple[np.ndarray, _FrameMetadata]]: ...
|
||||
|
||||
|
||||
def opencv_source(
|
||||
|
||||
Reference in New Issue
Block a user