#ifndef FUNCREGIONALPERSON_H #define FUNCREGIONALPERSON_H #include "FuncBase.h" #include #include #include #include "GlobalVariable.h" /** * @brief 报警规则 * */ struct PersonCountRuleInfo { 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); }; /** * @brief 报警参数 * */ struct EndAlarmParam { int ChannelID; /* 通道ID */ AppFunction AppID; /* 应用功能 */ int CameraID; /* 摄像机ID */ uint64_t insertAlarmNum; /* 报警编号?PKID? */ EndAlarmParam(); EndAlarmParam(const EndAlarmParam& other); EndAlarmParam& operator=(const EndAlarmParam& other); bool operator==(const EndAlarmParam& other); }; /** * @brief 房间内的人数信息 * */ struct RoomPeopleInfo { int RoomID; /* 房间ID */ Enum_RoomType RoomType; /* 房间类型 */ std::string RoomName; /* 房间名称 */ int MaxNum; /* 最大人数 */ std::string imagePath; /* 图片路径 */ 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、直播间+录播间报警:当前频率直播间人数+录播间人数大于或小于设定人数值时,记为报警行为,直接展示 报警结果 * */ class FuncRegionalPersonCount : public FuncBase { public: FuncRegionalPersonCount(); ~FuncRegionalPersonCount(); protected: void task() override; private: /* 获取该频率的人员计数规则 */ bool getPersonCountRuleInfo(PersonCountRuleInfo& personCountRuleInfo); /* 判断是否在检测时间段内 */ // bool isInPeriodTime(); /* 更新房间列表 */ void updateRoomList(); /* 自动结束报警 */ void autoEndAlarm(); /* 查找是否已经结束了报警 */ bool findAlarmEnd(EndAlarmParam& alarmParam); /* 取出一个房间内的最大人数 */ bool getRoomMaxNum(int roomID, int& maxNum, std::string& strImagePath); /* 处理房间内的人数最大值 */ void handleRoomMaxNum(const RoomPeopleInfo& peopleInfo); /* 根据房间ID查找报警缓冲区 */ bool findAlarmBuffer(int roomID, AlarmBuffer& alarmBuffer); /* 根据房间ID查找房间信息 */ bool findRoomInfo(int roomID, RoomCamActInfo& roomInfo); private: ListAlarmInfo* m_pListAlarm = nullptr; /* 报警信息 */ std::list m_listRoomCamAct; /* 房间和算法ID关联列表,这里存储的是直播间和导播间的房间信息 */ PersonCountRuleInfo m_personCountRule; /* 人员计数规则 */ std::list m_listEndAlarmPara; /* 报警列表 */ int m_liveDicNum = 0; /* 直播间和导播间的最大人数之和 */ std::string m_strLiveDicImagePath; /* 直播间和导播间的报警图片路径 */ std::map m_mapRoomPeople; /* 房间内的人数信息,int是房间ID */ std::map m_mapAlarmBuffer; /* 报警信息,int是房间ID */ }; #endif /* FUNCREGIONALPERSON_H */