Просмотр исходного кода

修复yolo输出标签与匹配度正常输入视觉模版中,与可手动设置置信度与iou

KWD 4 месяцев назад
Родитель
Сommit
4bf0932fc5

+ 58 - 58
TeamAAS-VM/Core/Management.cs

@@ -100,7 +100,7 @@ namespace TeamAAS_VP.Core
         // 扫码完成事件
         private readonly ManualResetEventSlim _scanDoneEvent = new ManualResetEventSlim(false);
         //键盘数据
-        public Dictionary<string, double> keyData = new Dictionary<string, double>{};
+        public Dictionary<string, double> keyData = new Dictionary<string, double> { };
         //键盘单独数据
         public Dictionary<string, double> keyData1 = new Dictionary<string, double> { };
         //键盘差值
@@ -275,7 +275,7 @@ namespace TeamAAS_VP.Core
             set { SetProperty(ref _ProductList, value); }
         }
 
-  
+
         #endregion
 
         #region 命令
@@ -1393,7 +1393,7 @@ namespace TeamAAS_VP.Core
                 monitorNodeIds.Add(string.Format(addressConfig.In_MesCheck.Address, i));
             }
             //订阅PLC地址变化
-            plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger,OpcUaSubscriptionMode.CustomPolling);
+            plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger, OpcUaSubscriptionMode.CustomPolling);
         }
 
         /// <summary>
@@ -1556,7 +1556,7 @@ namespace TeamAAS_VP.Core
                                 await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)2);
                                 return;
                             }
-                           
+
 
                             SetProducts(new int[] { targetPoint.Camera_Product1, targetPoint.Camera_Product2, targetPoint.Camera_Product3, targetPoint.Camera_Product4 });
 
@@ -1944,13 +1944,13 @@ namespace TeamAAS_VP.Core
                             var cameraProcedures = currentProduct.CameraProcedures;
                             if (cameraProcedures == null || cameraProcedures.Count == 0)
                             {
-                                if(cameraIndex != currentProduct.PhotoCountStop)
+                                if (cameraIndex != currentProduct.PhotoCountStop)
                                 {
                                     SendTaskMessage($"当前产品未配置 CameraProcedures,无法执行视觉流程", MessageLevel.Alarm);
                                     await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
                                     return;
                                 }
-                                
+
                             }
 
                             if (cameraIndex == currentProduct.PhotoCount)
@@ -2290,7 +2290,7 @@ namespace TeamAAS_VP.Core
                             }
 
                             _ImageTaskList.Clear();
-                            
+
                             foreach (var prcId in procIds)
                             {
                                 ProcedureModel selectedProcedure = null;
@@ -2312,12 +2312,12 @@ namespace TeamAAS_VP.Core
                                 {
                                     await _remoteCommandService.SetLightBeforePhoto(selectedProcedure);
                                 }
-                               
-                                if(sysConfig.PhotosUse==true)
+
+                                if (sysConfig.PhotosUse == true)
                                 {
                                     bool Is3dPhoto = Is3D(prcId);
-                                    var tt=await GrabImageEx(cameraIndex, prcId, Is3dPhoto);
-                                    if(tt.IsSucceed==false)
+                                    var tt = await GrabImageEx(cameraIndex, prcId, Is3dPhoto);
+                                    if (tt.IsSucceed == false)
                                     {
                                         SendTaskMessage($"图像采集失败!{cameraIndex}: {prcId}", MessageLevel.Alarm);
                                         return;
@@ -2329,7 +2329,7 @@ namespace TeamAAS_VP.Core
                                     bool Is3dPhoto = Is3D(prcId);
                                     _ImageTaskList.Add(GrabImageEx(cameraIndex, prcId, Is3dPhoto));
                                 }
-                                 
+
                                 if (sysConfig.TurnOnAllLightUse == false)
                                 {
                                     await _remoteCommandService.TurnOffLightAfterPhoto(selectedProcedure);
@@ -2348,7 +2348,7 @@ namespace TeamAAS_VP.Core
                                     if (item.IsSucceed)
                                     {
                                         bool Is3d = Is3D(item.procedureId);
-                                        _PrcTaskList.Add(ExecuteProcedureAsync(item.cameraIndex, item.procedureId, item.Images, Is3d));
+                                        _PrcTaskList.Add(ExecuteProcedureAsync(item.cameraIndex, item.procedureId, item.Images, Is3d, sysConfig.confThreshold, sysConfig.iouThreshold));
                                         //_PrcTaskList.Add(ExecuteProcedureAsync(cameraIndex, prcId, imageData.imges));
                                     }
                                     else
@@ -2366,12 +2366,12 @@ namespace TeamAAS_VP.Core
                                 {
                                     foreach (var item in lockResultsAll)
                                     {
-                                        if (item.PhotoPassed=="NG")
+                                        if (item.PhotoPassed == "NG")
                                         {
                                             resultFlog = false;
                                             break;
                                         }
-                                        
+
                                     }
                                 }
                                 else
@@ -2379,7 +2379,7 @@ namespace TeamAAS_VP.Core
                                     //等待所有的图像处理流程处理完成
                                     var results = await Task.WhenAll(_PrcTaskList);
 
-                                    
+
                                     foreach (var item in results)
                                     {
                                         if (!item.IsSucceed || item.Result == null)
@@ -2400,7 +2400,7 @@ namespace TeamAAS_VP.Core
                                         }
                                     }
                                 }
-                                
+
 
                                 //全部OK
                                 if (resultFlog)
@@ -2741,7 +2741,7 @@ namespace TeamAAS_VP.Core
 
                                     if (stationConfig.SaveCsvkeyData)
                                     {
-                                       
+
                                         if (keyData != null)
                                         {
                                             ok = CheckKeyBoardValue(keyData, out string msg);
@@ -2760,7 +2760,7 @@ namespace TeamAAS_VP.Core
                                             ShowMes_Result = true;
                                         }
                                     }
-                                    
+
                                     //StringBuilder submitDataError2 = new StringBuilder();
                                     //foreach (var item in keyData)
                                     //{
@@ -2775,7 +2775,7 @@ namespace TeamAAS_VP.Core
                                     if (submitData.Length > 0)
                                     {
                                         string data1 = submitData.ToString().TrimEnd('&');
-                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(0,ProductMainSN, "", submitData.ToString(), ShowMes_Result, submitDataError.ToString(), _LastMesCheckTime[i], serverTimeResult.Now);
+                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(0, ProductMainSN, "", submitData.ToString(), ShowMes_Result, submitDataError.ToString(), _LastMesCheckTime[i], serverTimeResult.Now);
                                         allSuccess &= isSuccess;
                                     }
                                     if (submitData2.Length > 0)
@@ -2787,7 +2787,7 @@ namespace TeamAAS_VP.Core
                                     if (submitData3.Length > 0)
                                     {
                                         string data3 = submitData3.ToString().TrimEnd('&');
-                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(2, ProductMainSN, "", submitData3.ToString(), ShowMes_Result   , submitDataError.ToString(), _LastMesCheckTime[i], serverTimeResult.Now);
+                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(2, ProductMainSN, "", submitData3.ToString(), ShowMes_Result, submitDataError.ToString(), _LastMesCheckTime[i], serverTimeResult.Now);
                                         allSuccess &= isSuccess;
                                     }
                                     if (submitData4.Length > 0)
@@ -2810,14 +2810,14 @@ namespace TeamAAS_VP.Core
                                     }
                                     await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
 
-                                    
+
                                     //是否保存当前的产品记录至CSV?
                                     if (stationConfig.SaveCsv)
                                     {
                                         string saveppid = "NA";
                                         if (stationConfig.SaveCsvPPID) saveppid = ppid;
                                         Dictionary<string, double> adjacentDiffDict = GetAdjacentDiffDict(keyData);
-                                       // Dictionary<string, double> adjacentDiffDict1 = GetAdjacentDiffDict(keyData1);
+                                        // Dictionary<string, double> adjacentDiffDict1 = GetAdjacentDiffDict(keyData1);
                                         //判断锁付路径字符串是否为空,如果不为空则保存,否则不保存
                                         if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
                                         {
@@ -2837,7 +2837,7 @@ namespace TeamAAS_VP.Core
                                                     //{
                                                     //    item.PhotoName = "_" + k.ToString();
                                                     //}
-                                                }                                               
+                                                }
                                                 DFC.Add(new DataFormCtq
                                                 {
                                                     PPID = saveppid,
@@ -2864,7 +2864,7 @@ namespace TeamAAS_VP.Core
                                                     PD_ATTR_03 = "",
                                                     PD_ATTR_04 = code,
                                                     PD_ATTR_05 = "",
-                                                });                                      
+                                                });
                                             }
                                             if (stationConfig.SaveCsvkeyData)
                                             {
@@ -3030,12 +3030,12 @@ namespace TeamAAS_VP.Core
                                         keyData.Clear();
                                         keyData1.Clear();
                                     }
-                                    
+
                                     ProductMainSN = "";
                                     LogHelper.WriteLogMes($"【mes结束ADD】");
                                     SendTaskMessage($"mes结束ADD", MessageLevel.Info);
                                 }
-                                
+
                                 else
                                 {
                                     SendTaskMessage($"{i}过站检查信号:state={state},处理为默认状态", MessageLevel.Alarm);
@@ -3046,7 +3046,7 @@ namespace TeamAAS_VP.Core
                     }
                 }
 
-                
+
 
 
             }
@@ -3222,7 +3222,7 @@ namespace TeamAAS_VP.Core
         /// <param name="pointIndex"></param>
         /// <param name="procedureId"></param>
         /// <returns></returns>
-        private Task<(bool IsSucceed, bool[] Result, string Message)> ExecuteProcedureAsync(int pointIndex, Guid procedureId, ICogImage[] images, bool is3dmodel)
+        private Task<(bool IsSucceed, bool[] Result, string Message)> ExecuteProcedureAsync(int pointIndex, Guid procedureId, ICogImage[] images, bool is3dmodel, float confThreshold = 0.25f, float iouThreshold = 0.45f)
         {
             return Task.Run(async () =>
             {
@@ -3278,7 +3278,7 @@ namespace TeamAAS_VP.Core
                         }
                         PhotoPath = selectedProcedure.SavePath;
                         //1. 执行拍照,图像处理
-                        var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint1(selectedProcedure, images, null, null, ctsAll.Token, is3dmodel);
+                        var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint1(selectedProcedure, images, null, null, ctsAll.Token, is3dmodel, confThreshold, iouThreshold);
                         if (visionResult.Count == 0)
                         {
                             SendTaskMessage("Count值为0", MessageLevel.Alarm);
@@ -3304,7 +3304,7 @@ namespace TeamAAS_VP.Core
                                 //}
                                 try
                                 {
-                                    
+
                                     string[] strpoints1 = visionResult.Items[i].Split(',');
                                     string[] body1 = strpoints1[1].Split(";");
 
@@ -3360,9 +3360,9 @@ namespace TeamAAS_VP.Core
                                                 keyData.Add(keyName, average);
                                                 keyData1.Add(keyName, chazhi);
                                             }
-                                        }                                      
+                                        }
                                     }
-                                                         
+
                                     if (body1.Length > 1)
                                     {
                                         for (int j = 1; j <= body1.Length; j++)
@@ -3446,9 +3446,9 @@ namespace TeamAAS_VP.Core
                                         lockResultsAll.Add(lockResult1);
                                     }
                                 }
