| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- """
- 摄像头配置
- """
- import platform
- import os
- LOG_CONFIG = {
- 'level': 'INFO',
- 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
- 'file': None, # 日志文件路径,设置为None则只输出到控制台
- 'max_bytes': 10 * 1024 * 1024,
- 'backup_count': 5,
- 'retention_days': 7, # 日志保留天数
- }
- # ============================================================
- # 单组摄像头配置(保持向后兼容)
- # ============================================================
- PANORAMA_CAMERA = {
- 'ip': '192.168.20.196',
- 'port': 37777,
- 'rtsp_port': 554,
- 'username': 'admin',
- 'password': 'Aa1234567',
- 'channel': 1,
- # 品牌:dahua 使用 SDK 登录;hikvision 仅使用 RTSP 取流
- 'brand': 'dahua',
- 'use_sdk': False,
- # 全景摄像头期望分辨率,支持 (width, height) 或字符串如 "1920x1080"
- # 常见值:3840x1080、2560x1440、1920x1080
- 'resolution': (3840, 1080),
- 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.20.196:554/cam/realmonitor?channel=1&subtype=0',
- }
- PTZ_CAMERA = {
- 'ip': '192.168.20.197',
- 'port': 37777,
- 'rtsp_port': 554,
- 'username': 'admin',
- 'password': 'Aa1234567',
- 'channel': 0, # PTZ 控制通道号 (SDK 从 0 开始)
- 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.20.197:554/cam/realmonitor?channel=1&subtype=0',
- }
- # ============================================================
- # 多组摄像头配置(新架构)
- # 使用方法:启用需要的组(enabled=True),配置对应的IP地址
- # ============================================================
- CAMERA_GROUPS = [
- {
- 'group_id': 'group_1',
- 'name': '现场主组',
- 'enabled': True,
- 'panorama': {
- 'ip': '192.168.20.196',
- 'port': 37777,
- 'rtsp_port': 554,
- 'username': 'admin',
- 'password': 'Aa1234567',
- 'channel': 1,
- # 品牌:dahua 使用 SDK 登录;hikvision 仅使用 RTSP 取流
- 'brand': 'dahua',
- 'use_sdk': False,
- # 全景摄像头期望分辨率,支持 (width, height) 或字符串如 "2560x1440"
- # 常见值:3840x1080、2560x1440、1920x1080
- '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': 0,
- 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.20.197:554/cam/realmonitor?channel=1&subtype=0',
- # 球机安装方向:ceiling=吸顶/吊装(镜头朝下), wall=壁装/立杆(镜头水平/竖装镜头朝上)
- # 当前球机竖装、镜头朝上,pan/tilt 运动方向均与视觉方向相反
- 'mount_type': 'wall',
- # pan_flip: 球机水平运动方向与视觉方向相反时设为 True
- 'pan_flip': True,
- # tilt_flip: 球机俯仰运动方向与视觉方向相反时设为 True
- 'tilt_flip': True,
- # 视野映射:全景 x=0 -> pan=-90, x=1 -> pan=+90
- 'pan_range': (-90, 90),
- 'pan_center': 0,
- # tilt:负值为向下看。竖装+倒影后,y=0(画面上方/远处)向上看,y=1 向下看
- # 人要被显示器挡住,需要适当向上看(tilt 正值)
- 'tilt_range': (-5, 20),
- 'tilt_center': 7,
- # tilt 全局偏移补偿(度):正值向下,负值向上;用于现场微调
- 'tilt_offset': 5,
- 'tilt_linear_enabled': False, # 使用手动标定的 tilt_lookup,不用线性映射
- 'tilt_y0': 13, # 备用:y=0(画面上方/远处)略向上,使人头/上半身不被切出画面
- 'tilt_y1': -5,
- 'tilt_curve_power': 0.8,
- # 自动校准扫描范围:完整 360° 粗扫 + 每步由下朝上细扫,建立全景→PTZ 映射
- 'overlap_pan_range': (0, 360),
- 'overlap_tilt_range': (-35, 45),
- 'overlap_pan_step': 20,
- 'overlap_tilt_step': 10,
- },
- 'calibration_file': '/home/admin/dsh/calibration_group1.json',
- 'paired_image_dir': '/home/admin/dsh/paired_images_group1',
- },
- ]
- # SDK 路径配置
- _ARCH = platform.machine()
- if _ARCH == 'aarch64':
- _SDK_DIR = '/home/admin/dsh/dh/arm/Bin'
- elif _ARCH == 'x86_64':
- _SDK_DIR = '/home/wen/dsh/dh/Bin'
- else:
- _SDK_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..', 'dh', 'Bin')
- SDK_PATH = {
- 'lib_path': _SDK_DIR,
- 'netsdk': 'libdhnetsdk.so',
- }
- def get_enabled_groups() -> list:
- """获取所有启用的摄像头组配置"""
- return [g for g in CAMERA_GROUPS if g.get('enabled', False)]
- def parse_resolution(resolution) -> tuple:
- """解析分辨率配置为 (width, height)
- 支持格式:
- - (3840, 1080)
- - [3840, 1080]
- - "3840x1080"
- - "3840*1080"
- - "3840X1080"
- Args:
- resolution: 分辨率配置
- Returns:
- (width, height) 元组
- """
- 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):
- # 支持 x、X、* 作为分隔符
- 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
|