| | |
| | | |
| | | add_subdirectory(StructureApp) |
| | | add_subdirectory(FaceDetectServer) |
| | | #add_subdirectory(YoloServer) |
| | | add_subdirectory(YoloServer) |
| | | add_subdirectory(FaceSearchServer) |
| | | add_subdirectory(VideoAnalysFromHC) |
| | | add_subdirectory(RapidStructureApp) |
| | |
| | | ../FaceSearchServer/CasiaFaceWrapper/CasiaFaceWrapperN.h |
| | | ../../../BasicPlatForm/basic/pipe_element/ffmpeg/FfmpegElement.cpp |
| | | ../../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoChangeScore.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | |
| | | |
| | | |
| | | ../../syncDBTool/ErlangDbTool.cpp |
| | |
| | | std::bind(&devHttpServer_c::editDevId, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | _HttpSrvRetRecieve.setInfo("^/findSdkRule$", "POST", |
| | | std::bind(&devHttpServer_c::findSdkRule, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | _HttpSrvRetRecieve.setInfo("^/editSdkRule$", "POST", |
| | | std::bind(&devHttpServer_c::editSdkRule, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | _HttpSrvRetRecieve.setInfo("^/getSnapshot$", "POST", |
| | | std::bind(&devHttpServer_c::getSnapshot, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | |
| | | _HttpSrvRetRecieve.start(); |
| | | _HttpSrvRetRecieve.waitForShutDown(); |
| | | } |
| | |
| | | elem["str_brand"] = iter->str_brand.toStdString(); |
| | | elem["str_reserved"] = iter->str_reserved.toStdString(); |
| | | |
| | | Record_Cam_Sdk rec_sdk = db_c.searchCamSdkTableByCamId(iter->str_cam_dev_id); |
| | | elem["str_sdks"] = rec_sdk.str_sdks.toStdString(); |
| | | elem["str_det_thr"] = rec_sdk.str_det_thr.toStdString(); |
| | | elem["str_cmp_thr"] = rec_sdk.str_cmp_thr.toStdString(); |
| | | // Record_Cam_Sdk rec_sdk = db_c.searchCamSdkTableByCamId(iter->str_cam_dev_id); |
| | | // elem["str_sdks"] = rec_sdk.str_sdks.toStdString(); |
| | | // elem["str_det_thr"] = rec_sdk.str_det_thr.toStdString(); |
| | | // elem["str_cmp_thr"] = rec_sdk.str_cmp_thr.toStdString(); |
| | | |
| | | cout << elem.toStyledString() << endl; |
| | | |
| | |
| | | rec.str_password = QString::fromStdString(value["str_password"].asString()); |
| | | rec.str_brand = QString::fromStdString(value["str_brand"].asString()); |
| | | |
| | | rec_sdk_old = db_c.searchCamSdkTableByCamId(rec.str_cam_dev_id); |
| | | // rec_sdk_old = db_c.searchCamSdkTableByCamId(rec.str_cam_dev_id); |
| | | |
| | | rec_sdk.str_cam_dev_id = rec.str_cam_dev_id; |
| | | rec_sdk.str_sdks = QString::fromStdString(value["str_sdks"].asString()); |
| | | rec_sdk.str_det_thr = QString::fromStdString(value["str_det_thr"].asString()); |
| | | rec_sdk.str_cmp_thr = QString::fromStdString(value["str_cmp_thr"].asString()); |
| | | // rec_sdk.str_cam_dev_id = rec.str_cam_dev_id; |
| | | // rec_sdk.str_sdks = QString::fromStdString(value["str_sdks"].asString()); |
| | | // rec_sdk.str_det_thr = QString::fromStdString(value["str_det_thr"].asString()); |
| | | // rec_sdk.str_cmp_thr = QString::fromStdString(value["str_cmp_thr"].asString()); |
| | | |
| | | ret = db_c.updateCamAndSdkTable(rec, rec_sdk); |
| | | if (!ret) { |
| | |
| | | db_c.updateConfigTableByDevType(DEV_CAMERA); |
| | | runAllApp(); |
| | | } |
| | | //edit camera's sdks |
| | | else/* if ((rec_sdk_old.str_sdks != rec_sdk.str_sdks) || |
| | | (rec_sdk_old.str_det_thr != rec_sdk.str_det_thr) || |
| | | (rec_sdk_old.str_cmp_thr != rec_sdk.str_cmp_thr)) */{ |
| | | killVideoAnalysFromHCApp(); |
| | | sleep(1); |
| | | runAllApp(); |
| | | } |
| | | //edit camera's sdks |
| | | // else/* if ((rec_sdk_old.str_sdks != rec_sdk.str_sdks) || |
| | | // (rec_sdk_old.str_det_thr != rec_sdk.str_det_thr) || |
| | | // (rec_sdk_old.str_cmp_thr != rec_sdk.str_cmp_thr)) */{ |
| | | // killVideoAnalysFromHCApp(); |
| | | // sleep(1); |
| | | // runAllApp(); |
| | | // } |
| | | |
| | | Json::Value value_out; |
| | | value_out["str_cam_dev_id"] = rec.str_cam_dev_id.toStdString(); |
| | |
| | | |
| | | if (reader.parse(content, value)) { |
| | | int cut_max_duration = value["cut_max_duration"].asInt(); |
| | | |
| | | ret = db_c.updateConfigTableByCutDuration(cut_max_duration); |
| | | int cut_min_duration = value["cut_min_duration"].asInt(); |
| | | ret = db_c.updateConfigTableByCutDuration(cut_max_duration, cut_min_duration); |
| | | |
| | | } else { |
| | | return "{\"ret_status\": \"ä¼ è¾é误ï¼è¯·æ£æ¥ï¼\"}"; |
| | |
| | | |
| | | Json::Value value; |
| | | |
| | | int cut_max_duration = db_c.searchConfigTableWithinCutDuration(); |
| | | |
| | | value["cut_max_duration"] = cut_max_duration; |
| | | Record_Config rec = db_c.searchConfigTableWithinServerInfo(); |
| | | |
| | | value["cut_max_duration"] = rec.n_cut_max_duration; |
| | | value["cut_min_duration"] = rec.n_cut_min_duration; |
| | | std::string out = value.toStyledString(); |
| | | |
| | | return out; |
| | |
| | | std::string devHttpServer_c::getVideoPathByTime(const std::string &time, const std::string &camId, qint64 &sub) { |
| | | std::string t_FilePath = appConfig.getStringProperty("cutPath"); |
| | | |
| | | bool find = false;; |
| | | bool find = false; |
| | | if (t_FilePath.back() != '/') { |
| | | t_FilePath.push_back('/'); |
| | | } |
| | |
| | | // return "{\"error\":\"ä¼ è¾é误ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | } |
| | | |
| | | std::string devHttpServer_c::editSdkRule(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | Json::FastWriter writer; |
| | | if (reader.parse(content, value)) { |
| | | SdkRule rule; |
| | | rule.nSdkType = value["nSdkType"].asInt(); |
| | | rule.nAlarmNumLowerLimit = value["nAlarmNumLowerLimit"].asInt(); |
| | | rule.nAlarmNumUpperLimit = value["nAlarmNumUpperLimit"].asInt(); |
| | | rule.nTriggerDelay = value["nTriggerDelay"].asInt(); |
| | | rule.nTriggerTolerance = value["nTriggerTolerance"].asInt(); |
| | | rule.nThreshold = value["nThreshold"].asInt(); |
| | | rule.nQuality = value["nQuality"].asInt(); |
| | | rule.nIsRun = value["nIsRun"].asInt(); |
| | | rule.strBroadcast = value["nIsBroadcast"].asCString(); |
| | | rule.strAreas = value["strAreas"].asCString(); |
| | | rule.strCamId = value["strCamId"].asCString(); |
| | | rule.strExAreas = value["strExAreas"].asCString(); |
| | | rule.strLine = value["strLine"].asCString(); |
| | | rule.strExLine = value["strExLine"].asCString(); |
| | | if (rule.strCamId.isEmpty()) { |
| | | return "{\"ret_status\":\"å
容æè¯¯ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | if (rule.nSdkType <= SdkTypeStart || rule.nSdkType >= SdkTypeEnd) { |
| | | return "{\"ret_status\":\"å
容æè¯¯ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | |
| | | for (int i = 0; i < value["weekRuleArray"].size(); ++i) { |
| | | Json::Value item = value["weekRuleArray"][i]; |
| | | LActRuleWeekRecord weekRule; |
| | | weekRule.m_nSdkType = rule.nSdkType; |
| | | weekRule.m_nType = item["nType"].asInt(); |
| | | weekRule.m_strCamId = rule.strCamId; |
| | | weekRule.m_strBegin = item["strBegin"].asCString(); |
| | | weekRule.m_strEnd = item["strEnd"].asCString(); |
| | | //rule.weekRuleVec.push_back(weekRule); |
| | | db_c.updateCameraWeekRule(weekRule); |
| | | } |
| | | |
| | | |
| | | if (db_c.updateSdkRule(rule)) { |
| | | // if(rule.nIsRun==1) |
| | | |
| | | killVideoAnalysFromHCApp(); |
| | | sleep(1); |
| | | runAllApp(); |
| | | |
| | | |
| | | return "{\"ret_status\": \"ok_ack\"}"; |
| | | } else { |
| | | return "{\"ret_status\":\"å
容æè¯¯ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | } else { |
| | | return "{\"error\":\"ä¼ è¾é误ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | } |
| | | |
| | | std::string devHttpServer_c::findSdkRule(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | |
| | | if (reader.parse(content, value)) { |
| | | |
| | | QString strCamId = value["strCamId"].asCString(); |
| | | |
| | | SdkRuleMap ruleMap = db_c.searchSdkRuleByCamId(strCamId); |
| | | |
| | | int count = ruleMap.size(); |
| | | |
| | | if (count > 0) { |
| | | Json::Value objs; |
| | | Json::Value obj; |
| | | |
| | | for (auto rule:ruleMap) { |
| | | obj["nSdkType"] = rule.second.nSdkType; |
| | | obj["nAlarmNumLowerLimit"] = rule.second.nAlarmNumLowerLimit; |
| | | obj["nAlarmNumUpperLimit"] = rule.second.nAlarmNumUpperLimit; |
| | | obj["nTriggerDelay"] = rule.second.nTriggerDelay; |
| | | obj["nTriggerTolerance"] = rule.second.nTriggerTolerance; |
| | | obj["nThreshold"] = rule.second.nThreshold; |
| | | obj["nQuality"] = rule.second.nQuality; |
| | | obj["nIsRun"] = rule.second.nIsRun; |
| | | obj["nIsBroadcast"] = rule.second.strBroadcast.toStdString(); |
| | | obj["strAreas"] = rule.second.strAreas.toStdString(); |
| | | obj["strCamId"] = rule.second.strCamId.toStdString(); |
| | | obj["strExAreas"] = rule.second.strExAreas.toStdString(); |
| | | obj["strLine"] = rule.second.strLine.toStdString(); |
| | | obj["strExLine"] = rule.second.strExLine.toStdString(); |
| | | Json::Value weekRuleArray; |
| | | |
| | | |
| | | Json::Value weekRule; |
| | | std::vector<LActRuleWeekRecord> weekRuleVec = db_c.searchCameraWeekRuleByCamId(strCamId, rule.first); |
| | | for (int k = 0; k < weekRuleVec.size(); ++k) { |
| | | Json::Value weekRuleObj; |
| | | weekRuleObj["nSdkType"] = weekRuleVec[k].m_nSdkType; |
| | | weekRuleObj["strCamId"] = weekRuleVec[k].m_strCamId.toStdString(); |
| | | weekRuleObj["strBegin"] = weekRuleVec[k].m_strBegin.toStdString(); |
| | | weekRuleObj["strEnd"] = weekRuleVec[k].m_strEnd.toStdString(); |
| | | weekRuleObj["nType"] = weekRuleVec[k].m_nType; |
| | | weekRule.append(weekRuleObj); |
| | | } |
| | | //weekRuleArray[j]=weekRule; |
| | | |
| | | |
| | | obj["weekRuleArray"] = weekRule; |
| | | objs.append(obj); |
| | | } |
| | | return objs.toStyledString(); |
| | | } else { |
| | | // return "{\"ret_status\":\"å
容æè¯¯ï¼è¯·æ£æ¥ï¼\"}"; |
| | | return "[]"; |
| | | } |
| | | } else { |
| | | return "{\"error\":\"ä¼ è¾é误ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | } |
| | | |
| | | std::string devHttpServer_c::getSnapshot(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | |
| | | if (reader.parse(content, value)) { |
| | | |
| | | std::string ip = value["str_ip"].asString(); |
| | | // int port= value["n_port"].asInt(); |
| | | int port = 554; |
| | | std::string username = value["str_username"].asString(); |
| | | std::string pass = value["str_password"].asString(); |
| | | std::string brand = value["str_brand"].asString(); |
| | | std::string rtsp_url = rtspAddrBuild(ip, port, username, pass, brand); |
| | | if (rtsp_url.empty()) { |
| | | return "{\"ret_status\":\"å
容æè¯¯ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | std::string str_imgName = appConfig.getStringProperty("cutPath"); |
| | | if (str_imgName.back() != '/') { |
| | | str_imgName.push_back('/'); |
| | | } |
| | | str_imgName += "snapshot.jpg"; |
| | | //admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream -r 1/25 -f image2 -s 1920*1080 /home/basic/work_src/a.jpg |
| | | std::string cmd("ffmpeg -i " + rtsp_url + " -r 1/25 -f image2 -s 1920*1080 -y " + str_imgName); |
| | | DBG(cmd); |
| | | system(cmd.c_str()); |
| | | |
| | | cv::Mat img = cv::imread(str_imgName); |
| | | |
| | | if (img.empty()) { |
| | | |
| | | return "{\"ret_status\":\"å
容æè¯¯ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | fdfsClient.rwLock.rdlock(); |
| | | std::string strImgUrl = "http://"; |
| | | if (fdfsClient.fastFds != nullptr) { |
| | | std::vector<unsigned char> buffer; |
| | | CvUtil::cvMat2Buffer(img, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient.fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient.fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | } |
| | | fdfsClient.rwLock.unlock(); |
| | | Json::Value result; |
| | | result["imgUrl"] = strImgUrl; |
| | | |
| | | return result.toStyledString(); |
| | | |
| | | |
| | | } else { |
| | | return "{\"error\":\"ä¼ è¾é误ï¼è¯·æ£æ¥ï¼\"}"; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | std::string editDevId(std::string ip, unsigned int port, std::string content, PResponse &response); |
| | | |
| | | std::string findSdkRule(std::string ip, unsigned int port, std::string content, PResponse &response); |
| | | |
| | | std::string editSdkRule(std::string ip, unsigned int port, std::string content, PResponse &response); |
| | | |
| | | std::string getSnapshot(std::string ip, unsigned int port, std::string content, PResponse &response); |
| | | |
| | | private: |
| | | void init(void); |
| | | |
| | |
| | | |
| | | bool getHKDevSerialNumber(const char *ip, const int port, const char *username, const char *passwd, |
| | | unsigned char *serialNumber = NULL) const; |
| | | bool createDevId(const int& dev_batch, const int& dev_sequence) ; |
| | | |
| | | std::string getVideoPathByTime(const std::string& time,const std::string& camId,qint64& sub); |
| | | bool createDevId(const int &dev_batch, const int &dev_sequence); |
| | | |
| | | std::string getVideoPathByTime(const std::string &time, const std::string &camId, qint64 &sub); |
| | | |
| | | std::vector<std::string> forEachFile(const std::string &dir_name); |
| | | |
| | | qint64 getVideoTime(/*const std::string& videoPath,*/std::string& str_tmpTime); |
| | | qint64 getVideoTime(/*const std::string& videoPath*/std::string &str_tmpTime); |
| | | }; |
| | | |
| | | #endif |
| | |
| | | "str_username" : "admin", |
| | | "str_password" : "123456", |
| | | "str_brand" : "dahua", |
| | | "str_sdks": "1,2,4", |
| | | "str_det_thr": "90,80,95", |
| | | "str_cmp_thr": "80,85,90", |
| | | //"str_sdks": "1,2,4", |
| | | //"str_det_thr": "90,80,95", |
| | | //"str_cmp_thr": "80,85,90", |
| | | "str_reserved": "" |
| | | } |
| | | è¿åï¼ |
| | |
| | | "str_addr" : "æäº¬soho大å¦å¡3 b座2005", |
| | | "str_brand" : "dahua", |
| | | "str_cam_dev_id" : "dahua:ca:me:ra:22:22:22", |
| | | "str_cmp_thr" : "80,92", |
| | | "str_det_thr" : "90,92", |
| | | //"str_cmp_thr" : "80,92", |
| | | // "str_det_thr" : "90,92", |
| | | "str_ip" : 8080, |
| | | "str_latitude" : "116.457092", |
| | | "str_longitude" : "39.994827", |
| | | "str_name" : "大åæåæº2", |
| | | "str_password" : "123456", |
| | | "str_reserved" : "", |
| | | "str_sdks" : "1,2", |
| | | // "str_sdks" : "1,2", |
| | | "str_username" : "admin" |
| | | }, |
| | | { |
| | | "str_addr" : "æäº¬soho大å¦å¡3 b座33", |
| | | "str_brand" : "dahua", |
| | | "str_cam_dev_id" : "dahua:ca:me:ra:33:33:33", |
| | | "str_cmp_thr" : "80,85,93", |
| | | "str_det_thr" : "90,80,93", |
| | | // "str_cmp_thr" : "80,85,93", |
| | | // "str_det_thr" : "90,80,93", |
| | | "str_ip" : 8080, |
| | | "str_latitude" : "116.457033", |
| | | "str_longitude" : "39.994833", |
| | | "str_name" : "大åæåæº3", |
| | | "str_password" : "123433", |
| | | "str_reserved" : "", |
| | | "str_sdks" : "1,2,3", |
| | | //"str_sdks" : "1,2,3", |
| | | "str_username" : "admin" |
| | | } |
| | | ] |
| | |
| | | è¿åï¼ |
| | | { |
| | | "cut_max_duration" : 4 |
| | | "cut_min_duration" : 4 |
| | | } |
| | | |
| | | //è§é¢æ¶é¿è®¾ç½® cut_dura_edit |
| | | ä¸åï¼ |
| | | { |
| | | "cut_max_duration" : 3 |
| | | "cut_min_duration" : 3 |
| | | } |
| | | è¿åï¼æ åè¿åå¼ |
| | | |
| | |
| | | } |
| | | é误: |
| | | æ åè¿åå¼ |
| | | |
| | | ä¿®æ¹å个sdkè§å editSdkRule |
| | | author:å¼ ç»§æ° |
| | | ä¸åï¼ |
| | | { |
| | | "nAlarmNumLowerLimit": 3, //æ¥è¦äººæ°ä¸é 没å¯ç¨ä½¿ç¨è´æ° |
| | | "nAlarmNumUpperLimit": 6, //æ¥è¦äººæ°ä¸é 没å¯ç¨ä½¿ç¨è´æ° |
| | | "nIsBroadcast": "妿 ¡,é£å ,宿è", //ip广æ |
| | | "nIsRun": 1, //æ¯å¦å¯ç¨ å¯ç¨å¡«1 |
| | | "nSdkType": 1,//sdkç±»å |
| | | "nTriggerDelay": 5,//æ¥è¦å»¶è¿ |
| | | "nTriggerTolerance": 20,//æä¸ä½¿ç¨ |
| | | "nQuality": 90, //å¾çè´¨é |
| | | "nThreshold": 90,//å¾çéå¼åçµæåº¦é½ç¨è¿ä¸ª |
| | | "strAreas": "[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]",//ç»æ¡åºååæ ï¼æ¯ ææ ç±»åçå¯ä¸æ¡ï¼ä¹æ¯é å³è¡çç¬¬ä¸æ¡ï¼æ°ç»é¿åº¦ä¸ºå¤è¾¹å½¢è¾¹æ° |
| | | "strCamId": "1",//camId ç¸æºid å¯ä¸æ 示 |
| | | "strExAreas": "",//é å³è¡ç¬¬äºä¸ªæ¡åæ ï¼åä¸ |
| | | "strExLine": "",//é å³è¡ç¬¬äºæ¡çº¿åæ æ°ç»é¿åº¦ä¸º2 |
| | | "strLine": "[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200}]",//线æ¡åæ ï¼æ°ç»å
ç´ ç±èµ·å§åæ å°ç»æåæ ï¼æ°ç»é¿åº¦ä¸º2 |
| | | "weekRuleArray": [ //å¨è§åæ¶é´ |
| | | { |
| | | "nSdkType": 1, // åä¸ ä¿æä¸è´ï¼å¯ä»¥ä¸ç©¿ |
| | | "nType": 1, //å¨1 |
| | | "strBegin": "00:00",//å¼å§æ¶é´ HH:mm |
| | | "strCamId": "1",//åä¸ ä¿æä¸è´ï¼å¯ä»¥ä¸ç©¿ |
| | | "strEnd": "23:59"//ç»ææ¶é´ HH:mm |
| | | }, |
| | | { |
| | | "nSdkType": 1, |
| | | "nType": 2, |
| | | "strBegin": "00:00", |
| | | "strCamId": "1", |
| | | "strEnd": "23:59" |
| | | } |
| | | ] |
| | | } |
| | | è¿åï¼ |
| | | { |
| | | "ret_status": "ok_ack" |
| | | } |
| | | æ¥è¯¢ææsdkè§å findSdkRule |
| | | author:å¼ ç»§æ° |
| | | ä¸åï¼ |
| | | {"strCamId": "1"} |
| | | è¿åï¼ |
| | | [ |
| | | { |
| | | "nAlarmNumLowerLimit" : 0, |
| | | "nAlarmNumUpperLimit" : 0, |
| | | "nIsBroadcast" : "", |
| | | "nIsRun" : 0, |
| | | "nQuality" : 0, |
| | | "nSdkType" : 1, |
| | | "nThreshold" : 0, |
| | | "nTriggerDelay" : 0, |
| | | "nTriggerTolerance" : 0, |
| | | "strAreas" : "", |
| | | "strCamId" : "1", |
| | | "strExAreas" : "", |
| | | "strExLine" : "", |
| | | "strLine" : "", |
| | | "weekRuleArray" : [ |
| | | |
| | | { |
| | | "nSdkType" : 1, |
| | | "nType" : 1, |
| | | "strBegin" : "00:00", |
| | | "strCamId" : "1", |
| | | "strEnd" : "23:59" |
| | | }, |
| | | { |
| | | "nSdkType" : 1, |
| | | "nType" : 2, |
| | | "strBegin" : "00:00", |
| | | "strCamId" : "1", |
| | | "strEnd" : "23:59" |
| | | } |
| | | |
| | | |
| | | ] |
| | | |
| | | } |
| | | ] |
| | | è·å宿¶æµæªå¾ getSnapshot |
| | | ä¸åï¼ |
| | | { |
| | | "str_ip":"192.168.1.215", |
| | | "n_port":554, |
| | | "str_username":"admin", |
| | | "str_password":"a1234567", |
| | | "str_brand":"haikang" |
| | | } |
| | | è¿åï¼ |
| | | { |
| | | "imgUrl" : "group2/M00/02/7F/wKgBnFw1whWAT5DbAALrl1a_A04988.jpg" |
| | | } |
| | |
| | | main_detect.cpp |
| | | FaceDetectServerI.cpp |
| | | rpc/FaceServer.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | ) |
| | | add_executable(FaceDetectResourcesTest |
| | | FaceDetectResourcesTest.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | ) |
| | | |
| | | add_executable(FaceExtractServer |
| | | main_extract.cpp |
| | | FaceExtractServerI.cpp |
| | | rpc/FaceServer.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | ) |
| | | |
| | | target_link_libraries(${PROJECT_NAME} |
| | |
| | | ../../../BasicPlatForm/basic/db/Elasticsearch/EsDBTool.cpp |
| | | ../../../BasicPlatForm/basic/db/Elasticsearch/EsDBTool.h |
| | | |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | |
| | | ../LocalDBTool/SqliteFaceEncap.cpp |
| | | ../../../BasicPlatForm/basic/db/sqlite/sqliteEncapsulation.cpp |
| | |
| | | ../../../BasicPlatForm/basic/pipe/TimerElement.cpp |
| | | ../../../BasicPlatForm/basic/util/file/FileUtil.cpp |
| | | ../../../BasicPlatForm/basic/pipe_element/ffmpeg/ffmpegRecoder/FileRecorder.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | ) |
| | | |
| | | SET(LIBS |
| | |
| | | } |
| | | |
| | | bool TriggerElement::getTriggerState() const { |
| | | return state; |
| | | return triggerState; |
| | | } |
| | | |
| | | void TriggerElement::threadInitial() { |
| | |
| | | #include <QtCore/QtGlobal> |
| | | #include <net_config.h> |
| | | |
| | | AppPipeController::AppPipeController(std::string folderPath, const Json::Value &json) : |
| | | //AppPipeController::AppPipeController(std::string folderPath, const Json::Value &json) : |
| | | // videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")), m_index(0), |
| | | // m_folderPath(folderPath), |
| | | // m_json(json), fdfsClient(nullptr), yoloRpcElement(folderPath + "yoloRpc"), faceRpcElement(folderPath + "faceRpc"), |
| | | // faceExtractElement(folderPath + "faceExtract"), triggerElement(25, 10), |
| | | // recordVideoElement(-1, json["rtsp"].asString()), bRecordVideoEnable(false) { |
| | | |
| | | // init(); |
| | | |
| | | //} |
| | | AppPipeController::AppPipeController(std::string folderPath, const SdkRuleMap &ruleMap) : |
| | | videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")), m_index(0), |
| | | m_folderPath(folderPath), |
| | | m_json(json), fdfsClient(nullptr), yoloRpcElement(folderPath + "yoloRpc"), faceRpcElement(folderPath + "faceRpc"), |
| | | faceExtractElement(folderPath + "faceExtract"), triggerElement(25, 10), |
| | | recordVideoElement(-1, json["rtsp"].asString()), bRecordVideoEnable(false) { |
| | | m_sdkRuleMap(ruleMap), |
| | | fdfsClient(nullptr), |
| | | yoloRpcElement(folderPath + "yoloRpc"), |
| | | faceRpcElement(folderPath + "faceRpc", ruleMap[FaceSdk]), |
| | | faceExtractElement(folderPath + "faceExtract", ruleMap[FaceSdk]), |
| | | triggerElement(25, 10), |
| | | recordVideoElement(-1, ""), |
| | | bRecordVideoEnable(false) { |
| | | |
| | | init(); |
| | | |
| | | } |
| | | |
| | | AppPipeController::AppPipeController(int index, const Json::Value &json, bool RecordVideoEnable) : |
| | | videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index"), RecordVideoEnable), |
| | | m_index(index), fdfsClient(nullptr), yoloRpcElement(to_string(index) + "yoloRpc"), |
| | | faceRpcElement(to_string(index) + "faceRpc"), m_json(json), faceExtractElement(to_string(index) + "faceExtract"), |
| | | triggerElement(25, 4), recordVideoElement(index, json["rtsp"].asString()), bRecordVideoEnable(RecordVideoEnable) { |
| | | init(); |
| | | } |
| | | //AppPipeController::AppPipeController(int index, const Json::Value &json, bool RecordVideoEnable) : |
| | | // videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index"), RecordVideoEnable), |
| | | // m_index(index), fdfsClient(nullptr), yoloRpcElement(to_string(index) + "yoloRpc"), |
| | | // faceRpcElement(to_string(index) + "faceRpc"), m_json(json), faceExtractElement(to_string(index) + "faceExtract"), |
| | | // triggerElement(25, 4), recordVideoElement(index, json["rtsp"].asString()), bRecordVideoEnable(RecordVideoEnable) { |
| | | // init(); |
| | | //} |
| | | |
| | | |
| | | AppPipeController::AppPipeController(std::string camId, const Json::Value &json, bool RecordVideoEnable) : |
| | | videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index")), |
| | | //AppPipeController::AppPipeController(std::string camId, const Json::Value &json, bool RecordVideoEnable) : |
| | | // videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index")), |
| | | // m_index(0), |
| | | // m_camId(camId), |
| | | // fdfsClient(nullptr), |
| | | // yoloRpcElement(camId + "yoloRpc"), |
| | | // faceRpcElement(camId + "faceRpc"), |
| | | // m_json(json), |
| | | // faceExtractElement(camId + "faceExtract"), |
| | | // triggerElement(25, 4), |
| | | // recordVideoElement(camId, json["rtsp"].asString()), |
| | | // newRecordVideoElement(camId), |
| | | // perimeterElement(1), |
| | | // crowdElement(json["crowd.num"].asInt()), |
| | | // bRecordVideoEnable(RecordVideoEnable) |
| | | //{ |
| | | // init(); |
| | | // initPerimeter(); |
| | | // initCrowd(); |
| | | // intKeepRight(); |
| | | //} |
| | | AppPipeController::AppPipeController(std::string camId, const SdkRuleMap &ruleMap, bool RecordVideoEnable) : |
| | | videoCaptureElement(appPref.getStringData(camId + "rtsp"), 25, 3000, appPref.getLongData("gpu.index")), |
| | | m_index(0), |
| | | m_camId(camId), |
| | | fdfsClient(nullptr), |
| | | yoloRpcElement(camId + "yoloRpc"), |
| | | faceRpcElement(camId + "faceRpc"), |
| | | m_json(json), |
| | | faceExtractElement(camId + "faceExtract"), |
| | | // peTriggerElement(json["perimeter.tolerance"].asInt(), json["perimeter.delay"].asInt()), |
| | | // leftTriggerElement(json["keepRight.tolerance"].asInt(), json["keepRight.delay"].asInt()), |
| | | // rightTriggerElement(json["keepRight.tolerance"].asInt(), json["keepRight.delay"].asInt()), |
| | | // crowdTriggerElement(json["crowd.tolerance"].asInt(), json["crowd.delay"].asInt()), |
| | | faceRpcElement(camId + "faceRpc", ruleMap[FaceSdk]), |
| | | faceExtractElement(camId + "faceExtract", ruleMap[FaceSdk]), |
| | | triggerElement(25, 4), |
| | | recordVideoElement(camId, json["rtsp"].asString()), |
| | | recordVideoElement(camId, appPref.getStringData(camId + "rtsp")), |
| | | newRecordVideoElement(camId), |
| | | perimeterElement(1), |
| | | crowdElement(json["crowd.num"].asInt()), |
| | | bRecordVideoEnable(RecordVideoEnable) { |
| | | perimeterElement(ruleMap[PerimeterSdk]), |
| | | crowdElement(ruleMap[CrowdSdk]), |
| | | perStaticElement(ruleMap[PerStaticSdk]), |
| | | perHubElement(ruleMap[PerHubSdk]), |
| | | leftJudgment(ruleMap[KeepRightSdk]), |
| | | rightJudgment(ruleMap[KeepRightSdk]), |
| | | bRecordVideoEnable(RecordVideoEnable), |
| | | m_sdkRuleMap(ruleMap) { |
| | | DBG("camId" << camId); |
| | | init(); |
| | | initPerimeter(); |
| | | initCrowd(); |
| | | intKeepRight(); |
| | | initKeepRight(); |
| | | initPerHub(); |
| | | initPerStatic(); |
| | | } |
| | | |
| | | AppPipeController::~AppPipeController() { |
| | |
| | | faceExtractElement.setProperty("dev_id", str_device_id); |
| | | faceExtractElement.setProperty("ch_id", str_ch_id); |
| | | faceExtractElement.setProperty("path", path); |
| | | yoloRpcElement.setProperty("dev_id", str_device_id); |
| | | yoloRpcElement.setProperty("ch_id", str_ch_id); |
| | | yoloRpcElement.setProperty("path", path); |
| | | personElement.setProperty("dev_id", str_device_id); |
| | | personElement.setProperty("ch_id", str_ch_id); |
| | | personElement.setProperty("path", path); |
| | | |
| | | //ä¿®æ¹æ¶é´ä¸ºå®é
åçæ¶é´ |
| | | QString strPath = QString::fromStdString(path); |
| | |
| | | if (!(GetIpAddress(net_ifname.c_str(), ip_old))) { |
| | | ERR("couldn't get ip"); |
| | | } |
| | | |
| | | m_localIp = std::string((char *) ip_old); |
| | | bUp = false; |
| | | |
| | | yoloRpcElement.setProperty("str_addr", m_json["addr"].asString()); |
| | | yoloRpcElement.setProperty("local_ip", std::string((char *) ip_old)); |
| | | personElement.setProperty("str_addr", m_sdkRuleMap[YoloSdk].strAddr.toStdString()); |
| | | personElement.setProperty("local_ip", std::string((char *) ip_old)); |
| | | |
| | | faceExtractElement.setProperty("str_addr", m_json["addr"].asString()); |
| | | faceExtractElement.setProperty("str_addr", m_sdkRuleMap[FaceSdk].strAddr.toStdString()); |
| | | faceExtractElement.setProperty("local_ip", std::string((char *) ip_old)); |
| | | |
| | | |
| | | if (bRecordVideoEnable) { |
| | | faceExtractElement.setProperty("dev_id", m_camId); |
| | | yoloRpcElement.setProperty("dev_id", m_camId); |
| | | m_json_Record["rtsp"] = m_json["rtsp"].asString(); |
| | | personElement.setProperty("dev_id", m_camId); |
| | | } |
| | | |
| | | |
| | |
| | | std::string strNewTime; |
| | | strNewTime = AppUtil::getTimeUSecString(); |
| | | |
| | | cv::putText(imageTemp, strNewTime, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 5, |
| | | cv::Scalar(255, 255, 0), 2); |
| | | // cv::putText(imageTemp, strNewTime, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 5, |
| | | // cv::Scalar(255, 255, 0), 2); |
| | | if (m_camId.size() > 0) { |
| | | |
| | | |
| | | if (bRecordVideoEnable) { |
| | | // DBG("strNewTime="<<strNewTime<<" camId="<<m_camId); |
| | | newRecordVideoElement.pushImgBuf(strNewTime, imageTemp); |
| | | newRecordVideoElement.setSdkTrigger(faceRpcElement.getTriggerState() ||//TODO |
| | | yoloRpcElement.getTrigger() || |
| | | personElement.getTrigger() || |
| | | leftJudgment.getTriggerState() || |
| | | rightJudgment.getTriggerState() || |
| | | perimeterElement.getTriggerState() || |
| | | crowdElement.getTriggerState()); |
| | | // newRecordVideoElement.submit(); |
| | | crowdElement.getTriggerState() || |
| | | perHubElement.getTriggerState() || |
| | | perStaticElement.getTriggerState() |
| | | ); |
| | | if (!newRecordVideoElement.isBusy()) { |
| | | newRecordVideoElement.submit(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | yoloRpcElement.registerConnector([&] { |
| | | imageDrawElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | imageDrawElement.setYoloObjects(personElement.getLastScoreRects()); |
| | | if (!personElement.isBusy()) { |
| | | |
| | | personElement.setObjsResults(yoloRpcElement.getLastScoreRects()); |
| | | personElement.submit(); |
| | | } |
| | | }); |
| | | |
| | | faceRpcElement.registerConnector([&] { |
| | |
| | | }); |
| | | |
| | | registerElement(videoCaptureElement); |
| | | if (m_json["yolo.enable"].asString() == "1") { |
| | | registerElement(yoloRpcElement); |
| | | if (m_sdkRuleMap[YoloSdk].nIsRun == 1) { |
| | | registerElement(personElement); |
| | | } |
| | | if (m_json["face.enable"].asString() == "1") { |
| | | if (m_sdkRuleMap[FaceSdk].nIsRun == 1) { |
| | | DBG("FaceSdk=" << m_sdkRuleMap[FaceSdk].nIsRun); |
| | | registerElement(faceRpcElement); |
| | | registerElement(faceExtractElement); |
| | | } |
| | | registerElement(imageDrawElement); |
| | | registerElement(newRecordVideoElement); |
| | | videoCaptureElement.setOutPutInterval(3); |
| | | videoCaptureElement.setOutPutInterval(5); |
| | | faceExtractElement.setProperty("index", to_string(m_index)); |
| | | registerElement(yoloRpcElement); |
| | | //#todo setProperty |
| | | // faceExtractElement.setProperty("index", to_string(m_index)); |
| | | // faceExtractElement.setProperty("index", to_string(m_index)); |
| | |
| | | void AppPipeController::setfdfsClient(FastFdsWithLock *p_fdfsClient) { |
| | | fdfsClient = p_fdfsClient; |
| | | faceExtractElement.setFdfs(fdfsClient); |
| | | yoloRpcElement.setFdfs(fdfsClient); |
| | | personElement.setFdfs(fdfsClient); |
| | | perHubElement.setFdfs(fdfsClient); |
| | | perimeterElement.setFdfs(fdfsClient); |
| | | perStaticElement.setFdfs(fdfsClient); |
| | | leftJudgment.setFdfs(fdfsClient); |
| | | rightJudgment.setFdfs(fdfsClient); |
| | | crowdElement.setFdfs(fdfsClient); |
| | | |
| | | } |
| | | |
| | | std::string AppPipeController::getRtmp() { |
| | |
| | | } |
| | | |
| | | void AppPipeController::initPerimeter() { |
| | | if (!m_json["perimeter.enable"] == "1") { |
| | | SdkRule rule = m_sdkRuleMap[PerimeterSdk]; |
| | | if (rule.nIsRun != 1) { |
| | | return; |
| | | } |
| | | std::string area = m_json["perimeter.area"].asString(); |
| | | //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; |
| | | perimeterElement.setMask(area); |
| | | perimeterElement.setFdfs(fdfsClient); |
| | | perimeterElement.setProperty("sdkType", "perimeter"); |
| | | |
| | | |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!perimeterElement.isBusy()) { |
| | | perimeterElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | perimeterElement.setImage(yoloRpcElement.getImage()); |
| | | |
| | | perimeterElement.setObjsResults(yoloRpcElement.getObjects()); |
| | | perimeterElement.submit(); |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | void AppPipeController::initCrowd() { |
| | | if (m_json["crowd.enable"] != "1") { |
| | | SdkRule rule = m_sdkRuleMap[CrowdSdk]; |
| | | if (rule.nIsRun != 1) { |
| | | return; |
| | | } |
| | | std::string area = m_json["crowd.area"].asString(); |
| | | // std::string area = m_json["crowd.area"].asString(); |
| | | //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; |
| | | crowdElement.setMask(area); |
| | | crowdElement.setFdfs(fdfsClient); |
| | | crowdElement.setProperty("sdkType", "crowd"); |
| | | |
| | | crowdElement.setProperty("local_ip", m_localIp); |
| | | |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!crowdElement.isBusy()) { |
| | | crowdElement.setObjsResults(yoloRpcElement.getObjects()); |
| | | crowdElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | crowdElement.setImage(yoloRpcElement.getImage()); |
| | | crowdElement.submit(); |
| | | } |
| | | }); |
| | | // crowdElement.registerConnector([&] { |
| | | // crowdTriggerElement.setState(crowdElement.getRealNum() >= m_json["crowd.num"].asInt()); |
| | | // crowdTriggerElement.triggerOnce(); |
| | | // }); |
| | | // crowdTriggerElement.registerConnector([&] { |
| | | |
| | | // switch (crowdTriggerElement.getTriggerType()) { |
| | | // case UP: |
| | | // //reqRecordMap[SdkType_Perimeter]=true; |
| | | // // startRecord(SdkType_Perimeter); |
| | | // DBG("crowdTriggerElement UP"); |
| | | // break; |
| | | // case DOWN: |
| | | // // reqRecordMap[SdkType_Perimeter]=false; |
| | | // //endRecord(SdkType_Perimeter); |
| | | // DBG("crowdTriggerElement Down"); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // }); |
| | | registerElement(crowdElement); |
| | | // registerElement(crowdTriggerElement); |
| | | } |
| | | |
| | | void AppPipeController::intKeepRight() { |
| | | if (m_json["keepRight.enable"] != "1") { |
| | | void AppPipeController::initKeepRight() { |
| | | SdkRule rule = m_sdkRuleMap[KeepRightSdk]; |
| | | if (rule.nIsRun != 1) { |
| | | return; |
| | | } |
| | | std::string leftArea = m_json["keepRight.leftArea"].asString(); |
| | | std::string leftLine = m_json["keepRight.leftLine"].asString(); |
| | | std::string rightArea = m_json["keepRight.rightArea"].asString(); |
| | | std::string rightLine = m_json["keepRight.rightLine"].asString(); |
| | | leftJudgment.init(QString::fromStdString(leftArea), QString::fromStdString(leftLine)); |
| | | rightJudgment.init(QString::fromStdString(rightArea), QString::fromStdString(rightLine)); |
| | | leftJudgment.setProperty("local_ip", m_localIp); |
| | | rightJudgment.setProperty("local_ip", m_localIp); |
| | | leftJudgment.init(rule.strAreas, rule.strLine); |
| | | rightJudgment.init(rule.strExAreas, rule.strExLine); |
| | | yoloRpcElement.registerConnector([&] { |
| | | leftJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | rightJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | leftJudgment.setImage(yoloRpcElement.getImage()); |
| | | rightJudgment.setImage(yoloRpcElement.getImage()); |
| | | }); |
| | | registerElement(leftJudgment); |
| | | registerElement(rightJudgment); |
| | | |
| | | } |
| | | |
| | | void AppPipeController::initPerStatic() { |
| | | SdkRule rule = m_sdkRuleMap[PerStaticSdk]; |
| | | if (rule.nIsRun != 1) { |
| | | return; |
| | | } |
| | | // std::string area = m_json["crowd.area"].asString(); |
| | | //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; |
| | | |
| | | perStaticElement.setProperty("local_ip", m_localIp); |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!perStaticElement.isBusy()) { |
| | | perStaticElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | perStaticElement.setImage(yoloRpcElement.getImage()); |
| | | perStaticElement.submit(); |
| | | } |
| | | }); |
| | | |
| | | registerElement(perStaticElement); |
| | | } |
| | | |
| | | void AppPipeController::initPerHub() { |
| | | SdkRule rule = m_sdkRuleMap[PerHubSdk]; |
| | | if (rule.nIsRun != 1) { |
| | | return; |
| | | } |
| | | // std::string area = m_json["crowd.area"].asString(); |
| | | //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; |
| | | |
| | | perHubElement.setProperty("local_ip", m_localIp); |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!perHubElement.isBusy()) { |
| | | perHubElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | perHubElement.setImage(yoloRpcElement.getImage()); |
| | | perHubElement.submit(); |
| | | } |
| | | }); |
| | | |
| | | registerElement(perHubElement); |
| | | } |
| | |
| | | #include "PerimeterElement.h" |
| | | #include "JudgmentRetrogradeTool.h" |
| | | #include "NewRecordVideoElement.h" |
| | | #include "PersonElement.h" |
| | | #include "PerStaticElement.h" |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | #include "DBStruct.h" |
| | | |
| | | class AppPipeController : public PipeController { |
| | | public: |
| | |
| | | * @param folderPath 任塿 ¹ç®å½ï¼ç¨äºåå
±äº«å
åid |
| | | * @param json åæ°ä¸ºrtspæµå°å sdkæ¯å¦å¯ç¨çæ è¯ |
| | | */ |
| | | AppPipeController(std::string folderPath, const Json::Value &json); |
| | | // AppPipeController(std::string folderPath, const Json::Value &json); |
| | | AppPipeController(std::string folderPath, const SdkRuleMap& ruleMap); |
| | | |
| | | AppPipeController(int index, const Json::Value &json, bool RecordVideoEnable = false); |
| | | // AppPipeController(int index, const Json::Value &json, bool RecordVideoEnable = false); |
| | | |
| | | AppPipeController(std::string camId, const Json::Value &json, bool RecordVideoEnable); |
| | | // AppPipeController(std::string camId, const Json::Value &json, bool RecordVideoEnable); |
| | | |
| | | AppPipeController(std::string camId, const SdkRuleMap& ruleMap, bool RecordVideoEnable); |
| | | |
| | | virtual ~AppPipeController(); |
| | | |
| | |
| | | |
| | | void setfdfsClient(FastFdsWithLock *p_fdfsClient); |
| | | |
| | | void setWeekRule(const std::map<int, std::vector<LActRuleWeekRecord>>& weekRuleMap); |
| | | private: |
| | | void init(); |
| | | |
| | | private://Perimete |
| | | PerimeterElement perimeterElement; |
| | | // TriggerElement peTriggerElement; |
| | |
| | | // TriggerElement leftTriggerElement; |
| | | // TriggerElement rightTriggerElement; |
| | | |
| | | void intKeepRight(); |
| | | void initKeepRight(); |
| | | |
| | | private: |
| | | PerStaticElement perStaticElement; |
| | | void initPerStatic(); |
| | | private://Perimete |
| | | PerimeterElement perHubElement; |
| | | // TriggerElement peTriggerElement; |
| | | |
| | | void initPerHub(); |
| | | private: |
| | | ffmpeg::VideoCaptureElement videoCaptureElement; |
| | | YoloRpcElement yoloRpcElement; |
| | |
| | | ImageDrawElement imageDrawElement; |
| | | RecordVideoElement recordVideoElement; |
| | | NewRecordVideoElement newRecordVideoElement; |
| | | PersonElement personElement; |
| | | |
| | | int m_index; |
| | | std::string m_camId; |
| | |
| | | |
| | | QDateTime m_dt; |
| | | |
| | | std::map<int, std::vector<LActRuleWeekRecord>> m_weekRuleMap; |
| | | SdkRuleMap m_sdkRuleMap; |
| | | std::string m_localIp; |
| | | std::string getFullFileName(); |
| | | |
| | | }; |
| | |
| | | json["face.enable"] = "1"; |
| | | json["yolo.enable"] = "1"; |
| | | |
| | | AppPipeController appPipeController(0, json); |
| | | appPipeController.resetVideoCapturePath( |
| | | "/home/bsk/development/c++/Qt/QiaoJiaSystem/build/load/123456/33/201808/27/123456-33-201808-20180827093100/2018-08-27 09:31:00.mp4"); |
| | | appPipeController.start(); |
| | | getchar(); |
| | | appPipeController.stop(); |
| | | appPipeController.wait(); |
| | | // AppPipeController appPipeController(0, json); |
| | | // appPipeController.resetVideoCapturePath( |
| | | // "/home/bsk/development/c++/Qt/QiaoJiaSystem/build/load/123456/33/201808/27/123456-33-201808-20180827093100/2018-08-27 09:31:00.mp4"); |
| | | // appPipeController.start(); |
| | | // getchar(); |
| | | // appPipeController.stop(); |
| | | // appPipeController.wait(); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | cout << postResponseStr << endl; |
| | | // system("pause"); |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | |
| | | SET(SOURCES |
| | | |
| | | |
| | | # HiredisTool.cpp |
| | | NewRecordVideoElement.cpp |
| | | JudgmentRetrogradeTool.cpp |
| | | PerimeterElement.cpp |
| | | NewEncodeVideoManager.cpp |
| | | NewEncodeVideo.cpp |
| | | HiredisTool.cpp |
| | | PersonElement.cpp |
| | | PerStaticElement.cpp |
| | | |
| | | TrackingTrigger.cpp |
| | | FaceRpcElement.cpp |
| | |
| | | ../../../BasicPlatForm/basic/db/Elasticsearch/EsDBTool.cpp |
| | | ../../../BasicPlatForm/basic/util/curl/HttpRequestWithCrul.hpp |
| | | ../../../BasicPlatForm/basic/util/net_config/net_config.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | ) |
| | | |
| | | SET(LIBS |
| | |
| | | /usr/include/x86_64-linux-gnu/qt5/QtCore |
| | | |
| | | ../../BasicPlatForm/libs/hiredis-master/include |
| | | ../VideoServer/QiaoJia/DB |
| | | ) |
| | | |
| | | link_directories( |
| | |
| | | } |
| | | } |
| | | |
| | | FaceExtractElement::FaceExtractElement(std::string shareMemoryName) : |
| | | FaceExtractElement::FaceExtractElement(std::string shareMemoryName, const SdkRule &rule) : |
| | | TimerElement(1000), sharedMemory(nullptr), fdfsClient(nullptr), |
| | | //#todo appPref.setStringData |
| | | faceExtractRpcClient(appPref.getStringData("faceExte.proxy"), appPref.getStringData("faceExte.ip"), |
| | |
| | | // faceExtractRpcClient(/*appPref.getStringData("face.extract.proxy")*/ |
| | | // "faceExtractServer", "", 10008, "tcp"),//人è¸ç¹å¾æå ä¿®æ¹æç¹å¯¹ç¹é讯 |
| | | faceSearchRpcClient(appPref.getStringData("faceSear.proxy"), appPref.getStringData("faceSear.ip"), |
| | | appPref.getIntData("faceSear.port"), "tcp") |
| | | appPref.getIntData("faceSear.port"), "tcp"), |
| | | // faceSearchRpcClient("faceCmServer", "", 10004, "tcp") |
| | | { |
| | | m_sdkRule(rule) { |
| | | sharedMemory = new QSharedMemory(QString(shareMemoryName.c_str())); |
| | | if (!sharedMemory->create(4608 * 2592 * 4)) { |
| | | sharedMemory->attach(); |
| | |
| | | try { |
| | | |
| | | string t_camIdex = getProperty("dev_id") + getProperty("ch_id"); |
| | | float t_com_sc = |
| | | appPref.getFloatData(t_camIdex + "face.cmp") == -1 ? 75 : appPref.getFloatData(t_camIdex + "face.cmp"); |
| | | float t_com_sc = m_sdkRule.nThreshold == 0 ? 75 : m_sdkRule.nThreshold; |
| | | |
| | | |
| | | DBG(" TESTCODE getValue" << t_camIdex << " " << t_com_sc << " " << t_com_sc / 100); |
| | | |
| | |
| | | t_json["picSmUrl"] = strImgUrl;//人åæå°å¾ |
| | | //#todo |
| | | t_json["picDate"] = faceExtractQueueTmp[i].scoredRects[j].properties["time"]; |
| | | DBG("picDate=" << t_json["picDate"].asString()); |
| | | // DBG("timeC ::::B" << t_json["picDate"].asString()); |
| | | // t_json["picDate"] = AppUtil::getTimeSecString(); |
| | | |
| | |
| | | #include <queue> |
| | | #include <mutex> |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | #include "DBStruct.h" |
| | | #define VECTOR_MAX 50 |
| | | |
| | | class QSharedMemory; |
| | |
| | | |
| | | class FaceExtractElement : public TimerElement { |
| | | public: |
| | | FaceExtractElement(std::string shareMemoryName); |
| | | FaceExtractElement(std::string shareMemoryName,const SdkRule& rule); |
| | | |
| | | ~FaceExtractElement(); |
| | | |
| | |
| | | std::vector<::FaceDetect::Data> features; |
| | | |
| | | Base64 base64; |
| | | SdkRule m_sdkRule; |
| | | }; |
| | | |
| | | |
| | |
| | | #include <QtCore/QString> |
| | | #include <basic/timer_counter/Clocktimer.h> |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | |
| | | #include <QJsonDocument> |
| | | #include <QJsonObject> |
| | | #define GETSCORE(IDENT) appPref.getFloatData(IDENT) == -1 ? 95 : appPref.getFloatData(IDENT); |
| | | |
| | | //************************************ |
| | |
| | | } |
| | | |
| | | //todo appPref.getStringData("face.detect.proxy") |
| | | FaceRpcElement::FaceRpcElement(string shareMemoryName) : |
| | | FaceRpcElement::FaceRpcElement(string shareMemoryName,const SdkRule& rule) : |
| | | //#todo |
| | | rpcClient(appPref.getStringData("faceDete.proxy"), appPref.getStringData("faceDete.ip"), |
| | | appPref.getIntData("faceDete.port"), "tcp"), m_triggerElement(0, 0), |
| | | appPref.getIntData("faceDete.port"), "tcp"), |
| | | m_triggerElement(0, 0), |
| | | // rpcClient("faceServer","",10002,"tcp"), |
| | | sharedMemory(nullptr), trackingTrigger(nullptr) { |
| | | sharedMemory(nullptr), |
| | | trackingTrigger(nullptr), |
| | | m_sdkRule(rule) |
| | | { |
| | | sharedMemory = new QSharedMemory(QString(shareMemoryName.c_str())); |
| | | if (!sharedMemory->create(4608 * 2592 * 4)) { |
| | | sharedMemory->attach(); |
| | |
| | | t_camIdex = shareMemoryName.substr(0, shareMemoryName.rfind("faceRpc")); |
| | | } |
| | | |
| | | float t_score = GETSCORE(t_camIdex + "face.det"); |
| | | float t_score = m_sdkRule.nQuality; |
| | | |
| | | DBG(" TESTCODE getValue" << t_camIdex << " " << t_score << " " << t_score / 100); |
| | | |
| | | t_score = t_score / 100; |
| | | |
| | | trackingTrigger = new TrackingTrigger(t_score); |
| | | setMask(m_sdkRule.strAreas.toStdString()); |
| | | } |
| | | |
| | | FaceRpcElement::~FaceRpcElement() { |
| | |
| | | // string string1(AppUtil::getTimeString() + "-ff2" + getProperty("time") + ".jpg"); |
| | | // cv::imwrite(string1, image); |
| | | // } |
| | | if(!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | triggerMats.clear(); |
| | | triggerFaces.clear(); |
| | | triggerScoredRects.clear(); |
| | |
| | | if (!server) ERR("server is null"); |
| | | faces = server->faceDetect(image.cols, image.rows, sharedMemory->key().toStdString()); |
| | | // DBG("faces.size " << faces.size()); |
| | | |
| | | for (auto face: faces) { |
| | | ::FaceDetect::RECT &rect = face.rcFace; |
| | | ScoredRect scoredRect; |
| | |
| | | int y = face.rcFace.top; |
| | | int w = face.rcFace.right - face.rcFace.left; |
| | | int h = face.rcFace.bottom - face.rcFace.top; |
| | | QRect re(x,y,w,h); |
| | | QPoint center = re.center(); |
| | | if(!mPolygon.containsPoint(center,Qt::OddEvenFill)) |
| | | { |
| | | return; |
| | | } |
| | | scoredRect.rect = {x, y, w, h}; |
| | | scoredRect.score = (float) face.fAngle.confidence; |
| | | |
| | |
| | | bool FaceRpcElement::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | | void FaceRpcElement::setMask(std::string mask) |
| | | { |
| | | QJsonArray arrayAreas = getJsonArrayFromQString(QString::fromStdString(mask)); |
| | | if(arrayAreas.isEmpty()) |
| | | { |
| | | return;//do not detect |
| | | } |
| | | for(int i = 0;i < arrayAreas.size();++i) |
| | | { |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toDouble()*4; |
| | | int y = obj.value("y").toDouble()*4; |
| | | mPolygon<<(QPoint(x,y)); |
| | | |
| | | } |
| | | } |
| | | QJsonArray FaceRpcElement::getJsonArrayFromQString(const QString& strJson) |
| | | { |
| | | QJsonDocument jsonDocument = QJsonDocument::fromJson(strJson.toLocal8Bit()); |
| | | if( jsonDocument.isNull() ){ |
| | | DBG("please check the string"<< strJson.toStdString()); |
| | | return QJsonArray(); |
| | | } |
| | | QJsonArray jsonArray = jsonDocument.array(); |
| | | return jsonArray; |
| | | } |
| | | bool FaceRpcElement::isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek) |
| | | { |
| | | |
| | | int nWeek = QDate::currentDate().dayOfWeek(); |
| | | for(int i = 0;i < ruleWeek.size();++i) |
| | | { |
| | | if(ruleWeek[i].m_nType == nWeek) |
| | | { |
| | | QString strCurrent = QDateTime::currentDateTime().toString("hh:mm"); |
| | | if(strCurrent >= ruleWeek[i].m_strBegin && strCurrent <= ruleWeek[i].m_strEnd) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | |
| | | #include <opencv2/opencv.hpp> |
| | | #include <RapidStructureApp/TriggerElement.h> |
| | | #include "TrackingTrigger.h" |
| | | |
| | | #include "DBStruct.h" |
| | | #include <QtGui/QPolygon> |
| | | #include <QJsonArray> |
| | | class QSharedMemory; |
| | | |
| | | class FaceRpcElement : public basic::PipeElement { |
| | | public: |
| | | FaceRpcElement(string); |
| | | FaceRpcElement(string,const SdkRule& rule); |
| | | |
| | | ~FaceRpcElement(); |
| | | |
| | |
| | | |
| | | cv::Mat getImage() const; |
| | | |
| | | |
| | | private: |
| | | virtual void threadFunc() override; |
| | | |
| | | void setMask(std::string mask); |
| | | QJsonArray getJsonArrayFromQString(const QString& strJson); |
| | | bool isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek); |
| | | private: |
| | | IceRpcClient<FaceDetect::FaceDetectServerPrx> rpcClient; |
| | | cv::Mat image; |
| | |
| | | ::FaceDetect::Faces triggerFaces; |
| | | std::vector<cv::Mat> triggerMats; |
| | | std::vector<ScoredRect> triggerScoredRects; |
| | | |
| | | QPolygon mPolygon; |
| | | TriggerElement m_triggerElement; |
| | | SdkRule m_sdkRule; |
| | | }; |
| | | |
| | | #endif // FACERPCELEMENT_H |
| | |
| | | // |
| | | // Created by basic on 18-8-24. |
| | | // |
| | | |
| | | #include "JudgmentRetrogradeTool.h" |
| | | #include <basic/util/opencv/CvMath.hpp> |
| | | #include <QtCore/QDebug> |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | #include <uuid/uuid.h> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | |
| | | JudgmentRetrogradeTool::JudgmentRetrogradeTool(): |
| | | TimerElement(1000), |
| | | m_triggerElement(0,50) |
| | | { |
| | | |
| | | JudgmentRetrogradeTool::JudgmentRetrogradeTool(const SdkRule &rule) : |
| | | TimerElement(1000), |
| | | m_triggerElement(0, rule.nTriggerDelay * 1000 * 1000), |
| | | m_sdkRule(rule), |
| | | pManagerEsDB(nullptr) { |
| | | pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | } |
| | | |
| | | JudgmentRetrogradeTool::~JudgmentRetrogradeTool() { |
| | | |
| | | if (pManagerEsDB) { |
| | | delete pManagerEsDB; |
| | | pManagerEsDB = nullptr; |
| | | } |
| | | } |
| | | |
| | | bool JudgmentRetrogradeTool::init(QString area,QString line) { |
| | | bool JudgmentRetrogradeTool::init(QString area, QString line) { |
| | | |
| | | //#todo string ->json |
| | | QJsonArray arrayAreas = getJsonArrayFromQString(area); |
| | | if(arrayAreas.isEmpty()) |
| | | { |
| | | if (arrayAreas.isEmpty()) { |
| | | return false;//do not detect |
| | | } |
| | | QVector<QPoint> vec; |
| | | for(int i = 0;i < arrayAreas.size();++i){ |
| | | for (int i = 0; i < arrayAreas.size(); ++i) { |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toInt()*2 ; |
| | | int y = obj.value("y").toInt()*2 ; |
| | | vec.push_back(QPoint(x,y)); |
| | | int x = obj.value("x").toDouble() * 4; |
| | | int y = obj.value("y").toDouble() * 4; |
| | | vec.push_back(QPoint(x, y)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | cv::Point start, end; |
| | | QJsonArray arrayLine = getJsonArrayFromQString(line); |
| | | if(arrayLine.size() == 2){ |
| | | if (arrayLine.size() == 2) { |
| | | QJsonValue jsonValue = arrayLine[0]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | start.x = obj.value("x").toInt() ; |
| | | start.y = obj.value("y").toInt() ; |
| | | start.x = obj.value("x").toDouble(); |
| | | start.y = obj.value("y").toDouble(); |
| | | |
| | | |
| | | QJsonValue jsonValue2 = arrayLine[1]; |
| | | QJsonObject obj2 = jsonValue2.toObject(); |
| | | end.x = obj2.value("x").toInt() ; |
| | | end.y = obj2.value("y").toInt() ; |
| | | end.x = obj2.value("x").toDouble(); |
| | | end.y = obj2.value("y").toDouble(); |
| | | |
| | | }else{ |
| | | } else { |
| | | return false; |
| | | } |
| | | setUpBaseline(start,end); |
| | | setUpBaseline(start, end); |
| | | |
| | | //setDownBaseline(start,end); |
| | | // setUpBaseline(); |
| | |
| | | return true; |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::setYoloObjects(std::vector<ScoredRect> value) |
| | | { |
| | | mObjs=value; |
| | | for(auto & item :value){ |
| | | setPerRect(item.id,item.rect); |
| | | void JudgmentRetrogradeTool::setYoloObjects(std::vector<ScoredRect> value) { |
| | | if (!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | mObjs = value; |
| | | for (auto &item :value) { |
| | | if (item.score < m_sdkRule.fSensitivity)continue; |
| | | |
| | | setPerRect(item.id, item.rect); |
| | | } |
| | | } |
| | | |
| | | |
| | | void JudgmentRetrogradeTool::setPerRect(const long& id,cv::Rect rect){ |
| | | setPerPoint(id,getCenterPoint(rect)); |
| | | void JudgmentRetrogradeTool::setPerRect(const long &id, cv::Rect rect) { |
| | | setPerPoint(id, getCenterPoint(rect)); |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::setPerPoint(const long &id, cv::Point2f result) { |
| | |
| | | tt.end_Point = listCache.back(); |
| | | auto &temp = m_mapPerDirection[id]; |
| | | //#TODO tt.end_Point in UP Area |
| | | QPoint center(tt.end_Point.x,tt.end_Point.y); |
| | | if(m_polygon.containsPoint(center,Qt::OddEvenFill)){ |
| | | QPoint center(tt.end_Point.x, tt.end_Point.y); |
| | | if (m_polygon.containsPoint(center, Qt::OddEvenFill)) { |
| | | temp.push_back(JRTOOL::low_filter(temp.back(), getTheta(m_UpBaseLine, tt))); |
| | | //DBG("ID="<<id<<" left getTheta="<<getTheta(m_DownBaseLine, tt)); |
| | | } |
| | | else |
| | | { |
| | | //DBG("ID="<<id<<" left getTheta="<<getTheta(m_DownBaseLine, tt)); |
| | | } else { |
| | | temp.clear(); |
| | | } |
| | | listCache.clear(); |
| | |
| | | return JRTOOL::getAngelOfTwoVector(directionVectorPoint, point); |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::timerFunc() |
| | | { |
| | | void JudgmentRetrogradeTool::timerFunc() { |
| | | func(); |
| | | fireConnectors(); |
| | | } |
| | |
| | | a++; |
| | | } |
| | | } |
| | | // DBG("id="<<item.first<<" a="<<a<<" b="<<b); |
| | | // DBG("id="<<item.first<<" a="<<a<<" b="<<b); |
| | | bool ret = a >= b ? true : false; |
| | | m_mapPerRet[item.first] = ret; |
| | | if (!ret) { |
| | | m_mapPerRet.insert(std::make_pair(item.first, false)); |
| | | // m_mapPerRet[item.first] = false; |
| | | |
| | | } |
| | | |
| | | |
| | | if (temp.size() > 9) { |
| | | temp.pop_front(); |
| | | } |
| | |
| | | for (auto scoredRect:mObjs) { |
| | | if (!getPerRet(scoredRect.id))//judgment.bool |
| | | { |
| | | DBG("scoredRect.id" << scoredRect.id << " val=" << m_mapPerRet[scoredRect.id]); |
| | | m_mapPerRet[scoredRect.id] = true; |
| | | |
| | | m_triggerElement.setState(true); |
| | | auto t_image = image( |
| | | CvUtil::zoomRectEqual(scoredRect.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // auto t_image = image(scoredRect.rect& cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl, scoredRect); |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | m_triggerElement.setState(false); |
| | | |
| | | } |
| | |
| | | m_triggerElement.triggerOnce(); |
| | | } |
| | | |
| | | QJsonArray JudgmentRetrogradeTool::getJsonArrayFromQString(const QString strJson) |
| | | { |
| | | std::string JudgmentRetrogradeTool::uploadImgToFdfs(cv::Mat &image) { |
| | | std::string strImgUrl = "http://"; |
| | | if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) { |
| | | fdfsClient->rwLock.rdlock(); |
| | | std::vector<unsigned char> buffer; |
| | | CvUtil::cvMat2Buffer(image, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | | fdfsClient->rwLock.unlock(); |
| | | } |
| | | return strImgUrl; |
| | | } |
| | | |
| | | bool JudgmentRetrogradeTool::saveInfoToEs(const std::string &imgUrl, const ScoredRect &obj) { |
| | | |
| | | |
| | | string str_uuid; |
| | | uuid_t t_uuid; |
| | | char str[36]; |
| | | uuid_generate(t_uuid); |
| | | uuid_unparse(t_uuid, str); |
| | | str_uuid = str; |
| | | |
| | | |
| | | Json::Value t_json; |
| | | t_json["Id"] = str_uuid; //ä¸»é® |
| | | //#todo |
| | | |
| | | t_json["videoReqNum"] = m_sdkRule.strCamId.toStdString(); |
| | | t_json["sdkType"] = to_string(m_sdkRule.nSdkType); |
| | | // t_json["Gender"] = obj.score; |
| | | |
| | | t_json["picName"] = "wait todo";// ææç
§çåç§° |
| | | t_json["content"] = "wait todo";// å
容æè¿° |
| | | t_json["personPicUrl"] = "";// 人å å°åºå¾ç |
| | | t_json["ChannlId"] = getProperty("ch_id"); // ééid |
| | | t_json["likeDate"] = AppUtil::getTimeSecString(); // æ¯å¯¹æ¶é´ |
| | | t_json["picAddress"] = getProperty("str_addr");// ææå°å |
| | | t_json["picMaxUrl"] = "wait todo"; // 大å¾è·¯å¾ |
| | | |
| | | |
| | | // t_json["Age"] ="wait todo"; |
| | | t_json["picDate"] = obj.properties["time"]; // æææ¶é´ï¼å¿
é¡»æ |
| | | t_json["picLocalUrl"] = "wait todo"; // æ¬å°è·¯å¾ |
| | | t_json["isDelete"] = "1";//é»è®¤1 ,0æ æ 1ææ |
| | | |
| | | t_json["likePer"] = obj.score; // ç¸ä¼¼å¼ |
| | | |
| | | t_json["BaseName"] = "wait todo";// å°åºåç§° |
| | | |
| | | t_json["videoNum"] = m_sdkRule.strCamId.toStdString();//Video设å¤ç¼å· |
| | | t_json["picSmUrl"] = imgUrl; // ææå¾ç |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID");;// 设å¤id |
| | | t_json["idcard"] = "wait todo"; |
| | | t_json["personId"] = "wait todo"; |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME");// 设å¤åç§° |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personIsHub"] = m_triggerElement.getTriggerState() ? "1" : "4"; //1: æ¥è¦ 2: å¯ç 3: å®å
¨ 4: æªç¥ |
| | | t_json["videoIp"] = getProperty("local_ip");//å½åæå¡å¨IPå°å |
| | | t_json["ack_alarm"] = m_triggerElement.getTriggerState() ? "0" : ""; // que ren shi fou bao jing |
| | | t_json["cluster_id"] = "wait todo"; // ji qun id |
| | | |
| | | bool retface = false; |
| | | if (pManagerEsDB) |
| | | retface = pManagerEsDB->insertData("personaction", "perVideoAction", t_json.toStyledString(), str_uuid); |
| | | |
| | | if (retface) { |
| | | INFO("perVideoAction db success"); |
| | | } else { |
| | | ERR("personaction db fail"); |
| | | } |
| | | } |
| | | |
| | | bool JudgmentRetrogradeTool::isInWeek(const std::vector<LActRuleWeekRecord> &ruleWeek) { |
| | | |
| | | int nWeek = QDate::currentDate().dayOfWeek(); |
| | | for (int i = 0; i < ruleWeek.size(); ++i) { |
| | | if (ruleWeek[i].m_nType == nWeek) { |
| | | QString strCurrent = QDateTime::currentDateTime().toString("hh:mm"); |
| | | if (strCurrent >= ruleWeek[i].m_strBegin && strCurrent <= ruleWeek[i].m_strEnd) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | QJsonArray JudgmentRetrogradeTool::getJsonArrayFromQString(const QString strJson) { |
| | | QJsonDocument jsonDocument = QJsonDocument::fromJson(strJson.toLocal8Bit()); |
| | | if( jsonDocument.isNull() ){ |
| | | qDebug()<< "please check the string"<< strJson.toLocal8Bit(); |
| | | if (jsonDocument.isNull()) { |
| | | qDebug() << "please check the string" << strJson.toLocal8Bit(); |
| | | return QJsonArray(); |
| | | } |
| | | QJsonArray jsonArray = jsonDocument.array(); |
| | | return jsonArray; |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::setUpDetectionArea() |
| | | { |
| | | void JudgmentRetrogradeTool::setUpDetectionArea() { |
| | | |
| | | } |
| | | void JudgmentRetrogradeTool::setDownDetectionArea() |
| | | { |
| | | |
| | | void JudgmentRetrogradeTool::setDownDetectionArea() { |
| | | |
| | | } |
| | | |
| | | bool JudgmentRetrogradeTool::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | | |
| | | void JudgmentRetrogradeTool::setImage(const cv::Mat &value) { |
| | | value.copyTo(image); |
| | | } |
| | |
| | | #include <QJsonObject> |
| | | #include <QJsonDocument> |
| | | #include <QtGui/QPolygon> |
| | | #include "DBStruct.h" |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | struct VectorPoint{ |
| | | struct VectorPoint { |
| | | cv::Point2f start_Point; |
| | | cv::Point2f end_Point; |
| | | }; |
| | | |
| | | typedef VectorPoint BaseLine; |
| | | namespace JRTOOL{ |
| | | namespace JRTOOL { |
| | | //以pt1为åºå |
| | | //计ç®ä¸¤ä¸ªåéç夹è§,0~90ä¹é´ä¸ºæ£å¸¸,90~180为éè¡ |
| | | static float getAngelOfTwoVector(VectorPoint &pt1, VectorPoint &pt2){ |
| | | float theta = atan2(pt1.end_Point.x - pt1.start_Point.x, pt1.end_Point.y - pt1.start_Point.y) |
| | | - atan2(pt2.end_Point.x - pt2.start_Point.x, pt2.end_Point.y - pt2.start_Point.y); |
| | | if (theta > CV_PI) |
| | | theta -= 2 * CV_PI; |
| | | if (theta < -CV_PI) |
| | | theta += 2 * CV_PI; |
| | | theta = theta * 180.0 / CV_PI; |
| | | return abs(theta); |
| | | } |
| | | static float getAngelOfTwoVector(VectorPoint &pt1, VectorPoint &pt2) { |
| | | float theta = atan2(pt1.end_Point.x - pt1.start_Point.x, pt1.end_Point.y - pt1.start_Point.y) |
| | | - atan2(pt2.end_Point.x - pt2.start_Point.x, pt2.end_Point.y - pt2.start_Point.y); |
| | | if (theta > CV_PI) |
| | | theta -= 2 * CV_PI; |
| | | if (theta < -CV_PI) |
| | | theta += 2 * CV_PI; |
| | | theta = theta * 180.0 / CV_PI; |
| | | return abs(theta); |
| | | } |
| | | |
| | | //滤波 |
| | | static float low_filter(float a, float b){ |
| | | float sample_value; |
| | | float X=0.1; |
| | | sample_value=(1-X)*b+X*a; |
| | | return(sample_value); |
| | | } |
| | | static float low_filter(float a, float b) { |
| | | float sample_value; |
| | | float X = 0.1; |
| | | sample_value = (1 - X) * b + X * a; |
| | | return (sample_value); |
| | | } |
| | | } |
| | | |
| | | |
| | | class JudgmentRetrogradeTool :public TimerElement { |
| | | class JudgmentRetrogradeTool : public TimerElement { |
| | | public: |
| | | JudgmentRetrogradeTool(); |
| | | JudgmentRetrogradeTool() : TimerElement(1000) {} |
| | | |
| | | JudgmentRetrogradeTool(const SdkRule &rule); |
| | | |
| | | virtual ~JudgmentRetrogradeTool(); |
| | | |
| | | bool init(QString area,QString line); |
| | | bool init(QString area, QString line); |
| | | |
| | | void setYoloObjects(std::vector<ScoredRect> value); |
| | | |
| | | bool getPerRet(const long&); |
| | | bool getPerRet(const long &); |
| | | |
| | | bool getTriggerState() const; |
| | | bool getTriggerState() const; |
| | | |
| | | void setFdfs(FastFdsWithLock *p_fdfsClient) { |
| | | fdfsClient = p_fdfsClient; |
| | | } |
| | | |
| | | void setImage(const cv::Mat &value); |
| | | |
| | | private: |
| | | void setPerPoint(const long&,cv::Point2f); |
| | | void setPerRect(const long&,cv::Rect rect); |
| | | void setPerPoint(const long &, cv::Point2f); |
| | | |
| | | void setPerRect(const long &, cv::Rect rect); |
| | | |
| | | //设置ä¸è¡çè¿å¨åºå线 |
| | | void setUpBaseline(cv::Point start,cv::Point end); |
| | | void setUpBaseline(cv::Point start, cv::Point end); |
| | | |
| | | //设置ä¸è¡æ£æµåºå |
| | | void setUpDetectionArea(); |
| | | |
| | | //设置ä¸è¡çè¿å¨åºå线 |
| | | void setDownBaseline(cv::Point start,cv::Point end); |
| | | void setDownBaseline(cv::Point start, cv::Point end); |
| | | |
| | | //设置ä¸è¡æ£æµåºå |
| | | void setDownDetectionArea(); |
| | |
| | | |
| | | void func(); |
| | | |
| | | float getTheta(BaseLine&,VectorPoint&); |
| | | float getTheta(BaseLine &, VectorPoint &); |
| | | |
| | | QJsonArray getJsonArrayFromQString(const QString strJson); |
| | | |
| | | std::string uploadImgToFdfs(cv::Mat &image); |
| | | |
| | | bool saveInfoToEs(const std::string &imgUrl, const ScoredRect &obj); |
| | | |
| | | bool isInWeek(const std::vector<LActRuleWeekRecord> &ruleWeek); |
| | | |
| | | private: |
| | | // virtual void threadInitial() override; |
| | | virtual void timerFunc()override; |
| | | virtual void timerFunc() override; |
| | | // virtual void threadClosing()override; |
| | | |
| | | private: |
| | |
| | | |
| | | //人åè¿å¨è½¨è¿¹ |
| | | //è·è¸ªid,è¿å¨ä¸å¿ç¹ |
| | | std::map<long,std::vector<cv::Point2f>> m_mapPerPoint; |
| | | std::map<long, std::vector<cv::Point2f>> m_mapPerPoint; |
| | | |
| | | //è·è¸ªid,ä¸åºå线ç夹è§å表 |
| | | std::map<long,std::list<float>> m_mapPerDirection; |
| | | std::map<long, std::list<float>> m_mapPerDirection; |
| | | |
| | | //è·è¸ªid,éè¡ç¶æ |
| | | std::map<long,bool> m_mapPerRet; |
| | | std::map<long, bool> m_mapPerRet; |
| | | |
| | | QPolygon m_polygon; |
| | | |
| | | TriggerElement m_triggerElement; |
| | | |
| | | std::vector<ScoredRect> mObjs; |
| | | |
| | | const SdkRule m_sdkRule; |
| | | |
| | | FastFdsWithLock *fdfsClient; |
| | | |
| | | cv::Mat image; |
| | | EsDBTool *pManagerEsDB; |
| | | }; |
| | | |
| | | |
New file |
| | |
| | | #include "PerStaticElement.h" |
| | | #include <basic/debug/Debug.h> |
| | | #include <iostream> |
| | | #include <opencv2/opencv.hpp> |
| | | #include <basic/timer_counter/Clocktimer.h> |
| | | #include <QJsonDocument> |
| | | #include <QJsonObject> |
| | | #include <QString> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | #include <uuid/uuid.h> |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | PerStaticElement::PerStaticElement(const SdkRule& rule): |
| | | PipeElement(true), |
| | | m_sdkRule(rule), |
| | | m_triggerElement(0,0), |
| | | m_lTime(AppUtil::getCurrentUs()), |
| | | pManagerEsDB(nullptr) |
| | | { |
| | | pManagerEsDB=new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | |
| | | } |
| | | |
| | | PerStaticElement::~PerStaticElement() |
| | | { |
| | | if(pManagerEsDB) |
| | | { |
| | | delete pManagerEsDB; |
| | | pManagerEsDB=nullptr; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | void PerStaticElement::threadInitial() |
| | | { |
| | | setMask(m_sdkRule.strAreas.toStdString()); |
| | | } |
| | | |
| | | |
| | | void PerStaticElement::threadFunc() |
| | | { |
| | | |
| | | if(!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | int num=0; |
| | | |
| | | |
| | | for(auto obj:mObjs) |
| | | { |
| | | |
| | | if(obj.score < m_sdkRule.fSensitivity)continue; |
| | | |
| | | QRect rect(obj.rect.x,obj.rect.y,obj.rect.width,obj.rect.height); |
| | | QPoint center = rect.center(); |
| | | if(mPolygon.containsPoint(center,Qt::OddEvenFill)) |
| | | { |
| | | for(auto score:m_lastScoreRect) |
| | | { |
| | | if(obj.id == score.id) |
| | | { |
| | | obj.isMove = score.isMove; |
| | | //DBG("moving? "<<_TrackingInfo.m_bMoveState) |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | if((AppUtil::getCurrentUs()-m_lTime)>(m_sdkRule.nTriggerDelay*60*1000*1000)) |
| | | { |
| | | for(auto& obj: mObjs){ |
| | | |
| | | //compare with last temp memery and clear temp memery |
| | | for(auto ele:m_lastScoreRect) |
| | | { |
| | | if(ele.id==obj.id) |
| | | { |
| | | if((obj.rect&ele.rect).area()>ele.rect.area()*0.8) |
| | | { |
| | | //not moving |
| | | obj.isMove = true; |
| | | |
| | | auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl=uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl,obj); |
| | | m_triggerElement.setState(true); |
| | | //DBG("not moving") |
| | | } |
| | | else |
| | | { |
| | | obj.isMove = false; |
| | | m_triggerElement.setState(false); |
| | | //DBG("moving") |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | //do temp memery |
| | | |
| | | } |
| | | m_lastScoreRect = mObjs; |
| | | m_lTime =AppUtil::getCurrentUs(); |
| | | } |
| | | m_lastScoreRect=mObjs; |
| | | m_triggerElement.triggerOnce(); |
| | | |
| | | |
| | | fireConnectors(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //void PerimeterElement::setSensitivity(float value) |
| | | //{ |
| | | // sensitivity = value; |
| | | //} |
| | | |
| | | |
| | | |
| | | void PerStaticElement::setObjsResults(const YoloDetect::ObjInfos &value) |
| | | { |
| | | m_objs = value; |
| | | } |
| | | |
| | | std::vector<ScoredRect> PerStaticElement::getLastScoreRects() const { |
| | | return trackingTrigger->getLastScoreRects(); |
| | | } |
| | | |
| | | void PerStaticElement::setYoloObjects(std::vector<ScoredRect> value) |
| | | { |
| | | mObjs=value; |
| | | } |
| | | |
| | | |
| | | void PerStaticElement::setMask(std::string mask) |
| | | { |
| | | QJsonArray arrayAreas = getJsonArrayFromQString(QString::fromStdString(mask)); |
| | | if(arrayAreas.isEmpty()) |
| | | { |
| | | return;//do not detect |
| | | } |
| | | for(int i = 0;i < arrayAreas.size();++i) |
| | | { |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toDouble()*4; |
| | | int y = obj.value("y").toDouble()*4; |
| | | mPolygon<<(QPoint(x,y)); |
| | | |
| | | } |
| | | } |
| | | QJsonArray PerStaticElement::getJsonArrayFromQString(const QString& strJson) |
| | | { |
| | | QJsonDocument jsonDocument = QJsonDocument::fromJson(strJson.toLocal8Bit()); |
| | | if( jsonDocument.isNull() ){ |
| | | //DBG("please check the string"<< strJson.toLocal8Bit()); |
| | | return QJsonArray(); |
| | | } |
| | | QJsonArray jsonArray = jsonDocument.array(); |
| | | return jsonArray; |
| | | } |
| | | |
| | | |
| | | bool PerStaticElement::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | | std::string PerStaticElement::uploadImgToFdfs(cv::Mat& image) |
| | | { |
| | | std::string strImgUrl = "http://"; |
| | | if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) { |
| | | fdfsClient->rwLock.rdlock(); |
| | | std::vector<unsigned char> buffer; |
| | | CvUtil::cvMat2Buffer(image, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | | fdfsClient->rwLock.unlock(); |
| | | } |
| | | return strImgUrl; |
| | | } |
| | | bool PerStaticElement::saveInfoToEs(const std::string& imgUrl,const ScoredRect& obj) |
| | | { |
| | | |
| | | |
| | | string str_uuid; |
| | | uuid_t t_uuid; |
| | | char str[36]; |
| | | uuid_generate(t_uuid); |
| | | uuid_unparse(t_uuid, str); |
| | | str_uuid = str; |
| | | |
| | | |
| | | Json::Value t_json; |
| | | t_json["Id"] = str_uuid; //ä¸»é® |
| | | //#todo |
| | | |
| | | t_json["videoReqNum"] = m_sdkRule.strCamId.toStdString(); |
| | | t_json["sdkType"] =to_string(m_sdkRule.nSdkType); |
| | | // t_json["Gender"] = obj.score; |
| | | |
| | | t_json["picName"] = "wait todo";// ææç
§çåç§° |
| | | t_json["content"] = "wait todo";// å
容æè¿° |
| | | t_json["personPicUrl"] = "";// 人å å°åºå¾ç |
| | | t_json["ChannlId"] = getProperty("ch_id"); // ééid |
| | | t_json["likeDate"] =AppUtil::getTimeSecString(); // æ¯å¯¹æ¶é´ |
| | | t_json["picAddress"] =getProperty("str_addr");// ææå°å |
| | | t_json["picMaxUrl"] = "wait todo"; // 大å¾è·¯å¾ |
| | | |
| | | |
| | | // t_json["Age"] ="wait todo"; |
| | | t_json["picDate"] = obj.properties["time"]; // æææ¶é´ï¼å¿
é¡»æ |
| | | t_json["picLocalUrl"] = "wait todo"; // æ¬å°è·¯å¾ |
| | | t_json["isDelete"] = "1";//é»è®¤1 ,0æ æ 1ææ |
| | | |
| | | t_json["likePer"] = obj.score; // ç¸ä¼¼å¼ |
| | | |
| | | t_json["BaseName"] = "wait todo";// å°åºåç§° |
| | | |
| | | t_json["videoNum"] = m_sdkRule.strCamId.toStdString();//Video设å¤ç¼å· |
| | | t_json["picSmUrl"] = imgUrl; // ææå¾ç |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID");;// 设å¤id |
| | | t_json["idcard"] = "wait todo"; |
| | | t_json["personId"] = "wait todo"; |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME");// 设å¤åç§° |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personIsHub"] = m_triggerElement.getTriggerState()?"1":"4"; //1: æ¥è¦ 2: å¯ç 3: å®å
¨ 4: æªç¥ |
| | | t_json["videoIp"] = m_sdkRule.strAddr.toStdString(); // 设å¤ip |
| | | t_json["ack_alarm"]=m_triggerElement.getTriggerState()?"0":""; // que ren shi fou bao jing |
| | | t_json["cluster_id"]="wait todo"; // ji qun id |
| | | |
| | | bool retface = false; |
| | | if(pManagerEsDB) |
| | | retface = pManagerEsDB->insertData("personaction", "perVideoAction", t_json.toStyledString(), str_uuid); |
| | | if (retface) |
| | | { |
| | | INFO("perVideoAction db success"); |
| | | } |
| | | else |
| | | { |
| | | ERR("personaction db fail"); |
| | | } |
| | | } |
| | | bool PerStaticElement::isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek) |
| | | { |
| | | |
| | | int nWeek = QDate::currentDate().dayOfWeek(); |
| | | for(int i = 0;i < ruleWeek.size();++i) |
| | | { |
| | | if(ruleWeek[i].m_nType == nWeek) |
| | | { |
| | | QString strCurrent = QDateTime::currentDateTime().toString("hh:mm"); |
| | | if(strCurrent >= ruleWeek[i].m_strBegin && strCurrent <= ruleWeek[i].m_strEnd) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | void PerStaticElement::setImage(const cv::Mat &value) |
| | | { |
| | | |
| | | value.copyTo(image); |
| | | } |
New file |
| | |
| | | #ifndef PERSTATICELEMENT |
| | | #define PERSTATICELEMENT |
| | | #include <basic/pipe/PipeElement.h> |
| | | #include <opencv2/opencv.hpp> |
| | | #include <Ice/Ice.h> |
| | | #include <YoloServer.h> |
| | | #include <QtGui/qpolygon.h> |
| | | #include "TrackingTrigger.h" |
| | | #include <QJsonArray> |
| | | #include <RapidStructureApp/TriggerElement.h> |
| | | #include <basic/util/fastdfs/FastFds.hpp> |
| | | #include "DBStruct.h" |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | class PerStaticElement : public basic::PipeElement |
| | | { |
| | | public: |
| | | PerStaticElement(){} |
| | | PerStaticElement(const SdkRule& rule); |
| | | public: |
| | | ~PerStaticElement(); |
| | | |
| | | //æ¯å¦æç©å½¢ |
| | | bool hasRects(); |
| | | //设置ROIåºå |
| | | |
| | | |
| | | |
| | | |
| | | void setYoloObjects(std::vector<ScoredRect> value); |
| | | |
| | | //å°æ£æµç»ææ¾å°æ¤åå
ä¸ |
| | | //void setVptResults(const vector<VPT_ObjInfo> &value); |
| | | void setObjsResults(const ::YoloDetect::ObjInfos &value); |
| | | |
| | | //设置置信度 |
| | | void setSensitivity(float value); |
| | | |
| | | //è·åç©å½¢æ¡ |
| | | std::vector<cv::Rect2f> getRects() const; |
| | | |
| | | //è·åYOLOæ£æµçç»æ |
| | | std::vector<ScoredRect> getLastScoreRects() const; |
| | | |
| | | |
| | | bool getTriggerState() const; |
| | | |
| | | void setFdfs(FastFdsWithLock *p_fdfsClient) { |
| | | fdfsClient = p_fdfsClient; |
| | | } |
| | | void setImage(const cv::Mat &value); |
| | | |
| | | private: |
| | | |
| | | |
| | | virtual void threadInitial()override; |
| | | |
| | | virtual void threadFunc()override; |
| | | |
| | | QJsonArray getJsonArrayFromQString(const QString& strJson); |
| | | |
| | | std::string uploadImgToFdfs(cv::Mat& image); |
| | | |
| | | bool saveInfoToEs(const std::string& imgUrl,const ScoredRect& obj); |
| | | void setMask(std::string mask); |
| | | bool isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek); |
| | | |
| | | private: |
| | | cv::Mat image; |
| | | //cv::Mat mask; |
| | | //vector<VPT_ObjInfo> vptResults; |
| | | ::YoloDetect::ObjInfos m_objs; |
| | | QPolygon mPolygon; |
| | | TrackingTrigger *trackingTrigger; |
| | | ::YoloDetect::stringData cocoData; |
| | | std::vector<ScoredRect> mObjs; |
| | | TriggerElement m_triggerElement; |
| | | FastFdsWithLock* fdfsClient; |
| | | SdkRule m_sdkRule; |
| | | std::vector<ScoredRect> m_lastScoreRect; |
| | | unsigned long long m_lTime; |
| | | EsDBTool* pManagerEsDB; |
| | | }; |
| | | |
| | | #endif // PAELEMENT_H |
| | |
| | | #include <QJsonObject> |
| | | #include <QString> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | #include <uuid/uuid.h> |
| | | #include <jsoncpp/json/json.h> |
| | | PerimeterElement::PerimeterElement(int alarm_people_num): |
| | | m_nAlarmPeopleNum(alarm_people_num), |
| | | PipeElement(true), |
| | | trackingTrigger(nullptr), |
| | | mRealNum(0), |
| | | m_triggerElement(0,50) |
| | | { |
| | | |
| | | trackingTrigger= new TrackingTrigger(0.5); |
| | | PerimeterElement::PerimeterElement(const SdkRule &rule) : |
| | | m_sdkRule(rule), |
| | | PipeElement(true), |
| | | trackingTrigger(nullptr), |
| | | mRealNum(0), |
| | | m_triggerElement(0, rule.nTriggerDelay * 1000 * 1000), |
| | | pManagerEsDB(nullptr), |
| | | npts(0) { |
| | | |
| | | |
| | | pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | } |
| | | |
| | | PerimeterElement::~PerimeterElement() |
| | | { |
| | | if(trackingTrigger) |
| | | { |
| | | delete trackingTrigger; |
| | | trackingTrigger=nullptr; |
| | | PerimeterElement::~PerimeterElement() { |
| | | if (pManagerEsDB) { |
| | | delete pManagerEsDB; |
| | | pManagerEsDB = nullptr; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | void PerimeterElement::threadInitial() |
| | | { |
| | | |
| | | void PerimeterElement::threadInitial() { |
| | | setMask(m_sdkRule.strAreas.toStdString()); |
| | | } |
| | | |
| | | |
| | | void PerimeterElement::threadFunc() |
| | | { |
| | | void PerimeterElement::threadFunc() { |
| | | |
| | | int num=0; |
| | | string detKey = getProperty("dev_id") + getProperty("ch_id")+getProperty("sdkType")+".det"; |
| | | float t_det_sc =0.75; |
| | | if (!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | int num = 0; |
| | | std::string picDate; |
| | | bool state = false; |
| | | |
| | | t_det_sc= appPref.getFloatData(detKey) == -1 ? 0.75 : appPref.getFloatData(detKey); |
| | | m_recVec.clear(); |
| | | // DBG("Objs="<<mObjs.size()<<" fSensitivity="<<m_sdkRule.fSensitivity<<" nThreshold"<<m_sdkRule.nThreshold); |
| | | |
| | | for (auto obj:mObjs) { |
| | | |
| | | // t_det_sc= appPref.getFloatData(t_camIdex + "perimeter.det") == -1 ? 0.75 : appPref.getFloatData(t_camIdex + "perimeter.det"); |
| | | if (obj.score < m_sdkRule.fSensitivity)continue; |
| | | |
| | | QRect rect(obj.rect.x, obj.rect.y, obj.rect.width, obj.rect.height); |
| | | QPoint center = rect.center(); |
| | | if (mPolygon.containsPoint(center, Qt::OddEvenFill)) { |
| | | m_recVec.push_back(obj.rect); |
| | | if (picDate.empty()) { |
| | | picDate = obj.properties["time"]; |
| | | // DBG("picDate="<<picDate); |
| | | |
| | | for(auto obj:m_objs){ |
| | | if(obj.type!=0) continue; |
| | | //todo |
| | | if(obj.prob < ((1-0.5)/2+0.5))continue; |
| | | |
| | | // ScoredRect scoredRect; |
| | | |
| | | int x = obj.rcObj.left * image.cols; |
| | | int y = obj.rcObj.top * image.rows; |
| | | int w = (obj.rcObj.right - obj.rcObj.left) * image.cols; |
| | | int h = (obj.rcObj.bottom - obj.rcObj.top) * image.rows; |
| | | // scoredRect.rect = cv::Rect(x, y, w, h); |
| | | // scoredRect.score = scoredRect.rect.area() > 0 ? obj.prob : 0; |
| | | // cv::Rect rec=obj.rect; |
| | | QRect rect(x,y,w,h); |
| | | QPoint center = rect.center(); |
| | | if(mPolygon.containsPoint(center,Qt::OddEvenFill)) |
| | | { |
| | | // scoredRect.isMask=true; |
| | | //if(bInWeekTime) |
| | | num++; |
| | | auto t_image = image(cv::Rect(x, y, w, h)& cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl=uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl,obj); |
| | | } |
| | | // if(trackingTrigger->triggerOnce(scoredRect)) |
| | | // { |
| | | // trackingTrigger->getLastRect().properties["id"] = to_string(scoredRect.id); |
| | | // trackingTrigger->getLastRect().properties["type"] = cocoData[obj.type]; |
| | | // } |
| | | |
| | | num++; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | trackingTrigger->triggerLine(); |
| | | if(num>=m_nAlarmPeopleNum) |
| | | { |
| | | m_triggerElement.setState(true); |
| | | |
| | | switch (m_sdkRule.nSdkType) { |
| | | case PerimeterSdk: |
| | | state = num > 0 && num != mRealNum; |
| | | |
| | | |
| | | break; |
| | | case CrowdSdk: |
| | | state = num > m_sdkRule.nAlarmNumLowerLimit && num != mRealNum; |
| | | |
| | | break; |
| | | case PerHubSdk: |
| | | state = num > m_sdkRule.nAlarmNumLowerLimit && num < m_sdkRule.nAlarmNumUpperLimit && num != mRealNum; |
| | | // if(m_sdkRule.nAlarmNumLowerLimit>0) |
| | | // { |
| | | // if( m_sdkRule.nAlarmNumUpperLimit>m_sdkRule.nAlarmNumLowerLimit+1) |
| | | // { |
| | | |
| | | // m_triggerElement.setState(num>m_sdkRule.nAlarmNumLowerLimit && num<m_sdkRule.nAlarmNumUpperLimit); |
| | | // } |
| | | // else |
| | | // { |
| | | // m_triggerElement.setState(num>m_sdkRule.nAlarmNumLowerLimit); |
| | | // } |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // if(m_sdkRule.nAlarmNumUpperLimit>0) |
| | | // { |
| | | // m_triggerElement.setState(num>m_sdkRule.nAlarmNumUpperLimit); |
| | | // } |
| | | // else |
| | | // { |
| | | // m_triggerElement.setState(false); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | m_triggerElement.setState(state); |
| | | |
| | | // DBG("imgUrl="<<imgUrl); |
| | | if (state) { |
| | | auto t_image = image(CutMask()).clone(); |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl, picDate); |
| | | DBG("num=" << num << " lastnum=" << mRealNum); |
| | | |
| | | } |
| | | else |
| | | { |
| | | m_triggerElement.setState(false); |
| | | } |
| | | |
| | | |
| | | m_triggerElement.triggerOnce(); |
| | | mRealNum=num; |
| | | |
| | | mRealNum = num; |
| | | // DBG("m_sdkRule.nSdkType="<<m_sdkRule.nSdkType<<" num="<<num); |
| | | fireConnectors(); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | void PerimeterElement::setSensitivity(float value) |
| | | { |
| | | sensitivity = value; |
| | | } |
| | | //void PerimeterElement::setSensitivity(float value) |
| | | //{ |
| | | // sensitivity = value; |
| | | //} |
| | | |
| | | |
| | | |
| | | void PerimeterElement::setObjsResults(const YoloDetect::ObjInfos &value) |
| | | { |
| | | void PerimeterElement::setObjsResults(const YoloDetect::ObjInfos &value) { |
| | | m_objs = value; |
| | | } |
| | | |
| | |
| | | return trackingTrigger->getLastScoreRects(); |
| | | } |
| | | |
| | | void PerimeterElement::setYoloObjects(std::vector<ScoredRect> value) |
| | | { |
| | | mObjs=value; |
| | | void PerimeterElement::setYoloObjects(std::vector<ScoredRect> value) { |
| | | mObjs.clear(); |
| | | mObjs = value; |
| | | } |
| | | |
| | | int PerimeterElement::getRealNum() const |
| | | { |
| | | int PerimeterElement::getRealNum() const { |
| | | //DBG("getRealNum "<<mRealNum); |
| | | return mRealNum; |
| | | } |
| | | void PerimeterElement::setMask(std::string mask) |
| | | { |
| | | |
| | | void PerimeterElement::setMask(std::string mask) { |
| | | QJsonArray arrayAreas = getJsonArrayFromQString(QString::fromStdString(mask)); |
| | | if(arrayAreas.isEmpty()) |
| | | { |
| | | if (arrayAreas.isEmpty()) { |
| | | return;//do not detect |
| | | } |
| | | for(int i = 0;i < arrayAreas.size();++i) |
| | | { |
| | | int size = arrayAreas.size(); |
| | | npts = size; |
| | | for (int i = 0; i < size; ++i) { |
| | | |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toInt()*2; |
| | | int y = obj.value("y").toInt()*2; |
| | | mPolygon<<(QPoint(x,y)); |
| | | int x = obj.value("x").toDouble() * 4; |
| | | int y = obj.value("y").toDouble() * 4; |
| | | |
| | | mPolygon << (QPoint(x, y)); |
| | | |
| | | } |
| | | } |
| | | QJsonArray PerimeterElement::getJsonArrayFromQString(const QString& strJson) |
| | | { |
| | | |
| | | QJsonArray PerimeterElement::getJsonArrayFromQString(const QString &strJson) { |
| | | QJsonDocument jsonDocument = QJsonDocument::fromJson(strJson.toLocal8Bit()); |
| | | if( jsonDocument.isNull() ){ |
| | | //DBG("please check the string"<< strJson.toLocal8Bit()); |
| | | if (jsonDocument.isNull()) { |
| | | DBG("please check the string" << strJson.toStdString()); |
| | | return QJsonArray(); |
| | | } |
| | | QJsonArray jsonArray = jsonDocument.array(); |
| | | return jsonArray; |
| | | } |
| | | |
| | | void PerimeterElement::setImage(const cv::Mat &value) |
| | | { |
| | | void PerimeterElement::setImage(const cv::Mat &value) { |
| | | // if (value.size != image.size) { |
| | | // image = cv::Mat(value.rows, value.cols, CV_8UC3, sharedMemory->data()); |
| | | // } |
| | | // value.copyTo(image); |
| | | value.copyTo(image); |
| | | } |
| | | |
| | | bool PerimeterElement::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | | std::string PerimeterElement::uploadImgToFdfs(cv::Mat& image) |
| | | { |
| | | |
| | | std::string PerimeterElement::uploadImgToFdfs(cv::Mat &image) { |
| | | std::string strImgUrl = "http://"; |
| | | if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) { |
| | | fdfsClient->rwLock.rdlock(); |
| | |
| | | } |
| | | return strImgUrl; |
| | | } |
| | | bool PerimeterElement::saveInfoToEs(const std::string& imgUrl,const ::YoloDetect::ObjInfo& obj) |
| | | { |
| | | |
| | | //#todo |
| | | EsDBTool pManagerEsDB(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | bool PerimeterElement::saveInfoToEs(const std::string &imgUrl, const std::string &time) { |
| | | |
| | | string str_uuid; |
| | | uuid_t t_uuid; |
| | | char str[36]; |
| | | uuid_generate(t_uuid); |
| | | uuid_unparse(t_uuid, str); |
| | | str_uuid = str; |
| | | string str_uuid; |
| | | uuid_t t_uuid; |
| | | char str[36]; |
| | | uuid_generate(t_uuid); |
| | | uuid_unparse(t_uuid, str); |
| | | str_uuid = str; |
| | | |
| | | |
| | | Json::Value t_json; |
| | | t_json["Id"] = str_uuid; //ä¸»é® |
| | | Json::Value t_json; |
| | | t_json["Id"] = str_uuid; //ä¸»é® |
| | | //#todo |
| | | |
| | | t_json["picName"] = "wait todo"; |
| | | t_json["DataType"] = cocoData[obj.type]; |
| | | t_json["Score"] = obj.prob; |
| | | t_json["videoReqNum"] = m_sdkRule.strCamId.toStdString(); |
| | | t_json["sdkType"] = to_string(m_sdkRule.nSdkType); |
| | | // DBG("to_string(m_sdkRule.nSdkType)="<<to_string(m_sdkRule.nSdkType)); |
| | | // t_json["Gender"] = obj.score; |
| | | |
| | | t_json["likeDate"] = AppUtil::getTimeSecString();//æ¯è¾æ¶é´ |
| | | t_json["picAddress"] = getProperty("str_addr");//ææå°å |
| | | t_json["picSmUrl"] = imgUrl;//人åæå°å¾ |
| | | t_json["picDate"] = getProperty("time"); |
| | | t_json["viType"] = "2";//åªæ4ç§ç±»å 1:personface 2:personbody 3:car 4:bicycle 5:none æªç¥ç±»å |
| | | t_json["personIsHub"] = "4";//1: æ¥è¦ 2: å¯ç 3: å®å
¨ 4: æªç¥ |
| | | t_json["videoIp"] = getProperty("local_ip");//å½åæå¡å¨IPå°å |
| | | t_json["picName"] = "wait todo";// ææç
§çåç§° |
| | | t_json["content"] = "wait todo";// å
容æè¿° |
| | | t_json["personPicUrl"] = "";// 人å å°åºå¾ç |
| | | t_json["ChannlId"] = getProperty("ch_id"); // ééid |
| | | t_json["likeDate"] = AppUtil::getTimeSecString(); // æ¯å¯¹æ¶é´ |
| | | t_json["picAddress"] = getProperty("str_addr");// ææå°å |
| | | t_json["picMaxUrl"] = "wait todo"; // 大å¾è·¯å¾ |
| | | |
| | | |
| | | t_json["videoNum"] = getProperty("path");//Videç¼å· å¤é® |
| | | t_json["videoReqNum"] = getProperty("dev_id");//Video设å¤ç¼å· |
| | | t_json["ChannlId"] = getProperty("ch_id");//ééid |
| | | t_json["isDelete"] = "1";//é»è®¤1 ,0æ æ 1ææ |
| | | // t_json["Age"] ="wait todo"; |
| | | t_json["picDate"] = time; // æææ¶é´ï¼å¿
é¡»æ |
| | | // DBG("picDate="<<time); |
| | | t_json["picLocalUrl"] = "wait todo"; // æ¬å°è·¯å¾ |
| | | t_json["isDelete"] = "1";//é»è®¤1 ,0æ æ 1ææ |
| | | |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID"); |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME"); |
| | | bool retface = false; |
| | | std::string name=getProperty("sdkType")+"det"; |
| | | retface = pManagerEsDB.insertData(name, "info", t_json.toStyledString(), str_uuid); |
| | | if (retface) |
| | | { |
| | | INFO(name<<"db success"); |
| | | t_json["likePer"] = "0"; // ç¸ä¼¼å¼ |
| | | |
| | | t_json["BaseName"] = "wait todo";// å°åºåç§° |
| | | |
| | | t_json["videoNum"] = m_sdkRule.strCamId.toStdString();//Video设å¤ç¼å· |
| | | t_json["picSmUrl"] = imgUrl; // ææå¾ç |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID");;// 设å¤id |
| | | t_json["idcard"] = "wait todo"; |
| | | t_json["personId"] = "wait todo"; |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME");// 设å¤åç§° |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personIsHub"] = m_triggerElement.getTriggerState() ? "1" : "4"; //1: æ¥è¦ 2: å¯ç 3: å®å
¨ 4: æªç¥ |
| | | t_json["videoIp"] = m_sdkRule.strAddr.toStdString(); // 设å¤ip |
| | | t_json["ack_alarm"] = m_triggerElement.getTriggerState() ? "0" : ""; // que ren shi fou bao jing |
| | | t_json["cluster_id"] = "wait todo"; // ji qun id |
| | | |
| | | bool retface = false; |
| | | if (pManagerEsDB) |
| | | retface = pManagerEsDB->insertData("personaction", "perVideoAction", t_json.toStyledString(), str_uuid); |
| | | if (retface) { |
| | | INFO("perVideoAction db success"); |
| | | } else { |
| | | ERR("personaction db fail"); |
| | | } |
| | | } |
| | | |
| | | bool PerimeterElement::isInWeek(const std::vector<LActRuleWeekRecord> &ruleWeek) { |
| | | |
| | | int nWeek = QDate::currentDate().dayOfWeek(); |
| | | for (int i = 0; i < ruleWeek.size(); ++i) { |
| | | if (ruleWeek[i].m_nType == nWeek) { |
| | | QString strCurrent = QDateTime::currentDateTime().toString("hh:mm"); |
| | | if (strCurrent >= ruleWeek[i].m_strBegin && strCurrent <= ruleWeek[i].m_strEnd) { |
| | | return true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ERR(name<<"db fail"); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | cv::Rect PerimeterElement::CutMask() { |
| | | int size = m_recVec.size(); |
| | | //QPoint max,secMax; |
| | | cv::Rect rect, max, min; |
| | | |
| | | if (size > 0) { |
| | | |
| | | max = m_recVec[0]; |
| | | min = m_recVec[0]; |
| | | } |
| | | |
| | | for (int i = 1; i < size; ++i) { |
| | | if (m_recVec[i].x > max.x) { |
| | | |
| | | max.x = m_recVec[i].x; |
| | | } |
| | | |
| | | |
| | | if (m_recVec[i].y > max.y) { |
| | | |
| | | max.y = m_recVec[i].y; |
| | | } |
| | | if (m_recVec[i].x < min.x) { |
| | | min.x = m_recVec[i].x; |
| | | } |
| | | |
| | | if (m_recVec[i].y < min.y) { |
| | | min.y = m_recVec[i].y; |
| | | } |
| | | |
| | | } |
| | | |
| | | if (size == 1) { |
| | | rect = max; |
| | | } else { |
| | | |
| | | rect.x = min.x; |
| | | rect.y = min.y; |
| | | rect.width = max.x + max.width - min.x; |
| | | rect.height = max.y + max.height - min.y; |
| | | } |
| | | |
| | | rect = CvUtil::zoomRectEqual(rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows); |
| | | // DBG("min x="<<min.x<<"y"<<min.y<<"w"<<min.width<<"h"<<min.height); |
| | | // DBG("max x="<<max.x<<"y"<<max.y<<"w"<<max.width<<"h"<<max.height); |
| | | // DBG("RECT x="<<rect.x<<"y"<<rect.y<<"w"<<rect.width<<"h"<<rect.height); |
| | | return rect; |
| | | } |
| | |
| | | #ifndef PERIMETERELEMENT |
| | | #define PERIMETERELEMENT |
| | | |
| | | #include <basic/pipe/PipeElement.h> |
| | | //#include <basic/event/EventHandler.hpp> |
| | | #include <opencv2/opencv.hpp> |
| | | #include <Ice/Ice.h> |
| | | #include <YoloServer.h> |
| | |
| | | #include <QJsonArray> |
| | | #include <RapidStructureApp/TriggerElement.h> |
| | | #include <basic/util/fastdfs/FastFds.hpp> |
| | | |
| | | class PerimeterElement : public basic::PipeElement { |
| | | #include "DBStruct.h" |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | class PerimeterElement : public basic::PipeElement |
| | | { |
| | | public: |
| | | PerimeterElement(int alarm_people_num = 1); |
| | | |
| | | PerimeterElement(){} |
| | | PerimeterElement(const SdkRule& rule); |
| | | public: |
| | | ~PerimeterElement(); |
| | | |
| | | //æ¯å¦æç©å½¢ |
| | | bool hasRects(); |
| | | |
| | | //设置ROIåºå |
| | | void setMask(std::string mask); |
| | | |
| | | |
| | | void setImage(const cv::Mat &value); |
| | | |
| | |
| | | void setFdfs(FastFdsWithLock *p_fdfsClient) { |
| | | fdfsClient = p_fdfsClient; |
| | | } |
| | | |
| | | void setImage(const cv::Mat &value) const; |
| | | |
| | | private: |
| | | |
| | | |
| | | virtual void threadInitial() override; |
| | | virtual void threadInitial()override; |
| | | |
| | | virtual void threadFunc() override; |
| | | virtual void threadFunc()override; |
| | | |
| | | QJsonArray getJsonArrayFromQString(const QString &strJson); |
| | | QJsonArray getJsonArrayFromQString(const QString& strJson); |
| | | |
| | | std::string uploadImgToFdfs(cv::Mat &image); |
| | | std::string uploadImgToFdfs(cv::Mat& image); |
| | | |
| | | bool saveInfoToEs(const std::string &imgUrl, const ::YoloDetect::ObjInfo &obj); |
| | | |
| | | |
| | | bool saveInfoToEs(const std::string& imgUrl,const std::string& time); |
| | | void setMask(std::string mask); |
| | | bool isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek); |
| | | cv::Rect CutMask(); |
| | | private: |
| | | cv::Mat image; |
| | | cv::Mat mask; |
| | | //cv::Mat mask; |
| | | //vector<VPT_ObjInfo> vptResults; |
| | | ::YoloDetect::ObjInfos m_objs; |
| | | float sensitivity; |
| | | QPolygon mPolygon; |
| | | TrackingTrigger *trackingTrigger; |
| | | ::YoloDetect::stringData cocoData; |
| | | int mRealNum; |
| | | int m_nAlarmPeopleNum; |
| | | std::vector<ScoredRect> mObjs; |
| | | TriggerElement m_triggerElement; |
| | | FastFdsWithLock *fdfsClient; |
| | | FastFdsWithLock* fdfsClient; |
| | | SdkRule m_sdkRule; |
| | | EsDBTool* pManagerEsDB; |
| | | |
| | | |
| | | int npts; |
| | | vector<cv::Rect> m_recVec; |
| | | }; |
| | | |
| | | #endif // PAELEMENT_H |
New file |
| | |
| | | #include "PersonElement.h" |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <QtCore/QSharedMemory> |
| | | #include <QtCore/QString> |
| | | #include <basic/timer_counter/Clocktimer.h> |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | |
| | | |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | #include <uuid/uuid.h> |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | #include <QtCore/QJsonDocument> |
| | | #include <QtCore/QJsonObject> |
| | | |
| | | PersonElement::PersonElement(const SdkRule& sdkRule) : |
| | | m_sdkRule(sdkRule), |
| | | // rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), |
| | | // appPref.getIntData("yolo.port"), "tcp"), |
| | | fdfsClient(nullptr), |
| | | m_triggerElement(0, sdkRule.nTriggerDelay) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | PersonElement::~PersonElement() { |
| | | |
| | | } |
| | | |
| | | void PersonElement::threadFunc() { |
| | | // ClockTimer ct("YoloRpcElement::threadFunc");. |
| | | triggerMats.clear(); |
| | | for (auto &obj: m_objs) { |
| | | |
| | | if (obj.score < m_sdkRule.fSensitivity) |
| | | continue; |
| | | |
| | | |
| | | auto t_image = image(obj.rect & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | triggerMats.push_back(t_image); |
| | | std::string strImgUrl = "http://"; |
| | | if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) { |
| | | fdfsClient->rwLock.rdlock(); |
| | | std::vector<unsigned char> buffer; |
| | | CvUtil::cvMat2Buffer(t_image, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | | fdfsClient->rwLock.unlock(); |
| | | } |
| | | |
| | | //使ç¨çæ¶åå°falseæ¹ä¸ºture |
| | | { |
| | | //#todo |
| | | EsDBTool pManagerEsDB(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | |
| | | string str_uuid; |
| | | uuid_t t_uuid; |
| | | char str[36]; |
| | | uuid_generate(t_uuid); |
| | | uuid_unparse(t_uuid, str); |
| | | str_uuid = str; |
| | | |
| | | // jsonyolo.insert("HardCamId","");//硬çæåæºid ï¼ï¼ï¼æ¿ä¸å° |
| | | // jsonyolo.insert("ChannlId","");//ééid ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("Time","");//æ¶é´ å¯ä»¥è·åå½åæ¶é´ æç¡®æ¶é´æ¯è·åå½åçè¿æ¯ä¼ è¿æ¥ç ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("ImgUrl","");//å¾åimgè·¯å¾ ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("Image","");//å¿«ç
§ ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("DataType",obj.type);//æ£æµçç±»å |
| | | // jsonyolo.insert("Score",obj.prob);//æ£æµçå¾å |
| | | |
| | | Json::Value t_json; |
| | | t_json["Id"] = str_uuid; //ä¸»é® |
| | | //#todo |
| | | |
| | | t_json["picName"] = "wait todo"; |
| | | t_json["DataType"] = obj.properties["type"]; |
| | | t_json["Score"] = obj.score; |
| | | |
| | | t_json["personPicUrl"] = "wait todo";//人åå¾ç store |
| | | t_json["likeDate"] = AppUtil::getTimeSecString();//æ¯è¾æ¶é´ |
| | | t_json["picAddress"] = m_sdkRule.strAddr.toStdString();//ææå°å |
| | | t_json["picMaxUrl"] = "wait todo";//大å¾è·¯å¾ |
| | | t_json["picLocalUrl"] = "wait todo";//æ¬å°è·¯å¾ |
| | | t_json["picSmUrl"] = strImgUrl;//人åæå°å¾ |
| | | |
| | | // faceRpcElement.setProperty("frame_number", frame_number); |
| | | t_json["picDate"] = obj.properties["time"]; |
| | | t_json["content"] = "wait todo"; |
| | | t_json["viType"] = "2";//åªæ4ç§ç±»å 1:personface 2:personbody 3:car 4:bicycle 5:none æªç¥ç±»å |
| | | t_json["personIsHub"] = "4";//1: æ¥è¦ 2: å¯ç 3: å®å
¨ 4: æªç¥ |
| | | t_json["videoIp"] = getProperty("local_ip");//å½åæå¡å¨IPå°å |
| | | |
| | | |
| | | t_json["videoNum"] = getProperty("path");//Videç¼å· å¤é® |
| | | t_json["videoReqNum"] = getProperty("dev_id");//Video设å¤ç¼å· |
| | | t_json["ChannlId"] = getProperty("ch_id");//ééid |
| | | t_json["isDelete"] = "1";//é»è®¤1 ,0æ æ 1ææ |
| | | |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID"); |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME"); |
| | | |
| | | DBG(t_json.toStyledString()); |
| | | bool retface = false; |
| | | retface = pManagerEsDB.insertData("yolodet", "info", t_json.toStyledString(), str_uuid); |
| | | if (retface) { |
| | | INFO("facedb success"); |
| | | } else { |
| | | ERR("facedb fail"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (triggerMats.size() > 0)fireConnectors("YoloTrigger"); |
| | | fireConnectors(); |
| | | |
| | | } |
| | | |
| | | void PersonElement::setObjsResults(const std::vector<ScoredRect>& objs) |
| | | { |
| | | m_objs = objs; |
| | | } |
| | | bool PersonElement::getTrigger() const { |
| | | return (m_objs.size() > 0 ? true : false); |
| | | } |
| | | |
| | | std::vector<cv::Mat> PersonElement::getTriggerMats() { |
| | | return triggerMats; |
| | | } |
| | | |
| | | std::vector<ScoredRect> PersonElement::getLastScoreRects() const { |
| | | return m_objs; |
| | | } |
| | | |
| | | void PersonElement::setImage(const cv::Mat &value) { |
| | | |
| | | value.copyTo(image); |
| | | } |
| | | |
| | | bool PersonElement::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | | |
New file |
| | |
| | | #ifndef PERSONELEMENT_H |
| | | #define PERSONELEMENT_H |
| | | |
| | | #include <YoloServer.h> |
| | | #include <basic/pipe/PipeElement.h> |
| | | #include <basic/rpc/IceRpc.hpp> |
| | | #include <opencv2/opencv.hpp> |
| | | #include <basic/util/fastdfs/FastFds.hpp> |
| | | #include <RapidStructureApp/TriggerElement.h> |
| | | #include "TrackingTrigger.h" |
| | | #include "DBStruct.h" |
| | | class QSharedMemory; |
| | | |
| | | class PersonElement : public basic::PipeElement { |
| | | public: |
| | | PersonElement(){} |
| | | PersonElement(const SdkRule& sdkRule); |
| | | |
| | | ~PersonElement(); |
| | | |
| | | void setImage(const cv::Mat &value); |
| | | |
| | | std::vector<cv::Mat> getTriggerMats(); |
| | | |
| | | std::vector<ScoredRect> getLastScoreRects() const; |
| | | |
| | | void setFdfs(FastFdsWithLock *p_fdfsClient) { |
| | | fdfsClient = p_fdfsClient; |
| | | } |
| | | |
| | | bool getTriggerState() const; |
| | | |
| | | bool getTrigger() const; |
| | | void setObjsResults(const std::vector<ScoredRect>& objs); |
| | | |
| | | private: |
| | | virtual void threadFunc() override; |
| | | |
| | | private: |
| | | // IceRpcClient<YoloDetect::YoloDetectServerPrx> rpcClient; |
| | | cv::Mat image; |
| | | // QSharedMemory *sharedMemory; |
| | | // ::YoloDetect::ObjInfos objs; |
| | | std::vector<ScoredRect> m_objs; |
| | | // TrackingTrigger *trackingTrigger; |
| | | std::vector<cv::Mat> triggerMats; |
| | | ::YoloDetect::stringData cocoData; |
| | | FastFdsWithLock *fdfsClient; |
| | | |
| | | TriggerElement m_triggerElement; |
| | | SdkRule m_sdkRule; |
| | | }; |
| | | |
| | | #endif // YOLORPCELEMENT_H |
| | |
| | | using namespace std; |
| | | |
| | | struct ScoredRect { |
| | | ScoredRect() : id(-1) ,isMask(false){} |
| | | bool isMask; |
| | | ScoredRect() : id(-1) ,isMove(false){} |
| | | bool isMove; |
| | | float score; |
| | | cv::Rect rect; |
| | | long id; |
| | |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | |
| | | |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | | #include <uuid/uuid.h> |
| | | #include <jsoncpp/json/json.h> |
| | | |
| | | #include <QtCore/QJsonDocument> |
| | | #include <QtCore/QJsonObject> |
| | | |
| | | YoloRpcElement::YoloRpcElement(string shareMemoryName) : |
| | | YoloRpcElement::YoloRpcElement(std::string shareMemoryName) : |
| | | rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), |
| | | appPref.getIntData("yolo.port"), "tcp"), fdfsClient(nullptr), sharedMemory(nullptr), |
| | | m_triggerElement(0, 50), trackingTrigger(nullptr) { |
| | | appPref.getIntData("yolo.port"), "tcp"), |
| | | sharedMemory(nullptr), |
| | | trackingTrigger(nullptr) |
| | | { |
| | | trackingTrigger = new TrackingTrigger(0.5); |
| | | sharedMemory = new QSharedMemory(QString(shareMemoryName.c_str())); |
| | | // DBG(shareMemoryName); |
| | | //1520 x 2688 1080 x 1920 //2560 * 1440 * 4 |
| | | if (!sharedMemory->create(4608 * 2592 * 4)) { |
| | | sharedMemory->attach(); |
| | | } |
| | | trackingTrigger = new TrackingTrigger(0.5); |
| | | |
| | | try { |
| | | auto server = rpcClient.getServer(); |
| | | cocoData = server->getCocoData(); |
| | |
| | | if (sharedMemory) { |
| | | delete sharedMemory; |
| | | } |
| | | if (trackingTrigger) { |
| | | if(trackingTrigger) |
| | | { |
| | | delete trackingTrigger; |
| | | trackingTrigger=nullptr; |
| | | } |
| | | } |
| | | void YoloRpcElement::setImage(const cv::Mat &value) |
| | | { |
| | | if (value.size != image.size) |
| | | { |
| | | image = cv::Mat(value.rows, value.cols, CV_8UC3, sharedMemory->data()); |
| | | } |
| | | value.copyTo(image); |
| | | } |
| | | ::YoloDetect::ObjInfos YoloRpcElement::getObjects() const |
| | | { |
| | | return objs; |
| | | } |
| | | |
| | | void YoloRpcElement::threadFunc() { |
| | | // ClockTimer ct("YoloRpcElement::threadFunc");. |
| | | triggerMats.clear(); |
| | | |
| | | std::vector<ScoredRect> YoloRpcElement::getLastScoreRects() const { |
| | | return triggerScoredRects; |
| | | } |
| | | |
| | | cv::Mat YoloRpcElement::getImage() const |
| | | { |
| | | return image; |
| | | } |
| | | |
| | | void YoloRpcElement::threadFunc() |
| | | { |
| | | triggerScoredRects.clear(); |
| | | try { |
| | | auto server = rpcClient.getServer(); |
| | | if (!server) { |
| | | ERR("server is null"); |
| | | return; |
| | | auto server = rpcClient.getServer(); |
| | | if (!server) |
| | | { |
| | | ERR("server is null"); |
| | | return; |
| | | } |
| | | objs = server->YoloDetect(image.cols, image.rows, sharedMemory->key().toStdString());//TODO |
| | | } |
| | | objs = server->YoloDetect(image.cols, image.rows, sharedMemory->key().toStdString());//TODO |
| | | if (objs.size() <= 0) { |
| | | m_triggerElement.setState(false); |
| | | m_triggerElement.triggerOnce(false); |
| | | trackingTrigger->triggerLine(); |
| | | return; |
| | | } else { |
| | | m_triggerElement.setState(true); |
| | | catch (std::exception &e) |
| | | { |
| | | ERR(e.what()) |
| | | } |
| | | string t_camIdex = getProperty("dev_id") + getProperty("ch_id"); |
| | | float t_det_sc = |
| | | appPref.getFloatData(t_camIdex + "yolo.det") == -1 ? 0.75 : appPref.getFloatData(t_camIdex + "yolo.det"); |
| | | int size=objs.size(); |
| | | if(size>30) |
| | | { |
| | | |
| | | for (auto &obj: objs) { |
| | | // cv::imshow("image", image); |
| | | |
| | | // cv::waitKey(); |
| | | |
| | | DBG("size="<<size); |
| | | return; |
| | | } |
| | | |
| | | for (auto &obj: objs) |
| | | { |
| | | if (obj.type != 0) |
| | | continue; |
| | | if (obj.prob < t_det_sc) { |
| | | continue; |
| | | } |
| | | |
| | | ScoredRect scoredRect; |
| | | |
| | | int x = obj.rcObj.left * image.cols; |
| | |
| | | int w = (obj.rcObj.right - obj.rcObj.left) * image.cols; |
| | | int h = (obj.rcObj.bottom - obj.rcObj.top) * image.rows; |
| | | scoredRect.rect = cv::Rect(x, y, w, h); |
| | | |
| | | scoredRect.score = scoredRect.rect.area() > 0 ? obj.prob : 0; |
| | | if (trackingTrigger->triggerOnce(scoredRect)) { |
| | | if (trackingTrigger->triggerOnce(scoredRect)) |
| | | { |
| | | trackingTrigger->getLastRect().properties["id"] = to_string(scoredRect.id); |
| | | trackingTrigger->getLastRect().properties["type"] = cocoData[obj.type]; |
| | | auto t_image = image(scoredRect.rect & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | triggerMats.push_back(t_image); |
| | | |
| | | std::string strImgUrl = "http://"; |
| | | if (fdfsClient != nullptr && fdfsClient->fastFds != nullptr) { |
| | | fdfsClient->rwLock.rdlock(); |
| | | std::vector<unsigned char> buffer; |
| | | CvUtil::cvMat2Buffer(t_image, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | | fdfsClient->rwLock.unlock(); |
| | | } |
| | | |
| | | //使ç¨çæ¶åå°falseæ¹ä¸ºture |
| | | { |
| | | //#todo |
| | | EsDBTool pManagerEsDB(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | |
| | | string str_uuid; |
| | | uuid_t t_uuid; |
| | | char str[36]; |
| | | uuid_generate(t_uuid); |
| | | uuid_unparse(t_uuid, str); |
| | | str_uuid = str; |
| | | |
| | | // jsonyolo.insert("HardCamId","");//硬çæåæºid ï¼ï¼ï¼æ¿ä¸å° |
| | | // jsonyolo.insert("ChannlId","");//ééid ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("Time","");//æ¶é´ å¯ä»¥è·åå½åæ¶é´ æç¡®æ¶é´æ¯è·åå½åçè¿æ¯ä¼ è¿æ¥ç ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("ImgUrl","");//å¾åimgè·¯å¾ ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("Image","");//å¿«ç
§ ï¼ï¼ï¼ æ¿ä¸å° |
| | | // jsonyolo.insert("DataType",obj.type);//æ£æµçç±»å |
| | | // jsonyolo.insert("Score",obj.prob);//æ£æµçå¾å |
| | | |
| | | Json::Value t_json; |
| | | t_json["Id"] = str_uuid; //ä¸»é® |
| | | //#todo |
| | | |
| | | t_json["picName"] = "wait todo"; |
| | | t_json["DataType"] = cocoData[obj.type]; |
| | | t_json["Score"] = obj.prob; |
| | | |
| | | t_json["personPicUrl"] = "wait todo";//人åå¾ç store |
| | | t_json["likeDate"] = AppUtil::getTimeSecString();//æ¯è¾æ¶é´ |
| | | t_json["picAddress"] = getProperty("str_addr");//ææå°å |
| | | t_json["picMaxUrl"] = "wait todo";//大å¾è·¯å¾ |
| | | t_json["picLocalUrl"] = "wait todo";//æ¬å°è·¯å¾ |
| | | t_json["picSmUrl"] = strImgUrl;//人åæå°å¾ |
| | | |
| | | // faceRpcElement.setProperty("frame_number", frame_number); |
| | | t_json["picDate"] = getProperty("time"); |
| | | t_json["content"] = "wait todo"; |
| | | t_json["viType"] = "2";//åªæ4ç§ç±»å 1:personface 2:personbody 3:car 4:bicycle 5:none æªç¥ç±»å |
| | | t_json["personIsHub"] = "4";//1: æ¥è¦ 2: å¯ç 3: å®å
¨ 4: æªç¥ |
| | | t_json["videoIp"] = getProperty("local_ip");//å½åæå¡å¨IPå°å |
| | | |
| | | |
| | | t_json["videoNum"] = getProperty("path");//Videç¼å· å¤é® |
| | | t_json["videoReqNum"] = getProperty("dev_id");//Video设å¤ç¼å· |
| | | t_json["ChannlId"] = getProperty("ch_id");//ééid |
| | | t_json["isDelete"] = "1";//é»è®¤1 ,0æ æ 1ææ |
| | | |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID"); |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME"); |
| | | |
| | | DBG(t_json.toStyledString()); |
| | | bool retface = false; |
| | | retface = pManagerEsDB.insertData("yolodet", "info", t_json.toStyledString(), str_uuid); |
| | | if (retface) { |
| | | INFO("facedb success"); |
| | | } else { |
| | | ERR("facedb fail"); |
| | | } |
| | | } |
| | | trackingTrigger->getLastRect().properties["time"] = getProperty("time"); |
| | | triggerScoredRects.push_back(trackingTrigger->getLastRect()); |
| | | } |
| | | } |
| | | trackingTrigger->triggerLine(); |
| | | m_triggerElement.triggerOnce(false); |
| | | if (triggerMats.size() > 0)fireConnectors("YoloTrigger"); |
| | | if(trackingTrigger->getLastScoreRects().size()>20) |
| | | { |
| | | DBG(""); |
| | | } |
| | | fireConnectors(); |
| | | } catch (std::exception &e) { |
| | | ERR(e.what()) |
| | | } |
| | | } |
| | | |
| | | ::YoloDetect::ObjInfos YoloRpcElement::getObjects() const { |
| | | return objs; |
| | | } |
| | | |
| | | bool YoloRpcElement::getTrigger() const { |
| | | return (objs.size() > 0 ? true : false); |
| | | } |
| | | |
| | | std::vector<cv::Mat> YoloRpcElement::getTriggerMats() { |
| | | return triggerMats; |
| | | } |
| | | |
| | | std::vector<ScoredRect> YoloRpcElement::getLastScoreRects() const { |
| | | return trackingTrigger->getLastScoreRects(); |
| | | } |
| | | |
| | | void YoloRpcElement::setImage(const cv::Mat &value) { |
| | | if (value.size != image.size) { |
| | | image = cv::Mat(value.rows, value.cols, CV_8UC3, sharedMemory->data()); |
| | | } |
| | | value.copyTo(image); |
| | | } |
| | | |
| | | bool YoloRpcElement::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | |
| | | #include <basic/util/fastdfs/FastFds.hpp> |
| | | #include <RapidStructureApp/TriggerElement.h> |
| | | #include "TrackingTrigger.h" |
| | | |
| | | #include "DBStruct.h" |
| | | class QSharedMemory; |
| | | |
| | | class YoloRpcElement : public basic::PipeElement { |
| | | public: |
| | | YoloRpcElement(string); |
| | | YoloRpcElement(std::string shareMemoryName); |
| | | |
| | | ~YoloRpcElement(); |
| | | |
| | | void setImage(const cv::Mat &value); |
| | | |
| | | cv::Mat getImage() const; |
| | | |
| | | ::YoloDetect::ObjInfos getObjects() const; |
| | | |
| | | std::vector<cv::Mat> getTriggerMats(); |
| | | |
| | | std::vector<ScoredRect> getLastScoreRects() const; |
| | | |
| | | void setFdfs(FastFdsWithLock *p_fdfsClient) { |
| | | fdfsClient = p_fdfsClient; |
| | | } |
| | | |
| | | bool getTriggerState() const; |
| | | |
| | | bool getTrigger() const; |
| | | |
| | | private: |
| | | virtual void threadFunc() override; |
| | | |
| | |
| | | cv::Mat image; |
| | | QSharedMemory *sharedMemory; |
| | | ::YoloDetect::ObjInfos objs; |
| | | TrackingTrigger *trackingTrigger; |
| | | std::vector<cv::Mat> triggerMats; |
| | | ::YoloDetect::stringData cocoData; |
| | | FastFdsWithLock *fdfsClient; |
| | | std::vector<ScoredRect> triggerScoredRects; |
| | | TrackingTrigger* trackingTrigger; |
| | | |
| | | TriggerElement m_triggerElement; |
| | | }; |
| | | |
| | | #endif // YOLORPCELEMENT_H |
| | |
| | | auto size = vec.size(); |
| | | // int size = 1; |
| | | int pos = 0; |
| | | AppPipeController _AppPipeController("test12344", json, true); |
| | | // AppPipeController _AppPipeController("test12344", json, true); |
| | | // AppPipeController _AppPipeController(src_path, json); |
| | | _AppPipeController.setfdfsClient(&fdfsClient); |
| | | // _AppPipeController.setfdfsClient(&fdfsClient); |
| | | // for (; pos < size;) { |
| | | // |
| | | // //#todo |
| | | // _AppPipeController.resetVideoCapturePath(vec[pos++]); |
| | | // _AppPipeController.resetVideoCapturePath( |
| | | // "/home/basic/work/qiaojia/cut/DS-7808N-SN0820161208AARR691369356WCVU/34/201810/11/DS-7808N-SN0820161208AARR691369356WCVU-34-20181011090000/2018-10-11 09:48:05.mp4"); |
| | | _AppPipeController.start(); |
| | | while (_AppPipeController.getRunning()) { |
| | | usleep(40000); |
| | | } |
| | | _AppPipeController.stop(); |
| | | _AppPipeController.wait(); |
| | | // _AppPipeController.start(); |
| | | // while (_AppPipeController.getRunning()) { |
| | | // usleep(40000); |
| | | // } |
| | | // _AppPipeController.stop(); |
| | | // _AppPipeController.wait(); |
| | | DBG("finish file"); |
| | | // } |
| | | // } |
| | |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <basic/http_server/HttpSrvRetRecieve.hpp> |
| | | #include <basic/util/net_config/net_config.h> |
| | | |
| | | #include "DBStruct.h" |
| | | #define SETSCORE(VEC, POS, IDENT) appPref.setFloatData(IDENT, POS >= VEC.size() ? 80 : VEC[POS]); |
| | | |
| | | class BaiscSDKAnalysVideo : public mythread<getsdkHdlManage> { |
| | |
| | | virtual void doFunc(std::shared_ptr<getsdkHdlManage> spPacket) { |
| | | |
| | | // DBG("do func sdk"); |
| | | Json::Value json; |
| | | // Json::Value json; |
| | | |
| | | //split sdks enable |
| | | //#todo other sdk |
| | |
| | | // std::string s_c = str_cmp_thr; |
| | | vector<int> sdkDetCoVec = chnString2Vec(spPacket->str_det_thr); |
| | | vector<int> sdkComCoVec = chnString2Vec(spPacket->str_cmp_thr); |
| | | |
| | | SdkRuleMap ruleMap; |
| | | int t_size = sdkVec.size(); |
| | | std::string str_pre(spPacket->strDevID); |
| | | str_pre.append(to_string(spPacket->nChannelID)); |
| | | for (int i = 0; i < t_size; i++) { |
| | | switch (sdkVec[i]) { |
| | | case 1: { |
| | | json["face.enable"] = "1"; |
| | | case FaceSdk: { |
| | | // json["face.enable"] = "1"; |
| | | |
| | | DBG("" << str_pre); |
| | | |
| | | DBG(" TESTCODE setValue" << str_pre << " " << sdkDetCoVec[i] << " " << sdkComCoVec[i]); |
| | | SETSCORE(sdkDetCoVec, i, str_pre + "face.det"); |
| | | SETSCORE(sdkComCoVec, i, str_pre + "face.cmp"); |
| | | // SETSCORE(sdkDetCoVec, i, str_pre + "face.det"); |
| | | // SETSCORE(sdkComCoVec, i, str_pre + "face.cmp"); |
| | | SdkRule rule; |
| | | rule.nIsRun=1; |
| | | rule.nQuality=sdkDetCoVec[i]; |
| | | rule.nThreshold=sdkComCoVec[i]; |
| | | rule.strAddr=spPacket->str_addr.c_str(); |
| | | ruleMap[FaceSdk]=rule; |
| | | break; |
| | | } |
| | | case 2: { |
| | | DBG("XX.enable " << "1"); |
| | | case CarSdk: { |
| | | // DBG("XX.enable " << "1"); |
| | | DBG(" TESTCODE setValue" << str_pre << " " << sdkDetCoVec[i] << " " << sdkComCoVec[i]); |
| | | SETSCORE(sdkDetCoVec, i, str_pre + "XX.det"); |
| | | SETSCORE(sdkComCoVec, i, str_pre + "XX.cmp"); |
| | | // SETSCORE(sdkDetCoVec, i, str_pre + "XX.det"); |
| | | // SETSCORE(sdkComCoVec, i, str_pre + "XX.cmp"); |
| | | SdkRule rule; |
| | | rule.nIsRun=1; |
| | | rule.nQuality=sdkDetCoVec[i]; |
| | | rule.nThreshold=sdkComCoVec[i]; |
| | | rule.strAddr=spPacket->str_addr.c_str(); |
| | | ruleMap[CarSdk]=rule; |
| | | break; |
| | | } |
| | | case 3: { |
| | | json["yolo.enable"] = "1"; |
| | | case YoloSdk: { |
| | | // json["yolo.enable"] = "1"; |
| | | DBG(" TESTCODE setValue" << str_pre << " " << sdkDetCoVec[i] << " " << sdkComCoVec[i]); |
| | | SETSCORE(sdkDetCoVec, i, str_pre + "yolo.det"); |
| | | SETSCORE(sdkComCoVec, i, str_pre + "yolo.cmp"); |
| | | // SETSCORE(sdkDetCoVec, i, str_pre + "yolo.det"); |
| | | // SETSCORE(sdkComCoVec, i, str_pre + "yolo.cmp"); |
| | | SdkRule rule; |
| | | rule.nIsRun=1; |
| | | rule.nQuality=sdkDetCoVec[i]; |
| | | rule.nThreshold=sdkComCoVec[i]; |
| | | rule.strAddr=spPacket->str_addr.c_str(); |
| | | ruleMap[YoloSdk]=rule; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | json["addr"] = spPacket->str_addr; |
| | | // json["addr"] = spPacket->str_addr; |
| | | INFO("cam add is " << spPacket->str_addr); |
| | | |
| | | //#todo get address |
| | | |
| | | AppPipeController _AppPipeController(spPacket->src_path, json); |
| | | AppPipeController _AppPipeController(spPacket->src_path, ruleMap); |
| | | _AppPipeController.setfdfsClient(&fdfsClient); |
| | | //#todo from path get file list |
| | | file_filter_type filter = [](const char *dirName, const char *dirent) { |
| | |
| | | ../StructureApp/NewEncodeVideoManager.cpp |
| | | ../StructureApp/NewEncodeVideo.cpp |
| | | ../StructureApp/HiredisTool.cpp |
| | | ../StructureApp/PersonElement.cpp |
| | | ../StructureApp/PerStaticElement.cpp |
| | | |
| | | ../YoloServer/rpc/YoloServer.cpp |
| | | ../FaceDetectServer/rpc/FaceServer.cpp |
| | |
| | | ../../../BasicPlatForm/basic/pipe_element/ImageFactoryElement.cpp |
| | | ../../../BasicPlatForm/basic/util/BASE64/Base64.cpp |
| | | ../../../BasicPlatForm/basic/util/fastdfs/FastdfsClient.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | |
| | | #çº¿ç¨æ± |
| | | myThread.cpp |
| | |
| | | |
| | | void RtspAnalysElement::init() { |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | auto lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | |
| | | appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration); |
| | | |
| | | appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration); |
| | | if (lst.size() > 0) { |
| | | Json::Value json; |
| | | for (auto item : lst) { |
| | | string t_camIdex = item.str_cam_dev_id.toStdString(); |
| | | // std::string rtsp_url; |
| | | // if (item.str_brand.toStdString() == "haikang") { |
| | | // //è°ç¨rtspæµrtsp://admin:a1234567@192.168.1.215:554/h264/ch1/main/av_stream |
| | | // int port = 554;//TODO |
| | | // string username =; |
| | | // DBG("username:" << username << "!!!"); |
| | | // string passwd = item.str_password.toStdString(); |
| | | // string ip = item.str_ip.toStdString(); |
| | | // |
| | | // rtsp_url = "rtsp://" + username + ":" + passwd + "@" + ip + ":" + std::to_string(port) + |
| | | // "/h264/ch1/main/av_stream"; |
| | | // |
| | | // }//else if(){} |
| | | |
| | | std::string t_camIdex = item.str_cam_dev_id.toStdString(); |
| | | std::string rtsp_url = rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(), |
| | | item.str_password.toStdString(), item.str_brand.toStdString()); |
| | | |
| | | |
| | | // lRec.str_det_thr = rec.value("det_thr").toString(); |
| | | // lRec.str_cmp_thr = rec.value("cmp_thr").toString(); |
| | | auto en_sdk = m_lDBTool->searchCamSdkTableByCamId(item.str_cam_dev_id); |
| | | vector<int> sdkVec = chnString2Vec(en_sdk.str_sdks.toStdString()); |
| | | |
| | | //è®¾ç½®æ£æµå¾å |
| | | // std::string s_d = str_det_thr; |
| | | // std::string s_c = str_cmp_thr; |
| | | vector<int> sdkDetCoVec = chnString2Vec(en_sdk.str_det_thr.toStdString()); |
| | | vector<int> sdkComCoVec = chnString2Vec(en_sdk.str_cmp_thr.toStdString()); |
| | | |
| | | int camId=item.str_cam_dev_id.toInt(); |
| | | int t_size = sdkVec.size(); |
| | | for (int i = 0; i < t_size; i++) { |
| | | switch (sdkVec[i]) { |
| | | case 1: { |
| | | // INFO("face.enable"); |
| | | json["face.enable"] = "1"; |
| | | SETSCORE(sdkDetCoVec, i, t_camIdex + "face.det"); |
| | | SETSCORE(sdkComCoVec, i, t_camIdex + "face.cmp"); |
| | | DBG(" TESTCODE " << sdkDetCoVec[i] << " " << sdkComCoVec[i]); |
| | | |
| | | break; |
| | | } |
| | | case 2: { |
| | | DBG("XX.enable " << "1"); |
| | | SETSCORE(sdkDetCoVec, i, t_camIdex + "XX.det"); |
| | | SETSCORE(sdkComCoVec, i, t_camIdex + "XX.cmp"); |
| | | break; |
| | | } |
| | | case 3: { |
| | | // INFO("face.enable"); |
| | | json["yolo.enable"] = "1"; |
| | | SETSCORE(sdkDetCoVec, i, t_camIdex + "yolo.det"); |
| | | SETSCORE(sdkComCoVec, i, t_camIdex + "yolo.cmp"); |
| | | break; |
| | | } |
| | | case 4: { |
| | | |
| | | json["perimeter.enable"] = "1"; |
| | | SETSCORE(sdkDetCoVec, i, t_camIdex + "perimeter.det"); |
| | | SETSCORE(sdkComCoVec, i, t_camIdex + "perimeter.cmp"); |
| | | setDataByType(4,json,camId); |
| | | break; |
| | | } |
| | | case 5: { |
| | | |
| | | json["crowd.enable"] = "1"; |
| | | SETSCORE(sdkDetCoVec, i, t_camIdex + "crowd.det"); |
| | | SETSCORE(sdkComCoVec, i, t_camIdex + "crowd.cmp"); |
| | | setDataByType(5,json,camId); |
| | | break; |
| | | } |
| | | case 6: { |
| | | |
| | | json["keepRight.enable"] = "1"; |
| | | SETSCORE(sdkDetCoVec, i, t_camIdex + "keepRight.det"); |
| | | SETSCORE(sdkComCoVec, i, t_camIdex + "keepRight.cmp"); |
| | | setDataByType(6,json,camId); |
| | | break; |
| | | } |
| | | SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id); |
| | | for (auto &rule:ruleMap) { |
| | | if (rule.second.nThreshold < 5 || rule.second.nThreshold > 95) { |
| | | rule.second.nThreshold = 75; |
| | | } |
| | | rule.second.fSensitivity = (float) (rule.second.nThreshold) / 100; |
| | | DBG("fSensitivity" << rule.second.fSensitivity); |
| | | rule.second.strAddr = item.str_addr; |
| | | rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first); |
| | | } |
| | | appPref.setStringData(t_camIdex + "rtsp", rtsp_url); |
| | | // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString()); |
| | | json["rtsp"] = rtsp_url; |
| | | json["addr"] = item.str_addr.toStdString(); |
| | | // json["addr"] = item.str_addr.toStdString(); |
| | | |
| | | INFO("cam add is " << item.str_addr.toStdString()); |
| | | |
| | | // DBG(t_camIdex); |
| | | |
| | | appPref.getLongData("gpu.index"); |
| | | addCamera(t_camIdex, json.toStyledString()); |
| | | addCamera(t_camIdex, ruleMap); |
| | | } |
| | | } else { |
| | | ERR("searchCamDevTableAll size is 0"); |
| | |
| | | controllers.clear(); |
| | | } |
| | | |
| | | int RtspAnalysElement::addCamera(const std::string &index, const std::string &json) { |
| | | int RtspAnalysElement::addCamera(const std::string &index, const std::map<int, SdkRule> &sdkRuleMap) { |
| | | if (controllers.find(index) == controllers.end()) { |
| | | if (currentCount >= maxCount) { |
| | | ERR("addCamera faild, camera's num is full!") |
| | | return -1; |
| | | } |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | |
| | | if (reader.parse(json, value)) { |
| | | controllers[index] = new AppPipeController(index, sdkRuleMap, true); |
| | | controllers[index]->setfdfsClient(&fdfsClient); |
| | | controllers[index]->start(); |
| | | currentCount++; |
| | | return 0; |
| | | |
| | | controllers[index] = new AppPipeController(index, std::move(value), true); |
| | | // controllers[index] = new AppPipeController(index, std::move(value), false); |
| | | |
| | | controllers[index]->setfdfsClient(&fdfsClient); |
| | | controllers[index]->start(); |
| | | currentCount++; |
| | | return 0; |
| | | } |
| | | return -1; |
| | | } else { |
| | | removeCamera(index); |
| | | DBG("removeCamera " << index) |
| | | return addCamera(index, json); |
| | | return addCamera(index, sdkRuleMap); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | return result; |
| | | } |
| | | void RtspAnalysElement::setDataByType(int type,Json::Value& json,int camId) |
| | | { |
| | | switch (type) { |
| | | case 4: |
| | | { |
| | | auto rule=m_lDBTool->searchPerimeterRuleByCamId(camId); |
| | | json["perimeter.area"]=rule.strAreas.toStdString(); |
| | | json["perimeter.num"]=rule.nAlarmPeopleNum; |
| | | json["perimeter.delay"]=rule.nTriggerDelay; |
| | | json["perimeter.tolerance"]=rule.nTriggertolerance; |
| | | break; |
| | | } |
| | | case 5: |
| | | { |
| | | auto rule=m_lDBTool->searchCrowdRuleByCamId(camId); |
| | | json["crowd.area"]=rule.strAreas.toStdString(); |
| | | json["crowd.num"]=rule.nAlarmPeopleNum; |
| | | json["crowd.delay"]=rule.nTriggerDelay; |
| | | json["crowd.tolerance"]=rule.nTriggertolerance; |
| | | break; |
| | | } |
| | | case 6: |
| | | { |
| | | auto rule=m_lDBTool->searchActRuleByCamId(camId); |
| | | json["keepRight.leftArea"]=rule.strAreas.toStdString(); |
| | | json["keepRight.leftLine"]=rule.strLine.toStdString(); |
| | | json["keepRight.rightArea"]=rule.strExAreas.toStdString(); |
| | | json["keepRight.rightLine"]=rule.strExLine.toStdString(); |
| | | json["keepRight.delay"]=rule.nTriggerDelay; |
| | | json["keepRight.tolerance"]=rule.nTriggertolerance; |
| | | break; |
| | | } |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //void RtspAnalysElement::setDataByType(Json::Value& json,const SdkRule& rule) |
| | | //{ |
| | | // std::string camId=rule.strCamId.toStdString(); |
| | | // sdkRuleMap[rule.nSdkType].weekRuleVec=m_lDBTool->searchCameraWeekRuleByCamId(rule.strCamId,rule.nSdkType); |
| | | // switch (rule.nSdkType) |
| | | // { |
| | | // case FaceSdk: |
| | | // { |
| | | // json["face.enable"] = "1"; |
| | | |
| | | // appPref.setFloatData(camId+"face.det",rule.nQuality); |
| | | // appPref.setFloatData(camId+"face.cmp",rule.nThreshold); |
| | | |
| | | |
| | | |
| | | // break; |
| | | // } |
| | | // case CarSdk: |
| | | // { |
| | | // // DBG("XX.enable " << "1"); |
| | | |
| | | // appPref.setFloatData(camId+"xx.det",rule.nQuality); |
| | | // appPref.setFloatData(camId+"xx.cmp",rule.nThreshold); |
| | | |
| | | // break; |
| | | // } |
| | | // case YoloSdk: |
| | | // { |
| | | // json["yolo.enable"] = "1"; |
| | | // appPref.setFloatData(camId+"yolo.det",rule.nQuality); |
| | | // appPref.setFloatData(camId+"yolo.cmp",rule.nThreshold); |
| | | |
| | | // break; |
| | | // } |
| | | // case PerimeterSdk: |
| | | // { |
| | | // // auto rule=m_lDBTool->searchPerimeterRuleByCamId(camId); |
| | | // json["perimeter.enable"] = 1; |
| | | // json["perimeter.area"]=rule.strAreas.toStdString(); |
| | | // json["perimeter.num"]=rule.nAlarmNumLowerLimit; |
| | | |
| | | // json["perimeter.delay"]=rule.nTriggerDelay; |
| | | // json["perimeter.tolerance"]=rule.nTriggerTolerance; |
| | | // appPref.setFloatData(camId+"perimeter.det",rule.nQuality); |
| | | // appPref.setFloatData(camId+"perimeter.cmp",rule.nThreshold); |
| | | |
| | | |
| | | // break; |
| | | // } |
| | | // case CrowdSdk: |
| | | // { |
| | | // json["crowd.enable"] = 1; |
| | | // json["crowd.area"]=rule.strAreas.toStdString(); |
| | | // json["crowd.num"]=rule.nAlarmNumLowerLimit; |
| | | // json["crowd.delay"]=rule.nTriggerDelay; |
| | | // json["crowd.tolerance"]=rule.nTriggerTolerance; |
| | | // appPref.setFloatData(camId+"crowd.det",rule.nQuality); |
| | | // appPref.setFloatData(camId+"crowd.cmp",rule.nThreshold); |
| | | |
| | | // break; |
| | | // } |
| | | // case KeepRightSdk: |
| | | // { |
| | | // json["keepRight.enable"] = 1; |
| | | // json["keepRight.leftArea"]=rule.strAreas.toStdString(); |
| | | // json["keepRight.leftLine"]=rule.strLine.toStdString(); |
| | | // json["keepRight.rightArea"]=rule.strExAreas.toStdString(); |
| | | // json["keepRight.rightLine"]=rule.strExLine.toStdString(); |
| | | // json["keepRight.delay"]=rule.nTriggerDelay; |
| | | // json["keepRight.tolerance"]=rule.nTriggerTolerance; |
| | | // appPref.setFloatData(camId+"keepRight.det",rule.nQuality); |
| | | // appPref.setFloatData(camId+"keepRight.cmp",rule.nThreshold); |
| | | // break; |
| | | // } |
| | | // default: |
| | | // break; |
| | | // } |
| | | //} |
| | |
| | | |
| | | virtual ~RtspAnalysElement(); |
| | | |
| | | int addCamera(const std::string &, const std::string &); |
| | | int addCamera(const std::string &, const std::map<int, SdkRule>& sdkRuleMap); |
| | | |
| | | int removeCamera(const std::string &); |
| | | |
| | |
| | | |
| | | static std::vector<int> chnString2Vec(std::string str_list); |
| | | |
| | | void setDataByType(int type,Json::Value& json,int camId); |
| | | void setDataByType(Json::Value& json,const SdkRule& rule); |
| | | |
| | | private: |
| | | LDBTool *m_lDBTool; |
| | |
| | | int maxCount; |
| | | |
| | | FastFdsWithLock fdfsClient; |
| | | std::map<int, SdkRule> sdkRuleMap; |
| | | }; |
| | | |
| | | |
| | |
| | | #ifndef DBCONNECTSTRUCT |
| | | #define DBCONNECTSTRUCT |
| | | |
| | | //#include <vector> |
| | | |
| | | //#include <QImage> |
| | | #include <QString> |
| | | #include <QDateTime> |
| | | #include <QVector> |
| | | #include <map> |
| | | struct Record_Storage_Dev |
| | | { |
| | | Record_Storage_Dev() |
| | |
| | | n_web_pic_port = 0; |
| | | str_es_pic_ip = ""; |
| | | n_es_pic_port = 0; |
| | | n_cut_max_duration = 0; |
| | | n_cut_max_duration = 20; |
| | | n_cut_min_duration = 5; |
| | | n_dev_type = 0; |
| | | str_reserved = ""; |
| | | dev_id = ""; |
| | |
| | | QString str_es_pic_ip;//ES端å¾çæå¡å¨ip |
| | | int n_es_pic_port;//ES端å¾çæå¡å¨ç«¯å£ |
| | | int n_cut_max_duration;//è£åªè§é¢æé¿ |
| | | int n_cut_min_duration;//è£åªè§é¢æduan |
| | | int n_dev_type;//0:no dev; 1:storage; 2:camera |
| | | QString str_reserved;//é¢ç |
| | | QString dev_id; |
| | |
| | | { |
| | | LActRuleWeekRecord() |
| | | { |
| | | m_nCamId=0; |
| | | m_strCamId=""; |
| | | m_nSdkType=0; |
| | | m_nType = 0; |
| | | m_strBegin = ""; |
| | | m_strEnd = ""; |
| | | } |
| | | int m_nCamId; |
| | | QString m_strCamId; |
| | | int m_nSdkType; |
| | | int m_nType; //å¨å |
| | | QString m_strBegin; |
| | | QString m_strEnd; |
| | | }; |
| | | struct ActRule |
| | | |
| | | |
| | | struct SdkRule |
| | | { |
| | | ActRule() |
| | | SdkRule() |
| | | { |
| | | nCamId = 0; |
| | | nIsRun=0; |
| | | nSdkType = 0 ; |
| | | strCamId = ""; |
| | | strAreas = ""; |
| | | strLine = ""; |
| | | strImageUrl = ""; |
| | | nTriggertolerance = 0; |
| | | nTriggerTolerance = 0; |
| | | nTriggerDelay=0; |
| | | fSensitivity = 0.5; |
| | | nAlarmPeopleNum = 0; |
| | | nQuality=0; |
| | | nThreshold=0; |
| | | nAlarmNumUpperLimit = 0; |
| | | nAlarmNumLowerLimit = 0; |
| | | fSensitivity=0; |
| | | strExAreas=""; |
| | | strLine=""; |
| | | strAddr=""; |
| | | } |
| | | int nCamId; |
| | | int nSdkType; |
| | | QString strCamId; |
| | | QString strAreas; //çæµåºå |
| | | QString strExAreas; |
| | | QString strLine; //åå²çº¿ |
| | | QString strExLine; |
| | | QString strImageUrl; //ååºåçå¾çè·¯å¾ |
| | | int nTriggertolerance; |
| | | QString strBroadcast; |
| | | QString strAddr; |
| | | int nTriggerTolerance; |
| | | int nTriggerDelay; //å»¶è¿æ¶é´ï¼ç§ï¼ |
| | | float fSensitivity;//çµæåº¦ |
| | | int nAlarmPeopleNum; //æ¥è¦äººæ°ï¼äººåæ¥æ¤ï¼ |
| | | int nQuality; |
| | | int nThreshold;//éå¼ |
| | | float fSensitivity; |
| | | int nAlarmNumUpperLimit; //æ¥è¦äººæ°ï¼äººåæ¥æ¤ï¼ |
| | | int nAlarmNumLowerLimit; |
| | | int nIsRun; |
| | | |
| | | std::vector<LActRuleWeekRecord> weekRuleVec; |
| | | }; |
| | | struct RuleCfg |
| | | typedef std::map<int,SdkRule> SdkRuleMap; |
| | | enum SdkType |
| | | { |
| | | |
| | | QVector<LActRuleWeekRecord> weekRuleVec; |
| | | ActRule actRule; |
| | | std::string strCamId; |
| | | std::string strRtsp; |
| | | std::string strAdrr; |
| | | SdkTypeStart=0, |
| | | FaceSdk, |
| | | CarSdk, |
| | | YoloSdk, //äººä½ |
| | | PerimeterSdk, |
| | | CrowdSdk, //äººåæ¥æ¤ |
| | | KeepRightSdk, |
| | | PerHubSdk, //人åå¼å¸¸7 |
| | | PerStaticSdk, //个ä½éæ¢8 |
| | | SdkTypeEnd |
| | | |
| | | }; |
| | | |
| | | #endif // DBCONNECTSTRUCT |
| | |
| | | |
| | | |
| | | //config ä¿®æ¹è£åªè§é¢æ¶é¿ |
| | | bool LDBTool::updateConfigTableByCutDuration(int n_cut_max_duration) { |
| | | bool LDBTool::updateConfigTableByCutDuration(int n_cut_max_duration,int n_cut_min_duration) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("config"); |
| | |
| | | |
| | | QSqlRecord rec = pModel.record(0); |
| | | rec.setValue("cut_max_duration", n_cut_max_duration); |
| | | |
| | | rec.setValue("cut_min_duration", n_cut_min_duration); |
| | | while (pModel.canFetchMore()) { |
| | | pModel.fetchMore(); |
| | | } |
| | |
| | | lRec.str_es_pic_ip = rec.value("es_pic_ip").toString(); |
| | | lRec.n_es_pic_port = rec.value("es_pic_port").toInt(); |
| | | lRec.n_cut_max_duration = rec.value("cut_max_duration").toInt(); |
| | | lRec.dev_id = QString::fromStdString(appConfig.getStringProperty("DEV_ID")); |
| | | lRec.n_cut_min_duration = rec.value("cut_min_duration").toInt(); |
| | | lRec.dev_name = rec.value("dev_name").toString(); |
| | | } |
| | | |
| | | lRec.dev_id = QString::fromStdString(appConfig.getStringProperty("DEV_ID")); |
| | | if(lRec.n_cut_max_duration == 0) |
| | | { |
| | | lRec.n_cut_max_duration = 20; |
| | | } |
| | | if(lRec.n_cut_min_duration == 0) |
| | | { |
| | | lRec.n_cut_min_duration = 4; |
| | | } |
| | | return lRec; |
| | | } |
| | | |
| | | //config æ¥è¯¢è£åªè§é¢æ¶é¿ |
| | | int LDBTool::searchConfigTableWithinCutDuration(void) { |
| | | int cut_max_duration = 5;//é»è®¤5åé |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("config"); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount > 0) { |
| | | QSqlRecord rec = pModel.record(0); |
| | | if (cut_max_duration != 0) { |
| | | cut_max_duration = rec.value("cut_max_duration").toInt(); |
| | | } |
| | | } |
| | | |
| | | return cut_max_duration; |
| | | } |
| | | |
| | | bool LDBTool::insertRecordVedioPath(QString pathKey, QString filePath) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | |
| | | return false; |
| | | } |
| | | } |
| | | bool LDBTool::insertPerimeterRule(ActRule actRule) |
| | | |
| | | |
| | | |
| | | |
| | | bool LDBTool::updateCameraWeekRule(const LActRuleWeekRecord& weekRule) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_perimeter"); |
| | | pModel.setTable("rule_week"); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' and type='%2' and sdk_type='%3'").arg(weekRule.m_strCamId).arg(weekRule.m_nType).arg(weekRule.m_nSdkType)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | |
| | | QSqlRecord rec = pModel.record(); |
| | | rec.setGenerated("rule_id", false); |
| | | rec.setValue("camera_id", actRule.nCamId); |
| | | rec.setValue("sensitivity", actRule.fSensitivity); |
| | | rec.setValue("delay",actRule.nTriggerDelay); |
| | | rec.setValue("tolerance",actRule.nTriggertolerance); |
| | | rec.setValue("show_pepole_num",actRule.nAlarmPeopleNum); |
| | | |
| | | pModel.insertRecord(-1, rec);//TODO |
| | | |
| | | m_db.transaction();//å¼å§äºå¡æä½ |
| | | |
| | | if (pModel.submitAll()) { |
| | | m_db.commit();//æäº¤ |
| | | return true; |
| | | } else { |
| | | m_db.rollback();//åæ» |
| | | ERR("insertCameraRule ,pModel_load Error: " << pModel.lastError().text().toStdString()); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | bool LDBTool::updatePerimeterRuleByCamId(ActRule actRule) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_perimeter"); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' ").arg(actRule.nCamId)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | |
| | | |
| | | pModel.select(); |
| | | QSqlRecord rec = pModel.record(0); |
| | | rec.setValue("camera_id", actRule.nCamId); |
| | | rec.setValue("sensitivity", actRule.fSensitivity); |
| | | rec.setValue("delay",actRule.nTriggerDelay); |
| | | rec.setValue("tolerance",actRule.nTriggertolerance); |
| | | rec.setValue("show_pepole_num",actRule.nAlarmPeopleNum); |
| | | //rec.setGenerated("id", false); |
| | | rec.setValue("camera_id",weekRule.m_strCamId); |
| | | rec.setValue("sdk_type",weekRule.m_nSdkType); |
| | | rec.setValue("type", weekRule.m_nType); |
| | | rec.setValue("begin_time", weekRule.m_strBegin); |
| | | rec.setValue("end_time",weekRule.m_strEnd); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount == 0) { |
| | | if (rowCount == 0) |
| | | { |
| | | pModel.insertRecord(-1, rec); |
| | | } else if (rowCount > 0) { |
| | | } |
| | | else if (rowCount > 0) |
| | | { |
| | | pModel.setRecord(0, rec);//TODO |
| | | } |
| | | |
| | |
| | | return true; |
| | | } else { |
| | | m_db.rollback();//åæ» |
| | | ERR("updateCameraRuleByCamId ,pModel_load Error: " << pModel.lastError().text().toStdString()); |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | ActRule LDBTool::searchPerimeterRuleByCamId(int camId) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_perimeter"); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' ").arg(camId)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | |
| | | ActRule rule; |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount > 0) { |
| | | QSqlRecord rec = pModel.record(0); |
| | | rule.nTriggerDelay=rec.value("delay").toInt(); |
| | | rule.nTriggertolerance=rec.value("tolerance").toInt(); |
| | | rule.strAreas=rec.value("area_points").toString(); |
| | | rule.nAlarmPeopleNum=rec.value("show_people_sum").toInt(); |
| | | rule.fSensitivity=rec.value("sensitivity").toFloat(); |
| | | } |
| | | |
| | | return rule; |
| | | } |
| | | |
| | | bool LDBTool::insertCameraWeekRule(LActRuleWeekRecord weekRule) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_week"); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | |
| | | QSqlRecord rec = pModel.record(); |
| | | rec.setGenerated("id", false); |
| | | rec.setValue("camera_id",weekRule.m_nCamId); |
| | | rec.setValue("type", weekRule.m_nType); |
| | | rec.setValue("start_time", weekRule.m_strBegin); |
| | | rec.setValue("end_time",weekRule.m_strEnd); |
| | | |
| | | pModel.insertRecord(-1, rec);//TODO |
| | | |
| | | m_db.transaction();//å¼å§äºå¡æä½ |
| | | |
| | | if (pModel.submitAll()) { |
| | | m_db.commit();//æäº¤ |
| | | return true; |
| | | } else { |
| | | m_db.rollback();//åæ» |
| | | ERR("insertCameraWeekRule ,pModel_load Error: " << pModel.lastError().text().toStdString()); |
| | | ERR("updateCameraWeekRule ,pModel_load Error: " << pModel.lastError().text().toStdString()); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | QVector<LActRuleWeekRecord> LDBTool::searchCameraWeekRuleByCamId(int camId) |
| | | std::vector<LActRuleWeekRecord> LDBTool::searchCameraWeekRuleByCamId(const QString& camId,const int& sdkType) |
| | | { |
| | | QVector<LActRuleWeekRecord> vecWeek; |
| | | std::vector<LActRuleWeekRecord> vecWeek; |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_week"); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' ").arg(camId)); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' and sdk_type='%2'").arg(camId).arg(sdkType)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | |
| | |
| | | { |
| | | LActRuleWeekRecord lActRuleWeekRec; |
| | | QSqlRecord rec = pModel.record(i); |
| | | lActRuleWeekRec.m_nSdkType = rec.value("sdk_type").toInt(); |
| | | lActRuleWeekRec.m_nType = rec.value("type").toInt(); |
| | | lActRuleWeekRec.m_strBegin = rec.value("begin").toString(); |
| | | lActRuleWeekRec.m_strEnd = rec.value("end").toString(); |
| | | lActRuleWeekRec.m_strBegin = rec.value("begin_time").toString(); |
| | | lActRuleWeekRec.m_strEnd = rec.value("end_time").toString(); |
| | | lActRuleWeekRec.m_strCamId=rec.value("camera_id").toString(); |
| | | vecWeek.push_back(lActRuleWeekRec); |
| | | } |
| | | |
| | | return vecWeek; |
| | | } |
| | | ActRule LDBTool::searchActRuleByCamId(int camId) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_act"); |
| | | pModel.setFilter(QObject::tr("cam_id = '%1' ").arg(camId)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | |
| | | ActRule rule; |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount > 0) { |
| | | QSqlRecord rec = pModel.record(0); |
| | | rule.nTriggertolerance=rec.value("tolerance").toInt(); |
| | | rule.nTriggerDelay=rec.value("delay").toInt(); |
| | | rule.strAreas=rec.value("act_left_area").toString(); |
| | | rule.strLine=rec.value("act_left_line").toString(); |
| | | rule.strExAreas=rec.value("act_right_area").toString(); |
| | | rule.strExLine=rec.value("act_right_line").toString(); |
| | | rule.fSensitivity=rec.value("sensitivity").toFloat(); |
| | | } |
| | | |
| | | return rule; |
| | | } |
| | | |
| | | ActRule LDBTool::searchCrowdRuleByCamId(int camId) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_crowd"); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' ").arg(camId)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | bool LDBTool::updateSdkRule(const SdkRule& sdkRule) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("sdk_rule"); |
| | | pModel.setFilter(QObject::tr("cam_id = '%1' and sdk_type = '%2' ").arg(sdkRule.strCamId).arg(sdkRule.nSdkType)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | QSqlRecord rec = pModel.record(0); |
| | | rec.setValue("cam_id", sdkRule.strCamId); |
| | | rec.setValue("sdk_type", sdkRule.nSdkType); |
| | | rec.setValue("area", sdkRule.strAreas); |
| | | rec.setValue("ex_area",sdkRule.strExAreas); |
| | | rec.setValue("line",sdkRule.strLine); |
| | | rec.setValue("ex_line",sdkRule.strExLine); |
| | | rec.setValue("alarm_delay",sdkRule.nTriggerDelay); |
| | | rec.setValue("tolerance",sdkRule.nTriggerTolerance); |
| | | rec.setValue("alarm_num_upper",sdkRule.nAlarmNumUpperLimit); |
| | | rec.setValue("alarm_num_lower",sdkRule.nAlarmNumLowerLimit); |
| | | rec.setValue("broadcast_area",sdkRule.strBroadcast); |
| | | rec.setValue("is_run",sdkRule.nIsRun); |
| | | rec.setValue("img_threshold",sdkRule.nThreshold); |
| | | rec.setValue("img_quality",sdkRule.nQuality); |
| | | |
| | | ActRule rule; |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount > 0) { |
| | | QSqlRecord rec = pModel.record(0); |
| | | rule.nTriggertolerance=rec.value("tolerance").toInt(); |
| | | rule.nTriggerDelay=rec.value("delay").toInt(); |
| | | rule.strAreas=rec.value("area_points").toString(); |
| | | rule.nAlarmPeopleNum=rec.value("alarm_people_num").toInt(); |
| | | } |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount == 0) |
| | | { |
| | | pModel.insertRecord(-1, rec); |
| | | } |
| | | else if (rowCount > 0) |
| | | { |
| | | pModel.setRecord(0, rec);//TODO |
| | | } |
| | | |
| | | return rule; |
| | | } |
| | | m_db.transaction();//å¼å§äºå¡æä½ |
| | | |
| | | if (pModel.submitAll()) |
| | | { |
| | | m_db.commit();//æäº¤ |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | m_db.rollback();//åæ» |
| | | ERR("updateSdkRule ,pModel_load Error: " << pModel.lastError().text().toStdString()); |
| | | return false; |
| | | } |
| | | } |
| | | SdkRuleMap LDBTool::searchSdkRuleByCamId(const QString& camId) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("sdk_rule"); |
| | | pModel.setFilter(QObject::tr("cam_id = '%1' ").arg(camId)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | std::map<int,SdkRule> ruleMap; |
| | | |
| | | //std::vector<SdkRule> ruleVec; |
| | | int rowCount = pModel.rowCount(); |
| | | for(int i=0;i<rowCount;++i) |
| | | { |
| | | SdkRule rule; |
| | | QSqlRecord rec = pModel.record(i); |
| | | rule.strCamId=rec.value("cam_id").toString(); |
| | | rule.strAreas=rec.value("area").toString(); |
| | | rule.strExAreas=rec.value("ex_area").toString(); |
| | | rule.strLine=rec.value("line").toString(); |
| | | rule.strExLine=rec.value("ex_line").toString(); |
| | | rule.nTriggerDelay=rec.value("alarm_delay").toInt(); |
| | | rule.nTriggerTolerance=rec.value("tolerance").toInt(); |
| | | rule.nQuality=rec.value("img_quality").toInt(); |
| | | rule.nThreshold=rec.value("img_threshold").toInt(); |
| | | rule.nAlarmNumUpperLimit=rec.value("alarm_num_upper").toInt(); |
| | | rule.nAlarmNumLowerLimit=rec.value("alarm_num_lower").toInt(); |
| | | rule.strBroadcast=rec.value("broadcast_area").toString(); |
| | | rule.nIsRun=rec.value("is_run").toInt(); |
| | | rule.nSdkType=rec.value("sdk_type").toInt(); |
| | | ruleMap[rule.nSdkType]=rule; |
| | | //ruleVec.push_back(rule); |
| | | } |
| | | |
| | | return ruleMap; |
| | | } |
| | |
| | | |
| | | //config |
| | | bool updateConfigTableByServerInfo(Record_Config configRec); |
| | | bool updateConfigTableByCutDuration(int n_cut_max_duration); |
| | | bool updateConfigTableByCutDuration(int n_cut_max_duration,int n_cut_min_duration); |
| | | Record_Config searchConfigTableWithinServerInfo(void); |
| | | int searchConfigTableWithinCutDuration(void); |
| | | bool updateConfigTableByDevType(int devType); |
| | | int searchDevTypeFromConfigTable(void); |
| | | //Record_Config searchDevIdFromConfigTable(void); |
| | |
| | | //name_key_match |
| | | bool insertRecordVedioPath(QString pathKey,QString filePath); |
| | | QString searchRecordVedioPathByKey(QString pathKey); |
| | | //perimeter_rule |
| | | bool insertPerimeterRule(ActRule actRule); |
| | | bool updatePerimeterRuleByCamId(ActRule actRule); |
| | | ActRule searchPerimeterRuleByCamId(int camId); |
| | | |
| | | //rule_week |
| | | bool insertCameraWeekRule(LActRuleWeekRecord weekRule); |
| | | QVector<LActRuleWeekRecord> searchCameraWeekRuleByCamId(int camId); |
| | | //rule_act |
| | | ActRule searchActRuleByCamId(int camId); |
| | | //crowd_rule |
| | | ActRule searchCrowdRuleByCamId(int camId); |
| | | bool updateCameraWeekRule(const LActRuleWeekRecord& weekRule); |
| | | std::vector<LActRuleWeekRecord> searchCameraWeekRuleByCamId(const QString& camId,const int& sdkType); |
| | | |
| | | //sdk_rule |
| | | bool updateSdkRule(const SdkRule& sdkRule); |
| | | SdkRuleMap searchSdkRuleByCamId(const QString& camId); |
| | | private: |
| | | QSqlDatabase m_db; |
| | | QSqlTableModel *m_pModel; |
| | |
| | | main.cpp |
| | | YoloDetectServerI.cpp |
| | | rpc/YoloServer.cpp |
| | | ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | ) |
| | | |
| | | target_link_libraries(${PROJECT_NAME} |
| | |
| | | # ../../BasicPlatForm/basic/pipe_element/ImageShowElement.h |
| | | # ../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoCaptureElement.cpp |
| | | # ../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoCaptureElement.h |
| | | # ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp |
| | | # rpc/YoloServer.cpp |
| | | # YoloDetectClientTest.cpp |
| | | # YoloRpcElement.cpp |