camera.py 3.3 KB

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