From c06ac5deb150c99b53d1ff460a88cf2543698788 Mon Sep 17 00:00:00 2001 From: chenshijun <csj_sky@126.com> Date: 星期一, 15 四月 2019 15:26:51 +0800 Subject: [PATCH] vpt调试基本ok --- QiaoJiaSystem/VptServer/CMakeLists.txt | 3 QiaoJiaSystem/VideoServer/QiaoJia/DB/DBStruct.h | 2 QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp | 16 + QiaoJiaSystem/StructureApp/PerimeterElement.cpp | 179 +++++++++++---------- QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp | 2 QiaoJiaSystem/VideoAnalysFromHC/main.cpp | 17 + QiaoJiaSystem/StructureApp/VptRpcElement.cpp | 44 ++-- QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp | 2 QiaoJiaSystem/StructureApp/AppPipeController.cpp | 4 QiaoJiaSystem/VptServer/VptDetectWrapper.cpp | 110 +++++++------ QiaoJiaSystem/DataManagerServer/http_configserver.cpp | 6 QiaoJiaSystem/RapidStructureApp/TriggerElement.cpp | 10 QiaoJiaSystem/StructureApp/PerimeterElement.h | 7 QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp | 2 QiaoJiaSystem/StructureApp/main.cpp | 17 + 15 files changed, 233 insertions(+), 188 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp index d5dd971..575bd8a 100644 --- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp +++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp @@ -3313,6 +3313,11 @@ rule.strExAreas = value["strExAreas"].asCString(); rule.strLine = value["strLine"].asCString(); rule.strExLine = value["strExLine"].asCString(); + + if(!value["strPerimeterObjType"].empty()) + { + rule.strPerimeterObjType = value["strPerimeterObjType"].asCString(); + } if (rule.strCamId.isEmpty()) { return "{\"ret_status\":\"鍐呭鏈夎锛岃妫�鏌ワ紒\"}"; } @@ -3389,6 +3394,7 @@ obj["strExAreas"] = rule.second.strExAreas.toStdString(); obj["strLine"] = rule.second.strLine.toStdString(); obj["strExLine"] = rule.second.strExLine.toStdString(); + obj["strPerimeterObjType"] = rule.second.strPerimeterObjType.toStdString(); Json::Value weekRuleArray; diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp index fdd97a4..974c3ce 100644 --- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp +++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp @@ -261,7 +261,7 @@ void BASICGB28181::VideoCaptureElementWithRtp::SaveVideo(const std::string &strImageName) { - INFO("SaveVideo: " << strImageName); +// INFO("SaveVideo: " << strImageName); std::string strTimeStamp = AppUtil::getTimeUSecString(); std::string strPath = MakeDir(strTimeStamp); m_fFmpegDecoderJPG.SaveVideoByImageName(strPath, strImageName); diff --git a/QiaoJiaSystem/RapidStructureApp/TriggerElement.cpp b/QiaoJiaSystem/RapidStructureApp/TriggerElement.cpp index 11233ce..541c29f 100644 --- a/QiaoJiaSystem/RapidStructureApp/TriggerElement.cpp +++ b/QiaoJiaSystem/RapidStructureApp/TriggerElement.cpp @@ -5,7 +5,7 @@ // TimerElement(1), triggerState(false), tolerance(tolerance), delay(delay), - triggerType(DOWN), triggerTimes(0),lastDown(0),lastUp(0) { + triggerType(DOWN), triggerTimes(0), lastDown(0), lastUp(0) { } @@ -78,12 +78,12 @@ lastDown = 0; triggerType = DOWN; } -void TriggerElement::resetTriggerState() -{ + +void TriggerElement::resetTriggerState() { //state=false; - triggerState=false; - triggerTimes=0; + triggerState = false; + triggerTimes = 0; } void TriggerElement::timerFunc() { diff --git a/QiaoJiaSystem/StructureApp/AppPipeController.cpp b/QiaoJiaSystem/StructureApp/AppPipeController.cpp index fcddc04..4e59bc8 100644 --- a/QiaoJiaSystem/StructureApp/AppPipeController.cpp +++ b/QiaoJiaSystem/StructureApp/AppPipeController.cpp @@ -95,7 +95,7 @@ perHubElement(ruleMap[PerHubSdk]), leftJudgment(ruleMap[KeepRightSdk]), rightJudgment(ruleMap[KeepRightSdk]), - bRecordVideoEnable(RecordVideoEnable), +// bRecordVideoEnable(RecordVideoEnable), m_sdkRuleMap(ruleMap), m_bSetWH(false) { DBG("camId" << camId); @@ -530,7 +530,7 @@ #else vptRpcElement.registerConnector([&] { if (!perimeterElement.isBusy()) { - perimeterElement.setYoloObjects(vptRpcElement.getLastHpRects()); + perimeterElement.setYoloObjects(vptRpcElement.getLastScoreRects()); perimeterElement.setImage(vptRpcElement.getImage()); perimeterElement.submit(); } diff --git a/QiaoJiaSystem/StructureApp/PerimeterElement.cpp b/QiaoJiaSystem/StructureApp/PerimeterElement.cpp index c637c6d..5345549 100644 --- a/QiaoJiaSystem/StructureApp/PerimeterElement.cpp +++ b/QiaoJiaSystem/StructureApp/PerimeterElement.cpp @@ -14,19 +14,19 @@ #include <jsoncpp/json/json.h> #define ALARM_PERCENT (25) //25% + PerimeterElement::PerimeterElement(const SdkRule &rule) : m_sdkRule(rule), PipeElement(true), trackingTrigger(nullptr), mRealNum(0), //姣忕鍑犲紶,灏变箻浠ュ嚑 - m_triggerElement(rule.nTriggerDelay*3,0), + m_triggerElement(rule.nTriggerDelay * 3, 0), pManagerEsDB(nullptr), m_bIsMask(true), m_bSetWH(false), pointArray(nullptr), - m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcVTIMPort"),"tcp") -{ + m_rpcClient("RtspAnalysServer", "127.0.0.1", appPref.getIntData("RpcVTIMPort"), "tcp") { pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); } @@ -36,8 +36,7 @@ delete pManagerEsDB; pManagerEsDB = nullptr; } - if(pointArray) - { + if (pointArray) { // delete[] pointArray[0]; delete[] pointArray; } @@ -60,11 +59,17 @@ bool state = false; m_recVec.clear(); + //todo debug + m_scoreVec.clear(); + m_objTypeVec.clear(); + // DBG("Objs="<<mObjs.size()<<" fSensitivity="<<m_sdkRule.fSensitivity<<" nThreshold"<<m_sdkRule.nThreshold); - for (auto obj:mObjs) { + for (auto &obj:mObjs) { if (obj.score < m_sdkRule.fSensitivity)continue; + DBG("objArea:" << obj.rect.width * obj.rect.height); + DBG("alarmObjType:" << obj.properties["type"]); QRect rect(obj.rect.x, obj.rect.y, obj.rect.width, obj.rect.height); QPoint center = rect.center(); @@ -74,66 +79,64 @@ // DBG("picDate="<<picDate); } - if(imgKey.empty()) - { - imgKey =obj.properties["imgKey"]; + if (imgKey.empty()) { + imgKey = obj.properties["imgKey"]; } - if (m_sdkRule.nSdkType == PerimeterSdk) - { - - if(m_bIsMask) + if (m_sdkRule.nSdkType == PerimeterSdk) { + //todo 瑙f瀽sdkrule 骞跺拰妫�娴嬬粨鏋滃姣� + if (m_sdkRule.strPerimeterObjType.toStdString().find(obj.properties["type"]) == + m_sdkRule.strPerimeterObjType.toStdString().npos)//椤甸潰娌℃湁閰嶇疆浜嗚绠楁硶 { - std::vector<Point> poly2; - std::vector<Point> interPoly; - poly2.push_back(Point(rect.x(),rect.y())); - poly2.push_back(Point(rect.x()+rect.width(),rect.y())); - poly2.push_back(Point(rect.x()+rect.width(),rect.y()+rect.height())); - poly2.push_back(Point(rect.x(),rect.y()+rect.height())); - IntAreaCalcUtil::PolygonClip(poly1,poly2,interPoly); - float inter = IntAreaCalcUtil::intAreaCalc(interPoly); - float total1 =IntAreaCalcUtil::intAreaCalc(poly1); - float total2 = IntAreaCalcUtil::intAreaCalc(poly2); - int per1 = (int)(inter / total1 * 100); - int per2 = (int)(inter / total2 * 100); - int per=std::max(per1,per2); + continue; + } - if(ALARM_PERCENT <= per) - { - //DBG("per 1="<<per1<<" per2="<<per2<<" per="<<per); - m_recVec.push_back(obj.rect); - num++; - } + if (m_bIsMask) { + std::vector<Point> poly2; + std::vector<Point> interPoly; + poly2.push_back(Point(rect.x(), rect.y())); + poly2.push_back(Point(rect.x() + rect.width(), rect.y())); + poly2.push_back(Point(rect.x() + rect.width(), rect.y() + rect.height())); + poly2.push_back(Point(rect.x(), rect.y() + rect.height())); + IntAreaCalcUtil::PolygonClip(poly1, poly2, interPoly); + float inter = IntAreaCalcUtil::intAreaCalc(interPoly); + float total1 = IntAreaCalcUtil::intAreaCalc(poly1); + float total2 = IntAreaCalcUtil::intAreaCalc(poly2); + int per1 = (int) (inter / total1 * 100); + int per2 = (int) (inter / total2 * 100); + int per = std::max(per1, per2); + + if (ALARM_PERCENT <= per) { + //DBG("per 1="<<per1<<" per2="<<per2<<" per="<<per); + m_recVec.push_back(obj.rect); + m_scoreVec.push_back(obj.score); + m_objTypeVec.push_back(obj.properties["type"]); + num++; + DBG("============alarmObjType:" << obj.properties["type"] << " score:" << obj.score); + } } - } - else if (mPolygon.containsPoint(center, Qt::OddEvenFill) || !m_bIsMask) - { + } else if (mPolygon.containsPoint(center, Qt::OddEvenFill) || !m_bIsMask) { m_recVec.push_back(obj.rect); - - num++; } - - - } switch (m_sdkRule.nSdkType) { case PerimeterSdk: //state = num > 0 ; - state =( num !=mRealNum); - // DBG("num="<<num<< "time="<< picDate); + state = (num != mRealNum); + // DBG("num="<<num<< "time="<< picDate); INFO("SDK Type: PerimeterSdk"); break; case CrowdSdk: - state = num > m_sdkRule.nAlarmNumLowerLimit && num !=mRealNum; + state = num > m_sdkRule.nAlarmNumLowerLimit && num != mRealNum; INFO("SDK Type: CrowdSdk"); break; case PerHubSdk: - state = num > m_sdkRule.nAlarmNumLowerLimit && num < m_sdkRule.nAlarmNumUpperLimit && num !=mRealNum; + state = num > m_sdkRule.nAlarmNumLowerLimit && num < m_sdkRule.nAlarmNumUpperLimit && num != mRealNum; INFO("SDK Type: PerHubSdk"); // if(m_sdkRule.nAlarmNumLowerLimit>=0) @@ -166,24 +169,32 @@ default: break; } - INFO("State:"<<state<<" Num:"<<num<<" mRealNum:"<<mRealNum<<" LowerLimit :"<<m_sdkRule.nAlarmNumLowerLimit<<" HightLimit: "<<m_sdkRule.nAlarmNumUpperLimit); + INFO("State:" << state << " Num:" << num << " mRealNum:" << mRealNum << " LowerLimit :" + << m_sdkRule.nAlarmNumLowerLimit << " HightLimit: " << m_sdkRule.nAlarmNumUpperLimit + << " m_triggerElement.getTriggerState() :" << m_triggerElement.getTriggerState()); m_triggerElement.setState(state); m_triggerElement.triggerOnce(); - if (m_triggerElement.getTriggerState()) - { - if(num > 0) { - if(pointArray!=nullptr) - { - const cv::Point2i* ppt[1] = { pointArray }; + DBG("m_triggerElement.getTriggerState():" << m_triggerElement.getTriggerState()); + if (m_triggerElement.getTriggerState()) { + if (num > 0) { + if (pointArray != nullptr) { + const cv::Point2i *ppt[1] = {pointArray}; - int npt[]={npts}; + int npt[] = {npts}; - cv::polylines(image, ppt,npt, 1, true,cv::Scalar(255,255,0), 2); + cv::polylines(image, ppt, npt, 1, true, cv::Scalar(255, 255, 0), 2); } - for(auto rect:m_recVec) - { - cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2); +// for(auto rect:m_recVec) +// { +// cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2); +// } + for (int i = 0; i < m_recVec.size(); i++) { + cv::rectangle(image, m_recVec[i], cv::Scalar(0, 0, 255), 2); + cv::putText(image, to_string(m_scoreVec[i]), cv::Point(m_recVec[i].x, m_recVec[i].y + 12), + cv::HersheyFonts::FONT_HERSHEY_PLAIN, 1.5, cv::Scalar(255, 255, 0)); + cv::putText(image, m_objTypeVec[i], cv::Point(m_recVec[i].x, m_recVec[i].y + 24), + cv::HersheyFonts::FONT_HERSHEY_PLAIN, 1.5, cv::Scalar(255, 255, 0)); } // cv::Mat t_image = image(CutMask()).clone(); // if(t_image.empty()) @@ -192,7 +203,7 @@ // return; // } std::string imgUrl = uploadImgToFdfs(image); - saveInfoToEs(imgUrl, picDate,imgKey); + saveInfoToEs(imgUrl, picDate, imgKey); } DBG("num=" << num << " lastnum=" << mRealNum); mRealNum = num; @@ -262,31 +273,28 @@ void PerimeterElement::setMask(std::string mask) { QJsonArray arrayAreas = getJsonArrayFromQString(QString::fromStdString(mask)); if (arrayAreas.isEmpty() && m_sdkRule.nSdkType != PerimeterSdk) { - m_bIsMask=false; + m_bIsMask = false; return;//do not detect } int size = arrayAreas.size(); npts = size; - float sizeW=(float)appPref.getIntData(m_sdkRule.strCamId.toStdString()+"width")/480; - float sizeH=(float)appPref.getIntData(m_sdkRule.strCamId.toStdString()+"height")/270; - pointArray=new cv::Point2i[npts]; + float sizeW = (float) appPref.getIntData(m_sdkRule.strCamId.toStdString() + "width") / 480; + float sizeH = (float) appPref.getIntData(m_sdkRule.strCamId.toStdString() + "height") / 270; + pointArray = new cv::Point2i[npts]; for (int i = 0; i < size; ++i) { QJsonValue jsonValue = arrayAreas[i]; QJsonObject obj = jsonValue.toObject(); - int x = obj.value("x").toDouble() *sizeW; - int y = obj.value("y").toDouble() *sizeH; - pointArray[i]={x,y}; - if(m_sdkRule.nSdkType == PerimeterSdk) - { - poly1.push_back(Point(x,y)); + int x = obj.value("x").toDouble() * sizeW; + int y = obj.value("y").toDouble() * sizeH; + pointArray[i] = {x, y}; + if (m_sdkRule.nSdkType == PerimeterSdk) { + poly1.push_back(Point(x, y)); + } else { + mPolygon << (QPoint(x, y)); } - else - { - mPolygon << (QPoint(x, y)); - } - DBG("width="<<sizeW); - DBG("height="<<sizeH); + DBG("width=" << sizeW); + DBG("height=" << sizeH); } @@ -307,10 +315,9 @@ // image = cv::Mat(value.rows, value.cols, CV_8UC3, sharedMemory->data()); // } value.copyTo(image); - if(!m_bSetWH) - { + if (!m_bSetWH) { setMask(m_sdkRule.strAreas.toStdString()); - m_bSetWH=true; + m_bSetWH = true; } } @@ -327,7 +334,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); @@ -336,7 +343,7 @@ return strImgUrl; } -bool PerimeterElement::saveInfoToEs(const std::string &imgUrl, const std::string &time,const std::string& imgKey) { +bool PerimeterElement::saveInfoToEs(const std::string &imgUrl, const std::string &time, const std::string &imgKey) { string str_uuid; uuid_t t_uuid; @@ -361,13 +368,13 @@ 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()); + DBG("picAddress=" << m_sdkRule.strAddr.toStdString()); t_json["picMaxUrl"] = ""; // 澶у浘璺緞 // t_json["Age"] ="wait todo"; t_json["picDate"] = time; // 鎶撴媿鏃堕棿锛屽繀椤绘湁 - DBG("picDate="<<time); + DBG("picDate=" << time); t_json["picLocalUrl"] = ""; // 鏈湴璺緞 t_json["isDelete"] = "1";//榛樿1 ,0鏃犳晥 1鏈夋晥 @@ -389,20 +396,18 @@ t_json["imgKey"] = imgKey; try { auto server = m_rpcClient.getServer(); - if (!server) - { + if (!server) { ERR("server is null"); //return false; } - INFO("Record Video "<<imgKey); + INFO("Record Video " << imgKey); server->recordVideo(imgKey); } - catch (std::exception &e) - { - ERR("Record Video Err: "<<imgKey <<" Message: "<<e.what()); + catch (std::exception &e) { + ERR("Record Video Err: " << imgKey << " Message: " << e.what()); //return false; } - INFO("SaveImgKeyToES: "<<imgKey); + INFO("SaveImgKeyToES: " << imgKey); bool retface = false; if (pManagerEsDB) retface = pManagerEsDB->insertData("personaction", "perVideoAction", t_json.toStyledString(), str_uuid); diff --git a/QiaoJiaSystem/StructureApp/PerimeterElement.h b/QiaoJiaSystem/StructureApp/PerimeterElement.h index df6deca..cdc80d7 100644 --- a/QiaoJiaSystem/StructureApp/PerimeterElement.h +++ b/QiaoJiaSystem/StructureApp/PerimeterElement.h @@ -85,7 +85,12 @@ int npts; - std::vector<cv::Rect> m_recVec; + std::vector<cv::Rect> m_recVec; + + //todo debug + std::vector<float> m_scoreVec; + std::vector<std::string> m_objTypeVec; + bool m_bIsMask; std::vector<Point> poly1; diff --git a/QiaoJiaSystem/StructureApp/VptRpcElement.cpp b/QiaoJiaSystem/StructureApp/VptRpcElement.cpp index 8607438..3168bf2 100644 --- a/QiaoJiaSystem/StructureApp/VptRpcElement.cpp +++ b/QiaoJiaSystem/StructureApp/VptRpcElement.cpp @@ -10,6 +10,7 @@ appPref.getStringData("vpt.ip"), appPref.getIntData("vpt.port"), "tcp"), m_sharedMemory(nullptr), m_trackingTrigger(nullptr) { + init(); } @@ -63,9 +64,9 @@ } for (auto &obj: m_objs) { - //#todo 浜�/浜洪獞杞�/杞� - if (obj.sdkDetectType != 0) - continue; +// //#todo 浜�/浜洪獞杞�/杞� +// if (obj.sdkDetectType != 0) +// continue; ScoredRect scoredRect; @@ -80,24 +81,25 @@ m_trackingTrigger->getLastRect().properties["time"] = getProperty("time"); m_trackingTrigger->getLastRect().properties["imgKey"] = getProperty("imgKey"); m_triggerScoredRects.push_back(m_trackingTrigger->getLastRect()); - switch (obj.sdkDetectType) { - case 0 : - m_HPScoredRects.push_back(m_trackingTrigger->getLastRect()); - break; - case 1: - case 2 : - m_HCPScoredRects.push_back(m_trackingTrigger->getLastRect()); - break; - case 4 : - case 5 : - case 6 : - case 8 : - m_CarScoredRects.push_back(m_trackingTrigger->getLastRect()); - break; - } + } } m_trackingTrigger->triggerLine(); + auto res_ = m_trackingTrigger->getLastScoreRects(); + for (auto &obj: res_) { + if(obj.properties["type"] == "person") { + m_HPScoredRects.push_back(obj); + DBG("person:" << obj.score); + }else if((obj.properties["type"] == "bike") || + (obj.properties["type"] == "motor")){ + m_HCPScoredRects.push_back(obj); + DBG("bike or moto:" << obj.score); + }else{ + m_CarScoredRects.push_back(obj); + DBG("car:" << obj.score); + } + } + fireConnectors(); } @@ -113,9 +115,9 @@ try { auto server = m_rpcClient.getServer(); - m_HpResStr = server->getStr(0); // 妫�娴嬬绫� case 0 - m_HcpResStr = server->getStr(1); // 妫�娴嬬绫� case 1 - m_TypeStr = server->getStr(2)[0]; // 妫�娴嬬绫� case 2 + m_HpResStr = server->getStr(0); // 琛屼汉浜屾灞炴�� case 0 + m_HcpResStr = server->getStr(1); // 浜洪獞杞︿簩娆″睘鎬� case 1 + m_TypeStr = server->getStr(2)[0]; // VPT妫�娴嬬绫� case 2 m_colorLabelStr = server->getStr(3)[0]; // 杞︾墝棰滆壊 case 3 } catch (std::exception &e) { diff --git a/QiaoJiaSystem/StructureApp/main.cpp b/QiaoJiaSystem/StructureApp/main.cpp index 7d62bc9..454701c 100644 --- a/QiaoJiaSystem/StructureApp/main.cpp +++ b/QiaoJiaSystem/StructureApp/main.cpp @@ -21,13 +21,18 @@ appPref.setIntData("gpu.index", 0); appPref.setIntData("show.image", 0); - //yolo server - appPref.setStringData("yolo.proxy", "yoloServer"); - //#todo - appPref.setStringData("yolo.ip", ""); - appPref.setIntData("yolo.port", 10003); -// rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), appPref.getLongData("yolo.port"),"tcp"), +// //yolo server +// appPref.setStringData("yolo.proxy", "yoloServer"); +// //#todo +// appPref.setStringData("yolo.ip", ""); +// appPref.setIntData("yolo.port", 10003); +//// rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), appPref.getLongData("yolo.port"),"tcp"), +//vpt server + appPref.setStringData("vpt.proxy", "VptServer"); + //#todo + appPref.setStringData("vpt.ip", ""); + appPref.setIntData("vpt.port", appPref.getIntData("RpcVptPort")); //face detect server appPref.setStringData("faceDete.proxy", "faceServer"); diff --git a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp index 6432932..dd07173 100644 --- a/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp +++ b/QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp @@ -254,14 +254,16 @@ rule.second.strAddr = item.str_addr; rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first); - if (rule.second.nSdkType == PerStaticSdk) { - float temp = 1 - (float) (rule.second.nThreshold) / 100; - rule.second.fSensitivity = (75 + 25 * temp) / 100; +// if (rule.second.nSdkType == PerStaticSdk || rule.second.nSdkType == PerimeterSdk +// || rule.second.nSdkType == KeepRightSdk || rule.second.nSdkType == KeepRightSdk) { + float temp = (float)1 - (float) (rule.second.nThreshold) / 100; + rule.second.fSensitivity = (temp * 75 + 25) / 100; +// rule.second.fSensitivity = (temp * 25 + 75) / 100; - } else if (rule.second.nSdkType != FaceSdk) { - float temp = 1 - (float) (rule.second.nThreshold) / 100; - rule.second.fSensitivity = (5 + 90 * temp) / 100; - } +// } else if (rule.second.nSdkType != FaceSdk) { +// float temp = (float)1 - (float) (rule.second.nThreshold) / 100; +// rule.second.fSensitivity = (temp * 90 + 5) / 100; +// } DBG("fSensitivity" << rule.second.fSensitivity); } appPref.setStringData(t_camIdex + "rtsp", rtsp_url); diff --git a/QiaoJiaSystem/VideoAnalysFromHC/main.cpp b/QiaoJiaSystem/VideoAnalysFromHC/main.cpp index 6edf3bf..d5a83dd 100644 --- a/QiaoJiaSystem/VideoAnalysFromHC/main.cpp +++ b/QiaoJiaSystem/VideoAnalysFromHC/main.cpp @@ -86,7 +86,7 @@ appPref.setIntData("gpu.index", atoi(argv[2])); appPref.setIntData("CamStartNO", atoi(argv[3])); appPref.setIntData("CamEndNO", atoi(argv[4])); - appPref.setIntData("RpcYOLOPort", atoi(argv[5])); + appPref.setIntData("RpcVptPort", atoi(argv[5])); appPref.setIntData("RpcFDPort", atoi(argv[6])); appPref.setIntData("RpcFEPort", atoi(argv[7])); appPref.setIntData("RpcFSPort", atoi(argv[8])); @@ -102,12 +102,17 @@ appPref.setIntData("ipPort", appConfig.getIntProperty("ES_PORT")); //yolo server - appPref.setStringData("yolo.proxy", "yoloServer"); - //#todo - appPref.setStringData("yolo.ip", ""); - appPref.setIntData("yolo.port", appPref.getIntData("RpcYOLOPort")); -// rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), appPref.getLongData("yolo.port"),"tcp"), +// appPref.setStringData("yolo.proxy", "yoloServer"); +// //#todo +// appPref.setStringData("yolo.ip", ""); +// appPref.setIntData("yolo.port", appPref.getIntData("RpcYOLOPort")); +//// rpcClient(appPref.getStringData("yolo.proxy"), appPref.getStringData("yolo.ip"), appPref.getLongData("yolo.port"),"tcp"), +//vpt server + appPref.setStringData("vpt.proxy", "vptServer"); + //#todo + appPref.setStringData("vpt.ip", ""); + appPref.setIntData("vpt.port", appPref.getIntData("RpcVptPort")); //face detect server appPref.setStringData("faceDete.proxy", "faceServer"); diff --git a/QiaoJiaSystem/VideoServer/QiaoJia/DB/DBStruct.h b/QiaoJiaSystem/VideoServer/QiaoJia/DB/DBStruct.h index 44e7822..5f7aa3a 100644 --- a/QiaoJiaSystem/VideoServer/QiaoJia/DB/DBStruct.h +++ b/QiaoJiaSystem/VideoServer/QiaoJia/DB/DBStruct.h @@ -299,6 +299,7 @@ strExAreas = ""; strLine = ""; strAddr = ""; + strPerimeterObjType = ""; } int nSdkType; @@ -318,6 +319,7 @@ int nAlarmNumUpperLimit; //鎶ヨ浜烘暟锛堜汉鍛樻嫢鎸わ級 int nAlarmNumLowerLimit; int nIsRun; + QString strPerimeterObjType;//鍏ヤ镜绫诲瀷 std::vector<LActRuleWeekRecord> weekRuleVec; }; diff --git a/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp b/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp index cba8280..d9bb45b 100644 --- a/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp +++ b/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp @@ -2688,6 +2688,7 @@ rec.setValue("is_run", sdkRule.nIsRun); rec.setValue("img_threshold", sdkRule.nThreshold); rec.setValue("img_quality", sdkRule.nQuality); + rec.setValue("perimeter_obj_type", sdkRule.strPerimeterObjType); int rowCount = pModel.rowCount(); if (rowCount == 0) { @@ -2734,6 +2735,7 @@ rule.nAlarmNumUpperLimit = rec.value("alarm_num_upper").toInt(); rule.nAlarmNumLowerLimit = rec.value("alarm_num_lower").toInt(); rule.strBroadcast = rec.value("broadcast_area").toString(); + rule.strPerimeterObjType = rec.value("perimeter_obj_type").toString(); rule.nIsRun = rec.value("is_run").toInt(); rule.nSdkType = rec.value("sdk_type").toInt(); ruleMap[rule.nSdkType] = rule; diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp index 36b2df4..3214411 100644 --- a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp +++ b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp @@ -443,7 +443,7 @@ //褰曞彇瑙嗛鐨凴PC鐨勬帴鍙e嚱鏁� ::std::string RtspAnalysManager::recordVideo(const ::std::string &name, const ::Ice::Current &) { - INFO("Record Video For: " << name); +// INFO("Record Video For: " << name); ImageName_s_t nameSt = ImageName_s_t::fromString(name); if (nameSt.Valid()) { if (m_GB28181_Enable) { diff --git a/QiaoJiaSystem/VptServer/CMakeLists.txt b/QiaoJiaSystem/VptServer/CMakeLists.txt index b7ccfac..91e237a 100644 --- a/QiaoJiaSystem/VptServer/CMakeLists.txt +++ b/QiaoJiaSystem/VptServer/CMakeLists.txt @@ -36,6 +36,9 @@ VptServerI.cpp VptDetectWrapper.cpp ./rpc/VptServer.cpp + + ../../../BasicPlatForm/basic/timer_counter/Clocktimer.h + ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp # GlobalSignalWaitLock.hpp ) diff --git a/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp b/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp index 8b6b353..95ccdc3 100644 --- a/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp +++ b/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp @@ -4,6 +4,7 @@ #include <basic/debug/Debug.h> #include "VptDetectWrapper.h" +#include <basic/timer_counter/Clocktimer.h> VptDetectWrapper::VptDetectWrapper() { init(); @@ -43,6 +44,7 @@ } list<VptDetectResults> VptDetectWrapper::process_image(cv::Mat &_img) { + ClockTimer ct("VptDetectWrapper::process_image"); m_results.clear(); sy_img img; @@ -61,6 +63,7 @@ int colorIndex = result.info[i].obj_index; if (colorIndex < 0 || colorIndex >= 9)continue; + if(colorIndex==4) DBG("detect a car, score =" << result.info[i].obj_score); // sprintf(str_i, "%s:%.2f", type[colorIndex].c_str(), result.info[i].obj_score); // rectangle(process_image, @@ -100,7 +103,7 @@ delete[] result.info; result.info = NULL; } - DBG(m_results.size()); +// DBG(m_results.size()); return m_results; } @@ -146,61 +149,66 @@ auto &carRes = vptDetectResults.vptDetectRes.carDetectRes; // 杞﹂鑹� - carRes.colorLabel = static_cast<ColorLabel>(cur_res->vc_res.res_index); - carRes.colorLabelProb = cur_res->vc_res.res_prob; + if(m_param.vehicle_color_config == SY_CONFIG_OPEN) { + carRes.colorLabel = static_cast<ColorLabel>(cur_res->vc_res.res_index); + carRes.colorLabelProb = cur_res->vc_res.res_prob; + } // 杞﹀瀷璇嗗埆 - if (cur_res->vr_res.vehicle_brand != NULL) { - cout << " 杞﹁締鍝佺墝 - " << cur_res->vr_res.vehicle_brand << endl; - carRes.vehicle_brand = cur_res->vr_res.vehicle_brand; + if(m_param.vehicle_recg_config == SY_CONFIG_OPEN) { + if (cur_res->vr_res.vehicle_brand != NULL) { + cout << " 杞﹁締鍝佺墝 - " << cur_res->vr_res.vehicle_brand << endl; + carRes.vehicle_brand = cur_res->vr_res.vehicle_brand; // carRes.vehicle_brand = string(cur_res->vr_res.vehicle_brand); // carRes.vehicle_brand = "鍙�"; - delete[] cur_res->vr_res.vehicle_brand; - cur_res->vr_res.vehicle_brand = NULL; - } - if (cur_res->vr_res.vehicle_subbrand != NULL) { - cout << " 杞﹁締瀛愬搧鐗� - " << cur_res->vr_res.vehicle_subbrand << endl; - carRes.vehicle_subbrand = cur_res->vr_res.vehicle_subbrand; -// carRes.vehicle_subbrand = cur_res->vr_res.vehicle_subbrand; - delete[] cur_res->vr_res.vehicle_subbrand; - cur_res->vr_res.vehicle_subbrand = NULL; - } - if (cur_res->vr_res.vehicle_issue_year != NULL) { - cout << " 杞﹁締骞存 - " << cur_res->vr_res.vehicle_issue_year << endl; - carRes.vehicle_issue_year = cur_res->vr_res.vehicle_issue_year; - delete[] cur_res->vr_res.vehicle_issue_year; - cur_res->vr_res.vehicle_issue_year = NULL; - } - if (cur_res->vr_res.vehicle_type != NULL) { - cout << " 杞﹁締绫诲瀷 - " << cur_res->vr_res.vehicle_type << endl; - carRes.vehicle_type = cur_res->vr_res.vehicle_type; - delete[] cur_res->vr_res.vehicle_type; - cur_res->vr_res.vehicle_type = NULL; - } - if (cur_res->vr_res.freight_ton != NULL) { - cout << " 璐ц溅鍚ㄧ骇 - " << cur_res->vr_res.freight_ton << endl; - carRes.freight_ton = cur_res->vr_res.freight_ton; - delete[] cur_res->vr_res.freight_ton; - cur_res->vr_res.freight_ton = NULL; - } -// cout << " " << cur_res->vr_res.name_score << endl; - carRes.vehicle_score = cur_res->vr_res.name_score; - - // 杞︾墝 - if (cur_res->vp_res.rect.height_ != 0 && cur_res->vp_res.rect.width_ != 0) { - cout << "杞︾墝浣嶇疆: " << cur_res->vp_res.rect.left_ << " " << cur_res->vp_res.rect.top_ << " " - << cur_res->vp_res.rect.width_ << " " << cur_res->vp_res.rect.height_ << endl; - carRes.carPlateRect.setRect(cur_res->vp_res.rect.left_, cur_res->vp_res.rect.top_, - cur_res->vp_res.rect.width_, cur_res->vp_res.rect.height_); - carRes.carPlateRectScore = cur_res->vp_res.detectScore; - std::string _carPlate; - for (int m = 0; m < 7; m++) { - printf("%s", cur_res->vp_res.recg[m].character); - _carPlate.append(cur_res->vp_res.recg[m].character); + delete[] cur_res->vr_res.vehicle_brand; + cur_res->vr_res.vehicle_brand = NULL; } - carRes.carPlate = const_cast<char *>(_carPlate.c_str()); - carRes.carPlateRectScore = cur_res->vp_res.numScore; - carRes.carPlatetype = cur_res->vp_res.type; + if (cur_res->vr_res.vehicle_subbrand != NULL) { + cout << " 杞﹁締瀛愬搧鐗� - " << cur_res->vr_res.vehicle_subbrand << endl; + carRes.vehicle_subbrand = cur_res->vr_res.vehicle_subbrand; +// carRes.vehicle_subbrand = cur_res->vr_res.vehicle_subbrand; + delete[] cur_res->vr_res.vehicle_subbrand; + cur_res->vr_res.vehicle_subbrand = NULL; + } + if (cur_res->vr_res.vehicle_issue_year != NULL) { + cout << " 杞﹁締骞存 - " << cur_res->vr_res.vehicle_issue_year << endl; + carRes.vehicle_issue_year = cur_res->vr_res.vehicle_issue_year; + delete[] cur_res->vr_res.vehicle_issue_year; + cur_res->vr_res.vehicle_issue_year = NULL; + } + if (cur_res->vr_res.vehicle_type != NULL) { + cout << " 杞﹁締绫诲瀷 - " << cur_res->vr_res.vehicle_type << endl; + carRes.vehicle_type = cur_res->vr_res.vehicle_type; + delete[] cur_res->vr_res.vehicle_type; + cur_res->vr_res.vehicle_type = NULL; + } + if (cur_res->vr_res.freight_ton != NULL) { + cout << " 璐ц溅鍚ㄧ骇 - " << cur_res->vr_res.freight_ton << endl; + carRes.freight_ton = cur_res->vr_res.freight_ton; + delete[] cur_res->vr_res.freight_ton; + cur_res->vr_res.freight_ton = NULL; + } +// cout << " " << cur_res->vr_res.name_score << endl; + carRes.vehicle_score = cur_res->vr_res.name_score; + } + + if(m_param.vehicle_pendant_det_recg_config == SY_CONFIG_OPEN) { + // 杞︾墝 + if (cur_res->vp_res.rect.height_ != 0 && cur_res->vp_res.rect.width_ != 0) { + cout << "杞︾墝浣嶇疆: " << cur_res->vp_res.rect.left_ << " " << cur_res->vp_res.rect.top_ << " " + << cur_res->vp_res.rect.width_ << " " << cur_res->vp_res.rect.height_ << endl; + carRes.carPlateRect.setRect(cur_res->vp_res.rect.left_, cur_res->vp_res.rect.top_, + cur_res->vp_res.rect.width_, cur_res->vp_res.rect.height_); + carRes.carPlateRectScore = cur_res->vp_res.detectScore; + std::string _carPlate; + for (int m = 0; m < 7; m++) { + printf("%s", cur_res->vp_res.recg[m].character); + _carPlate.append(cur_res->vp_res.recg[m].character); + } + carRes.carPlate = const_cast<char *>(_carPlate.c_str()); + carRes.carPlateRectScore = cur_res->vp_res.numScore; + carRes.carPlatetype = cur_res->vp_res.type; // printf(" numScore = %.2f, detectScore = %.2f\n", cur_res->vp_res.numScore, cur_res->vp_res.detectScore); } }; -- Gitblit v1.8.0