Refactor: Logging Cleanup
This commit is contained in:
parent
7a9a149955
commit
5176f99ba7
9 changed files with 37 additions and 72 deletions
|
@ -67,8 +67,9 @@ class FrameBuffer:
|
|||
'size_mb': frame.nbytes / (1024 * 1024)
|
||||
}
|
||||
|
||||
logger.debug(f"Stored {stream_type.value} frame for camera {camera_id}: "
|
||||
f"{frame.shape[1]}x{frame.shape[0]}, {frame.nbytes / (1024 * 1024):.2f}MB")
|
||||
# Commented out verbose frame storage logging
|
||||
# logger.debug(f"Stored {stream_type.value} frame for camera {camera_id}: "
|
||||
# f"{frame.shape[1]}x{frame.shape[0]}, {frame.nbytes / (1024 * 1024):.2f}MB")
|
||||
|
||||
def get_frame(self, camera_id: str) -> Optional[np.ndarray]:
|
||||
"""Get the latest frame for the given camera ID."""
|
||||
|
@ -400,31 +401,3 @@ shared_frame_buffer = FrameBuffer(max_age_seconds=5)
|
|||
shared_cache_buffer = CacheBuffer(max_age_seconds=10)
|
||||
|
||||
|
||||
def save_frame_for_testing(camera_id: str, frame: np.ndarray, test_dir: str = "test_frames"):
|
||||
"""Save frame to test directory for verification purposes."""
|
||||
import os
|
||||
|
||||
try:
|
||||
os.makedirs(test_dir, exist_ok=True)
|
||||
timestamp = int(time.time() * 1000) # milliseconds
|
||||
filename = f"{camera_id}_{timestamp}.jpg"
|
||||
filepath = os.path.join(test_dir, filename)
|
||||
|
||||
# Use appropriate quality based on frame size
|
||||
h, w = frame.shape[:2]
|
||||
if w >= 2000: # High resolution
|
||||
quality = 95
|
||||
else: # Standard resolution
|
||||
quality = 90
|
||||
|
||||
encode_params = [cv2.IMWRITE_JPEG_QUALITY, quality]
|
||||
success = cv2.imwrite(filepath, frame, encode_params)
|
||||
|
||||
if success:
|
||||
size_kb = os.path.getsize(filepath) / 1024
|
||||
logger.info(f"Saved test frame: {filepath} ({w}x{h}, {size_kb:.1f}KB)")
|
||||
else:
|
||||
logger.error(f"Failed to save test frame: {filepath}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error saving test frame for camera {camera_id}: {e}")
|
Loading…
Add table
Add a link
Reference in a new issue