-                                catch (Exception ex) 
+                                catch (Exception ex)
                                 {
-                                    SendTaskMessage($"拆分视觉结果出错:{ex}",MessageLevel.Error);
+                                    SendTaskMessage($"拆分视觉结果出错:{ex}", MessageLevel.Error);
 
                                 }
                                 App.Current.Dispatcher.Invoke(() =>
@@ -3653,7 +3653,7 @@ namespace TeamAAS_VP.Core
                     if (cameras is TeamAAS_VP.Core.Cameras.SSZNCamera sszn)
                     {
                         sszn.CameraRevFinish = false;
-                        sszn.SetProducts(CameraNum,points);
+                        sszn.SetProducts(CameraNum, points);
                     }
                 }
                 catch (Exception ex)
@@ -3725,7 +3725,7 @@ namespace TeamAAS_VP.Core
                 if (!stationConfig.EnableMES || !stationConfig.EnableDoubleMes || !stationConfig.SaveCsv)
                 {
                     mesStatus = false;
-                    
+
                 }
 
 
@@ -3818,10 +3818,10 @@ namespace TeamAAS_VP.Core
                 // ==============================================
                 // 第一行:ESC + F1~F12
                 // ==============================================
-                ["ESC"] = new List<string> { "F1", "~",  },
+                ["ESC"] = new List<string> { "F1", "~", },
                 ["F1"] = new List<string> { "ESC", "F2", "1" },
-                ["F2"] = new List<string> { "F1", "F3",  "2" },
-                ["F3"] = new List<string> { "F2", "F4", "2", "3"},
+                ["F2"] = new List<string> { "F1", "F3", "2" },
+                ["F3"] = new List<string> { "F2", "F4", "2", "3" },
                 ["F4"] = new List<string> { "F3", "F5", "3", "4" },
                 ["F5"] = new List<string> { "F4", "F6", "4", "5" },
                 ["F6"] = new List<string> { "F5", "F7", "5", "6" },
@@ -3832,24 +3832,24 @@ namespace TeamAAS_VP.Core
                 ["F11"] = new List<string> { "F10", "F12", "0", "-" },
                 ["F12"] = new List<string> { "F11", "-", "=", "Insert" },
                 ["Insert"] = new List<string> { "F12", "Power", "Backspace" },
-                ["Power"] = new List<string> {"Backspace" },
+                ["Power"] = new List<string> { "Backspace" },
 
                 // ==============================================
                 // 第二行:` 1 2 3 4 5 6 7 8 9 0 - = Backspace
                 // ==============================================
                 ["~"] = new List<string> { "ESC", "1", "TAB" },
-                ["1"] = new List<string> {  "F1", "`", "2", "TAB", "Q" },
-                ["2"] = new List<string> {  "F2", "1", "3", "Q", "W" },
-                ["3"] = new List<string> {  "F3", "F4", "2", "4", "W", "E" },
-                ["4"] = new List<string> {  "F4", "F5", "3", "5", "E", "R" },
-                ["5"] = new List<string> {  "F5", "F6", "4", "6", "R", "T" },
-                ["6"] = new List<string> {  "F6", "F7", "5", "7", "T", "Y" },
-                ["7"] = new List<string> {  "F7", "F8", "6", "8", "Y", "U" },
-                ["8"] = new List<string> {  "F8", "F9", "7", "9", "U", "I" },
-                ["9"] = new List<string> {  "F9", "F10", "8", "0", "I", "O" },
-                ["0"] = new List<string> {  "F10", "F11", "9", "-", "O", "P" },
-                ["-"] = new List<string> {  "F11", "F12", "0", "=", "P", "{" },
-                ["="] = new List<string> {  "F12", "-", "Backspace", "{", "}" },
+                ["1"] = new List<string> { "F1", "`", "2", "TAB", "Q" },
+                ["2"] = new List<string> { "F2", "1", "3", "Q", "W" },
+                ["3"] = new List<string> { "F3", "F4", "2", "4", "W", "E" },
+                ["4"] = new List<string> { "F4", "F5", "3", "5", "E", "R" },
+                ["5"] = new List<string> { "F5", "F6", "4", "6", "R", "T" },
+                ["6"] = new List<string> { "F6", "F7", "5", "7", "T", "Y" },
+                ["7"] = new List<string> { "F7", "F8", "6", "8", "Y", "U" },
+                ["8"] = new List<string> { "F8", "F9", "7", "9", "U", "I" },
+                ["9"] = new List<string> { "F9", "F10", "8", "0", "I", "O" },
+                ["0"] = new List<string> { "F10", "F11", "9", "-", "O", "P" },
+                ["-"] = new List<string> { "F11", "F12", "0", "=", "P", "{" },
+                ["="] = new List<string> { "F12", "-", "Backspace", "{", "}" },
                 ["Backspace"] = new List<string> { "Insert", "=", "}", "|", "Power" },
 
                 // ==============================================
@@ -3865,7 +3865,7 @@ namespace TeamAAS_VP.Core
                 ["U"] = new List<string> { "Y", "6", "7", "8", "I", "H", "J" },
                 ["I"] = new List<string> { "U", "7", "8", "9", "O", "J", "K" },
                 ["O"] = new List<string> { "I", "8", "9", "0", "P", "K", "L" },
-                ["P"] = new List<string> { "O", "9", "0", "-", "{", "L", ";" }, 
+                ["P"] = new List<string> { "O", "9", "0", "-", "{", "L", ";" },
                 ["{"] = new List<string> { "P", "0", "-", "=", "}", ";", "'" },
                 ["}"] = new List<string> { "{", "-", "=", "Backspace", "|", "'", "Enter" },
                 ["|"] = new List<string> { "}", "Backspace", "Enter" },
@@ -3878,7 +3878,7 @@ namespace TeamAAS_VP.Core
                 ["S"] = new List<string> { "A", "W", "E", "D", "Z", "X", "LeftShift" },
                 ["D"] = new List<string> { "S", "E", "R", "F", "X", "C", "LeftShift" },
                 ["F"] = new List<string> { "D", "R", "T", "G", "C", "V" },
-                ["G"] = new List<string> { "F", "T", "Y", "H", "V", "B" }, 
+                ["G"] = new List<string> { "F", "T", "Y", "H", "V", "B" },
                 ["H"] = new List<string> { "G", "Y", "U", "J", "B", "N" },
                 ["J"] = new List<string> { "H", "U", "I", "K", "N", "M" },
                 ["K"] = new List<string> { "J", "I", "O", "L", "M", "," },
@@ -3912,7 +3912,7 @@ namespace TeamAAS_VP.Core
                 ["Alt1"] = new List<string> { "Win", "Space" },
                 ["Space1"] = new List<string> { "Alt", "Alt2" },
                 ["Alt2"] = new List<string> { "Space", "Ctrl2" },
-               // ["RightFn"] = new List<string> { "RightAlt", "RightCtrl" },
+                // ["RightFn"] = new List<string> { "RightAlt", "RightCtrl" },
                 ["Ctrl2"] = new List<string> { "Alt2", "Left", "Updown", "Right" },
                 ["Left"] = new List<string> { "RightCtrl", "Updown" },
                 ["Updown"] = new List<string> { "Left", "Right", "Ctrl2" },
@@ -4218,7 +4218,7 @@ namespace TeamAAS_VP.Core
         /// </summary>
         /// <param name="procedureId"></param>
         /// <returns></returns>
