| | |
| | | #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); |
| | | } |