| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- """
- 摄像头配置
- """
- 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': True,
- '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',
- },
- '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,
- },
- },
- {
- 'group_id': 'group_prod',
- 'name': '正式环境',
- 'enabled': True,
- 'panorama': {
- 'ip': '192.168.20.196',
- '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.20.196:554/cam/realmonitor?channel=1&subtype=0',
- },
- 'ptz': {
- 'ip': '192.168.20.197',
- '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.20.197:554/cam/realmonitor?channel=1&subtype=0',
- 'pan_flip': False,
- 'ceiling_mount': True,
- },
- },
- ]
- 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
|