""" 摄像头配置 """ import platform import os LOG_CONFIG = { 'level': 'INFO', 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 'file': None, 'max_bytes': 10 * 1024 * 1024, 'backup_count': 5, 'retention_days': 7, } # ============================================================ # 多组摄像头配置 # 使用方法:启用需要的组(enabled=True),配置对应的IP地址 # ============================================================ # 摄像头组配置(devices.md) CAMERA_GROUPS = [ { 'group_id': 'group_test', 'name': '测试环境', 'enabled': False, 'panorama': { 'ip': '192.168.8.2', 'port': 37777, 'rtsp_port': 554, 'username': 'admin', 'password': 'QAZwsx12', 'channel': 1, 'brand': 'hikvision', 'use_sdk': False, 'resolution': (2560, 1440), 'rtsp_url': 'rtsp://admin:QAZwsx12@192.168.8.2:554/Streaming/Channels/101', 'install_address': '新芮庄桥-东侧', }, 'ptz': { 'ip': '192.168.8.5', 'port': 37777, 'rtsp_port': 554, 'username': 'admin', 'password': 'Aa1234567', 'channel': 1, 'brand': 'dahua', 'subtype': 1, 'resolution': (3840, 2160), 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.8.5:554/cam/realmonitor?channel=1&subtype=1', 'pan_flip': True, 'ceiling_mount': True, 'install_address': '新芮庄桥-东侧', }, }, { 'group_id': 'group_10_11_12', 'name': '10.11.12.1 现场环境', 'enabled': True, 'panorama': { 'ip': '192.168.1.8', 'port': 37777, 'rtsp_port': 554, 'username': 'admin', 'password': 'Aa1234567', 'channel': 1, 'brand': 'dahua', 'use_sdk': False, 'resolution': (3840, 1080), 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.1.8:554/cam/realmonitor?channel=1&subtype=0', 'install_address': '新芮庄桥-东侧', }, 'ptz': { 'ip': '192.168.1.9', 'port': 37777, 'rtsp_port': 554, 'username': 'admin', 'password': 'Aa1234567', 'channel': 1, 'brand': 'dahua', 'subtype': 0, 'resolution': (3840, 2160), 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.1.9:554/cam/realmonitor?channel=1&subtype=0', 'pan_flip': False, 'ceiling_mount': True, 'install_address': '新芮庄桥-东侧', }, }, ] def get_enabled_groups() -> list: """获取所有启用的摄像头组配置""" return [g for g in CAMERA_GROUPS if g.get('enabled', False)] def parse_resolution(resolution) -> tuple: if resolution is None: return 1920, 1080 if isinstance(resolution, (tuple, list)) and len(resolution) == 2: return int(resolution[0]), int(resolution[1]) if isinstance(resolution, str): for sep in ['x', 'X', '*']: if sep in resolution: parts = resolution.split(sep) if len(parts) == 2: return int(parts[0]), int(parts[1]) return 1920, 1080