Ver código fonte

V0.2.4
1、继续完成应用实例

Apple 6 meses atrás
pai
commit
b47c0302c0

+ 95 - 1
SecurePlayAuxServer/GlobalInfo/GlobalInfo.cpp

@@ -12,6 +12,8 @@ int g_eventTimeVaild = 600;         /* 事件时间有效性,单位秒,超
 
 
 
+ActionList g_actionList;            /* 全局算法列表 */
+
 /* ====================================================================================
  * ***************************    DeviceInfo成员函数    *******************************
  * ====================================================================================*/
@@ -527,11 +529,103 @@ bool FuncActionInfo::addActionInfo(const ActionInfo& info)
     {
         return false;
     }
-    
+    /* 将其添加到对应的房间 */
+    bool isFind = false;
+    for(auto& it0 : listRoomCamActInfo)
+    {
+        if((it0.RoomID == info.RoomID) && (it0.RoomType == info.RoomType))
+        {
+            isFind = true;
+            it0.mapCameraAction.insert(std::make_pair(info.CameraID, info.ActionID));
+        }
+    }
+    /* 没找到这个房间,就创建 */
+    if(!isFind)
+    {
+        RoomCamActInfo roomCamActInfo;
+        roomCamActInfo.RoomID = info.RoomID;
+        roomCamActInfo.RoomType = info.RoomType;
+        roomCamActInfo.mapCameraAction.insert(std::make_pair(info.CameraID, info.ActionID));
+        listRoomCamActInfo.push_back(roomCamActInfo);
+    }
+
+
+    return true;
+}
+
+/**
+ * @brief 添加功能信息,一个应用功能在一个频道内只有一个实例
+ * 
+ * @param func 应用功能
+ * @return true 添加成功,或者已有这个应用功能
+ * @return false 
+ */
+bool ListFuncActInfo::addFuncActionInfo(AppFunction func)
+{
+    if(func == AppFunction::APP_NONE)
+    {
+        return false;
+    }
+    /* 先查找有没有这个应用信息 */
+    if(findAppFunction(func))
+    {
+        return true;
+    }
+    FuncActionInfo* pFuncActionInfo = new FuncActionInfo;
+    pFuncActionInfo->appFunction = func;
+    listFuncActionInfo.push_back(pFuncActionInfo);
 
     return true;
 }
 
+/**
+ * @brief 添加算法信息,根据传进来的算法ID,将其加入到对应的功能中
+ * 
+ * @param info 
+ * @return true 
+ * @return false 
+ */
+bool ListFuncActInfo::addActionInfo(const ActionInfo& info)
+{
+    if(info.ActionID.empty())
+    {
+        return false;
+    }
+    /* 人脸识别算法 */
+    if(info.ActionID == g_actionList.ActFace)
+    {
+        
+    }
+
+
+    return true;
+}
+
+/* 查找应用信息 */
+bool ListFuncActInfo::findAppFunction(const AppFunction func)
+{
+    for(const auto& it0 : listFuncActionInfo)
+    {
+        if(it0->appFunction == func)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+/* 根据频率和功能查找实例 */
+FuncActionInfo* ListFuncActInfo::findAppFunction(const int ChannelID, const AppFunction func)
+{
+    for(const auto& it0 : listFuncActionInfo)
+    {
+        if( (it0->appFunction == func) && (it0->ChannelID == ChannelID) )
+        {
+            return it0;
+        }
+    }
+    return nullptr;
+}
+
 
 /* ====================================================================================
  * **************************    GlobalConfig成员函数    ******************************

+ 31 - 8
SecurePlayAuxServer/GlobalInfo/GlobalInfo.h

@@ -5,6 +5,7 @@
 #include <vector>
 #include <list>
 #include <map>
+#include <mutex>
 #include "nlohmann/json.hpp"
 
 
@@ -13,11 +14,19 @@
  * *******************************    全局变量定义    **********************************
  * ====================================================================================*/
 
+/**
+ * @brief 全局信息
+ * 
+ */
 
+using nJson = nlohmann::json;
 
+/* Rides数据时间有效性 */
 extern int g_eventTimeVaild;
 
 
+
+
 /* 线程运行时的状态 */
 enum class RunTimeState
 {
@@ -44,16 +53,27 @@ enum class AppFunction
 };
 
 
+/* 全局算法列表 */
+class ActionList
+{
+public:
+    /* 全局算法ID */
+    std::mutex mutexActionID;             /* 算法ID的互斥锁 */
+
+    std::string ActFace;                  /* 人脸识别 */
+    std::string ActPersonNumber;          /* 人员计数 */
+    std::string ActPlayPhone;             /* 玩手机 */
+    std::string ActContraband;            /* 违禁品物品 */
+    std::string ActSleep;                 /* 睡岗识别 */
+    std::string ActFatigueDetection;      /* 疲劳检测 */
+    std::string ActAnimalDetect;          /* 动物识别 */
+    std::string ActMouseDetect;           /* 老鼠识别 */
+    std::string ActMask;                  /* 口罩识别 */
+};
 
+extern ActionList g_actionList;
 
 
-/**
- * @brief 全局信息
- * 
- */
-
-using nJson = nlohmann::json;
-
 
 /* 算法相关信息 */
 struct AlgorithmInfo
@@ -453,7 +473,7 @@ public:
     ListFuncActInfo() = default;
 
     /* 添加功能信息 */
-    bool addFuncActionInfo(FuncActionInfo* pInfo);
+    bool addFuncActionInfo(AppFunction func);
     /* 添加算法信息 */
     bool addActionInfo(const ActionInfo& info);
     /* 清空无用的功能信息 */
@@ -464,6 +484,9 @@ public:
     std::list<FuncActionInfo*>& getData() {
         return listFuncActionInfo;
     }
+    /* 查找应用信息 */
+    bool findAppFunction(const AppFunction func);
+    FuncActionInfo* findAppFunction(const int ChannelID, const AppFunction func);
 
     std::list<FuncActionInfo*> listFuncActionInfo;    /* 功能信息列表 */
  };

+ 15 - 1
安播辅助服务程序说明.md

@@ -51,7 +51,20 @@
     |port|CamerPort|
     |userAccount|CamerUsr|
     |userPWD|CamerPwd|
-    
+
+5. 安播可能会用到的算法
+    |编号|算法名称|能力|基础算子|
+    |:--|:--|:--|:--|
+    |1|人脸识别|facerecognitionstudio|facelib|
+    |2|人员计数|mancount|atom-msrcnn|
+    |3|违禁物品|contraband|atom-msrcnn|
+    |4|玩手机|playPhone|atom-hodet(atom-yolo1)|
+    |5|睡岗识别|sleep|atom-yolo(atom-itc)|
+    |6|疲劳检测||atom-itc|
+    |7|动物识别|animal|atom-msrcnn|
+    |8|老鼠识别|mousedetection|atom-yolo1|
+    |9|未戴口罩|mask|atom-yolo1|
+
     
 ## 从Redis获取数据
 1. `Key`的组成:`%d : %s`, `DeviceID`, `算法ID`
@@ -109,6 +122,7 @@
 3. `tActionCamer`摄像机ID,和算法ID关联
 4. `tFaceUser`用户信息表,读取到超脑返回的用户数据,写入该表
 5. `tRuleInfo`报警规则表,区域人员检测(人员计数)会使用到
+6. `tWorkOnInfo`人员在岗信息表,主要给客户端同步用的
 
 ## 启动程序,可能需要从EQM获取的数据
 1. `tCamerinfo`获取摄像机信息