SPAServer.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  1. #include "SPAServer.h"
  2. #include "spdlog/spdlog.h"
  3. #include <filesystem>
  4. #include "ThreadPool/ThreadPool.h"
  5. #include "GlobalInfo/GlobalVariable.h"
  6. #include "GlobalInfo/GlobalConfig.h"
  7. #include "UniversalFunc.h"
  8. #include "FuncOrdinary.h"
  9. #include <QCoreApplication>
  10. SPAServer::SPAServer()
  11. {
  12. m_logger = spdlog::get("SPAServer");
  13. if(m_logger == nullptr)
  14. {
  15. SPDLOG_ERROR("APAServer logger is nullptr");
  16. return;
  17. }
  18. /* 读取全局的配置文件 */
  19. QString strConfigFile = QCoreApplication::applicationDirPath() + "/config.ini";
  20. if(!GConfig.readConfig(strConfigFile))
  21. {
  22. /* 读取配置文件失败,直接退出程序 */
  23. return;
  24. }
  25. GConfig.printValue();
  26. m_threadRunning = true;
  27. /* 初始化WebAPI */
  28. m_toEQMDataBase.initWebApi("http://192.1.3.133:31000/v6/", "", "4c2f9fc91c22dd98331e47af2e2964f4");
  29. /* 模拟违禁品算法ID,后续需要动态调整 */
  30. g_actionList.ActContraband = "OD210_026_005246_001-IZRTKyEx";
  31. }
  32. SPAServer::~SPAServer()
  33. {
  34. }
  35. /* 启动服务 */
  36. void SPAServer::startServer()
  37. {
  38. /* 添加获取基础信息的线程 */
  39. // CPPTP.add_task(&SPAServer::threadFromSuperBrain, this);
  40. /* 测试Redis读取并解析数据线程 */
  41. CameraThreadInfo info;
  42. info.RedisIP = "172.16.36.80";
  43. info.RedisPort = 32222;
  44. info.RedisPWD = "Ff1z@TOFr^iwd%Ra";
  45. info.DeviceID = 117;
  46. info.vecAction.push_back("OD210_026_005246_001-IZRTKyEx");
  47. g_actionList.ActContraband = "OD210_026_005246_001-IZRTKyEx";
  48. // CPPTP.add_task(&SPAServer::threadFromRedis, this, info);
  49. // threadFromRedis(info);
  50. }
  51. /**
  52. * @brief 从基础平台获取算法信息和设备信息的线程函数
  53. * 从基础平台获取算法信息和设备信息,然后更新到EQM数据库所对应的表中
  54. *
  55. */
  56. void SPAServer::threadFromSuperBrain()
  57. {
  58. SPDLOG_LOGGER_INFO(m_logger, "开启 fromSuperBrainThread 线程, 获取算法和设备信息");
  59. /* 创建变量 */
  60. std::vector<AlgorithmInfo> vecAlgNewInfo;
  61. std::vector<DeviceInfo> vecDevNewInfo;
  62. /* 获取一次token,后续失效了再获取 */
  63. m_fromSuperBrain.getToken();
  64. while (m_threadRunning)
  65. {
  66. SPDLOG_LOGGER_INFO(m_logger, "刷新算法和设备信息");
  67. /* 先更新数据库的信息,防止从其他地方更改了数据库,这里没有刷新本地缓存 */
  68. m_toEQMDataBase.getAlgorithmInfo(m_vecEqmAlgInfo);
  69. m_toEQMDataBase.getDeviceInfo(m_vecEqmDevInfo);
  70. m_toEQMDataBase.getDeviceAlgorithmInfo(m_vecEqmDevInfo, m_listDevIDDelete);
  71. /* 从超脑获取基础信息 */
  72. m_fromSuperBrain.getTaskTypeList(vecAlgNewInfo);
  73. m_fromSuperBrain.getDeviceList(vecDevNewInfo);
  74. /* 处理算法信息 */
  75. bool algIsUpdate = processAlgorithmInfo(vecAlgNewInfo);
  76. /* 处理设备信息 */
  77. bool devIsUpdate = processDeviceInfo(vecDevNewInfo);
  78. vecAlgNewInfo.clear();
  79. vecDevNewInfo.clear();
  80. /* 更新算法详细信息 */
  81. m_mutexActionInfo.lock();
  82. m_toEQMDataBase.getActionInfo(m_listActionInfo);
  83. m_mutexActionInfo.unlock();
  84. /* 更新通道名称和摄像机名称信息 */
  85. std::map<int, std::string> mapChannelName;
  86. m_toEQMDataBase.getChannelInfo(mapChannelName);
  87. /* 10秒更新一次 */
  88. std::this_thread::sleep_for(std::chrono::seconds(10));
  89. }
  90. SPDLOG_LOGGER_INFO(m_logger, "退出 fromSuperBrainThread 线程");
  91. }
  92. /* 处理算法信息,返回值为true,说明有改变,需要重新读取 */
  93. bool SPAServer::processAlgorithmInfo(std::vector<AlgorithmInfo> vecNewAlgInfo)
  94. {
  95. std::vector<AlgorithmInfo> vecAlgUpdate;
  96. std::vector<AlgorithmInfo> vecAlgDelete;
  97. /* 对比数据库表格信息,这里只有插入和删除,没有更新 */
  98. compareAlgorithmInfo(vecNewAlgInfo, vecAlgUpdate, vecAlgDelete);
  99. /* 更新数据库,先删除,再写入刷新 */
  100. bool isUpdate = false;
  101. if(vecAlgDelete.size() > 0)
  102. {
  103. SPDLOG_LOGGER_DEBUG(m_logger, "删除算法信息");
  104. m_toEQMDataBase.deleteAlgorithmInfo(vecAlgDelete);
  105. isUpdate = true;
  106. }
  107. if(vecAlgUpdate.size() > 0)
  108. {
  109. SPDLOG_LOGGER_DEBUG(m_logger, "写入算法信息");
  110. m_toEQMDataBase.writeAlgorithmInfo(vecAlgUpdate);
  111. isUpdate = true;
  112. }
  113. return isUpdate;
  114. }
  115. /**
  116. * @brief 处理设备信息
  117. *
  118. * @param vecNewDevInfo 传入新获取到的值
  119. * @return true 需要重新读取数据库,获取新的数据
  120. * @return false 无需读取数据库
  121. */
  122. bool SPAServer::processDeviceInfo(std::vector<DeviceInfo> vecNewDevInfo)
  123. {
  124. std::vector<DeviceInfo> vecDevInsert;
  125. std::vector<DeviceInfo> vecDevUpdate;
  126. std::vector<DeviceInfo> vecDevDelete;
  127. /*-------------------------------------------------------------------------
  128. ****** 这里只对比设备信息,不对比设备的算法信息,算法信息在下面单独对比 *******
  129. *------------------------------------------------------------------------*/
  130. /* 如果本地缓存没有数据,那么就全部插入 */
  131. if(m_vecEqmDevInfo.size() > 0)
  132. {
  133. for(auto& DevInfo : vecNewDevInfo)
  134. {
  135. bool isExist = false;
  136. for(auto& it0 : m_vecEqmDevInfo)
  137. {
  138. if(DevInfo.DeviceID == it0.DeviceID)
  139. {
  140. isExist = true;
  141. /* 对比其他项是否相等,不相等就更新 */
  142. if(DevInfo == it0)
  143. {
  144. continue;
  145. }else {
  146. vecDevUpdate.push_back(DevInfo);
  147. }
  148. break;
  149. }
  150. }
  151. if(!isExist)
  152. {
  153. vecDevInsert.push_back(DevInfo);
  154. }
  155. }
  156. }else {
  157. vecDevInsert = vecNewDevInfo;
  158. }
  159. /* 获取删除列表 */
  160. if(vecNewDevInfo.size() > 0)
  161. {
  162. bool isExist = false;
  163. for(const auto& it : m_vecEqmDevInfo)
  164. {
  165. isExist = false;
  166. for(const auto& it0 : vecNewDevInfo)
  167. {
  168. if(it.DeviceID == it0.DeviceID)
  169. {
  170. isExist = true;
  171. break;
  172. }
  173. }
  174. if(!isExist)
  175. {
  176. vecDevDelete.push_back(it);
  177. }
  178. }
  179. }else {
  180. vecDevDelete = m_vecEqmDevInfo;
  181. }
  182. bool isUpdate = false;
  183. /* 先删除多余的数据 */
  184. if(vecDevDelete.size() > 0)
  185. {
  186. SPDLOG_LOGGER_DEBUG(m_logger, "删除设备信息, 表: tActionCamer");
  187. m_toEQMDataBase.deleteDeviceInfo(vecDevDelete);
  188. isUpdate = true;
  189. }
  190. /* 更新数据 */
  191. if(vecDevUpdate.size() > 0)
  192. {
  193. SPDLOG_LOGGER_DEBUG(m_logger, "更新设备信息, 表: tActionCamer");
  194. m_toEQMDataBase.updateDeviceInfo(vecDevUpdate);
  195. isUpdate = true;
  196. }
  197. /* 插入数据 */
  198. if(vecDevInsert.size() > 0)
  199. {
  200. SPDLOG_LOGGER_DEBUG(m_logger, "插入设备信息, 表: tActionCamer");
  201. m_toEQMDataBase.insertDeviceInfo(vecDevInsert);
  202. isUpdate = true;
  203. }
  204. /*-------------------------------------------------------------------------
  205. ************* 处理设备和算子关联的表格,单独对比设备的算法信息 *************
  206. *------------------------------------------------------------------------*/
  207. /* 插入新的设备信息 */
  208. if(vecDevInsert.size() > 0)
  209. {
  210. SPDLOG_LOGGER_DEBUG(m_logger, "插入设备和算法关联表(tActionCamer)");
  211. m_toEQMDataBase.insertDeviceAlgorithmInfo(vecDevInsert);
  212. isUpdate = true;
  213. }
  214. vecDevUpdate.clear();
  215. /* 对比现有的设备是否需要更新算法 */
  216. compareDeviceAlgorithmInfo(vecNewDevInfo, vecDevUpdate);
  217. if(vecDevUpdate.size() > 0)
  218. {
  219. SPDLOG_LOGGER_DEBUG(m_logger, "更新设备和算法关联表(tActionCamer), 更新设备数目:{}", vecDevUpdate.size());
  220. m_toEQMDataBase.updateDeviceAlgorithmInfo(vecDevUpdate);
  221. }
  222. /* 删除tActionCamer表中消失的设备信息 */
  223. if(m_listDevIDDelete.size() > 0)
  224. {
  225. SPDLOG_LOGGER_DEBUG(m_logger, "删除消失的设备关联的算法(tActionCamer)");
  226. m_toEQMDataBase.deleteDeviceAlgorithmInfo(m_listDevIDDelete);
  227. isUpdate = true;
  228. }
  229. return isUpdate;
  230. }
  231. /* 对比现有的数据和新获取到的数据,取出要删除和添加的数据 */
  232. void SPAServer::compareAlgorithmInfo(const std::vector<AlgorithmInfo>& vecNewInfo, std::vector<AlgorithmInfo>& vecAlgUpdate, std::vector<AlgorithmInfo>& vecAlgDelete)
  233. {
  234. /* 取出要添加的,如果本地缓存是0,那么全部都要添加 */
  235. if(m_vecEqmAlgInfo.size() > 0)
  236. {
  237. for(const auto& it : vecNewInfo)
  238. {
  239. bool isExist = false;
  240. for(const auto& it0 : m_vecEqmAlgInfo)
  241. {
  242. /* 如果存在就退出循环 */
  243. if(it.ActionID == it0.ActionID)
  244. {
  245. isExist = true;
  246. break;
  247. }
  248. }
  249. if(!isExist)
  250. {
  251. vecAlgUpdate.push_back(it);
  252. }
  253. }
  254. }else {
  255. vecAlgUpdate = vecNewInfo;
  256. }
  257. /* 取出要删除的,如果新的数据是0,那么全部都要删除 */
  258. if(vecNewInfo.size() > 0)
  259. {
  260. bool isExist = false;
  261. for(const auto& it : m_vecEqmAlgInfo)
  262. {
  263. isExist = false;
  264. for(const auto& it0 : vecNewInfo)
  265. {
  266. if(it.ActionID == it0.ActionID)
  267. {
  268. isExist = true;
  269. break;
  270. }
  271. }
  272. if(!isExist)
  273. {
  274. vecAlgDelete.push_back(it);
  275. }
  276. }
  277. }else {
  278. vecAlgDelete = m_vecEqmAlgInfo;
  279. }
  280. }
  281. /**
  282. * @brief 对比设备和算法关联表是否需要更新
  283. * 对比规则:
  284. * 1、这里只对比已有的设备ID,需要删除的ID在获取到tActionCamer表是就已经取出来了
  285. * 2、如果设备ID相等,那么进一步对比算法信息是否相等
  286. * 3、如果设备ID相等,但是算法信息数目不相等,那么直接加入更新列表
  287. * 4、如果设备ID相等,算法信息数目相等,进一步对比算法信息
  288. *
  289. * @param vecNewInfo
  290. * @param vecDevUpdate
  291. */
  292. void SPAServer::compareDeviceAlgorithmInfo(const std::vector<DeviceInfo>& vecNewInfo, std::vector<DeviceInfo>& vecDevUpdate)
  293. {
  294. vecDevUpdate.clear();
  295. for(const auto& it0 : vecNewInfo)
  296. {
  297. for(const auto& it1 : m_vecEqmDevInfo)
  298. {
  299. if(it0.DeviceID == it1.DeviceID)
  300. {
  301. /* 设备的算法信息数目不相等,直接加入更新列表 */
  302. if(it0.vecAlgorithmInfo.size() != it1.vecAlgorithmInfo.size())
  303. {
  304. vecDevUpdate.push_back(it0);
  305. break;
  306. }
  307. /* 设备的算法信息数目相等,进一步对比算法信息 */
  308. bool isEquality = true;
  309. for(const auto& it2 : it0.vecAlgorithmInfo)
  310. {
  311. bool isEq2 = false;
  312. for(const auto& it3 : it1.vecAlgorithmInfo)
  313. {
  314. /* 这里只对比算法ID */
  315. if(it2.ActionID != it3.ActionID)
  316. {
  317. continue;
  318. }else {
  319. isEq2 = true;
  320. break;
  321. }
  322. }
  323. if(!isEq2)
  324. {
  325. isEquality = false;
  326. break;
  327. }
  328. }
  329. if(!isEquality)
  330. {
  331. vecDevUpdate.push_back(it0);
  332. break;
  333. }
  334. }
  335. }
  336. }
  337. }
  338. /**
  339. * @brief 从Redis获取数据线程函数,这个是摄像机线程
  340. * 一个设备一个线程,这个线程的相关变量只在这个线程中使用
  341. * (注意,这个函数未被使用,不从这里获取Redis数据)
  342. * @param info
  343. */
  344. void SPAServer::threadFromRedis(const CameraThreadInfo& info)
  345. {
  346. SPDLOG_LOGGER_INFO(m_logger, "开启 fromRedisThread 线程,设备ID:{}", info.DeviceID);
  347. FromRedis fromRedis;
  348. fromRedis.setRedisIPAndPort(info.RedisIP, info.RedisPort);
  349. fromRedis.setRedisPassword(info.RedisPWD);
  350. if(fromRedis.connectRedis())
  351. {
  352. SPDLOG_LOGGER_INFO(m_logger, "连接Redis成功");
  353. }else {
  354. SPDLOG_LOGGER_ERROR(m_logger, "连接Redis失败");
  355. return;
  356. }
  357. CameraThreadInfo threadInfo = info;
  358. // std::string strKey = "117:OD210_026_005246_001-IZRTKyEx";
  359. /* 取出该设备的Key */
  360. std::vector<std::string> vecKey;
  361. for(const auto& it : info.vecAction)
  362. {
  363. std::string strKey = std::to_string(info.DeviceID) + ":" + it;
  364. vecKey.push_back(strKey);
  365. }
  366. std::string strRetValue;
  367. /* 进入线程循环 */
  368. while (m_threadRunning)
  369. {
  370. /* 循环读取这个设备关联的算法信息 */
  371. for(const auto& it : vecKey)
  372. {
  373. SPDLOG_LOGGER_INFO(m_logger, "读取Redis信息, Key: {}", it);
  374. if( !fromRedis.getRedisString(it, strRetValue) )
  375. {
  376. continue;
  377. }
  378. SPDLOG_LOGGER_TRACE(m_logger, "Redis Value:\n{}", strRetValue);
  379. /* 解析数据 */
  380. AlarmInfo alarmInfo;
  381. alarmInfo.ActionID = it.substr(it.find(":") + 1);
  382. /* 解析数据 */
  383. parseRedisBaseData(strRetValue, alarmInfo);
  384. parseRedisBBoxesData(strRetValue, alarmInfo);
  385. /* 信息时间有的效性判断,主要是记录Redis数据的有效性,是否长时间没有变化,排查错误时用的
  386. * 如果数据长时间数据不变,那么超脑那里就挂了,写入日志 */
  387. isEventTimeVaild(alarmInfo.EventTime);
  388. /* 是否需要写入EQM数据库判断
  389. * 人员计数和区域人员检测需要多次判断,其他的直接写入即可 */
  390. }
  391. std::this_thread::sleep_for(std::chrono::seconds(2));
  392. }
  393. return;
  394. }
  395. /**
  396. * @brief 分派任务的线程
  397. 1、 线程定时刷新房间和摄像机的关联关系,以及和算法Action的关联关系
  398. 2、 将算法信息加入到不同的列表中
  399. 需要多个摄像机配合的加入到 m_runListRoomActionInfo 列表
  400. 不需要多个摄像机配合的加入到 m_runListActionInfo 列表
  401. 3、 每次刷新都会清空ActionInfo或者RoomActionInfo的摄像机列表,但是不会动其他基本信息,如果是列表中没有对应的信息,
  402. 就会创建新的ActionInfo,那么RunState的状态是INIT,需要开启新的线程
  403. 如果刷新完成后,算法对应的摄像机列表为空,那么对应的线程就会停止运行,将RunState设置为STOP,本线程的下一轮
  404. 循环就会删除这个ActionInfo
  405. */
  406. void SPAServer::threadDistribution()
  407. {
  408. SPDLOG_LOGGER_INFO(m_logger, "开启分派任务线程");
  409. /* 房间相机关联信息 */
  410. std::list<RoomCameraInfo> listRC;
  411. /* 存储获取到的应用和启用时间的信息 */
  412. std::list<AppAndTimeInfo> listAppAndTime;
  413. /* 创建连接数据库实例 */
  414. std::shared_ptr<ToEQMDataBase> toEQMDataBase = std::make_shared<ToEQMDataBase>();
  415. while (m_threadRunning)
  416. {
  417. GThreadInfo.lockRunFAI();
  418. /* 先清理已经退出的线程所用到的Action或者RoomAction */
  419. GThreadInfo.clearNoneFuncActionInfo();
  420. /* 清空已经停止运行的功能类实例 */
  421. clearNoneFuncActionInfo();
  422. /* 创建应用信息,根据从EQM数据库读取到的配置的应用信息创建 */
  423. toEQMDataBase->getAlarmAppInfo(listAppAndTime);
  424. for(const auto& it : listAppAndTime)
  425. {
  426. /* 创建应用信息,如果已有该应用,就更新时间
  427. * 这里只创建应用信息块,没有对应的房间、算法信息 */
  428. GThreadInfo.addFuncActionInfo(it);
  429. }
  430. /* 先获取EQM数据库信息,取出房间和摄像机关联信息,包括所在的频率 */
  431. m_mutexActionInfo.lock();
  432. toEQMDataBase->getActionInfo(m_listActionInfo);
  433. /* 将算法信息加入到不同的功能列表中,先清空功能对应的算法设备列表 */
  434. GThreadInfo.clearActionList();
  435. for(const auto& it : m_listActionInfo.getData())
  436. {
  437. GThreadInfo.addActionInfo(*it);
  438. }
  439. /* 检查算法信息的状态,频率里的应用没有配置摄像机就设置为线程运行状态为停止,退出该线程 */
  440. GThreadInfo.setNoneCameraFuncStop();
  441. m_mutexActionInfo.unlock();
  442. /* 开启线程 */
  443. for(const auto& it0 : GThreadInfo.getList())
  444. {
  445. if(it0->RunState == RunTimeState::RUN_STATE_INIT)
  446. {
  447. /* 创建实例 */
  448. FuncBase* pFunc = createFuncInstance(*it0);
  449. if(pFunc == nullptr)
  450. {
  451. SPDLOG_LOGGER_ERROR(m_logger, "创建功能实例失败:{}", it0->strFunctionName);
  452. continue;
  453. }
  454. CPPTP.add_task(&FuncBase::thread_task, pFunc);
  455. m_listFuncBase.push_back(pFunc);
  456. }
  457. }
  458. GThreadInfo.unlockRunFAI();
  459. /* 休眠n秒,默认应该是300秒 */
  460. std::this_thread::sleep_for(std::chrono::seconds(GConfig.CheckSet));
  461. }
  462. SPDLOG_LOGGER_INFO(m_logger, "分派任务线程退出");
  463. }
  464. /**
  465. * @brief 创建任务实例的函数,根据不同的功能创建出不同的实例
  466. *
  467. * @param info
  468. * @return FuncBase*
  469. */
  470. FuncBase* SPAServer::createFuncInstance(FuncActionInfo& info)
  471. {
  472. if(info.appFunction == AppFunction::APP_NONE)
  473. {
  474. return nullptr;
  475. }
  476. FuncBase* pFunc = nullptr;
  477. /* 普通的功能,只用一个摄像机一个算法的功能 */
  478. if( info.appFunction == AppFunction::APP_AllDown || info.appFunction == AppFunction::APP_NoMask ||
  479. info.appFunction == AppFunction::APP_PlayPhone || info.appFunction == AppFunction::APP_Mouse ||
  480. info.appFunction == AppFunction::APP_Fatigue || info.appFunction == AppFunction::APP_Contraband )
  481. {
  482. auto tmpFunc = new FuncOrdinary();
  483. tmpFunc->setFuncActionInfo(info);
  484. pFunc = tmpFunc;
  485. }
  486. else if(info.appFunction == AppFunction::APP_OnWork)
  487. {
  488. /* 人员在岗检测 */
  489. }
  490. else if(info.appFunction == AppFunction::APP_Illegal)
  491. {
  492. /* 非法入侵 */
  493. }
  494. else if(info.appFunction == AppFunction::APP_Regional)
  495. {
  496. /* 区域人员检测 */
  497. }
  498. return pFunc;
  499. }
  500. /* 清理没有在运行的线程实例 */
  501. void SPAServer::clearNoneFuncActionInfo()
  502. {
  503. for(auto it = m_listFuncBase.begin(); it != m_listFuncBase.end(); )
  504. {
  505. if(!(*it)->getThreadRunning())
  506. {
  507. /* 需要转换成相应的子类实例才能删除 */
  508. if( (*it)->getApp() == AppFunction::APP_AllDown || (*it)->getApp() == AppFunction::APP_NoMask ||
  509. (*it)->getApp() == AppFunction::APP_PlayPhone || (*it)->getApp() == AppFunction::APP_Mouse ||
  510. (*it)->getApp() == AppFunction::APP_Fatigue || (*it)->getApp() == AppFunction::APP_Contraband )
  511. {
  512. FuncOrdinary* p = dynamic_cast<FuncOrdinary*>(*it);
  513. delete p;
  514. }
  515. else if((*it)->getApp() == AppFunction::APP_OnWork)
  516. {
  517. /* 人员在岗检测 */
  518. }
  519. else if((*it)->getApp() == AppFunction::APP_Illegal)
  520. {
  521. /* 非法入侵 */
  522. }
  523. else if((*it)->getApp() == AppFunction::APP_Regional)
  524. {
  525. /* 区域人员检测 */
  526. }
  527. it = m_listFuncBase.erase(it);
  528. }else {
  529. ++it;
  530. }
  531. }
  532. }
  533. /**
  534. * @brief 人员在岗识别线程,这个功能主要是给客户端提供实时的人脸识别信息
  535. * 1、这个写入tWorkOnInfo表格,十分钟写一次
  536. * 2、理论上这里需要实时更新数据库,但是实际上时每十分钟写入一次数据
  537. * 3、这个线程也会进行在岗离岗的识别报警
  538. *
  539. * @param RFAInfo 传入房间ID和算法ID
  540. */
  541. // void SPAServer::threadActPersonWork(FuncActionInfo* RFAInfo)
  542. // {
  543. // SPDLOG_LOGGER_INFO(m_logger, "开启 {} 线程,ChannelID:{} ,", RFAInfo->strFunctionName, RFAInfo->ChannelID);
  544. // /* 创建读取Redis的实例 */
  545. // std::shared_ptr<FromRedis> fromRedis = std::make_shared<FromRedis>();
  546. // /* 创建写入数据库实例 */
  547. // std::shared_ptr<ToEQMDataBase> toEQMDataBase = std::make_shared<ToEQMDataBase>();
  548. // /* 局部变量 */
  549. // std::shared_ptr<FuncActionInfo> pRFAInfo = std::make_shared<FuncActionInfo>();
  550. // *pRFAInfo = *RFAInfo;
  551. // /* 保存每个摄像机的报警信息 */
  552. // std::shared_ptr<std::list<AlarmInfo>> pListAlarmInfo = std::make_shared<std::list<AlarmInfo>>();
  553. // /* 保存人脸信息的数据 */
  554. // std::shared_ptr<ListRoomFaceInfo> pListRoomFaceInfo = std::make_shared<ListRoomFaceInfo>();
  555. // while (m_threadRunning)
  556. // {
  557. // /* 更新线程信息 */
  558. // GThreadInfo.updateFuncInfo(pRFAInfo.get());
  559. // if(pRFAInfo->appFunction == AppFunction::APP_NONE)
  560. // {
  561. // break;
  562. // }
  563. // /* 读取Redis数据 */
  564. // pListAlarmInfo->clear();
  565. // for(const auto& RoomInfo : pRFAInfo->listRoomCamActInfo)
  566. // {
  567. // for(const auto& it : RoomInfo.mapCameraAction)
  568. // {
  569. // std::string strKey = std::to_string(it.first) + ":" + it.second;
  570. // std::string strRetValue;
  571. // if(!fromRedis->getRedisString(strKey, strRetValue))
  572. // {
  573. // SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
  574. // std::this_thread::sleep_for(std::chrono::milliseconds(100));
  575. // continue;
  576. // }
  577. // /* 解析数据 */
  578. // AlarmInfo alarmInfo;
  579. // parseRedisBaseData(strRetValue, alarmInfo);
  580. // parseRedisBBoxesData(strRetValue, alarmInfo);
  581. // /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
  582. // if(isEventTimeVaild(alarmInfo.EventTime))
  583. // {
  584. // SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
  585. // std::this_thread::sleep_for(std::chrono::milliseconds(100));
  586. // continue;
  587. // }
  588. // pListAlarmInfo->push_back(alarmInfo);
  589. // }
  590. // }
  591. // /* 处理数据,将报警信息的人脸信息取出来,放入到人脸信息列表中 */
  592. // for(auto& alarmInfo : *pListAlarmInfo)
  593. // {
  594. // /* 添加到人脸列表中,会自动去重,自动创建对应的频道和房间信息 */
  595. // pListRoomFaceInfo->addRoomFaceInfo(alarmInfo);
  596. // }
  597. // /* 计算人脸个数,并判断是否需要写入数据库 */
  598. // QDateTime now = QDateTime::currentDateTime();
  599. // for(auto it = pListRoomFaceInfo->listRoomFaceInfo.begin(); it != pListRoomFaceInfo->listRoomFaceInfo.end(); )
  600. // {
  601. // if(it->MaxNum < it->listPersonInfo.size())
  602. // {
  603. // it->MaxNum = it->listPersonInfo.size();
  604. // }
  605. // if(it->MinNum > it->listPersonInfo.size())
  606. // {
  607. // it->MinNum = it->listPersonInfo.size();
  608. // }
  609. // /* 判断是否需要写入数据库,超过设置的时间就写入,默认是600秒 */
  610. // if(now.toSecsSinceEpoch() - it->StartTime.toSecsSinceEpoch() > GConfig.AppUpdateOnWorkTimeInterval_Time)
  611. // {
  612. // /* 写入数据库 */
  613. // if(toEQMDataBase->insertOnWorkInfo(*it))
  614. // {
  615. // SPDLOG_LOGGER_INFO(m_logger, "ChannelID:{}, RoomID:{}, 在岗信息写入数据库成功, StartTime", it->ChannelID, it->RoomID, it->StartTime.toString("yyyy-MM-dd hh:mm:ss").toStdString());
  616. // /* 删除这条信息 */
  617. // it = pListRoomFaceInfo->listRoomFaceInfo.erase(it);
  618. // continue;
  619. // }
  620. // }
  621. // ++it;
  622. // }
  623. // std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
  624. // }
  625. // GThreadInfo.setThreadState(pRFAInfo.get(), RunTimeState::RUN_STATE_STOP);
  626. // SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
  627. // }
  628. /**
  629. * @brief 区域非法入侵检测
  630. 1、野猫、宠物识别:报警判断条件:机房内出现摄像头的宠物识别算法输出报警结果时,记为报警行为,直接
  631. 展示报警结果
  632. 2、无权限人员识别:报警判断条件:当判断出区域非法入侵行为时,依据人脸识别结果,判断是否为人脸库人
  633. 员,非人脸库的人员时判断为非法入侵行为(背影需要报警需要结合区域人员检测算法判断)
  634. 3、人员计数和人脸识别数不相等时,判断为非法入侵行为
  635. 检测逻辑:
  636. 1、先检测非法的人脸信息
  637. 2、再检测人员计数和人脸识别数不相等
  638. *
  639. * @param info
  640. */
  641. void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
  642. {
  643. SPDLOG_LOGGER_INFO(m_logger, "开启 {} 线程,ChannelID:{} ,", RFAInfo->strFunctionName, RFAInfo->ChannelID);
  644. /* 创建读取Redis的实例 */
  645. std::shared_ptr<FromRedis> fromRedis = std::make_shared<FromRedis>();
  646. /* 创建写入数据库实例 */
  647. std::shared_ptr<ToEQMDataBase> toEQMDataBase = std::make_shared<ToEQMDataBase>();
  648. /* 局部变量 */
  649. std::shared_ptr<FuncActionInfo> pRFAInfo = std::make_shared<FuncActionInfo>();
  650. *pRFAInfo = *RFAInfo;
  651. /* 保存每个摄像机的报警信息 */
  652. std::shared_ptr<std::list<AlarmInfo>> pListAlarmInfo = std::make_shared<std::list<AlarmInfo>>();
  653. /* 保存非法入侵的信息 */
  654. std::shared_ptr<ListIllegalInvasionInfo> pListIllInfo = std::make_shared<ListIllegalInvasionInfo>();
  655. std::string strFaceActionID; /* 人脸识别的Action */
  656. std::string strCountActionID; /* 人员计数的Action */
  657. /* 封装lambda表达式 */
  658. std::function<bool(const std::vector<PersonInfo>&)> funcIsAlarm = [](const std::vector<PersonInfo>& vecPersion) {
  659. for(const auto& it : vecPersion)
  660. {
  661. if(it.PersonID == "-1")
  662. {
  663. return true;
  664. }
  665. }
  666. return false;
  667. };
  668. while (m_threadRunning)
  669. {
  670. /* 更新线程信息 */
  671. GThreadInfo.updateFuncInfo(pRFAInfo.get());
  672. if(pRFAInfo->appFunction == AppFunction::APP_NONE)
  673. {
  674. break;
  675. }
  676. /* 更新算法ActionID */
  677. {
  678. g_actionList.mutexRW.lockForRead();
  679. strFaceActionID = g_actionList.ActFace;
  680. strCountActionID = g_actionList.ActPersonNumber;
  681. g_actionList.mutexRW.unlock();
  682. }
  683. /* 读取Redis数据 */
  684. pListAlarmInfo->clear();
  685. for(const auto& RoomInfo : pRFAInfo->listRoomCamActInfo)
  686. {
  687. for(const auto& it : RoomInfo.mapCameraAction)
  688. {
  689. std::string strKey = std::to_string(it.first) + ":" + it.second;
  690. std::string strRetValue;
  691. if(!fromRedis->getRedisString(strKey, strRetValue))
  692. {
  693. SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
  694. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  695. continue;
  696. }
  697. /* 解析数据 */
  698. AlarmInfo alarmInfo;
  699. // parseRedisData(strRetValue, alarmInfo);
  700. parseRedisBaseData(strRetValue, alarmInfo);
  701. parseRedisBBoxesData(strRetValue, alarmInfo);
  702. /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
  703. if(isEventTimeVaild(alarmInfo.EventTime))
  704. {
  705. SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
  706. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  707. continue;
  708. }
  709. pListAlarmInfo->push_back(alarmInfo);
  710. }
  711. }
  712. /* 找出房间的个数,按照房间进行判断 */
  713. ListRoomIll listRoomIll;
  714. for(auto& it : pRFAInfo->listRoomCamActInfo)
  715. {
  716. listRoomIll.addRoom(it.RoomID, it.RoomType);
  717. }
  718. /* 根据房间解析人脸识别的非法入侵,这个有了就不用判断后面的人员计数不相等了 */
  719. for(auto& room : listRoomIll.getData())
  720. {
  721. for(const auto& it : *pListAlarmInfo)
  722. {
  723. /* 人俩识别算法 */
  724. if(it.ActionID == strFaceActionID)
  725. {
  726. if(it.vecPersonInfo.size() > room.numMaxFace)
  727. {
  728. room.numMaxFace = it.vecPersonInfo.size();
  729. room.strBoxList = it.listBbox;
  730. room.vecPersonInfo = it.vecPersonInfo;
  731. }
  732. }
  733. /* 判断有没有非法入侵人员 */
  734. if(funcIsAlarm(it.vecPersonInfo))
  735. {
  736. room.isAlarm = true;
  737. room.strMessage = "人员非法入侵(未知人员)";
  738. if( !it.ImageInfo.empty() )
  739. {
  740. room.strImage = it.ImageInfo;
  741. }
  742. room.CameraID = it.DeviceID;
  743. }
  744. }
  745. }
  746. /* 判断人脸识别到的数目和人员计数算法识别到的人数是否相等,如果上面报警了,这里就不用检测了 */
  747. for(auto& room : listRoomIll.getData())
  748. {
  749. if(room.isAlarm)
  750. {
  751. continue;
  752. }
  753. /* 这个房间的人脸算法没有识别到非法入侵 */
  754. for(const auto& it : *pListAlarmInfo)
  755. {
  756. if(it.ActionID == strCountActionID)
  757. {
  758. if(it.vecPersonInfo.size() > room.numMaxPerson)
  759. {
  760. room.numMaxPerson = it.vecPersonInfo.size();
  761. room.strBoxList = it.listBbox;
  762. if(!it.ImageInfo.empty())
  763. {
  764. room.strImage = it.ImageInfo;
  765. }
  766. room.CameraID = it.DeviceID;
  767. }
  768. }
  769. }
  770. /* 判断人数是否一致 */
  771. if(room.numMaxFace != room.numMaxPerson)
  772. {
  773. room.strMessage = fmt::format("非法入侵(人员计数 {} 和人脸数 {} 不一致)", room.numMaxPerson, room.numMaxFace);
  774. room.isAlarm = true;
  775. }
  776. }
  777. /* 将非法入侵的信息存储到数组缓存中,等待报警结束后判断是否需要写入EQM数据库 */
  778. for(auto& room : listRoomIll.getData())
  779. {
  780. auto pIll = pListIllInfo->findIllInfo(room.RoomID, room.RoomType);
  781. if(room.isAlarm)
  782. {
  783. /* 正在报警,检查是否有 */
  784. if(pIll == nullptr)
  785. {
  786. IllegalInvasionInfo info;
  787. info.ChannelID = pRFAInfo->ChannelID;
  788. info.CameraID = room.CameraID;
  789. info.RoomID = room.RoomID;
  790. info.RoomType = room.RoomType;
  791. info.strActionDec = room.strMessage;
  792. info.strImageInfo = room.strImage;
  793. info.FirstTime = QDateTime::currentDateTime();;
  794. pListIllInfo->addIllInfo(info);
  795. }
  796. }
  797. else
  798. {
  799. /* 没有报警,检查是否是报警结束了,是否符合写入数据库的条件 */
  800. QDateTime currTime = QDateTime::currentDateTime();
  801. int secs = currTime.toSecsSinceEpoch() - pIll->FirstTime.toSecsSinceEpoch();
  802. if(secs >= GConfig.AppBadMan)
  803. {
  804. if(!pIll->strImageInfo.empty())
  805. {
  806. /* 超过非法入侵的时间,写入数据库 */
  807. AlarmInfo ai;
  808. ai.ChannelID = pRFAInfo->ChannelID;
  809. ai.RoomID = pIll->RoomID;
  810. ai.ActionID = g_actionList.ActPersonNumber;
  811. ai.ActionDes = pIll->strActionDec;
  812. ai.ImageInfo = pIll->strImageInfo;
  813. ai.StartTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
  814. ai.EndTime = currTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
  815. ai.EventTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
  816. ai.vecPersonInfo = room.vecPersonInfo;
  817. ai.listBbox = room.strBoxList;
  818. bool insertRet = toEQMDataBase->insertAlarmInfo(ai);
  819. if(insertRet)
  820. {
  821. std::string actionName = g_actionList.getActionName(ai.ActionID);
  822. SPDLOG_LOGGER_INFO(m_logger, "☆ 新增报警信息,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸,{}",
  823. pIll->ChannelID, pIll->RoomID, pIll->CameraID, actionName, ai.ActionDes, ai.listBbox.size(), ai.FaceIDList.size(), ai.ImageInfo);
  824. }
  825. }
  826. /* 删除这个非法入侵信息 */
  827. pListIllInfo->deleteIllInfo(*pIll);
  828. }
  829. }
  830. }
  831. std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
  832. }
  833. GThreadInfo.setThreadState(pRFAInfo.get(), RunTimeState::RUN_STATE_STOP);
  834. SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
  835. }
  836. /**
  837. * @brief 区域人员检测,检测这个区域内的人数,不能少于多少人,不能多余多少人
  838. * 1、报警判断条件:直播间报警:当前频率所有直播间摄像头的区域人员检测算法输出结果均大于或小于设定人
  839. 数值时,记为报警行为,直接展示报警结果
  840. 2、录播间报警:当前频率所有录播间摄像头的区域人员检测算法输出结果均大于或小于设定人数值时,记为报
  841. 警行为,直接展示报警结果
  842. 3、直播间+录播间报警:当前频率直播间人数+录播间人数大于或小于设定人数值时,记为报警行为,直接展示
  843. 报警结果
  844. *
  845. * @param RAInfo 传入的房间ID和算法ID
  846. */
  847. void SPAServer::threadActRegionalPersonnelDetection(FuncActionInfo* RFAInfo)
  848. {
  849. SPDLOG_LOGGER_INFO(m_logger, "开启 {} 线程,ChannelID:{} ,", RFAInfo->strFunctionName, RFAInfo->ChannelID);
  850. /* 创建读取Redis的实例 */
  851. std::shared_ptr<FromRedis> fromRedis = std::make_shared<FromRedis>();
  852. /* 创建写入数据库实例 */
  853. std::shared_ptr<ToEQMDataBase> toEQMDataBase = std::make_shared<ToEQMDataBase>();
  854. /* 局部变量,线程功能需要的信息 */
  855. std::shared_ptr<FuncActionInfo> pRFAInfo = std::make_shared<FuncActionInfo>();
  856. *pRFAInfo = *RFAInfo;
  857. /* 保存每个摄像机的报警信息 */
  858. std::shared_ptr<std::list<AlarmInfo>> pListAlarmInfo = std::make_shared<std::list<AlarmInfo>>();
  859. /* 报警时间段 */
  860. std::shared_ptr<std::vector<PersonCountRuleInfo>> pPersonCountRuleInfo = std::make_shared<std::vector<PersonCountRuleInfo>>();
  861. /* 获取报警规则信息 */
  862. toEQMDataBase->getPersonCountRuleInfo(*pPersonCountRuleInfo);
  863. while (m_threadRunning)
  864. {
  865. std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
  866. /************ 更新线程信息 ************/
  867. GThreadInfo.updateFuncInfo(pRFAInfo.get());
  868. if(pRFAInfo->appFunction == AppFunction::APP_NONE)
  869. {
  870. break;
  871. }
  872. /************ 读取Redis数据 ************/
  873. pListAlarmInfo->clear();
  874. for(const auto& RoomInfo : pRFAInfo->listRoomCamActInfo)
  875. {
  876. for(const auto& it : RoomInfo.mapCameraAction)
  877. {
  878. std::string strKey = std::to_string(it.first) + ":" + it.second;
  879. std::string strRetValue;
  880. if(!fromRedis->getRedisString(strKey, strRetValue))
  881. {
  882. SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
  883. continue;
  884. }
  885. /* 解析数据 */
  886. AlarmInfo alarmInfo;
  887. parseRedisBaseData(strRetValue, alarmInfo);
  888. parseRedisBBoxesData(strRetValue, alarmInfo);
  889. /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
  890. if(isEventTimeVaild(alarmInfo.EventTime))
  891. {
  892. SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
  893. continue;
  894. }
  895. pListAlarmInfo->push_back(alarmInfo);
  896. }
  897. }
  898. /************ 获取报警规则(从数据库更新?) ************/
  899. if(!toEQMDataBase->getPersonCountRuleInfo(*pPersonCountRuleInfo))
  900. {
  901. SPDLOG_LOGGER_ERROR(m_logger, "《人员计数》获取报警规则失败");
  902. continue;
  903. }
  904. if(pPersonCountRuleInfo->size() == 0)
  905. {
  906. SPDLOG_LOGGER_ERROR(m_logger, "《人员计数》无报警规则");
  907. break;
  908. }
  909. /* 获取这个频率的报警信息 */
  910. PersonCountRuleInfo personCountRuleInfo;
  911. for(auto& it : *pPersonCountRuleInfo)
  912. {
  913. if(it.ChannelID == pRFAInfo->ChannelID)
  914. {
  915. personCountRuleInfo = it;
  916. break;
  917. }
  918. }
  919. if(personCountRuleInfo.ChannelID < 0)
  920. {
  921. SPDLOG_LOGGER_ERROR(m_logger, "《人员计数》获取报警规则失败, ChannelID:{}", pRFAInfo->ChannelID);
  922. break;
  923. }
  924. /************ 判断是否在检测时间内 ************/
  925. QDateTime now = QDateTime::currentDateTime();
  926. /* 判断检测时间类型 */
  927. if(personCountRuleInfo.RuleType == 0)
  928. {
  929. /* 所有时段 */
  930. }
  931. else if(personCountRuleInfo.RuleType == 1)
  932. {
  933. /* 按天检测 */
  934. if(personCountRuleInfo.StartTime <= now && personCountRuleInfo.EndTime >= now)
  935. {
  936. /* 在检测时间内 */
  937. } else
  938. {
  939. /* 不在检测时间内 */
  940. continue;
  941. }
  942. }
  943. else if (personCountRuleInfo.RuleType == 2)
  944. {
  945. /* 按周检测 */
  946. if(personCountRuleInfo.week != now.date().dayOfWeek())
  947. {
  948. /* 不在检测时间内 */
  949. continue;
  950. }
  951. /* 在检测时间内 */
  952. if(personCountRuleInfo.StartTime.time() <= now.time() && personCountRuleInfo.EndTime.time() >= now.time())
  953. {
  954. /* 在检测时间内 */
  955. } else
  956. {
  957. /* 不在检测时间内 */
  958. continue;
  959. }
  960. }
  961. /************ 挨个房间检测人数 ************/
  962. /************ 检测频率直播间 + 导播间房间的人数 ************/
  963. }
  964. GThreadInfo.setThreadState(pRFAInfo.get(), RunTimeState::RUN_STATE_STOP);
  965. SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
  966. }
  967. /* 将该算法对应的摄像机放入摄像机列表 */
  968. // bool SPAServer::insertCameraToAction(RoomActionInfo* pRAInfo, std::list<RoomCameraInfo>& listRC, std::multimap<int, std::string>& mapCameraActionID)
  969. // {
  970. // for(const auto& rci : listRC)
  971. // {
  972. // if(rci.RoomID == pRAInfo->RoomID)
  973. // {
  974. // /* 这个摄像机在这个房间内,再判断这个摄像机有没有这个算法 */
  975. // for(const auto& camID : rci.listCameraID)
  976. // {
  977. // for(const auto& cai : mapCameraActionID)
  978. // {
  979. // if(camID == cai.first)
  980. // {
  981. // /* 再判断这个摄像机的算法是否是当前需要的 */
  982. // if(cai.second == pRAInfo->ActionID)
  983. // {
  984. // pRAInfo->listCameraID.push_back(camID);
  985. // }
  986. // }
  987. // }
  988. // }
  989. // }
  990. // }
  991. // return true;
  992. // }