FuncRegionalPerson.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef FUNCREGIONALPERSON_H
  2. #define FUNCREGIONALPERSON_H
  3. #include "FuncBase.h"
  4. #include <cstdint>
  5. #include <qdatetime.h>
  6. #include <string>
  7. #include "GlobalVariable.h"
  8. /**
  9. * @brief 报警规则
  10. *
  11. */
  12. struct PersonCountRuleInfo
  13. {
  14. int ChannelID; /* 通道ID */
  15. // std::string PeriodName; /* 时间段名称 */
  16. // QDateTime StartTime; /* 开始时间 */
  17. // QDateTime EndTime; /* 结束时间 */
  18. // int week; /* 星期 */
  19. // Enum_PeriodType RuleType; /* 规则类型,0表示所有时段,1表示按天,2表示按周 */
  20. bool LiveMinEnable; /* 启用直播间最小人数 */
  21. bool LiveMaxEnable; /* 启用直播间最大人数 */
  22. bool DicMinEnable; /* 启用导播间最小人数 */
  23. bool DicMaxEnable; /* 启用导播间最大人数 */
  24. bool LiveDicMinEnable; /* 启用直播间和导播间最小人数 */
  25. bool LiveDicMaxEnable; /* 启用直播间和导播间最大人数 */
  26. int LiveMin; /* 直播间最小人数 */
  27. int LiveMax; /* 直播间最大人数 */
  28. int DicMin; /* 导播间最小人数 */
  29. int DicMax; /* 导播间最大人数 */
  30. int LiveDicMin; /* 直播间和导播间最小人数 */
  31. int LiveDicMax; /* 直播间和导播间最大人数 */
  32. std::string RuleName; /* 规则名称 */
  33. PersonCountRuleInfo();
  34. PersonCountRuleInfo& operator=(PersonCountRuleInfo& other);
  35. };
  36. /**
  37. * @brief 报警参数
  38. *
  39. */
  40. struct EndAlarmParam
  41. {
  42. int ChannelID; /* 通道ID */
  43. AppFunction AppID; /* 应用功能 */
  44. int CameraID; /* 摄像机ID */
  45. uint64_t insertAlarmNum; /* 报警编号?PKID? */
  46. EndAlarmParam();
  47. EndAlarmParam(const EndAlarmParam& other);
  48. EndAlarmParam& operator=(const EndAlarmParam& other);
  49. bool operator==(const EndAlarmParam& other);
  50. };
  51. /**
  52. * @brief 房间内的人数信息
  53. *
  54. */
  55. struct RoomPeopleInfo
  56. {
  57. int RoomID; /* 房间ID */
  58. Enum_RoomType RoomType; /* 房间类型 */
  59. std::string RoomName; /* 房间名称 */
  60. int MaxNum; /* 最大人数 */
  61. std::string imagePath; /* 图片路径 */
  62. RoomPeopleInfo();
  63. RoomPeopleInfo(const RoomPeopleInfo& other);
  64. RoomPeopleInfo& operator=(const RoomPeopleInfo& other);
  65. };
  66. struct AlarmBuffer
  67. {
  68. bool isMax; /* 是否最大人数,false是最小人数 */
  69. // bool isInsertDB; /* 是否已经插入数据库 */
  70. int ChannelID; /* 通道ID */
  71. int RoomID; /* 房间ID */
  72. Enum_RoomType RoomType; /* 房间类型 */
  73. int PeopleNum; /* 人数 */
  74. uint64_t PKID; /* 报警编号,在数据库中的编号 */
  75. QDateTime AlarmTime; /* 报警时间 */
  76. std::string imagePath; /* 图片路径 */
  77. std::string actionDecs; /* 报警描述 */
  78. AlarmBuffer();
  79. AlarmBuffer(const AlarmBuffer& other);
  80. AlarmBuffer& operator=(const AlarmBuffer& other);
  81. };
  82. /**
  83. * @brief 区域人员检测,检测这个区域内的人数,不能少于多少人,不能多余多少人
  84. * 1、报警判断条件:直播间报警:当前频率所有直播间摄像头的区域人员检测算法输出结果均大于或小于设定人
  85. 数值时,记为报警行为,直接展示报警结果
  86. 2、录播间报警:当前频率所有录播间摄像头的区域人员检测算法输出结果均大于或小于设定人数值时,记为报
  87. 警行为,直接展示报警结果
  88. 3、直播间+录播间报警:当前频率直播间人数+录播间人数大于或小于设定人数值时,记为报警行为,直接展示
  89. 报警结果
  90. *
  91. */
  92. class FuncRegionalPersonCount : public FuncBase
  93. {
  94. public:
  95. FuncRegionalPersonCount();
  96. ~FuncRegionalPersonCount();
  97. protected:
  98. void task() override;
  99. private:
  100. /* 获取该频率的人员计数规则 */
  101. bool getPersonCountRuleInfo(PersonCountRuleInfo& personCountRuleInfo);
  102. /* 判断是否在检测时间段内 */
  103. // bool isInPeriodTime();
  104. /* 更新房间列表 */
  105. void updateRoomList();
  106. /* 自动结束报警 */
  107. void autoEndAlarm();
  108. /* 查找是否已经结束了报警 */
  109. bool findAlarmEnd(EndAlarmParam& alarmParam);
  110. /* 取出一个房间内的最大人数 */
  111. bool getRoomMaxNum(int roomID, int& maxNum, std::string& strImagePath);
  112. /* 处理房间内的人数最大值 */
  113. void handleRoomMaxNum(const RoomPeopleInfo& peopleInfo);
  114. /* 根据房间ID查找报警缓冲区 */
  115. bool findAlarmBuffer(int roomID, AlarmBuffer& alarmBuffer);
  116. /* 根据房间ID查找房间信息 */
  117. bool findRoomInfo(int roomID, RoomCamActInfo& roomInfo);
  118. private:
  119. ListAlarmInfo* m_pListAlarm = nullptr; /* 报警信息 */
  120. std::list<RoomCamActInfo> m_listRoomCamAct; /* 房间和算法ID关联列表,这里存储的是直播间和导播间的房间信息 */
  121. PersonCountRuleInfo m_personCountRule; /* 人员计数规则 */
  122. std::list<EndAlarmParam> m_listEndAlarmPara; /* 报警列表 */
  123. int m_liveDicNum = 0; /* 直播间和导播间的最大人数之和 */
  124. std::string m_strLiveDicImagePath; /* 直播间和导播间的报警图片路径 */
  125. std::map<int, RoomPeopleInfo> m_mapRoomPeople; /* 房间内的人数信息,int是房间ID */
  126. std::map<int, AlarmBuffer> m_mapAlarmBuffer; /* 报警信息,int是房间ID */
  127. };
  128. #endif /* FUNCREGIONALPERSON_H */