From e4c9b5bfb1d9000c08d84f2f044cd0c3605a2945 Mon Sep 17 00:00:00 2001
From: miyanhui <dennismi1024@gmail.com>
Date: 星期三, 13 二月 2019 14:17:13 +0800
Subject: [PATCH] 修复检测结果ImgKey不对应的问题
---
QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp | 158 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 107 insertions(+), 51 deletions(-)
diff --git a/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp b/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp
index d04013c..6dc6bee 100644
--- a/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp
+++ b/QiaoJiaSystem/StructureApp/JudgmentRetrogradeTool.cpp
@@ -10,10 +10,13 @@
#include <basic/util/app/AppPreference.hpp>
JudgmentRetrogradeTool::JudgmentRetrogradeTool(const SdkRule &rule) :
- TimerElement(1000),
- m_triggerElement(0, rule.nTriggerDelay * 1000 * 1000),
+ m_triggerElement(0, 0),
m_sdkRule(rule),
- pManagerEsDB(nullptr) {
+ pManagerEsDB(nullptr),
+ m_bSetWH(false),
+ pointArray(nullptr),
+ npts(0)
+{
pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort"));
}
@@ -22,22 +25,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;//do not detect
+ 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);
}
@@ -79,14 +99,9 @@
}
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);
- }
+ mObjs = value;
+
}
@@ -118,7 +133,7 @@
}
bool JudgmentRetrogradeTool::getPerRet(const long &id) {
- bool ret = (m_mapPerRet.find(id) == m_mapPerRet.end()) ? true : m_mapPerRet[id];
+ bool ret = (m_mapPerRet.find(id) == m_mapPerRet.end()) ? false :m_mapPerRet[id]>=m_sdkRule.nTriggerDelay * 8;
return ret;
}
@@ -137,12 +152,58 @@
return JRTOOL::getAngelOfTwoVector(directionVectorPoint, point);
}
-void JudgmentRetrogradeTool::timerFunc() {
+void JudgmentRetrogradeTool::threadFunc() {
func();
fireConnectors();
}
void JudgmentRetrogradeTool::func() {
+ if (!isInWeek(m_sdkRule.weekRuleVec))
+ return;
+ bool state=false;
+ for (auto &scoredRect :mObjs) {
+ if (scoredRect.score < m_sdkRule.fSensitivity)continue;
+
+ 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(scoredRect.rect& cv::Rect(0, 0, image.cols, image.rows)).clone();
+
+ 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;
+
+
+ // break;
+ }
+// m_triggerElement.triggerOnce();
+// if(m_triggerElement.getState())
+// {
+
+// 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);
+// }
+
+ setPerRect(scoredRect.id, scoredRect.rect);
+ }
+ m_triggerElement.setState(state);
+ m_triggerElement.triggerOnce();
for (auto &item : m_mapPerDirection) {
int a = 0;
int b = 0;
@@ -154,13 +215,18 @@
a++;
}
}
- // DBG("id="<<item.first<<" a="<<a<<" b="<<b);
- bool ret = a >= b ? true : false;
- if (!ret) {
- m_mapPerRet.insert(std::make_pair(item.first, false));
- // m_mapPerRet[item.first] = false;
+ if(b!=0)
+ {
+ bool ret = a >= b ? true : false;
+ // DBG("id="<<item.first<<" a="<<a<<" b="<<b<<" ret="<<ret);
+ if (!ret) {
+ m_mapPerRet[item.first]+=1;
+ // m_mapPerRet.insert(std::make_pair(item.first, false));
+ // m_mapPerRet[item.first] = false;
+ }
}
+
if (temp.size() > 9) {
@@ -168,25 +234,8 @@
}
}
- 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 {
- m_triggerElement.setState(false);
- }
- }
- m_triggerElement.triggerOnce();
}
std::string JudgmentRetrogradeTool::uploadImgToFdfs(cv::Mat &image) {
@@ -197,7 +246,7 @@
CvUtil::cvMat2Buffer(image, buffer);
std::string strImgUrlTmp = "";
fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg");
- strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp);
+ // strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp);
strImgUrl.clear();
strImgUrl = strImgUrlTmp;
// strImgUrl.append("/").append(strImgUrlTmp);
@@ -225,36 +274,38 @@
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"] = getProperty("str_addr");// 鎶撴媿鍦板潃
- t_json["picMaxUrl"] = "wait todo"; // 澶у浘璺緞
+ t_json["picAddress"] = m_sdkRule.strAddr.toStdString();// 鎶撴媿鍦板潃
+ DBG("picAddress="<<m_sdkRule.strAddr.toStdString());
+ 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"] = "wait todo"; // ji qun id
-
+ t_json["cluster_id"] = appPref.getStringData("clusterID");; // ji qun id
+ t_json["imgKey"]=obj.properties["imgKey"];
+ INFO("SaveImageKey ToES: "<<obj.properties["imgKey"]);
bool retface = false;
if (pManagerEsDB)
retface = pManagerEsDB->insertData("personaction", "perVideoAction", t_json.toStyledString(), str_uuid);
@@ -304,4 +355,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