detection.py 2.6 KB

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