|
@@ -9,21 +9,37 @@ from .ptz import PTZ_CONFIG
|
|
|
|
|
|
|
|
|
|
|
|
|
def _default_model_paths():
|
|
def _default_model_paths():
|
|
|
- """根据平台返回默认模型路径。"""
|
|
|
|
|
|
|
+ """根据平台返回默认模型路径。
|
|
|
|
|
+
|
|
|
|
|
+ 平台策略:
|
|
|
|
|
+ - Linux aarch64 (RK3588): 优先 RKNN,回退 PyTorch
|
|
|
|
|
+ - Linux x86_64: 优先 PyTorch,回退 RKNN(实际通常仍用 PyTorch)
|
|
|
|
|
+ - Darwin/macOS: 仅 PyTorch
|
|
|
|
|
+ - 未知平台: 仅 PyTorch
|
|
|
|
|
+ """
|
|
|
system = platform.system()
|
|
system = platform.system()
|
|
|
machine = platform.machine()
|
|
machine = platform.machine()
|
|
|
|
|
|
|
|
if system == 'Linux' and machine == 'aarch64':
|
|
if system == 'Linux' and machine == 'aarch64':
|
|
|
- base = '/home/admin/dsh/model'
|
|
|
|
|
|
|
+ base = '/home/admin/dsh/yolo'
|
|
|
|
|
+ primary = f'{base}/yolo11.rknn'
|
|
|
|
|
+ fallback = f'{base}/yolo11n.pt'
|
|
|
elif system == 'Linux' and machine == 'x86_64':
|
|
elif system == 'Linux' and machine == 'x86_64':
|
|
|
- base = '/home/wen/dsh/model'
|
|
|
|
|
|
|
+ base = '/home/wen/dsh/yolo'
|
|
|
|
|
+ primary = f'{base}/yolo11n.pt'
|
|
|
|
|
+ # x86_64 通常无法运行 RKNN,回退仍使用同一 PyTorch 模型
|
|
|
|
|
+ fallback = primary
|
|
|
elif system == 'Darwin':
|
|
elif system == 'Darwin':
|
|
|
base = '/Users/wenhongquan/Desktop/阿里云同步/项目/dnn/sb/model'
|
|
base = '/Users/wenhongquan/Desktop/阿里云同步/项目/dnn/sb/model'
|
|
|
|
|
+ primary = f'{base}/yolo11n.pt'
|
|
|
|
|
+ fallback = primary
|
|
|
else:
|
|
else:
|
|
|
- # 未知平台降级为项目相对路径
|
|
|
|
|
- base = '../model'
|
|
|
|
|
|
|
+ # 未知平台降级为项目相对路径,仅 PyTorch
|
|
|
|
|
+ base = '../yolo'
|
|
|
|
|
+ primary = f'{base}/yolo11n.pt'
|
|
|
|
|
+ fallback = primary
|
|
|
|
|
|
|
|
- return f'{base}/yolo11.rknn', f'{base}/yolo11n.pt'
|
|
|
|
|
|
|
+ return primary, fallback
|
|
|
|
|
|
|
|
|
|
|
|
|
_MODEL_PATH, _FALLBACK_MODEL_PATH = _default_model_paths()
|
|
_MODEL_PATH, _FALLBACK_MODEL_PATH = _default_model_paths()
|
|
@@ -37,26 +53,23 @@ TRACKING_CONFIG = {
|
|
|
|
|
|
|
|
# 跟踪器
|
|
# 跟踪器
|
|
|
'tracker_type': 'bytetrack', # 'bytetrack' | 'botsort'
|
|
'tracker_type': 'bytetrack', # 'bytetrack' | 'botsort'
|
|
|
- 'max_tracking_targets': COORDINATOR_CONFIG.get('max_tracking_targets', 4),
|
|
|
|
|
- 'tracking_timeout': COORDINATOR_CONFIG.get('tracking_timeout', 3.0),
|
|
|
|
|
|
|
+ 'max_tracking_targets': COORDINATOR_CONFIG['max_tracking_targets'],
|
|
|
|
|
+ 'tracking_timeout': COORDINATOR_CONFIG['tracking_timeout'],
|
|
|
'conf_threshold': 0.5,
|
|
'conf_threshold': 0.5,
|
|
|
'person_threshold': 0.5,
|
|
'person_threshold': 0.5,
|
|
|
'max_lost': 30, # Tracker 内部参数:跟踪器允许目标丢失多少帧后仍保留 ID
|
|
'max_lost': 30, # Tracker 内部参数:跟踪器允许目标丢失多少帧后仍保留 ID
|
|
|
|
|
|
|
|
# 轮询抓拍
|
|
# 轮询抓拍
|
|
|
- 'ptz_stabilize_time': PTZ_CONFIG.get('stabilize_time', 2.0),
|
|
|
|
|
- 'ptz_command_cooldown': PTZ_CONFIG.get('command_cooldown', 0.2),
|
|
|
|
|
|
|
+ # PTZ_CONFIG 中没有顶层的 stabilize_time/command_cooldown;
|
|
|
|
|
+ # 使用 PTZ_CONFIG['capture']['stabilize_time'] 作为稳定等待时间,
|
|
|
|
|
+ # command_cooldown 在 PTZ_CONFIG 中无对应键,保留字面默认值。
|
|
|
|
|
+ 'ptz_stabilize_time': PTZ_CONFIG['capture']['stabilize_time'],
|
|
|
|
|
+ 'ptz_command_cooldown': 0.2, # PTZ_CONFIG 中无此键,使用默认值
|
|
|
'capture_dir': '/home/admin/dsh/tracking_captures',
|
|
'capture_dir': '/home/admin/dsh/tracking_captures',
|
|
|
'save_panorama_pair': True,
|
|
'save_panorama_pair': True,
|
|
|
'max_capture_per_target': 0, # 0 表示不限制
|
|
'max_capture_per_target': 0, # 0 表示不限制
|
|
|
|
|
+ 'enable_upload': True, # 跟踪抓拍独立上传开关
|
|
|
|
|
|
|
|
# 目标选择(淘汰策略)
|
|
# 目标选择(淘汰策略)
|
|
|
- 'target_selection': COORDINATOR_CONFIG.get('target_selection', {
|
|
|
|
|
- 'strategy': 'area',
|
|
|
|
|
- 'area_weight': 0.6,
|
|
|
|
|
- 'confidence_weight': 0.4,
|
|
|
|
|
- 'prefer_center': True,
|
|
|
|
|
- 'center_weight': 0.2,
|
|
|
|
|
- 'min_area_threshold': 2000,
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ 'target_selection': COORDINATOR_CONFIG['target_selection'],
|
|
|
}
|
|
}
|