-        private async Task<(bool IsSucceed, ICogImage[] imges, string Message, int pointIndex, Guid procedureId)> GrabImageEx(int pointIndex, Guid procedureId,bool Is3dPhoto)
+        private async Task<(bool IsSucceed, ICogImage[] imges, string Message, int pointIndex, Guid procedureId)> GrabImageEx(int pointIndex, Guid procedureId, bool Is3dPhoto)
         {
             // 获取当前产品
             var currentProduct = _productService.GetCurrentProduct();
@@ -4267,7 +4267,7 @@ namespace TeamAAS_VP.Core
                         await _remoteCommandService.SetLightBeforePhoto(selectedProcedure);
                     }
                     //1. 执行拍照
-                    var res = await _remoteCommandService.ExecuteGrabImageAsync(selectedProcedure,Is3dPhoto);
+                    var res = await _remoteCommandService.ExecuteGrabImageAsync(selectedProcedure, Is3dPhoto);
                     return (res.IsSucceed, res.Image, res.Msg, pointIndex, procedureId);
                 }
                 catch (Exception ex)

+ 1 - 1
TeamAAS-VM/Interfaces/IRemoteCommandService.cs

@@ -275,7 +275,7 @@ namespace TeamAAS_VP.Interfaces
         /// <param name="robotCoord"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken,bool is3dmodel);
+        Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken,bool is3dmodel, float confThreshold = 0.25f, float iouThreshold = 0.45f);
 
         /// <summary>
         /// 执行相机拍照获取单个点位结果

+ 16 - 0
TeamAAS-VM/Models/SystemConfiguration.cs

@@ -516,6 +516,22 @@ namespace TeamAAS_VP.Models
             set => SetProperty(ref _PhotosUse, value);
         }
 
+        private float _confThreshold;
+
+        public float confThreshold
+        {
+            get { return _confThreshold; }
+            set => SetProperty(ref _confThreshold, value);
+        }
+
+        private float _iouThreshold;
+
+        public float iouThreshold
+        {
+            get { return _iouThreshold; }
+            set => SetProperty(ref _iouThreshold, value);
+        }
+
 
     }
 }

+ 13 - 17
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1793,7 +1793,7 @@ namespace TeamAAS_VP.Services
         /// 执行相机拍照并运行 ToolBlock,返回是否成功并通过 out 参数返回 Outputs。
         /// 该方法会发布 RenderUpdateNotification 以更新 UI。
         /// </summary>
