Ver código fonte

V0.3.3
1、基本完成了非法入侵检测

Apple 6 meses atrás
pai
commit
5ab9a96344

+ 31 - 4
SecurePlayAuxServer/GlobalInfo/GlobalInfo.cpp

@@ -91,7 +91,7 @@ AlarmInfo::AlarmInfo()
     ActionDes = "";
     FaceIDList = "";
     FaceNameList = "";
-    BboxList = "";
+    listBbox.clear();
 }
 
 
@@ -114,7 +114,7 @@ AlarmInfo::AlarmInfo(const AlarmInfo& other)
     ActionDes = other.ActionDes;
     FaceIDList = other.FaceIDList;
     FaceNameList = other.FaceNameList;
-    BboxList = other.BboxList;
+    listBbox = other.listBbox;
     vecPersonInfo = other.vecPersonInfo;
 }
 
@@ -139,7 +139,7 @@ AlarmInfo& AlarmInfo::operator=(AlarmInfo& other)
         ActionDes = other.ActionDes;
         FaceIDList = other.FaceIDList;
         FaceNameList = other.FaceNameList;
-        BboxList = other.BboxList;
+        listBbox = other.listBbox;
         vecPersonInfo = other.vecPersonInfo;
     }
     return *this;
@@ -165,7 +165,7 @@ void AlarmInfo::reInit()
     ActionDes = "";
     FaceIDList = "";
     FaceNameList = "";
-    BboxList = "";
+    listBbox.clear();
 }
 
 /**
@@ -352,6 +352,33 @@ IllegalInvasionInfo* ListIllegalInvasionInfo::findIllInfo(int roomID, int roomTy
     return nullptr;
 }
 
+/* 删除报警信息 */
+void ListIllegalInvasionInfo::deleteIllInfo(IllegalInvasionInfo& info)
+{
+    for(auto it = listIll.begin(); it != listIll.end();)
+    {
+        if(it->RoomID == info.RoomID && it->RoomType == info.RoomType)
+        {
+            it = listIll.erase(it);
+        }else {
+            ++it;
+        }
+    }
+}
+
+void ListIllegalInvasionInfo::deleteIllInfo(int roomID, int roomType)
+{
+    for(auto it = listIll.begin(); it != listIll.end();)
+    {
+        if(it->RoomID == roomID && it->RoomType == roomType)
+        {
+            it = listIll.erase(it);
+        }else {
+            ++it;
+        }
+    }
+}
+
 
 RoomIllegalInvasionInfo::RoomIllegalInvasionInfo(RoomIllegalInvasionInfo& o)
 {

+ 20 - 2
SecurePlayAuxServer/GlobalInfo/GlobalInfo.h

@@ -72,6 +72,21 @@ public:
     std::string ActAnimalDetect;          /* 动物识别 */
     std::string ActMouseDetect;           /* 老鼠识别 */
     std::string ActMask;                  /* 口罩识别 */
+
+    std::map<std::string, std::string> mapAction;   /* 算法ID和算法名称的对应关系 */
+
+    ActionList() = default;
+
+    std::string getActionName(const std::string& actionID) {
+        std::string actionName;
+        mutexRW.lockForRead();
+        auto it = mapAction.find(actionID);
+        if(it != mapAction.end()) {
+            actionName = it->second;
+        }
+        mutexRW.unlock();
+        return actionName;
+    }
 };
 
 extern ActionList g_actionList;
@@ -237,7 +252,7 @@ struct AlarmInfo
     std::string ActionDes;      /* 算法描述信息 */
     std::string FaceIDList;     /* 人脸ID列表 */
     std::string FaceNameList;   /* 人脸名称列表 */
-    std::string BboxList;       /* Bbox列表,应该是图片中的报警位置 */
+    std::list<std::string> listBbox;       /* Bbox列表,应该是图片中的报警位置 */
     std::vector<PersonInfo> vecPersonInfo;    /* 人员信息 */
 
     AlarmInfo();
