FuncRegionalPerson.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. QDateTime StartTime; /* 这一轮检测的检测开始时间 */
  52. QDateTime EventTime; /* 报警时间 */
  53. std::list<std::string> listBbox; /* Bbox列表,图片中的报警位置 */
  54. RoomPeopleInfo();
  55. RoomPeopleInfo(const RoomPeopleInfo& other);
  56. RoomPeopleInfo& operator=(const RoomPeopleInfo& other);
  57. };
  58. struct AlarmBuffer
  59. {
  60. // bool isMax; /* 是否最大人数,false是最小人数 */
  61. // bool isInsertDB; /* 是否已经插入数据库 */
  62. int ChannelID; /* 通道ID */
  63. int RoomID; /* 房间ID */
  64. Enum_RoomType RoomType; /* 房间类型 */
  65. int PeopleNum; /* 人数 */
  66. uint64_t PKID; /* 报警编号,在数据库中的编号 */
  67. QDateTime AlarmTime; /* 报警时间 */
  68. std::string imagePath; /* 图片路径 */
  69. std::string actionDecs; /* 报警描述 */
  70. AlarmBuffer();
  71. AlarmBuffer(const AlarmBuffer& other);
  72. AlarmBuffer& operator=(const AlarmBuffer& other);
  73. };
  74. /**
  75. * @brief 区域人员检测,检测这个区域内的人数,不能少于多少人,不能多余多少人
  76. * 1、报警判断条件:直播间报警:当前频率所有直播间摄像头的区域人员检测算法输出结果均大于或小于设定人
  77. 数值时,记为报警行为,直接展示报警结果
  78. 2、录播间报警:当前频率所有录播间摄像头的区域人员检测算法输出结果均大于或小于设定人数值时,记为报
  79. 警行为,直接展示报警结果
  80. 3、直播间+录播间报警:当前频率直播间人数+录播间人数大于或小于设定人数值时,记为报警行为,直接展示
  81. 报警结果
  82. 4、人员数目是看的bBox中的方框数目,不是用的PersonList数目,老代码是这么做的
  83. *
  84. */
  85. class FuncRegionalPersonCount : public FuncBase
  86. {
  87. public:
  88. FuncRegionalPersonCount();
  89. ~FuncRegionalPersonCount();
  90. protected:
  91. void task() override;
  92. private:
  93. /* 读取Redis数据 */
  94. void readRedisData();
  95. /* 获取该频率的人员计数规则 */
  96. bool getPersonCountRuleInfo();
  97. /* 更新房间列表 */
  98. void updateRoomList();
  99. /* 自动结束报警 */
  100. void autoEndAlarm();
  101. /* 取出一个房间内的最大人数 */
  102. bool getRoomMaxNum(int roomID, RoomPeopleInfo& roomInfo);
  103. /* 处理房间内的人数最大值 */
  104. void handleRoomMaxNum(const RoomPeopleInfo& peopleInfo);
  105. /* 处理房间内人数最小值 */
  106. void handleRoomMinNum(const RoomPeopleInfo& peopleInfo);
  107. /* 根据房间ID查找报警缓冲区 */
  108. AlarmBuffer* findAlarmBuffer(int roomID);
  109. /* 根据房间ID查找房间信息 */
  110. bool findRoomInfo(int roomID, RoomCamActInfo& roomInfo);
  111. /* 清空报警缓存列表 */
  112. void clearAlarmBufferMap();
  113. private:
  114. ListAlarmInfo m_listSrcAlarm; /* 报警信息 */
  115. std::list<RoomCamActInfo> m_listRoomCamAct; /* 房间和算法ID关联列表,这里存储的是直播间和导播间的房间信息 */
  116. PersonCountRuleInfo m_personCountRule; /* 人员计数规则 */
  117. int m_liveDicNum = 0; /* 直播间和导播间的最大人数之和 */
  118. std::string m_strLiveDicImagePath; /* 直播间和导播间的报警图片路径 */
  119. std::map<int, RoomPeopleInfo> m_mapRoomPeople; /* 房间内的人数信息,int是房间ID */
  120. std::map<int, AlarmBuffer*> m_mapAlarmBuffer; /* 报警信息,int是房间ID */
  121. };
  122. #endif /* FUNCREGIONALPERSON_H */