| | |
| | | |
| | | #include <basic/pipe_element/ffmpeg/basic_struct_for_video_image.h> |
| | | //AppPipeController::AppPipeController(std::string folderPath, const Json::Value &json) : |
| | | // videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")), m_index(0), |
| | | // videoCaptureElement("filePath", 25, -1, appPref.getIntData("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), |
| | |
| | | |
| | | //} |
| | | AppPipeController::AppPipeController(std::string folderPath, const SdkRuleMap &ruleMap) : |
| | | videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcVTIMPort"), "tcp"), |
| | | videoCaptureElement("filePath", 25, -1, appPref.getIntData("gpu.index")), |
| | | // videoCaptureElement(40), |
| | | m_index(0), |
| | | m_folderPath(folderPath), |
| | | m_sdkRuleMap(ruleMap), |
| | | fdfsClient(nullptr), |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement(folderPath + "yoloRpc"), |
| | | #else |
| | | vptRpcElement(folderPath + "yoloRpc"), |
| | | #endif |
| | | faceRpcElement(folderPath + "faceRpc", ruleMap[FaceSdk]), |
| | | faceExtractElement(folderPath + "faceExtract", ruleMap[FaceSdk]), |
| | | triggerElement(25, 10), |
| | | recordVideoElement(-1, ""), |
| | | // recordVideoElement(-1, ""), |
| | | bRecordVideoEnable(false), |
| | | rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp"), |
| | | m_bSetWH(false) |
| | | { |
| | | |
| | | m_bSetWH(false) { |
| | | |
| | | init(); |
| | | |
| | | } |
| | | //AppPipeController::AppPipeController(int index, const Json::Value &json, bool RecordVideoEnable) : |
| | | // videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index"), RecordVideoEnable), |
| | | // videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getIntData("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) { |
| | |
| | | |
| | | |
| | | //AppPipeController::AppPipeController(std::string camId, const Json::Value &json, bool RecordVideoEnable) : |
| | | // videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getLongData("gpu.index")), |
| | | // videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getIntData("gpu.index")), |
| | | // m_index(0), |
| | | // m_camId(camId), |
| | | // fdfsClient(nullptr), |
| | |
| | | // intKeepRight(); |
| | | //} |
| | | AppPipeController::AppPipeController(std::string camId, const SdkRuleMap &ruleMap, bool RecordVideoEnable) : |
| | | videoCaptureElement(appPref.getStringData(camId + "rtsp"), 25, 3000, appPref.getLongData("gpu.index")), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcVTIMPort"), "tcp"), |
| | | videoCaptureElement(appPref.getStringData(camId + "rtsp"), 25, 3000, appPref.getIntData("gpu.index")), |
| | | // videoCaptureElement(40), |
| | | m_index(0), |
| | | m_camId(camId), |
| | | fdfsClient(nullptr), |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement(camId + "yoloRpc"), |
| | | #else |
| | | vptRpcElement(camId + "yoloRpc"), |
| | | #endif |
| | | faceRpcElement(camId + "faceRpc", ruleMap[FaceSdk]), |
| | | faceExtractElement(camId + "faceExtract", ruleMap[FaceSdk]), |
| | | triggerElement(25, 4), |
| | | recordVideoElement(camId, appPref.getStringData(camId + "rtsp")), |
| | | newRecordVideoElement(camId), |
| | | // recordVideoElement(camId, appPref.getStringData(camId + "rtsp")), |
| | | // newRecordVideoElement(camId), |
| | | perimeterElement(ruleMap[PerimeterSdk]), |
| | | crowdElement(ruleMap[CrowdSdk]), |
| | | perStaticElement(ruleMap[PerStaticSdk]), |
| | | perHubElement(ruleMap[PerHubSdk]), |
| | | leftJudgment(ruleMap[KeepRightSdk]), |
| | | rightJudgment(ruleMap[KeepRightSdk]), |
| | | bRecordVideoEnable(RecordVideoEnable), |
| | | // bRecordVideoEnable(RecordVideoEnable), |
| | | m_sdkRuleMap(ruleMap), |
| | | rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp"), |
| | | m_bSetWH(false) |
| | | |
| | | { |
| | | m_bSetWH(false) { |
| | | DBG("camId" << camId); |
| | | init(); |
| | | initPerimeter(); |
| | |
| | | |
| | | string test_str; |
| | | |
| | | |
| | | void AppPipeController::RecordVideo() { |
| | | std::string imgKeyYolo = yoloRpcElement.getProperty("imgKey"); |
| | | /*std::string imgKeyYolo = yoloRpcElement.getProperty("imgKey"); |
| | | |
| | | std::string imgKeyFace = faceRpcElement.getProperty("imgKey"); |
| | | if(faceRpcElement.getTriggerState() || |
| | |
| | | } |
| | | } |
| | | else { |
| | | INFO("ImageNoFace Yolo:"<<imgKeyYolo<<" Face:"<<imgKeyFace); |
| | | INFO("faceRpcElement: "<< faceRpcElement.getTriggerState() <<" "<< |
| | | "personElement: "<<personElement.getTriggerState() <<" "<< |
| | | "leftJudgment: "<<leftJudgment.getTriggerState() <<" "<< |
| | |
| | | "crowdElement: "<<crowdElement.getTriggerState()<<" "<< |
| | | "perHubElement: "<<perHubElement.getTriggerState()<<" "<< |
| | | "perStaticElement: "<<perStaticElement.getTriggerState()); |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | void AppPipeController::init() { |
| | | |
| | | unsigned char ip_old[15] = {0}; |
| | |
| | | videoCaptureElement.registerConnector([&] { |
| | | |
| | | std::string imgKey; |
| | | m_hiredisTool.listRpop(m_camId,imgKey); |
| | | if(imgKey.empty()) |
| | | { |
| | | ERR("CamId "<<m_camId<<" No ImgKey"); |
| | | m_hiredisTool.listRpop(m_camId, imgKey); |
| | | if (imgKey.empty()) { |
| | | // ERR("CamId "<<m_camId<<" No ImgKey"); |
| | | return; |
| | | } |
| | | |
| | | cv::Mat imageTemp; |
| | | m_hiredisTool.getKeyImage(imgKey,imageTemp); |
| | | if(!m_bSetWH) |
| | | { |
| | | INFO("SetWidth:"<<imageTemp.cols<<" Height:"<<imageTemp.rows); |
| | | appPref.setIntData(m_camId+"width",imageTemp.cols); |
| | | appPref.setIntData(m_camId+"height",imageTemp.rows); |
| | | m_bSetWH=true; |
| | | m_hiredisTool.getKeyImage(imgKey, imageTemp); |
| | | if (!m_bSetWH) { |
| | | INFO("SetWidth:" << imageTemp.cols << " Height:" << imageTemp.rows); |
| | | appPref.setIntData(m_camId + "width", imageTemp.cols); |
| | | appPref.setIntData(m_camId + "height", imageTemp.rows); |
| | | m_bSetWH = true; |
| | | } |
| | | |
| | | m_hiredisTool.delKey(imgKey); |
| | | if(imageTemp.empty()) |
| | | { |
| | | ERR("No Image Data In: "<<m_camId<<" ImgKey:"<<imgKey); |
| | | if (imageTemp.empty()) { |
| | | ERR("No Image Data In: " << m_camId << " ImgKey:" << imgKey); |
| | | return; |
| | | } |
| | | std::string strNewTime = AppUtil::getTimeUSecString(); |
| | | std::string strNewTime = AppUtil::getTimeUSecString(); |
| | | |
| | | ImageName_s_t imgSt = ImageName_s_t::fromString(imgKey); |
| | | |
| | |
| | | if (!faceRpcElement.isBusy()) { |
| | | //#todo |
| | | faceRpcElement.setProperty("time", strNewTime); |
| | | faceRpcElement.setProperty("imgKey",imgKey); |
| | | INFO("Write To FaceRPC ES time:"<<strNewTime<< " ImgKey: "<<imgKey); |
| | | faceRpcElement.setProperty("imgKey", imgKey); |
| | | // INFO("Write To FaceRPC ES time:" << strNewTime << " ImgKey: " << imgKey); |
| | | faceRpcElement.setImage(imageTemp); |
| | | faceRpcElement.submit(); |
| | | } |
| | | |
| | | #ifdef YOLOSERVER |
| | | if (!yoloRpcElement.isBusy()) { |
| | | //#todo |
| | | yoloRpcElement.setProperty("time", strNewTime); |
| | | yoloRpcElement.setProperty("imgKey",imgKey); |
| | | INFO("Write To YoloES time:"<<strNewTime<< " ImgKey: "<<imgKey); |
| | | yoloRpcElement.setProperty("imgKey", imgKey); |
| | | // INFO("Write To YoloES time:" << strNewTime << " ImgKey: " << imgKey); |
| | | yoloRpcElement.setImage(imageTemp); |
| | | yoloRpcElement.submit(); |
| | | } |
| | | #else |
| | | if (!vptRpcElement.isBusy()) { |
| | | //#todo |
| | | vptRpcElement.setProperty("time", strNewTime); |
| | | vptRpcElement.setProperty("imgKey", imgKey); |
| | | INFO("Write To vptRpcElement time:" << strNewTime << " ImgKey: " << imgKey); |
| | | vptRpcElement.setImage(imageTemp); |
| | | vptRpcElement.submit(); |
| | | } |
| | | #endif |
| | | |
| | | |
| | | if (appPref.getIntData("show.image") == 1 && !imageDrawElement.isBusy()) { |
| | | imageDrawElement.setImage(imageTemp); |
| | | imageDrawElement.submit(); |
| | | } |
| | | |
| | | //this->RecordVideo(); |
| | | /*if(faceRpcElement.getTriggerState() || |
| | | personElement.getTriggerState() || |
| | | leftJudgment.getTriggerState() || |
| | |
| | | }); |
| | | |
| | | |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector([&] { |
| | | imageDrawElement.setYoloObjects(personElement.getLastScoreRects()); |
| | | if (!personElement.isBusy()) { |
| | | personElement.setObjsResults(yoloRpcElement.getLastScoreRects()); |
| | | personElement.submit(); |
| | | } |
| | | INFO("Record Video By Yolo"); |
| | | this->RecordVideo(); |
| | | //INFO("Record Video By Yolo"); |
| | | //this->RecordVideo(); |
| | | }); |
| | | #else |
| | | vptRpcElement.registerConnector([&] { |
| | | imageDrawElement.setYoloObjects(personElement.getLastScoreRects()); |
| | | if (!personElement.isBusy()) { |
| | | personElement.setObjsResults(vptRpcElement.getLastHpRects()); |
| | | personElement.submit(); |
| | | } |
| | | //#todo HCP |
| | | //#todo Car |
| | | //INFO("Record Video By Yolo"); |
| | | //this->RecordVideo(); |
| | | }); |
| | | #endif |
| | | |
| | | faceRpcElement.registerConnector([&] { |
| | | imageDrawElement.setFaces(faceRpcElement.getLastScoreRects()); |
| | | INFO("Record Video By Face"); |
| | | this->RecordVideo(); |
| | | //INFO("Record Video By Face"); |
| | | //this->RecordVideo(); |
| | | }); |
| | | |
| | | |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector("YoloTrigger", [&] { |
| | | // auto images = yoloRpcElement.getTriggerMats(); |
| | | //INFO("Record Video By Yolo"); |
| | | //this->RecordVideo(); |
| | | }); |
| | | #else |
| | | vptRpcElement.registerConnector("YoloTrigger", [&] { |
| | | // auto images = yoloRpcElement.getTriggerMats(); |
| | | //INFO("Record Video By Yolo"); |
| | | //this->RecordVideo(); |
| | | }); |
| | | #endif |
| | | |
| | | faceRpcElement.registerConnector("FaceTrigger", [&] { |
| | | // auto images = faceRpcElement.getTriggerMats(); |
| | |
| | | faceRpcElement.getTriggerFaces(), |
| | | faceRpcElement.getTriggerScoreRects(), |
| | | faceRpcElement.getTriggerMats()}); |
| | | //INFO("Record Video By Face"); |
| | | //this->RecordVideo(); |
| | | }); |
| | | |
| | | imageDrawElement.registerConnector([&] { |
| | | if (appPref.getIntData("show.image") == 1) { |
| | | ImageShowElement::showImage(to_string(this->m_index), *imageDrawElement.getImage()); |
| | | ImageShowElement::showImage(to_string(this->m_index), *imageDrawElement.getImage()); |
| | | } |
| | | }); |
| | | |
| | |
| | | registerElement(faceRpcElement); |
| | | registerElement(faceExtractElement); |
| | | } |
| | | if(appPref.getIntData("show.image") == 1) |
| | | { |
| | | if (appPref.getIntData("show.image") == 1) { |
| | | imageDrawElement.registerConnector([&] { |
| | | |
| | | ImageShowElement::showImage(to_string(this->m_index), *imageDrawElement.getImage()); |
| | |
| | | registerElement(imageDrawElement); |
| | | } |
| | | |
| | | // registerElement(newRecordVideoElement); |
| | | videoCaptureElement.setOutPutInterval(3); |
| | | // registerElement(newRecordVideoElement); |
| | | //videoCaptureElement.setOutPutInterval(3); |
| | | faceExtractElement.setProperty("index", to_string(m_index)); |
| | | #ifdef YOLOSERVER |
| | | registerElement(yoloRpcElement); |
| | | #else |
| | | registerElement(vptRpcElement); |
| | | #endif |
| | | //#todo setProperty |
| | | // faceExtractElement.setProperty("index", to_string(m_index)); |
| | | // faceExtractElement.setProperty("index", to_string(m_index)); |
| | |
| | | if (rule.nIsRun != 1) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!perimeterElement.isBusy()) { |
| | | perimeterElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | perimeterElement.setImage(yoloRpcElement.getImage()); |
| | | |
| | | perimeterElement.submit(); |
| | | } |
| | | }); |
| | | #else |
| | | vptRpcElement.registerConnector([&] { |
| | | if (!perimeterElement.isBusy()) { |
| | | perimeterElement.setYoloObjects(vptRpcElement.getLastScoreRects()); |
| | | perimeterElement.setImage(vptRpcElement.getImage()); |
| | | perimeterElement.submit(); |
| | | } |
| | | // car |
| | | // prc |
| | | }); |
| | | #endif |
| | | // perimeterElement.registerConnector([&] { |
| | | |
| | | // peTriggerElement.setState(perimeterElement.getRealNum() > 0); |
| | |
| | | |
| | | crowdElement.setProperty("local_ip", m_localIp); |
| | | |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!crowdElement.isBusy()) { |
| | | crowdElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | |
| | | crowdElement.submit(); |
| | | } |
| | | }); |
| | | |
| | | #else |
| | | vptRpcElement.registerConnector([&] { |
| | | if (!perimeterElement.isBusy()) { |
| | | perimeterElement.setYoloObjects(vptRpcElement.getLastHpRects()); |
| | | perimeterElement.setImage(vptRpcElement.getImage()); |
| | | perimeterElement.submit(); |
| | | } |
| | | // car |
| | | // prc |
| | | }); |
| | | #endif |
| | | registerElement(crowdElement); |
| | | // registerElement(crowdTriggerElement); |
| | | } |
| | |
| | | rightJudgment.setProperty("local_ip", m_localIp); |
| | | leftJudgment.init(rule.strAreas, rule.strLine); |
| | | rightJudgment.init(rule.strExAreas, rule.strExLine); |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector([&] { |
| | | if(!leftJudgment.isBusy()) |
| | | { |
| | | leftJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | leftJudgment.setImage(yoloRpcElement.getImage()); |
| | | leftJudgment.submit(); |
| | | if (!leftJudgment.isBusy()) { |
| | | leftJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | leftJudgment.setImage(yoloRpcElement.getImage()); |
| | | leftJudgment.submit(); |
| | | } |
| | | if(!rightJudgment.isBusy()) |
| | | { |
| | | if (!rightJudgment.isBusy()) { |
| | | rightJudgment.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | | |
| | | rightJudgment.setImage(yoloRpcElement.getImage()); |
| | |
| | | } |
| | | |
| | | }); |
| | | #else |
| | | vptRpcElement.registerConnector([&] { |
| | | if (!leftJudgment.isBusy()) { |
| | | leftJudgment.setYoloObjects(vptRpcElement.getLastHpRects()); |
| | | leftJudgment.setImage(vptRpcElement.getImage()); |
| | | leftJudgment.submit(); |
| | | } |
| | | if (!rightJudgment.isBusy()) { |
| | | rightJudgment.setYoloObjects(vptRpcElement.getLastHpRects()); |
| | | |
| | | rightJudgment.setImage(vptRpcElement.getImage()); |
| | | rightJudgment.submit(); |
| | | } |
| | | }); |
| | | #endif |
| | | |
| | | registerElement(leftJudgment); |
| | | registerElement(rightJudgment); |
| | | |
| | |
| | | //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; |
| | | |
| | | perStaticElement.setProperty("local_ip", m_localIp); |
| | | |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!perStaticElement.isBusy()) { |
| | | perStaticElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | |
| | | perStaticElement.submit(); |
| | | } |
| | | }); |
| | | |
| | | #else |
| | | vptRpcElement.registerConnector([&] { |
| | | if (!perStaticElement.isBusy()) { |
| | | perStaticElement.setYoloObjects(vptRpcElement.getLastHpRects()); |
| | | perStaticElement.setImage(vptRpcElement.getImage()); |
| | | perStaticElement.submit(); |
| | | } |
| | | }); |
| | | #endif |
| | | registerElement(perStaticElement); |
| | | } |
| | | |
| | |
| | | //area="[{\"x\":100,\"y\":6},{\"x\":100,\"y\":1200},{\"x\":1800,\"y\":1200},{\"x\":1800,\"y\":6}]"; |
| | | |
| | | perHubElement.setProperty("local_ip", m_localIp); |
| | | |
| | | #ifdef YOLOSERVER |
| | | yoloRpcElement.registerConnector([&] { |
| | | if (!perHubElement.isBusy()) { |
| | | perHubElement.setYoloObjects(yoloRpcElement.getLastScoreRects()); |
| | |
| | | perHubElement.submit(); |
| | | } |
| | | }); |
| | | #else |
| | | vptRpcElement.registerConnector([&] { |
| | | if (!perHubElement.isBusy()) { |
| | | perHubElement.setYoloObjects(vptRpcElement.getLastHpRects()); |
| | | perHubElement.setImage(vptRpcElement.getImage()); |
| | | perHubElement.submit(); |
| | | } |
| | | }); |
| | | #endif |
| | | |
| | | registerElement(perHubElement); |
| | | } |