@@ -342,6 +357,9 @@ struct ListIllegalInvasionInfo
     /* 查找相同的信息 */
     IllegalInvasionInfo* findIllInfo(IllegalInvasionInfo& info);
     IllegalInvasionInfo* findIllInfo(int roomID, int roomType);
+    /* 删除报警信息 */
+    void deleteIllInfo(IllegalInvasionInfo& info);
+    void deleteIllInfo(int roomID, int roomType);
 };
 
 
@@ -357,7 +375,7 @@ struct RoomIllegalInvasionInfo
     int numMaxFace = 0;                     /* 最大人脸数 */
     int numMaxPerson = 0;                   /* 最大人员数 */
     int CameraID = 0;                       /* 摄像机ID,这个存储的是使用的哪个报警信息的ID */
-    std::string strBoxList;                 /* box */
+    std::list<std::string> strBoxList;      /* box */
     std::string strMessage;                 /* 报警信息字符串 */
     std::string strImage;                   /* 报警图片 */
     std::vector<PersonInfo> vecPersonInfo;  /* 人员信息 */

+ 179 - 150
SecurePlayAuxServer/SPAServer.cpp

@@ -413,7 +413,8 @@ void SPAServer::threadFromRedis(const CameraThreadInfo& info)
             AlarmInfo alarmInfo;
             alarmInfo.ActionID = it.substr(it.find(":") + 1);
             /* 解析数据 */
-            parseRedisData(strRetValue, alarmInfo);
+            parseRedisBaseData(strRetValue, alarmInfo);
+            parseRedisBBoxesData(strRetValue, alarmInfo);
             /* 信息时间有的效性判断,主要是记录Redis数据的有效性,是否长时间没有变化,排查错误时用的
              * 如果数据长时间数据不变,那么超脑那里就挂了,写入日志 */
             isEventTimeVaild(alarmInfo.EventTime);
@@ -430,132 +431,132 @@ void SPAServer::threadFromRedis(const CameraThreadInfo& info)
     return;
 }
 
