Refactor: nearly done phase 5
This commit is contained in:
parent
227e696ed6
commit
7a9a149955
12 changed files with 2750 additions and 105 deletions
|
@ -422,6 +422,31 @@ class HTTPSnapshotReader:
|
|||
logger.error(f"Error decoding snapshot for {self.camera_id}: {e}")
|
||||
return None
|
||||
|
||||
def fetch_single_snapshot(self) -> Optional[np.ndarray]:
|
||||
"""
|
||||
Fetch a single high-quality snapshot on demand for pipeline processing.
|
||||
This method is for one-time fetch from HTTP URL, not continuous streaming.
|
||||
|
||||
Returns:
|
||||
High quality 2K snapshot frame or None if failed
|
||||
"""
|
||||
logger.info(f"[SNAPSHOT] Fetching snapshot for {self.camera_id} from {self.snapshot_url}")
|
||||
|
||||
# Try to fetch snapshot with retries
|
||||
for attempt in range(self.max_retries):
|
||||
frame = self._fetch_snapshot()
|
||||
|
||||
if frame is not None:
|
||||
logger.info(f"[SNAPSHOT] Successfully fetched {frame.shape[1]}x{frame.shape[0]} snapshot for {self.camera_id}")
|
||||
return frame
|
||||
|
||||
if attempt < self.max_retries - 1:
|
||||
logger.warning(f"[SNAPSHOT] Attempt {attempt + 1}/{self.max_retries} failed for {self.camera_id}, retrying...")
|
||||
time.sleep(0.5)
|
||||
|
||||
logger.error(f"[SNAPSHOT] Failed to fetch snapshot for {self.camera_id} after {self.max_retries} attempts")
|
||||
return None
|
||||
|
||||
def _resize_maintain_aspect(self, frame: np.ndarray, target_width: int, target_height: int) -> np.ndarray:
|
||||
"""Resize image while maintaining aspect ratio for high quality."""
|
||||
h, w = frame.shape[:2]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue