#ifndef FUNCREGIONALPERSON_H #define FUNCREGIONALPERSON_H #include "FuncBase.h" #include #include #include #include "GlobalVariable.h" /** * @brief 报警规则 * */ struct PersonCountRuleInfo { bool isUpdate; /* 是否更新 */ bool noRule; /* 没有规则 */ int ChannelID; /* 通道ID */ // std::string PeriodName; /* 时间段名称 */ // QDateTime StartTime; /* 开始时间 */ // QDateTime EndTime; /* 结束时间 */ // int week; /* 星期 */ // Enum_PeriodType RuleType; /* 规则类型,0表示所有时段,1表示按天,2表示按周 */ bool LiveMinEnable; /* 启用直播间最小人数 */ bool LiveMaxEnable; /* 启用直播间最大人数 */ bool DicMinEnable; /* 启用导播间最小人数 */ bool DicMaxEnable; /* 启用导播间最大人数 */ bool LiveDicMinEnable; /* 启用直播间和导播间最小人数 */ bool LiveDicMaxEnable; /* 启用直播间和导播间最大人数 */ int LiveMin; /* 直播间最小人数 */ int LiveMax; /* 直播间最大人数 */ int DicMin; /* 导播间最小人数 */ int DicMax; /* 导播间最大人数 */ int LiveDicMin; /* 直播间和导播间最小人数 */ int LiveDicMax; /* 直播间和导播间最大人数 */ std::string RuleName; /* 规则名称 */ PersonCountRuleInfo(); PersonCountRuleInfo& operator=(PersonCountRuleInfo& other); /* 对比规则需不需要更新 */ bool equals(const PersonCountRuleInfo& other) const; }; /** * @brief 房间内的人数信息 * */ struct RoomPeopleInfo { int RoomID; /* 房间ID */ Enum_RoomType RoomType; /* 房间类型 */ std::string RoomName; /* 房间名称 */ int MaxNum; /* 最大人数 */ std::string imagePath; /* 图片路径 */ QDateTime StartTime; /* 这一轮检测的检测开始时间 */ QDateTime EventTime; /* 报警时间 */ std::list listBbox; /* Bbox列表,图片中的报警位置 */ RoomPeopleInfo(); RoomPeopleInfo(const RoomPeopleInfo& other); RoomPeopleInfo& operator=(const RoomPeopleInfo& other); }; struct AlarmBuffer { // bool isMax; /* 是否最大人数,false是最小人数 */ // bool isInsertDB; /* 是否已经插入数据库 */ int ChannelID; /* 通道ID */ int RoomID; /* 房间ID */ Enum_RoomType RoomType; /* 房间类型 */ int PeopleNum; /* 人数 */ uint64_t PKID; /* 报警编号,在数据库中的编号 */ QDateTime AlarmTime; /* 报警时间 */ std::string imagePath; /* 图片路径 */ std::string actionDecs; /* 报警描述 */ AlarmBuffer(); AlarmBuffer(const AlarmBuffer& other); AlarmBuffer& operator=(const AlarmBuffer& other); }; /** * @brief 区域人员检测,检测这个区域内的人数,不能少于多少人,不能多余多少人 * 1、报警判断条件:直播间报警:当前频率所有直播间摄像头的区域人员检测算法输出结果均大于或小于设定人 数值时,记为报警行为,直接展示报警结果 2、录播间报警:当前频率所有录播间摄像头的区域人员检测算法输出结果均大于或小于设定人数值时,记为报 警行为,直接展示报警结果 3、直播间+录播间报警:当前频率直播间人数+录播间人数大于或小于设定人数值时,记为报警行为,直接展示 报警结果 4、人员数目是看的bBox中的方框数目,不是用的PersonList数目,老代码是这么做的 * */ class FuncRegionalPersonCount : public FuncBase { public: FuncRegionalPersonCount(); ~FuncRegionalPersonCount(); protected: void task() override; private: /* 读取Redis数据 */ void readRedisData(); /* 获取该频率的人员计数规则 */ bool getPersonCountRuleInfo(); /* 更新房间列表 */ void updateRoomList(); /* 自动结束报警 */ void autoEndAlarm(); /* 取出一个房间内的最大人数 */ bool getRoomMaxNum(int roomID, RoomPeopleInfo& roomInfo); /* 处理房间内的人数最大值 */ void handleRoomMaxNum(const RoomPeopleInfo& peopleInfo); /* 处理房间内人数最小值 */ void handleRoomMinNum(const RoomPeopleInfo& peopleInfo); /* 根据房间ID查找报警缓冲区 */ AlarmBuffer* findAlarmBuffer(int roomID); /* 根据房间ID查找房间信息 */ bool findRoomInfo(int roomID, RoomCamActInfo& roomInfo); /* 清空报警缓存列表 */ void clearAlarmBufferMap(); private: ListAlarmInfo m_listSrcAlarm; /* 报警信息 */ std::list m_listRoomCamAct; /* 房间和算法ID关联列表,这里存储的是直播间和导播间的房间信息 */ PersonCountRuleInfo m_personCountRule; /* 人员计数规则 */ int m_liveDicNum = 0; /* 直播间和导播间的最大人数之和 */ std::string m_strLiveDicImagePath; /* 直播间和导播间的报警图片路径 */ std::map m_mapRoomPeople; /* 房间内的人数信息,int是房间ID */ std::map m_mapAlarmBuffer; /* 报警信息,int是房间ID */ }; #endif /* FUNCREGIONALPERSON_H */