-/* 解析Redis基础数据 */
-void SPAServer::parseRedisData(const std::string& strData, AlarmInfo& alarmInfo)
-{
-    try
-    {
-        nJson json0;
-        json0 = nJson::parse(strData);
-        alarmInfo.AlarmID = json0["alarmId"].get<int>();
-        alarmInfo.ChannelID = json0["channel"].get<int>();
-        alarmInfo.PicUrl = json0["picUrl"].get<std::string>();
-        alarmInfo.ImageInfo = json0["imageInfo"].get<std::string>();
+// /* 解析Redis基础数据 */
+// void SPAServer::parseRedisData(const std::string& strData, AlarmInfo& alarmInfo)
+// {
+//     try
+//     {
+//         nJson json0;
+//         json0 = nJson::parse(strData);
+//         alarmInfo.AlarmID = json0["alarmId"].get<int>();
+//         alarmInfo.ChannelID = json0["channel"].get<int>();
+//         alarmInfo.PicUrl = json0["picUrl"].get<std::string>();
+//         alarmInfo.ImageInfo = json0["imageInfo"].get<std::string>();
         
-        /* 解析时间,需要将时间中的“T”换成空格 */
-        alarmInfo.StartTime = json0["beginTime"].get<std::string>();
-        std::replace(alarmInfo.StartTime.begin(), alarmInfo.StartTime.end(), 'T', ' ');
-        alarmInfo.EndTime = json0["endTime"].get<std::string>();
-        std::replace(alarmInfo.EndTime.begin(), alarmInfo.EndTime.end(), 'T', ' ');
-        alarmInfo.EventTime = json0["eventTime"].get<std::string>();
-        std::replace(alarmInfo.EventTime.begin(), alarmInfo.EventTime.end(), 'T', ' ');
-        /* 判断bBoxes有无数据,有数据就解析,没数据就直接返回了 */
-        nJson json1 = json0["bBoxes"];
+//         /* 解析时间,需要将时间中的“T”换成空格 */
+//         alarmInfo.StartTime = json0["beginTime"].get<std::string>();
+//         std::replace(alarmInfo.StartTime.begin(), alarmInfo.StartTime.end(), 'T', ' ');
+//         alarmInfo.EndTime = json0["endTime"].get<std::string>();
+//         std::replace(alarmInfo.EndTime.begin(), alarmInfo.EndTime.end(), 'T', ' ');
+//         alarmInfo.EventTime = json0["eventTime"].get<std::string>();
+//         std::replace(alarmInfo.EventTime.begin(), alarmInfo.EventTime.end(), 'T', ' ');
+//         /* 判断bBoxes有无数据,有数据就解析,没数据就直接返回了 */
+//         nJson json1 = json0["bBoxes"];
         
-        std::string labelList;              /* 记录违禁品 */
-        std::string bboxList;               /* 记录bbox */
-        if(!json1.empty())
-        {
-            for(auto& it0 : json1)
-            {
-                /* 如果status是true,就不是报警,直接跳过 */
-                bool status = it0["status"].get<bool>();
-                if(status)
-                {
-                    continue;
-                }
-                /* 这一条Box数据报警了将其内容存储起来 */
-                alarmInfo.Is_Alarm = true;
-                /* 解析label,违禁品关键字,先判断这个是不是违禁品检测的算法ID */
-                if(alarmInfo.ActionID == g_actionList.ActContraband)
-                {
-                    /* 解析报警,取出报警类型 */
-                    nJson label = it0["label"];
-                    for(auto& it1 : label)
-                    {
-                        std::string strLabel = it1.get<std::string>();
-                        /* 检测是否已经加入到字符串中了 */
-                        strLabel += "|";
-                        if(labelList.find(strLabel) != std::string::npos)
-                        {
-                            continue;
-                        }
-                        labelList += strLabel;
-                    }
-                }
-                /* 解析bbox,貌似是在图像中的位置 */
-                nJson bbox = it0["bbox"];
-                std::string strBbox;
-                for(auto& it1 : bbox)
-                {
-                    strBbox += std::to_string(it1.get<int>()) + ",";
-                }
-                /* 去掉最后一个“,” */
-                if(!strBbox.empty())
-                {
-                    strBbox.pop_back();
-                }
-                bboxList += strBbox + "|";
-            }
-            /* 去掉最后一个“|” */
-            if(!labelList.empty())
-            {
-                labelList.pop_back();
-            }
-            if(!bboxList.empty())
-            {
-                bboxList.pop_back();
-            }
-            SPDLOG_LOGGER_DEBUG(m_logger, "违禁品列表:{}", labelList);
-            SPDLOG_LOGGER_DEBUG(m_logger, "bbox列表:{}", bboxList);
-        }
+//         std::string labelList;              /* 记录违禁品 */
+//         std::string bboxList;               /* 记录bbox */
+//         if(!json1.empty())
+//         {
+//             for(auto& it0 : json1)
+//             {
+//                 /* 如果status是true,就不是报警,直接跳过 */
+//                 bool status = it0["status"].get<bool>();
+//                 if(status)
+//                 {
+//                     continue;
+//                 }
+//                 /* 这一条Box数据报警了将其内容存储起来 */
+//                 alarmInfo.Is_Alarm = true;
+//                 /* 解析label,违禁品关键字,先判断这个是不是违禁品检测的算法ID */
+//                 if(alarmInfo.ActionID == g_actionList.ActContraband)
+//                 {
+//                     /* 解析报警,取出报警类型 */
+//                     nJson label = it0["label"];
+//                     for(auto& it1 : label)
+//                     {
+//                         std::string strLabel = it1.get<std::string>();
+//                         /* 检测是否已经加入到字符串中了 */
+//                         strLabel += "|";
+//                         if(labelList.find(strLabel) != std::string::npos)
+//                         {
+//                             continue;
+//                         }
+//                         labelList += strLabel;
+//                     }
+//                 }
+//                 /* 解析bbox,貌似是在图像中的位置 */
+//                 nJson bbox = it0["bbox"];
+//                 std::string strBbox;
+//                 for(auto& it1 : bbox)
+//                 {
+//                     strBbox += std::to_string(it1.get<int>()) + ",";
+//                 }
+//                 /* 去掉最后一个“,” */
+//                 if(!strBbox.empty())
+//                 {
+//                     strBbox.pop_back();
+//                 }
+//                 bboxList += strBbox + "|";
+//             }
+//             /* 去掉最后一个“|” */
+//             if(!labelList.empty())
+//             {
+//                 labelList.pop_back();
+//             }
+//             if(!bboxList.empty())
+//             {
+//                 bboxList.pop_back();
+//             }
+//             SPDLOG_LOGGER_DEBUG(m_logger, "违禁品列表:{}", labelList);
+//             SPDLOG_LOGGER_DEBUG(m_logger, "bbox列表:{}", bboxList);
+//         }
         
-        /* 如果有报警的Box */
-        if(alarmInfo.Is_Alarm)
-        {
-            /* 添加报警信息的提示信息 */
-            alarmInfo.BboxList = bboxList;
-            if( (alarmInfo.ActionID == g_actionList.ActContraband) && !labelList.empty() )
-            {
-                alarmInfo.ActionDes = fmt::format("出现违禁品[{}]告警", labelList);
-                SPDLOG_LOGGER_INFO(m_logger, "{}", alarmInfo.ActionDes);
-            }else {
-                alarmInfo.ActionDes = json0["actionDes"].get<std::string>();
-            }
-            /* 判断有没有报警数据 */
-            if(alarmInfo.ImageInfo.empty())
-            {
-                SPDLOG_LOGGER_ERROR(m_logger, "有报警区域,但是没有图片信息");
-                return;
-            }
-            /* 如果是人员报警,就存储人员报警信息 */
-            if(alarmInfo.ActionID == g_actionList.ActFace)
-            {
-                nJson jsonArray = json0["personList"];
-                for(auto& it : jsonArray)
-                {
-                    PersonInfo personInfo;
-                    personInfo.PersonID = it["personId"].get<std::string>();
-                    personInfo.PersonName = it["personName"].get<std::string>();
-                    alarmInfo.vecPersonInfo.push_back(personInfo);
-                }
-            }
-        }
+//         /* 如果有报警的Box */
+//         if(alarmInfo.Is_Alarm)
+//         {
+//             /* 添加报警信息的提示信息 */
+//             alarmInfo.BboxList = bboxList;
+//             if( (alarmInfo.ActionID == g_actionList.ActContraband) && !labelList.empty() )
+//             {
+//                 alarmInfo.ActionDes = fmt::format("出现违禁品[{}]告警", labelList);
+//                 SPDLOG_LOGGER_INFO(m_logger, "{}", alarmInfo.ActionDes);
+//             }else {
+//                 alarmInfo.ActionDes = json0["actionDes"].get<std::string>();
+//             }
+//             /* 判断有没有报警数据 */
+//             if(alarmInfo.ImageInfo.empty())
+//             {
+//                 SPDLOG_LOGGER_ERROR(m_logger, "有报警区域,但是没有图片信息");
+//                 return;
+//             }
+//             /* 如果是人员报警,就存储人员报警信息 */
+//             if(alarmInfo.ActionID == g_actionList.ActFace)
+//             {
+//                 nJson jsonArray = json0["personList"];
+//                 for(auto& it : jsonArray)
+//                 {
+//                     PersonInfo personInfo;
+//                     personInfo.PersonID = it["personId"].get<std::string>();
+//                     personInfo.PersonName = it["personName"].get<std::string>();
+//                     alarmInfo.vecPersonInfo.push_back(personInfo);
+//                 }
+//             }
+//         }
 
         
-    }
-    catch (const nJson::parse_error& e)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "解析Redis数据失败:{}, 错误ID:{}", e.what(), e.id);
-        return;
-    }
-    catch (const nJson::type_error& e)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "解析Redis数据失败:{}, 错误ID:{}", e.what(), e.id);
-        return;
-    }
-
-}
+//     }
+//     catch (const nJson::parse_error& e)
+//     {
+//         SPDLOG_LOGGER_ERROR(m_logger, "解析Redis数据失败:{}, 错误ID:{}", e.what(), e.id);
+//         return;
+//     }
+//     catch (const nJson::type_error& e)
+//     {
+//         SPDLOG_LOGGER_ERROR(m_logger, "解析Redis数据失败:{}, 错误ID:{}", e.what(), e.id);
+//         return;
+//     }
+
+// }
 
 /**
  * @brief 解析Redis的基础通用数据,不包含bBoxes数组数据
@@ -611,7 +612,7 @@ void SPAServer::parseRedisBBoxesData(const std::string& strData, AlarmInfo& alar
         nJson json1 = json0["bBoxes"];
         
         std::string labelList;              /* 记录违禁品 */
-        std::string bboxList;               /* 记录bbox */
+        std::list<std::string> listBbox;    /* 记录bbox */
         if(!json1.empty())
         {
             for(auto& it0 : json1)
@@ -653,26 +654,21 @@ void SPAServer::parseRedisBBoxesData(const std::string& strData, AlarmInfo& alar
                 {
                     strBbox.pop_back();
                 }
-                bboxList += strBbox + "|";
+                listBbox.push_back(strBbox);
             }
             /* 去掉最后一个“|” */
             if(!labelList.empty())
             {
                 labelList.pop_back();
             }
-            if(!bboxList.empty())
-            {
-                bboxList.pop_back();
-            }
             SPDLOG_LOGGER_DEBUG(m_logger, "违禁品列表:{}", labelList);
-            SPDLOG_LOGGER_DEBUG(m_logger, "bbox列表:{}", bboxList);
+            
         }
-        
         /* 如果有报警的Box,解析出报警的说明 */
         if(alarmInfo.Is_Alarm)
         {
             /* 添加报警信息的提示信息 */
-            alarmInfo.BboxList = bboxList;
+            alarmInfo.listBbox = listBbox;
             /* 违禁品报警信息,违禁品列表不是空的,就添加补充的文字 */
             if( (alarmInfo.ActionID == g_actionList.ActContraband) && !labelList.empty() )
             {
@@ -836,6 +832,7 @@ void SPAServer::threadRoomCamera()
  * @brief 人员在岗识别线程,这个功能主要是给客户端提供实时的人脸识别信息
  *        1、这个写入tWorkOnInfo表格,十分钟写一次
  *        2、理论上这里需要实时更新数据库,但是实际上时每十分钟写入一次数据
+ *        3、这个线程也会进行在岗离岗的识别报警
  * 
  * @param RFAInfo 传入房间ID和算法ID
  */
@@ -880,7 +877,8 @@ void SPAServer::threadActPersonWork(FuncActionInfo* RFAInfo)
                 }
                 /* 解析数据 */
                 AlarmInfo alarmInfo;
-                parseRedisData(strRetValue, alarmInfo);
+                parseRedisBaseData(strRetValue, alarmInfo);
+                parseRedisBBoxesData(strRetValue, alarmInfo);
                 /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
                 if(isEventTimeVaild(alarmInfo.EventTime))
                 {
@@ -924,7 +922,7 @@ void SPAServer::threadActPersonWork(FuncActionInfo* RFAInfo)
             }
             ++it;
         }
-
+        std::this_thread::sleep_for(std::chrono::milliseconds(g_config.ThreadSleepMS));
     }
     setThreadState(pRFAInfo, RunTimeState::RUN_STATE_STOP);
     SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
@@ -979,6 +977,13 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
         {
             break;
         }
+        /* 更新算法ActionID */
+        {
+            g_actionList.mutexRW.lockForRead();
+            strFaceActionID = g_actionList.ActFace;
+            strCountActionID = g_actionList.ActPersonNumber;
+            g_actionList.mutexRW.unlock();
+        }
 
         /* 读取Redis数据 */
         pListAlarmInfo->clear();
@@ -996,7 +1001,9 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
                 }
                 /* 解析数据 */
                 AlarmInfo alarmInfo;
-                parseRedisData(strRetValue, alarmInfo);
+                // parseRedisData(strRetValue, alarmInfo);
+                parseRedisBaseData(strRetValue, alarmInfo);
+                parseRedisBBoxesData(strRetValue, alarmInfo);
                 /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
                 if(isEventTimeVaild(alarmInfo.EventTime))
                 {
@@ -1007,13 +1014,6 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
                 pListAlarmInfo->push_back(alarmInfo);
             }
         }
-        /* 更新算法ActionID */
-        {
-            g_actionList.mutexRW.lockForRead();
-            strFaceActionID = g_actionList.ActFace;
-            strCountActionID = g_actionList.ActPersonNumber;
-            g_actionList.mutexRW.unlock();
-        }
 
         /* 找出房间的个数,按照房间进行判断 */
         ListRoomIll listRoomIll;
@@ -1033,7 +1033,7 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
                     if(it.vecPersonInfo.size() > room.numMaxFace)
                     {
                         room.numMaxFace = it.vecPersonInfo.size();
-                        room.strBoxList = it.BboxList;
+                        room.strBoxList = it.listBbox;
                         room.vecPersonInfo = it.vecPersonInfo;
                     }
                 }
@@ -1067,7 +1067,7 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
                     if(it.vecPersonInfo.size() > room.numMaxPerson)
                     {
                         room.numMaxPerson = it.vecPersonInfo.size();
-                        room.strBoxList = it.BboxList;
+                        room.strBoxList = it.listBbox;
                         if(!it.ImageInfo.empty())
                         {
                             room.strImage = it.ImageInfo;
@@ -1087,10 +1087,11 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
         /* 将非法入侵的信息存储到数组缓存中,等待报警结束后判断是否需要写入EQM数据库 */
         for(auto& room : listRoomIll.getData())
         {
+            auto pIll = pListIllInfo->findIllInfo(room.RoomID, room.RoomType);
             if(room.isAlarm)
             {
                 /* 正在报警,检查是否有 */
-                if(pListIllInfo->findIllInfo(room.RoomID, room.RoomType) == nullptr)
+                if(pIll == nullptr)
                 {
                     IllegalInvasionInfo info;
                     info.ChannelID = pRFAInfo->ChannelID;
@@ -1103,12 +1104,41 @@ void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
                     pListIllInfo->addIllInfo(info);
                 }
             }
-            else {
+            else 
+            {
                 /* 没有报警,检查是否是报警结束了,是否符合写入数据库的条件 */
                 QDateTime currTime = QDateTime::currentDateTime();
+                int secs = currTime.toSecsSinceEpoch() - pIll->FirstTime.toSecsSinceEpoch();
+                if(secs >= g_config.AppBadMan)
+                {
+                    if(!pIll->strImageInfo.empty())
+                    {
+                        /* 超过非法入侵的时间,写入数据库 */
+                        AlarmInfo ai;
+                        ai.ChannelID = pRFAInfo->ChannelID;
+                        ai.RoomID = pIll->RoomID;
+                        ai.ActionID = g_actionList.ActPersonNumber;
+                        ai.ActionDes = pIll->strActionDec;
+                        ai.ImageInfo = pIll->strImageInfo;
+                        ai.StartTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                        ai.EndTime = currTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                        ai.EventTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                        ai.vecPersonInfo = room.vecPersonInfo;
+                        ai.listBbox = room.strBoxList;
+                        bool insertRet  = toEQMDataBase->insertAlarmInfo(ai);
+                        if(insertRet)
+                        {
+                            std::string actionName = g_actionList.getActionName(ai.ActionID);
+                            SPDLOG_LOGGER_INFO(m_logger, "☆ 新增报警信息,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸,{}", 
+                            pIll->ChannelID, pIll->RoomID, pIll->CameraID, actionName, ai.ActionDes, ai.listBbox, ai.FaceIDList.size(), ai.ImageInfo);
+                        }
+                    }
+                    /* 删除这个非法入侵信息 */
+                    pListIllInfo->deleteIllInfo(*pIll);
+                }
             }
         }
-
+        std::this_thread::sleep_for(std::chrono::milliseconds(g_config.ThreadSleepMS));
     }
     setThreadState(pRFAInfo, RunTimeState::RUN_STATE_STOP);
     SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
@@ -1165,7 +1195,8 @@ void SPAServer::threadActRegionalPersonnelDetection(FuncActionInfo* RFAInfo)
                 }
                 /* 解析数据 */
                 AlarmInfo alarmInfo;
-                parseRedisData(strRetValue, alarmInfo);
+                parseRedisBaseData(strRetValue, alarmInfo);
+                parseRedisBBoxesData(strRetValue, alarmInfo);
                 /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
                 if(isEventTimeVaild(alarmInfo.EventTime))
                 {
@@ -1179,7 +1210,7 @@ void SPAServer::threadActRegionalPersonnelDetection(FuncActionInfo* RFAInfo)
 
         
 
-
+        std::this_thread::sleep_for(std::chrono::milliseconds(g_config.ThreadSleepMS));
     }
     setThreadState(pRFAInfo, RunTimeState::RUN_STATE_STOP);
     SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
@@ -1313,8 +1344,6 @@ void SPAServer::threadActNormal(FuncActionInfo* info)
             }
         }
         
-        
-        
         /* 休眠设置的时间 */
         std::this_thread::sleep_for(std::chrono::seconds(g_config.ThreadSleepMS));
     }

+ 1 - 2
SecurePlayAuxServer/SPAServer.h

@@ -35,7 +35,7 @@ private:
     void threadFromRedis(const CameraThreadInfo& info);
 
     /* 解析Redis基础数据 */
-    void parseRedisData(const std::string& strData, AlarmInfo& alarmInfo);
+    // void parseRedisData(const std::string& strData, AlarmInfo& alarmInfo);
     /* 解析Redis的基础通用数据,不包含bBoxes数组数据 */
     void parseRedisBaseData(const std::string& strData, AlarmInfo& alarmInfo);
     /* 解析Redis的bBoxes数据, */
@@ -52,7 +52,6 @@ private:
     void threadActIllegalInvasion(FuncActionInfo* RFAInfo);
     /* 区域人员检测(人员计数),检测这个区域内的人数,不能少于多少人,不能多余多少人 */
     void threadActRegionalPersonnelDetection(FuncActionInfo* RFAInfo);
-    
     /* 普通任务线程,一个算法值对应一个摄像机 */
     void threadActNormal(FuncActionInfo* info);
     

+ 18 - 1
SecurePlayAuxServer/communication/ToEQMDataBase.cpp

@@ -809,6 +809,23 @@ bool ToEQMDataBase::insertAlarmInfo(const AlarmInfo& alarmInfo)
         SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
         return false;
     }
+    /* 判断是否有图片,没有图片就取消报警 */
+    if(alarmInfo.ImageInfo.empty())
+    {
+        SPDLOG_LOGGER_WARN(m_logger, "× 取消新增报警信息,因为没有图片,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸",
+                            alarmInfo.ChannelID, alarmInfo.RoomID, alarmInfo.DeviceID, alarmInfo.ActionDes, alarmInfo.ImageInfo, alarmInfo.listBbox.size(), alarmInfo.vecPersonInfo.size());
+        return false;
+    }
+    /* 拼接Bbox */
+    std::string strBbox;
+    for(const auto& it : alarmInfo.listBbox)
+    {
+        strBbox += it;
+        strBbox += "|";
+    }
+    /* 去掉最后一个“|” */
+    strBbox.pop_back();
+
     nJson json0;
     json0["opName"] = "SPSS_InsertToAlarmInfo";
     nJson json1;
@@ -816,7 +833,7 @@ bool ToEQMDataBase::insertAlarmInfo(const AlarmInfo& alarmInfo)
     json1["StartTime"] = alarmInfo.StartTime;
     json1["CreateTime"] = alarmInfo.EventTime;
     json1["EndTime"] = alarmInfo.EndTime;
-    json1["bBox"] = alarmInfo.BboxList;
+    json1["bBox"] = strBbox;
     json1["PicUrl"] = alarmInfo.PicUrl;
     json1["AppID"] = alarmInfo.AppID;
     json1["ActionID"] = alarmInfo.ActionID;