-        public bool ExecutePhoto(ProcedureModel procedure,ICogImage[] imges,Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection,bool is3dmodel)
+        public bool ExecutePhoto(ProcedureModel procedure,ICogImage[] imges,Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection,bool is3dmodel, float confThreshold = 0.25f, float iouThreshold = 0.45f)
         {
             try
             {
@@ -1804,7 +1804,6 @@ namespace TeamAAS_VP.Services
                     procedure.ToolBlock.Inputs["InputImage2"].Value = imges[1];
                 }
                 
-
                 // 2. 为ToolBlock传入其他输入终端
                 if (InputTerminal != null)
                 {
@@ -1829,9 +1828,7 @@ namespace TeamAAS_VP.Services
                 // photoAiValue 可能为 null/空,建议给个默认值
                 bool enablePhotoAi = photoAiValue == "1";
                 if (enablePhotoAi == true)
-                {
-
-                    
+                {                    
                     string exeDir = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
 
                     string modelPath = System.IO.Path.Combine(exeDir, "TrainPhoto", "weights", "best_openvino_model", "best.xml");
@@ -1848,26 +1845,26 @@ namespace TeamAAS_VP.Services
 
                     //string imagePath = "G:\\TEST\\文件\\左上插线\\1.bmp";
 
-                    using (var yolo = new YoloOpenVINOInference(modelPath, metadataPath))
+                    using (var yolo = new YoloOpenVINOInference(modelPath, metadataPath, confThreshold, iouThreshold))
                     {
                         using (var bitmap = imges[0].ToBitmap())
                         {
                             var results = yolo.Infer(bitmap);
                             procedure.ToolBlock.Inputs["PhotoData"].Value = "";
+                            procedure.ToolBlock.Inputs["Confidence"].Value ="";
                             // 输出结果
-                            //Console.WriteLine($"检测到 {results.Count} 个目标:");
                             SendTaskMessage($"识别的个数:{results.Count()}", MessageLevel.Alarm);
-
+                            string ClassName = "";
+                            string Confidence = "";
                             foreach (var det in results)
                             {
-                                //Console.WriteLine($"  - {det.ClassName}: 置信度={det.Confidence:F4}, " +
-                                //                  $"边界框=[{det.Box[0]:F0}, {det.Box[1]:F0}, {det.Box[2]:F0}, {det.Box[3]:F0}]");
                                 SendTaskMessage($"  - {det.ClassName}: 置信度={det.Confidence:F4}, " +
                                                   $"边界框=[{det.Box[0]:F0}, {det.Box[1]:F0}, {det.Box[2]:F0}, {det.Box[3]:F0}]", MessageLevel.Alarm);
-                                procedure.ToolBlock.Inputs["PhotoData"].Value = $"{det.ClassName}" + ",";
+                                ClassName += $"{det.ClassName}" + ",";
+                                Confidence += $"{det.Confidence}" + ",";
                             }
-
-
+                            procedure.ToolBlock.Inputs["PhotoData"].Value = ClassName;
+                            procedure.ToolBlock.Inputs["Confidence"].Value = Confidence;
                             // 绘制结果 - 使用 OpenCvSharp
                             using (var image2 = ImageHelper.ICogImageConvertMat(imges[0]))
                             {
@@ -1941,6 +1938,7 @@ namespace TeamAAS_VP.Services
                                 //Console.WriteLine($"结果已保存到: {outputPath}");
                                 var cogImage = ImageHelper.MatConvertICogImage(image2);
                                 procedure.ToolBlock.Inputs["InputImage"].Value = cogImage;
+                                procedure.ToolBlock.Run();
                                 outputCollection = procedure.ToolBlock.Outputs;     //获取输出终端集合
                                 ICogRecord record = null;
                                 foreach (CogToolBlockTerminal item in outputCollection)
@@ -1967,12 +1965,10 @@ namespace TeamAAS_VP.Services
                                     // 生成文件名
                                     imgName = template.Generate();
                                 }
-                                procedure.ToolBlock.Run();
                                 _eventAggregator.GetEvent<RenderUpdateNotification>().Publish(new ShowRender()
                                 {
                                     Id = procedure.DisplayId,
                                     DisplayName = procedure.DisplayName,
-                                    //Image = (ICogImage)procedure.ToolBlock.Outputs["OriImage"].Value,
                                     Image = cogImage,
                                     Graphic = outputCollection["Graphic"].Value as CogGraphicCollection,
                                     Record = record,
@@ -2406,7 +2402,7 @@ namespace TeamAAS_VP.Services
         /// <param name="robotCoord"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public async Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken,bool is3dmodel)
+        public async Task<(bool IsSucceed, string[] Items, double Count)> ExecutePhotoGetSinglePoint1(ProcedureModel procedure, ICogImage[] imges, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken,bool is3dmodel, float confThreshold = 0.25f, float iouThreshold = 0.45f)
         {
             DateTime nowtime = DateTime.Now;
             try
@@ -2418,7 +2414,7 @@ namespace TeamAAS_VP.Services
                     SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
 
                     // 1. 执行相机拍照并运行视觉工具
-                    bool visionSucceed = ExecutePhoto(procedure, imges, InputTerminal, out CogToolBlockTerminalCollection outputCollection, is3dmodel);
+                    bool visionSucceed = ExecutePhoto(procedure, imges, InputTerminal, out CogToolBlockTerminalCollection outputCollection, is3dmodel, confThreshold, iouThreshold);
                     if (!visionSucceed)
                     {
                         SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);