From eff39fab10e5285f0d1196037f3a237a676346d2 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期四, 09 七月 2020 10:17:26 +0800
Subject: [PATCH] IImageSet添加图片信息序列化输出 操作配置添加输出信息序列化输出 添加激光扫描参数模型 修改CollectionHImage方法,输出IImageSet

---
 src/Bro.M071.Process/M071Process.cs |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs
index 8f08ba9..0b2ad8b 100644
--- a/src/Bro.M071.Process/M071Process.cs
+++ b/src/Bro.M071.Process/M071Process.cs
@@ -5,6 +5,7 @@
 using Bro.M071.Model;
 using Bro.Process;
 using HalconDotNet;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -219,11 +220,10 @@
                       if (camera == null)
                           return;
 
-                      string imgSetId = "";
-                      HImage hImage = null;
+                      IImageSet set = null;
                       try
                       {
-                          hImage = CollectHImage(camera, s.CameraOp.OpConfig, out imgSetId);
+                          set = CollectHImage(camera, s.CameraOp.OpConfig);
                       }
                       catch (ProcessException pEx)
                       {
@@ -231,12 +231,12 @@
                           throw pEx;
                       }
 
-                      if (string.IsNullOrWhiteSpace(imgSetId))
+                      if (set == null)
                       {
                           return;
                       }
 
-                      RunImageHandle(camera, s.CameraOp.OpConfig, hImage, s.Id, s.Name, pMeasure.Measurements);
+                      RunImageHandle(camera, s.CameraOp.OpConfig, set, s.Id, s.Name, pMeasure.Measurements);
                   });
 
             BarCode = "";
@@ -468,7 +468,7 @@
         }
         #endregion
 
-        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, HImage hImage, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
+        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, IImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
         {
             await Task.Run(() =>
              {
@@ -476,7 +476,8 @@
                  var keyBindCollection = measureList.SelectMany(u => u.KeyUnitCollection).Where(u => keys.Any(k => k.Key == u.Key)).ToList();
 
                  string toolKey = (opConfig as CameraOprerationConfigBase).AlgorithemPath;
-                 HObject images = hImage;
+                 HObject images = imgSet.HImage;
+                 LaserScanParam scanParam = JsonConvert.DeserializeObject<LaserScanParam>(imgSet.ImageData);
 
                  if (!string.IsNullOrWhiteSpace(toolKey))
                  {
@@ -488,7 +489,7 @@
                          return;
                      }
 
-                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = hImage;
+                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = imgSet.HImage;
                      if (!_halconToolDict[toolKey].RunProcedure(out string error))
                      {
                          LogAsync(DateTime.Now, $"{snapshotName}鍙栧浘绠楁硶寮傚父锛寋error}", "");
@@ -536,6 +537,8 @@
                              else
                              {
                                  _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image;
+                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X;
+                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z;
                                  if (!_halconToolDict[keyToolKey].RunProcedure(out string error))
                                  {
                                      LogAsync(DateTime.Now, $"{k.AliasName}妫�娴嬬畻娉曞紓甯革紝{error}", "");
@@ -568,11 +571,11 @@
                      image.Dispose();
                  });
 
-                 if (count.I != 1)
-                 {
-                     hImage?.Dispose();
-                     hImage = null;
-                 }
+                 //if (count.I != 1)
+                 //{
+                 //    hImage?.Dispose();
+                 //    hImage = null;
+                 //}
              });
         }
         #endregion

--
Gitblit v1.8.0