Refactor camera management to conditionally import SDK and handle mock mode; update API base URL references to localhost in documentation and code.
This commit is contained in:
@@ -12,9 +12,15 @@ import logging
|
||||
from typing import Dict, List, Optional, Tuple, Any
|
||||
from datetime import datetime
|
||||
|
||||
# Add camera SDK to path
|
||||
# Add camera SDK to path and import conditionally
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "camera_sdk"))
|
||||
import mvsdk
|
||||
try:
|
||||
import mvsdk
|
||||
CAMERA_SDK_AVAILABLE = True
|
||||
except (ImportError, OSError) as e:
|
||||
# Camera SDK not available - system will run in mock mode
|
||||
mvsdk = None
|
||||
CAMERA_SDK_AVAILABLE = False
|
||||
|
||||
from ..core.config import Config, CameraConfig
|
||||
from ..core.state_manager import StateManager, CameraStatus
|
||||
@@ -35,8 +41,11 @@ class CameraManager:
|
||||
self.event_system = event_system
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
# Initialize SDK early to suppress error messages
|
||||
initialize_sdk_with_suppression()
|
||||
# Initialize SDK early to suppress error messages (if available)
|
||||
if CAMERA_SDK_AVAILABLE:
|
||||
initialize_sdk_with_suppression()
|
||||
else:
|
||||
self.logger.warning("Camera SDK not available - running in mock mode")
|
||||
|
||||
# Camera management
|
||||
self.available_cameras: List[Any] = [] # mvsdk camera device info
|
||||
@@ -111,6 +120,11 @@ class CameraManager:
|
||||
try:
|
||||
self.logger.info("Discovering GigE cameras...")
|
||||
|
||||
if not CAMERA_SDK_AVAILABLE:
|
||||
self.logger.warning("Camera SDK not available - no cameras will be discovered")
|
||||
self.available_cameras = []
|
||||
return
|
||||
|
||||
# Enumerate cameras using mvsdk
|
||||
device_list = mvsdk.CameraEnumerateDevice()
|
||||
self.available_cameras = device_list
|
||||
|
||||
Reference in New Issue
Block a user