leixiwen 1 سال پیش
والد
کامیت
f6dca91001
2فایلهای تغییر یافته به همراه49 افزوده شده و 23 حذف شده
  1. 48 22
      JdydAlgorithnm.cpp
  2. 1 1
      YunDaISASImageRecognitionService.cpp

+ 48 - 22
JdydAlgorithnm.cpp

@@ -14,7 +14,6 @@ static ElectronPlateDectect electronPlateDectect;
 static NumberDectect numberDectect;
 static InstructionsDectect instructionsDectect;
 static ContactDectect contactDectect;
-static OperatingHandleStateDectect operatingHandleStateDectect;
 bool JdydAlgorithnm::Init()
 {
     try
@@ -28,10 +27,6 @@ bool JdydAlgorithnm::Init()
         YunDaISASImageRecognitionService::ConsoleLog(QStringLiteral("隔离开关模型"));
         QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
 
-        operatingHandleStateDectect.Init(isCuda);
-        YunDaISASImageRecognitionService::ConsoleLog(QStringLiteral("操作手柄模型"));
-        QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
-
         oilLevelDectect.Init(isCuda);
         YunDaISASImageRecognitionService::ConsoleLog(QStringLiteral("油位模型"));
         QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
@@ -83,6 +78,7 @@ bool JdydAlgorithnm::Init()
         contactDectect.Init(isCuda);
         YunDaISASImageRecognitionService::ConsoleLog(QStringLiteral("连接点识别模型"));
 
+
     }
     catch (const std::exception& ex)
     {
@@ -149,6 +145,7 @@ json JdydAlgorithnm::CallAlgorithnm(string pluginName, string filePath, string m
         int instructionsConfidenceMaxId = -1;
         float pluginNameConfidenceMax = 0;
         int pluginNameId = -1;
+       
         for (size_t i = 0; i < result.size(); i++)
         {
             int absX = cv::abs((result[i].box.x + result[i].box.width / 2)  - centerX);
@@ -200,12 +197,36 @@ json JdydAlgorithnm::CallAlgorithnm(string pluginName, string filePath, string m
             IDetection::DectectResult dectectResult = instructionsDectect.GetStateResult(ROI, result[instructionsConfidenceMaxId].box);
             instructionsDectectResultStr = dectectResult.m_sValue;
         }
-        string tempResult = "";
-        string tempResultValue = "";
-        GetMaxConfidenceRecoResult(tempResult, tempResultValue, instructionsDectectResultStr,result, maxCenterBoxId, pluginNameId,ROI);
-        rstStr = tempResult;
-        rstValue = tempResultValue;
-
+       /* string tempResult = "";
+        string tempResultValue = "";*/
+        GetMaxConfidenceRecoResult(rstStr, rstValue, instructionsDectectResultStr,result, maxCenterBoxId, pluginNameId,ROI);
+     /*   rstStr = tempResult;
+        rstValue = tempResultValue;*/
+    }
+    else
+    {
+        if (pluginName.size() > 0)
+        {
+            for (size_t i = 0; i < classifyDectect.className.size(); i++)
+            {
+                if (classifyDectect.className[i] == pluginName)
+                {
+                    Output pluginNameOutput;
+                    pluginNameOutput.box.x = 0;
+                    pluginNameOutput.box.y = 0;
+                    pluginNameOutput.box.width = ROI.cols;
+                    pluginNameOutput.box.height = ROI.rows;
+                    pluginNameOutput.id = i;
+                    pluginNameOutput.confidence = 0.99;
+                    result.push_back(pluginNameOutput);
+                    int pluginNameId = 0;
+                    string instructionsDectectResultStr = "";
+                    int maxCenterBoxId = 0;
+                    GetMaxConfidenceRecoResult(rstStr, rstValue, instructionsDectectResultStr, result, maxCenterBoxId, pluginNameId, ROI);
+                }
+            }
+        }
+       
     }
     if (rstStr.size()>300)
     {
@@ -215,7 +236,16 @@ json JdydAlgorithnm::CallAlgorithnm(string pluginName, string filePath, string m
 
     return resultJson;
 }
-
+/// <summary>
+/// 获取
+/// </summary>
+/// <param name="tempResult"></param>
+/// <param name="tempResultValue"></param>
+/// <param name="instructionsDectectResultStr"></param>
+/// <param name="result"></param>
+/// <param name="maxCenterBoxId"></param>
+/// <param name="pluginNameId"></param>
+/// <param name="ROI"></param>
 void JdydAlgorithnm::GetMaxConfidenceRecoResult(string &tempResult, string &tempResultValue,  const string instructionsDectectResultStr,vector<Output> result, int maxCenterBoxId,const int pluginNameId,const cv::Mat ROI)
 {
     if (pluginNameId > -1)
@@ -241,11 +271,6 @@ void JdydAlgorithnm::GetMaxConfidenceRecoResult(string &tempResult, string &temp
         IDetection::DectectResult dectectResultVec = disconnectorDectect.GetStateResult(ROI, result[maxCenterBoxId].box);
         tempResult = classifyDectect.className[result[maxCenterBoxId].id] + "_" + dectectResultVec.m_sValue;
     }
-    else if (classifyDectect.className[result[maxCenterBoxId].id] == "operating_handle")//操作手柄
-    {
-        IDetection::DectectResult dectectResultVec = operatingHandleStateDectect.GetStateResult(ROI, result[maxCenterBoxId].box);
-        tempResult = classifyDectect.className[result[maxCenterBoxId].id] + "_" + dectectResultVec.m_sValue;
-    }
     else if (classifyDectect.className[result[maxCenterBoxId].id] == "oil_level")//油位
     {
         IDetection::DectectResult dectectResultVec = oilLevelDectect.GetDigitResult(ROI, result[maxCenterBoxId].box);
@@ -418,6 +443,12 @@ void JdydAlgorithnm::GetMaxConfidenceRecoResult(string &tempResult, string &temp
         IDetection::DectectResult dectectResultVec = contactDectect.GetStateResult(ROI, result[maxCenterBoxId].box);
         tempResult = classifyDectect.className[result[maxCenterBoxId].id] + "_" + dectectResultVec.m_sValue;
     }
+    else if (classifyDectect.className[result[maxCenterBoxId].id] == "operating_handle")
+    {
+        IDetection::DectectResult dectectResultVec = contactDectect.GetStateResult(ROI, result[maxCenterBoxId].box);
+        tempResult = classifyDectect.className[result[maxCenterBoxId].id] + "_" + dectectResultVec.m_sValue;
+    }
+
 }
 
 ClassifyDectect& JdydAlgorithnm::GetClassifyDectectInstance() {
@@ -460,9 +491,4 @@ NumberDectect& JdydAlgorithnm::GeNumberDectectInstance()
     return numberDectect;
 }
 
-OperatingHandleStateDectect& JdydAlgorithnm::GetoperatingHandleStateDectectInstance() 
-{
-    return operatingHandleStateDectect;
-}
-
 

+ 1 - 1
YunDaISASImageRecognitionService.cpp

@@ -67,7 +67,7 @@ YunDaISASImageRecognitionService::YunDaISASImageRecognitionService(QWidget *pare
         IsShowDectect = true;
         });
     noshowdectect = new QAction(QStringLiteral("隐藏识别过程"));
-    connect(showdectect, &QAction::triggered, [&]() {
+    connect(noshowdectect, &QAction::triggered, [&]() {
         IsShowDectect = false;
         });
     min = new QAction(QStringLiteral("最小化"));