| | |
| | | m_sdkRule(rule), |
| | | m_triggerElement(0,0), |
| | | m_lTime(AppUtil::getCurrentUs()), |
| | | pManagerEsDB(nullptr) |
| | | pManagerEsDB(nullptr), |
| | | m_bIsMask(true) |
| | | { |
| | | pManagerEsDB=new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | |
| | |
| | | |
| | | void PerStaticElement::threadInitial() |
| | | { |
| | | setMask(m_sdkRule.strAreas.toStdString()); |
| | | // setMask(m_sdkRule.strAreas.toStdString()); |
| | | } |
| | | |
| | | |
| | |
| | | if(!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | int num=0; |
| | | |
| | | |
| | | for(auto obj:mObjs) |
| | | bool state=false; |
| | | time_t now= AppUtil::getCurrentUs(); |
| | | for(auto& obj:mObjs) |
| | | { |
| | | |
| | | if(obj.score < m_sdkRule.fSensitivity)continue; |
| | | |
| | | QRect rect(obj.rect.x,obj.rect.y,obj.rect.width,obj.rect.height); |
| | | QPoint center = rect.center(); |
| | | if(mPolygon.containsPoint(center,Qt::OddEvenFill)) |
| | | if(mPolygon.containsPoint(center,Qt::OddEvenFill) || !m_bIsMask) |
| | | { |
| | | for(auto score:m_lastScoreRect) |
| | | for(auto ele:m_lastScoreRect) |
| | | { |
| | | if(obj.id == score.id) |
| | | if(obj.id == ele.id && (obj.rect&ele.rect).area()>ele.rect.area()*m_sdkRule.fSensitivity) |
| | | { |
| | | obj.isMove = score.isMove; |
| | | if(obj.times ==0) |
| | | { |
| | | obj.times=AppUtil::getCurrentUs(); |
| | | } |
| | | else if( (now-obj.times)>m_sdkRule.nTriggerDelay*60*1000*1000) |
| | | { |
| | | DBG("now-obj.times="<<now-obj.times); |
| | | if(pointArray!=nullptr) |
| | | { |
| | | const cv::Point2i* ppt[1] = { pointArray }; |
| | | |
| | | int npt[]={npts}; |
| | | |
| | | cv::polylines(image, ppt,npt, 1, true,cv::Scalar(255,255,0)); |
| | | } |
| | | cv::rectangle(image, obj.rect, cv::Scalar(0, 0, 255), 2); |
| | | auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl=uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl,obj); |
| | | obj.times=0; |
| | | } |
| | | //DBG("moving? "<<_TrackingInfo.m_bMoveState) |
| | | break; |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | if((AppUtil::getCurrentUs()-m_lTime)>(m_sdkRule.nTriggerDelay*60*1000*1000)) |
| | | { |
| | | for(auto& obj: mObjs){ |
| | | |
| | | //compare with last temp memery and clear temp memery |
| | | for(auto ele:m_lastScoreRect) |
| | | { |
| | | if(ele.id==obj.id) |
| | | { |
| | | if((obj.rect&ele.rect).area()>ele.rect.area()*0.8) |
| | | { |
| | | //not moving |
| | | obj.isMove = true; |
| | | |
| | | auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl=uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl,obj); |
| | | m_triggerElement.setState(true); |
| | | //DBG("not moving") |
| | | } |
| | | else |
| | | { |
| | | obj.isMove = false; |
| | | m_triggerElement.setState(false); |
| | | //DBG("moving") |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | //do temp memery |
| | | |
| | | } |
| | | m_lastScoreRect = mObjs; |
| | | m_lTime =AppUtil::getCurrentUs(); |
| | | } |
| | | m_lastScoreRect=mObjs; |
| | | m_triggerElement.triggerOnce(); |
| | | // if((AppUtil::getCurrentUs()-m_lTime)>(m_sdkRule.nTriggerDelay*60*1000*1000)) |
| | | // { |
| | | // for(auto& obj: mObjs){ |
| | | |
| | | // //compare with last temp memery and clear temp memery |
| | | // for(auto ele:m_lastScoreRect) |
| | | // { |
| | | // if(ele.id==obj.id) |
| | | // { |
| | | // if((obj.rect&ele.rect).area()>ele.rect.area()*m_sdkRule.fSensitivity) |
| | | // { |
| | | // //not moving |
| | | // obj.isMove = true; |
| | | |
| | | // auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // std::string imgUrl=uploadImgToFdfs(t_image); |
| | | // saveInfoToEs(imgUrl,obj); |
| | | // m_triggerElement.setState(true); |
| | | // //DBG("not moving") |
| | | // } |
| | | // else |
| | | // { |
| | | // obj.isMove = false; |
| | | // m_triggerElement.setState(false); |
| | | // //DBG("moving") |
| | | // } |
| | | // break; |
| | | // } |
| | | // } |
| | | // //do temp memery |
| | | |
| | | // } |
| | | // // m_lastScoreRect = mObjs; |
| | | // m_lTime =AppUtil::getCurrentUs(); |
| | | // } |
| | | |
| | | // m_lastScoreRect=mObjs; |
| | | |
| | | m_triggerElement.setState(true); |
| | | m_triggerElement.triggerOnce(); |
| | | |
| | | |
| | | fireConnectors(); |
| | |
| | | QJsonArray arrayAreas = getJsonArrayFromQString(QString::fromStdString(mask)); |
| | | if(arrayAreas.isEmpty()) |
| | | { |
| | | m_bIsMask=false; |
| | | return;//do not detect |
| | | } |
| | | int size=arrayAreas.size(); |
| | | npts=size; |
| | | pointArray=new cv::Point2i[size]; |
| | | 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) |
| | | { |
| | | 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; |
| | | mPolygon<<(QPoint(x,y)); |
| | | |
| | | DBG("width="<<sizeW); |
| | | DBG("height="<<sizeH); |
| | | } |
| | | } |
| | | QJsonArray PerStaticElement::getJsonArrayFromQString(const QString& strJson) |
| | |
| | | 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();// 抓拍地址 |
| | | 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"] = m_sdkRule.strAddr.toStdString(); // 设备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 |
| | | |
| | | t_json["imgKey"] = obj.properties["imgKey"]; |
| | | INFO("SaveImgKeyToES: "<<obj.properties["imgKey"]); |
| | | bool retface = false; |
| | | if(pManagerEsDB) |
| | | retface = pManagerEsDB->insertData("personaction", "perVideoAction", t_json.toStyledString(), str_uuid); |
| | |
| | | { |
| | | |
| | | value.copyTo(image); |
| | | if(!m_bSetWH) |
| | | { |
| | | setMask(m_sdkRule.strAreas.toStdString()); |
| | | m_bSetWH=true; |
| | | } |
| | | } |