From c8e6fb13202d18e3c1ada38578d2a5cc3c184198 Mon Sep 17 00:00:00 2001 From: miyanhui <dennismi1024@gmail.com> Date: 星期一, 18 二月 2019 17:15:45 +0800 Subject: [PATCH] VideoToImageMulth和VideoAnalyFromHC支持RPC的端口设置 --- QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp | 86 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 70 insertions(+), 16 deletions(-) diff --git a/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp b/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp index bcf0518..5c3b95c 100644 --- a/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp +++ b/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp @@ -12,7 +12,11 @@ JudgmentRetrogradeTool::JudgmentRetrogradeTool(const SdkRule &rule) : m_triggerElement(0, 0), m_sdkRule(rule), - pManagerEsDB(nullptr) + pManagerEsDB(nullptr), + m_bSetWH(false), + pointArray(nullptr), + npts(0), + m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp") { pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); } @@ -22,22 +26,39 @@ delete pManagerEsDB; pManagerEsDB = nullptr; } + if(pointArray) + { + delete pointArray; + pointArray=nullptr; + } + +} +bool JudgmentRetrogradeTool::init(QString area, QString line) +{ + m_area=area; + m_line=line; } -bool JudgmentRetrogradeTool::init(QString area, QString line) { +bool JudgmentRetrogradeTool::setMask(QString area, QString line) { //#todo string ->json QJsonArray arrayAreas = getJsonArrayFromQString(area); if (arrayAreas.isEmpty()) { return false; } + int size=arrayAreas.size(); QVector<QPoint> vec; + float sizeW=(float)appPref.getIntData(m_sdkRule.strCamId.toStdString()+"width")/480; + float sizeH=(float)appPref.getIntData(m_sdkRule.strCamId.toStdString()+"height")/270; for (int i = 0; i < arrayAreas.size(); ++i) { + pointArray=new cv::Point2i[size]; QJsonValue jsonValue = arrayAreas[i]; QJsonObject obj = jsonValue.toObject(); - int x = obj.value("x").toDouble() * 4; - int y = obj.value("y").toDouble() * 4; + int x = obj.value("x").toDouble() *sizeW; + int y = obj.value("y").toDouble() *sizeH; vec.push_back(QPoint(x, y)); + DBG("width="<<sizeW); + DBG("height="<<sizeH); } @@ -146,12 +167,22 @@ if (getPerRet(scoredRect.id))//judgment.bool { + DBG("scoredRect.id" << scoredRect.id << " val=" << m_mapPerRet[scoredRect.id]); m_mapPerRet[scoredRect.id] -=2400; - 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( +// 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); + + if(pointArray==nullptr) return; + const cv::Point2i* ppt[1] = { pointArray }; + + int npt[]={npts}; + cv::polylines(image, ppt,npt, 1, true,cv::Scalar(255,255,0)); + cv::arrowedLine(image,m_UpBaseLine.start_Point,m_UpBaseLine.end_Point,cv::Scalar(0,0,255)); + + cv::rectangle(image, scoredRect.rect, cv::Scalar(0, 0, 255), 2); + std::string imgUrl = uploadImgToFdfs(image); saveInfoToEs(imgUrl, scoredRect); state=true; @@ -243,36 +274,54 @@ 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["picName"] = "";// 鎶撴媿鐓х墖鍚嶇О + t_json["content"] = "";// 鍐呭鎻忚堪 t_json["personPicUrl"] = "";// 浜哄憳 鍦板簱鍥剧墖 t_json["ChannlId"] = getProperty("ch_id"); // 閫氶亾id t_json["likeDate"] = AppUtil::getTimeSecString(); // 姣斿鏃堕棿 t_json["picAddress"] = m_sdkRule.strAddr.toStdString();// 鎶撴媿鍦板潃 DBG("picAddress="<<m_sdkRule.strAddr.toStdString()); - t_json["picMaxUrl"] = "wait todo"; // 澶у浘璺緞 + t_json["picMaxUrl"] = ""; // 澶у浘璺緞 - // t_json["Age"] ="wait todo"; + // t_json["Age"] =""; t_json["picDate"] = obj.properties["time"]; // 鎶撴媿鏃堕棿锛屽繀椤绘湁 - t_json["picLocalUrl"] = "wait todo"; // 鏈湴璺緞 + t_json["picLocalUrl"] = ""; // 鏈湴璺緞 t_json["isDelete"] = "1";//榛樿1 ,0鏃犳晥 1鏈夋晥 - t_json["likePer"] = obj.score; // 鐩镐技鍊� + t_json["likePer"] = 1.0; // 鐩镐技鍊� - t_json["BaseName"] = "wait todo";// 鍦板簱鍚嶇О + t_json["BaseName"] = "";// 鍦板簱鍚嶇О 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["idcard"] = ""; + t_json["personId"] = ""; 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");//褰撳墠鏈嶅姟鍣↖P鍦板潃 t_json["ack_alarm"] = m_triggerElement.getTriggerState() ? "0" : ""; // que ren shi fou bao jing t_json["cluster_id"] = appPref.getStringData("clusterID");; // ji qun id + std::string imgKey = obj.properties["imgKey"]; + t_json["imgKey"]=imgKey; + INFO("SaveImageKey ToES: "<<obj.properties["imgKey"]); + try { + auto server = m_rpcClient.getServer(); + if (!server) + { + ERR("server is null"); + return false; + } + INFO("Record Video "<<imgKey); + server->recordVideo(imgKey); + } + catch (std::exception &e) + { + ERR("Record Video Err: "<<imgKey <<" Message: "<<e.what()); + return false; + } bool retface = false; if (pManagerEsDB) @@ -323,4 +372,9 @@ void JudgmentRetrogradeTool::setImage(const cv::Mat &value) { value.copyTo(image); + if(!m_bSetWH) + { + setMask(m_area,m_line); + m_bSetWH=true; + } } -- Gitblit v1.8.0