zly 4 ماه پیش
والد
کامیت
1224e47513

+ 9 - 2
TeamAAS-VM/Core/Management.cs

@@ -163,7 +163,7 @@ namespace TeamAAS_VP.Core
             set { SetProperty(ref _ShowMes_Query, value); }
         }
 
-        private bool _ShowMes_Result;
+        private bool _ShowMes_Result = false;
         /// <summary>
         /// 显示上传结果
         /// </summary>
@@ -171,6 +171,7 @@ namespace TeamAAS_VP.Core
         {
             get { return _ShowMes_Result; }
             set { SetProperty(ref _ShowMes_Result, value); }
+
         }
 
         /// <summary>
@@ -2779,6 +2780,12 @@ namespace TeamAAS_VP.Core
                                     }
                                     bool allSuccess = true;
                                     bool ok = false;
+
+                                    if (homeview.IsResultTrue)
+                                    {
+                                        ShowMes_Result = true;
+                                    }
+
                                     string name = currentProduct.Name;
                                     if (stationConfig.SaveCsvkeyData)
                                     {
@@ -2796,7 +2803,7 @@ namespace TeamAAS_VP.Core
                                         {
                                             ShowMes_Result = false;
                                         }
-                                        if (homeview.IsResultTrue == false)
+                                        if (homeview.IsResultTrue == true)
                                         {
                                             ShowMes_Result = true;
                                         }

+ 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);

+ 16 - 7
TeamAAS-VM/ViewModels/Product/VisionDynamicAccuracyAnalyzerViewModel.cs

@@ -24,6 +24,7 @@ using TeamAAS_VP.Core.PLCs;
 using TeamAAS_VP.Enums;
 using TeamAAS_VP.Interfaces;
 using TeamAAS_VP.Models;
+using TeamAAS_VP.Models.Calibration;
 using TeamAAS_VP.Resources.Languages;
 using TeamAAS_VP.Services;
 using static TeamAAS_VP.Core.StabilityAnalyzer;
@@ -1200,11 +1201,11 @@ namespace TeamAAS_VP.ViewModels.Product
                         //}
 
                         ////获取机器人当前坐标系
-                        //RPoint rPoint = Robot.GetRobotPos();
-                        //double[] point = new double[3];
-                        //point[0] = rPoint.X;
-                        //point[1] = rPoint.Y;
-                        //point[2] = rPoint.U;
+                        RPoint rPoint = Robot.GetRobotPos();
+                        double[] point = new double[3];
+                        point[0] = rPoint.X;
+                        point[1] = rPoint.Y;
+                        point[2] = rPoint.U;
                         //if (calib.CameraMount == CameraMount.FixedUp || calib.CameraMount == CameraMount.FixedDown)
                         //{
                         //    point = null;
@@ -1219,9 +1220,17 @@ namespace TeamAAS_VP.ViewModels.Product
                         //eturn (true, _pixel_x, _pixel_y, _pixel_u, calibResult.X, calibResult.Y); ;
                         if (!outputCollection.Contains("dis1"))
                         {
+                            CalibrationInfo calibration = new CalibrationInfo();
                             string[] Point1 = ((string)(outputCollection["Point"].Value)).Split(',');
-                            var calibration = _calibrationService.GetCalibration(SelectProcedure.CalibrationId);
-                            (bool IsSucceed, double X, double Y, double U) = _calibrationService.ConvertPixelToPosition((double.Parse(Point1[0]), double.Parse(Point1[1]), double.Parse(Point1[2])), null, calibration);
+                            try
+                            {
+                                calibration = _calibrationService.GetCalibration(SelectProcedure.CalibrationId);
+                            }
+                            catch (Exception)
+                            {
+                                SendTaskMessage("坐标转换失败!");
+                            }
+                            (bool IsSucceed, double X, double Y, double U) = _calibrationService.ConvertPixelToPosition((double.Parse(Point1[0]), double.Parse(Point1[1]), double.Parse(Point1[2])), point, calibration);
                             if (!IsSucceed)
                             {
                                 SendTaskMessage("坐标转换失败!");

+ 4 - 0
TeamAAS-VM/ViewModels/Setting/EditCameraViewModel.cs

@@ -159,6 +159,10 @@ namespace TeamAAS_VP.ViewModels.Setting
             {
                 cameras = SSZNCamera.GetDevices();
             }
+            else if (cameraBrand == CameraBrand.IKap)
+            {
+                cameras = IKapCamera.GetDevices();
+            }
             CameraList.Clear();
             if (cameras != null)
             {

+ 5 - 1
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -918,7 +918,11 @@ namespace TeamAAS_VP.ViewModels
                     break;
                 case CameraBrand.SSZN:
                     softwarename = "SSZN Camera Viewer";
-                    result = OptCamera.CheckSoftwareInstalled();
+                    result = SSZNCamera.CheckSoftwareInstalled();
+                    break;
+                case CameraBrand.IKap:
+                    softwarename = "IKap Camera Viewer";
+                    result = IKapCamera.CheckSoftwareInstalled();
                     break;
                 default:
                     break;