camera.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. """
  2. 摄像头配置
  3. """
  4. import platform
  5. import os
  6. LOG_CONFIG = {
  7. 'level': 'INFO',
  8. 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
  9. 'file': None, # 日志文件路径,设置为None则只输出到控制台
  10. 'max_bytes': 10 * 1024 * 1024,
  11. 'backup_count': 5,
  12. 'retention_days': 7, # 日志保留天数
  13. }
  14. # ============================================================
  15. # 单组摄像头配置(保持向后兼容)
  16. # ============================================================
  17. PANORAMA_CAMERA = {
  18. 'ip': '192.168.20.196',
  19. 'port': 37777,
  20. 'rtsp_port': 554,
  21. 'username': 'admin',
  22. 'password': 'Aa1234567',
  23. 'channel': 1,
  24. 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.20.196:554/cam/realmonitor?channel=1&subtype=0',
  25. }
  26. PTZ_CAMERA = {
  27. 'ip': '192.168.20.197',
  28. 'port': 37777,
  29. 'rtsp_port': 554,
  30. 'username': 'admin',
  31. 'password': 'Aa1234567',
  32. 'channel': 0, # PTZ 控制通道号 (SDK 从 0 开始)
  33. 'rtsp_url': 'rtsp://admin:Aa1234567@192.168.20.197:554/cam/realmonitor?channel=1&subtype=0',
  34. }
  35. # ============================================================
  36. # 多组摄像头配置(新架构)
  37. # 使用方法:启用需要的组(enabled=True),配置对应的IP地址
  38. # ============================================================
  39. CAMERA_GROUPS = [
  40. {
  41. 'group_id': 'group_1',
  42. 'name': '第一组',
  43. 'enabled': True,
  44. 'panorama': {
  45. 'ip': '192.168.20.196',
  46. 'port': 37777,
  47. 'rtsp_port': 554,
  48. 'username': 'admin',
  49. 'password': 'Aa1234567',
  50. 'channel': 1,
  51. },
  52. 'ptz': {
  53. 'ip': '192.168.20.197',
  54. 'port': 37777,
  55. 'rtsp_port': 554,
  56. 'username': 'admin',
  57. 'password': 'Aa1234567',
  58. 'channel': 0,
  59. 'pan_flip': True, # pan方向翻转
  60. 'ceiling_mount': True, # 吸顶安装
  61. },
  62. 'calibration_file': '/home/admin/dsh/calibration_group1.json',
  63. 'paired_image_dir': '/home/admin/dsh/paired_images_group1',
  64. },
  65. # 第二组配置(示例,按需启用)
  66. # {
  67. # 'group_id': 'group_2',
  68. # 'name': '第二组',
  69. # 'enabled': False, # 设为 True 启用
  70. # 'panorama': {
  71. # 'ip': '192.168.20.198',
  72. # 'port': 37777,
  73. # 'rtsp_port': 554,
  74. # 'username': 'admin',
  75. # 'password': 'Aa1234567',
  76. # 'channel': 1,
  77. # },
  78. # 'ptz': {
  79. # 'ip': '192.168.20.199',
  80. # 'port': 37777,
  81. # 'rtsp_port': 554,
  82. # 'username': 'admin',
  83. # 'password': 'Aa1234567',
  84. # 'channel': 0,
  85. # 'pan_flip': True,
  86. # 'ceiling_mount': True,
  87. # },
  88. # 'calibration_file': '/home/admin/dsh/calibration_group2.json',
  89. # 'paired_image_dir': '/home/admin/dsh/paired_images_group2',
  90. # },
  91. ]
  92. # SDK 路径配置
  93. _ARCH = platform.machine()
  94. if _ARCH == 'aarch64':
  95. _SDK_DIR = '/home/admin/dsh/dh/arm/Bin'
  96. elif _ARCH == 'x86_64':
  97. _SDK_DIR = '/home/wen/dsh/dh/Bin'
  98. else:
  99. _SDK_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..', 'dh', 'Bin')
  100. SDK_PATH = {
  101. 'lib_path': _SDK_DIR,
  102. 'netsdk': 'libdhnetsdk.so',
  103. }
  104. def get_enabled_groups() -> list:
  105. """获取所有启用的摄像头组配置"""
  106. return [g for g in CAMERA_GROUPS if g.get('enabled', False)]