| | |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | |
| | | JudgmentRetrogradeTool::JudgmentRetrogradeTool(const SdkRule &rule) : |
| | | m_triggerElement(rule.nTriggerDelay * 8, 0), |
| | | 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")); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | 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; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | |
| | | |
| | | break; |
| | | } else { |
| | | m_triggerElement.setState(false); |
| | | |
| | | } |
| | | m_triggerElement.triggerOnce(); |
| | | if(m_triggerElement.getTriggerState()) |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | 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); |
| | |
| | | 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");//当前服务器IP地址 |
| | | 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) |
| | |
| | | |
| | | void JudgmentRetrogradeTool::setImage(const cv::Mat &value) { |
| | | value.copyTo(image); |
| | | if(!m_bSetWH) |
| | | { |
| | | setMask(m_area,m_line); |
| | | m_bSetWH=true; |
| | | } |
| | | } |