FuncRegionalPerson.h 5.5 KB

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