detection.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """
  2. 检测配置
  3. """
  4. # 检测配置
  5. DETECTION_CONFIG = {
  6. 'target_classes': ['person'], # 检测目标类别 (支持中英文)
  7. 'confidence_threshold': 0.5, # 置信度阈值
  8. 'detection_fps': 2, # 检测帧率(每秒检测帧数),替代原来的detection_interval
  9. 'detection_interval': 4, # 兼容保留:检测间隔(秒),当detection_fps=2时间隔为0.5秒
  10. # 检测图片保存配置
  11. 'save_detection_image': False, # 是否保存检测到人的图片
  12. 'detection_image_dir': '/home/admin/dsh/detection_images', # 图片保存目录
  13. # 配对图片保存配置(全景+球机图片归入同一目录)
  14. 'enable_paired_saving': True, # 是否启用配对图片保存
  15. 'paired_image_dir': '/home/admin/dsh/paired_images', # 配对图片保存目录
  16. 'paired_time_window': 5.0, # 批次时间窗口(秒),同一窗口内的检测归为一批
  17. # RK3588 平台使用 RKNN 安全检测模型 (包含人体检测)
  18. # 类别映射: 0=安全帽, 3=人, 4=反光衣
  19. 'model_path': '/home/admin/dsh/testrk3588/yolo11m_safety.rknn',
  20. 'model_type': 'rknn', # 模型类型: 'rknn', 'yolo', 'onnx'
  21. 'use_gpu': False, # RKNN 使用 NPU,不依赖 GPU
  22. # 安全检测模型的类别映射
  23. 'class_map': {
  24. 0: 'hat',
  25. 3: 'person',
  26. 4: 'reflective'
  27. },
  28. 'person_class_id': 3, # 人员在模型中的类别ID
  29. 'person_threshold': 0.8, # 人员检测置信度阈值
  30. }
  31. # 安全检测模型配置
  32. SAFETY_DETECTION_CONFIG = {
  33. # 模型路径 - 支持三种格式:
  34. # - YOLO: .pt 文件, 使用 ultralytics
  35. # - RKNN: .rknn 文件, 使用 rknnlite (RK3588 平台)
  36. # - ONNX: .onnx 文件, 使用 onnxruntime
  37. 'model_path': '/home/admin/dsh/testrk3588/yolo11m_safety.rknn',
  38. 'model_type': 'rknn', # 模型类型: 'auto', 'yolo', 'rknn', 'onnx'
  39. 'use_gpu': False, # RKNN 使用 NPU,不依赖 GPU
  40. 'conf_threshold': 0.5, # 一般物品置信度阈值 (安全帽、反光衣)
  41. 'person_threshold': 0.8, # 人员检测置信度阈值
  42. # 检测类别映射
  43. 'class_map': {
  44. 0: 'hat',
  45. 3: 'person',
  46. 4: 'reflective'
  47. },
  48. # 检测帧率配置
  49. 'detection_fps': 2, # 检测帧率(每秒检测帧数),默认每秒2帧
  50. 'detection_interval': 0.5, # 兼容保留:检测间隔(秒),由detection_fps计算得出
  51. # 告警控制
  52. 'alert_cooldown': 3.0, # 同一目标告警冷却时间(秒)
  53. 'max_alerts_per_minute': 10, # 每分钟最大告警数
  54. # 检测图片保存配置
  55. 'save_detection_image': True, # 是否保存检测到人的图片
  56. 'detection_image_dir': '/home/admin/dsh/detection_images', # 图片保存目录
  57. 'detection_image_max_count': 100, # 最大保存图片数量,超过后自动清理旧图片
  58. }