C3204
2025-12-30 4b3a410a5083970bb2e56d2ab459d860c4fa22d0
添加单流程多相机处理功能。
已修改36个文件
1559 ■■■■■ 文件已修改
LB_SmartVision/Forms/Pages/ProcessPage/AllProcessesPage.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/Forms/Pages/ProcessPage/ProcessPage.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/ProcessRun/ProcessContext.cs 107 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/ProcessRun/ProcessRunBll.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/VisionForm.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionControl/UserHSmartWindowControl.cs 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionFlowNode/FlowPanel.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/BaseAlgorithm/TAlgorithm.cs 297 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/BaseAlgorithm/TAlgorithmEdit.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/BaseAlgorithm/TestTool/TestToolEdit.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobTool.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobToolEdit.Designer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobToolEdit.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dTool.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dToolEdit.Designer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dToolEdit.cs 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dToolEdit.resx 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineTool.cs 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineToolEdit.Designer.cs 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineToolEdit.cs 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineToolEdit.resx 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelTool.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelToolEdit.Designer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelToolEdit.cs 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelToolEdit.resx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelTool.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelToolEdit.Designer.cs 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelToolEdit.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelToolEdit.resx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HMulitModelControl.Designer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/OpenCvSharp/BlobTool/BlobToolEdit.cs 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/OpenCvSharp/FindLineTool/FindLineToolEdit.cs 230 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Alogrithms/OpenCvSharp/FindModelTool/FindModelToolEdit.cs 395 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/IProcess.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Processes/BaseProcess.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/Forms/Pages/ProcessPage/AllProcessesPage.cs
@@ -20,6 +20,7 @@
            Name = "AllProcessesPage";
            Text = "主界面";
            //this.Font = new Font("Microsoft YaHei UI", 16F, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.BackColor = Color.FromArgb(32, 41, 50);
            InitVisionUI();
@@ -30,7 +31,6 @@
        public void InitVisionUI()
        {
            this.controlsPanel.Dock = DockStyle.Fill;
            List<string> keys = dicProcessControls.Keys.ToList();
            foreach (var title in keys)
@@ -59,9 +59,7 @@
            foreach (var layout in GlobalVar.dicLayout.Values)
            {
                if (GlobalVar.dicProcesses.ContainsKey(layout.ProcessName))
                {
                    enableLayout++;
                }
            }
            int index = 0;
@@ -76,13 +74,12 @@
                        ProcessControl processControl = dicProcessControls[title];
                        processControl.Size
                            = new Size(this.controlsPanel.Size.Width / enableLayout
                            , this.controlsPanel.Size.Height-40);
                            , this.controlsPanel.Size.Height);
                        processControl.Location
                            = new Point(processControl.Size.Width * index, 0);
                        if (GlobalVar.dicProcesses[name].GetImage(GlobalVar.dicLayout[i], out _, out HImage RecordImage))
                        {
                        if (GlobalVar.dicProcesses[name].GetImage(GlobalVar.dicLayout[i], out _, out HObject RecordImage))
                            dicProcessControls[title].ShowHoImage(RecordImage);
                        }
                    }
                    else
                    {
@@ -97,10 +94,8 @@
                        dicProcessControls.TryAdd(title, processControl);
                        this.controlsPanel.Controls.Add(processControl);
                        if (GlobalVar.dicProcesses[name].GetImage(GlobalVar.dicLayout[i], out _, out HImage RecordImage))
                        {
                        if (GlobalVar.dicProcesses[name].GetImage(GlobalVar.dicLayout[i], out _, out HObject RecordImage))
                            dicProcessControls[title].ShowHoImage(RecordImage);
                        }
                    }
                    index++;
                }
LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs
@@ -72,19 +72,17 @@
                }));
            }
            else
            {
                UserHSmartWindowControl.ClearObj();
            }
        }
        /// <summary>
        /// 异步显示图片
        /// </summary>
        /// <param name="ho_image"></param>
        public void ShowHoImage(HImage ho_image)
        public void ShowHoImage(HObject ho_image)
        {
            string str = this.lblTitle.Text;
            UserHSmartWindowControl.hImage = ho_image;
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Action(() =>
@@ -93,9 +91,7 @@
                }));
            }
            else
            {
                this.label1.Text = $"总数:{ProcessRunBll.total}";
            }
        }
        public bool Run(out string msg)
@@ -107,9 +103,7 @@
            }
            if (isCircleRuning || ProcessRunBll.bRuning)
            {
                ProcessRunBll.LogInfo($"{ProcessRunBll.Name}正在运行", LogInfoType.ERROR);
            }
            ProcessRunBll.Run();
@@ -126,19 +120,15 @@
                try
                {
                    if (ProcessRunBll == null)
                    {
                        return;
                    }
                    ProcessRunBll.LogInfo(string.Format("流程[{0}]开始运行", this.ProcessRunBll.Name), LogInfoType.INFO);
                    ClearObj();
                    result = Run(out msg);
                    if (ProcessRunBll.GetImage(_Layout, out _, out HImage RecordImage))
                    {
                    if (ProcessRunBll.GetImage(_Layout, out _, out HObject RecordImage))
                        ShowHoImage(RecordImage);
                    }
                }
                catch { msg = "运行出现了异常"; }
@@ -166,7 +156,7 @@
                else
                {
                    isCircleRuning = false;
                    //threadCircleRun.Abort();
                    threadCircleRun.Abort();
                }
            }
            catch { }
@@ -198,15 +188,13 @@
                    ProcessRunBll.LogInfo($"{ProcessRunBll.Name}运行结束,结果为:{msg}"
                        , result ? LogInfoType.PASS : LogInfoType.ERROR);
                    if (ProcessRunBll.GetImage(_Layout, out _, out HImage RecordImage))
                    {
                    if (ProcessRunBll.GetImage(_Layout, out _, out HObject RecordImage))
                        ShowHoImage(RecordImage);
                    }
                }
                catch { }
                //}));
                Thread.Sleep(33);
                Thread.Sleep(100);
            }
        }
LB_SmartVision/Forms/Pages/ProcessPage/ProcessPage.cs
@@ -64,7 +64,7 @@
            else
                btn_Run.ButtonType = ReaLTaiizor.Util.HopeButtonType.Danger;
            if (ProcessRunBll.GetImage(out _, out HImage RecordImage))
            if (ProcessRunBll.GetImage(out _, out HObject RecordImage))
                UserHSmartWindowControl.ShowHoImage(RecordImage);
        }
@@ -93,7 +93,7 @@
                LogInfo?.Invoke(string.Format("流程[{0}]运行完成,结果:{1}", this.ProcessRunBll.Name, msg)
                    , result ? LogInfoType.PASS : LogInfoType.ERROR);
                if (ProcessRunBll.GetImage(out _, out HImage RecordImage))
                if (ProcessRunBll.GetImage(out _, out HObject RecordImage))
                    UserHSmartWindowControl.ShowHoImage(RecordImage);
                if (result)
LB_SmartVision/ProcessRun/ProcessContext.cs
@@ -301,7 +301,7 @@
            return res;
        }
        public bool GetImage(Layout layout, out HImage InputImage, out HImage RecordImage)
        public bool GetImage(Layout layout, out HObject InputImage, out HObject RecordImage)
        {
            InputImage = null; RecordImage = null;
            try
@@ -329,37 +329,24 @@
                    IndexValueName = arrOutputs[2];
                    object o_InputImage = ((IProcess)dicContext[IndexProcessName]).OutputImage;
                    if (o_InputImage != null && o_InputImage is HImage ho_image && ho_image.IsInitialized())
                    {
                        InputImage = ho_image.Clone();
                        ho_image.Dispose();
                    }
                    else if (o_InputImage != null && o_InputImage is Bitmap)
                    if (o_InputImage is HObject ho_image && ho_image.IsInitialized())
                        InputImage = ho_image;
                    else if (o_InputImage is Bitmap)
                    {
                        //将Mat转换为HObject
                        using (HImage ho_RecordImage = TAlgorithm.Bitmap2HImage((Bitmap)o_InputImage))
                        {
                            if (ho_RecordImage != null && ho_RecordImage.Key != IntPtr.Zero)
                            {
                                InputImage = ho_RecordImage.Clone();
                            }
                        }
                        TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage, out HObject ho_RecordImage);
                        InputImage = ho_RecordImage;
                    }
                    else if (o_InputImage != null && o_InputImage is Mat)
                    else if (o_InputImage is Mat)
                    {
                        //将Mat转换为HObject
                        using (HImage ho_RecordImage = TAlgorithm.Mat2HImage((Mat)o_InputImage))
                        {
                            if (ho_RecordImage != null && ho_RecordImage.Key != IntPtr.Zero)
                            {
                                InputImage = ho_RecordImage.Clone();
                            }
                        }
                        TAlgorithm.Mat2HObject((Mat)o_InputImage, out HObject ho_RecordImage);
                        InputImage = ho_RecordImage;
                    }
                    if (InputImage != null && InputImage.Key != IntPtr.Zero && InputImage.IsInitialized())
                    if (InputImage != null && InputImage.IsInitialized())
                    {
                        InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight);
                        HOperatorSet.GetImageSize(InputImage, out ho_ImageWidth, out ho_ImageHeight);
                        //图片尺寸变化才更新窗口尺寸[提高速度]
                        if ((ho_ImageWidth.Length > 0 && ho_ImageWidth.TupleInt() != hWindowControl.Size.Width)
@@ -387,13 +374,11 @@
                    if (dicContext.ContainsKey(IndexProcessName))
                    {
                        using (ObjectRecord objectRecord1 = ((IProcess)dicContext[IndexProcessName]).Record)
                        ObjectRecord objectRecord1 = ((IProcess)dicContext[IndexProcessName]).Record;
                        if (objectRecord1 != null)
                        {
                            if (objectRecord1 != null)
                            {
                                objectRecord1.Display(hWindowControl.HalconWindow);
                                objectRecord1.Dispose();
                            }
                            objectRecord1.Display(hWindowControl.HalconWindow);
                            objectRecord1.Dispose();
                        }
                    }
                }
@@ -407,13 +392,11 @@
                    if (dicContext.ContainsKey(IndexProcessName))
                    {
                        using (ObjectRecord objectRecord2 = ((IProcess)dicContext[IndexProcessName]).Record)
                        ObjectRecord objectRecord2 = ((IProcess)dicContext[IndexProcessName]).Record;
                        if (objectRecord2 != null)
                        {
                            if (objectRecord2 != null)
                            {
                                objectRecord2.Display(hWindowControl.HalconWindow);
                                objectRecord2.Dispose();
                            }
                            objectRecord2.Display(hWindowControl.HalconWindow);
                            objectRecord2.Dispose();
                        }
                    }
                }
@@ -427,13 +410,11 @@
                    if (dicContext.ContainsKey(IndexProcessName))
                    {
                        using (ObjectRecord objectRecord3 = ((IProcess)dicContext[IndexProcessName]).Record)
                        ObjectRecord objectRecord3 = ((IProcess)dicContext[IndexProcessName]).Record;
                        if (objectRecord3 != null)
                        {
                            if (objectRecord3 != null)
                            {
                                objectRecord3.Display(hWindowControl.HalconWindow);
                                objectRecord3.Dispose();
                            }
                            objectRecord3.Display(hWindowControl.HalconWindow);
                            objectRecord3.Dispose();
                        }
                    }
                }
@@ -441,13 +422,13 @@
                if (Result)
                {
                    Msg = "运行成功";
                    hWindowControl.HalconWindow.SetColor("green");
                    HOperatorSet.SetColor(hWindowControl.HalconWindow, "green");
                }
                else
                    hWindowControl.HalconWindow.SetColor("red");
                    HOperatorSet.SetColor(hWindowControl.HalconWindow, "red");
                TAlgorithm.DispMsg(Msg, hWindowControl.HalconWindow, Result ? "green" : "red", 0, 0);
                RecordImage = hWindowControl.HalconWindow.DumpWindowImage();
                HOperatorSet.DumpWindowImage(out RecordImage, hWindowControl.HalconWindow);
                #endregion
                return true;
@@ -508,38 +489,7 @@
                if (dicContext.TryGetValue(ProcessName, out IProcess obj)
                    && obj is IProcess process)
                {
                    if (process.InputImage != null)
                    {
                        if (process.InputImage is HObject)
                        {
                            ((HObject)process.InputImage).Dispose();
                        }
                        else if (process.InputImage is Mat)
                        {
                            ((Mat)process.InputImage).Dispose();
                        }
                        else if (process.InputImage is Bitmap)
                        {
                            ((Bitmap)process.InputImage).Dispose();
                        }
                        process.InputImage = null;
                    }
                    if (process.OutputImage != null)
                    {
                        if (process.OutputImage is HObject)
                        {
                            ((HObject)process.OutputImage).Dispose();
                        }
                        else if (process.OutputImage is Mat)
                        {
                            ((Mat)process.OutputImage).Dispose();
                        }
                        else if (process.OutputImage is Bitmap)
                        {
                            ((Bitmap)process.OutputImage).Dispose();
                        }
                        process.OutputImage = null;
                    }
                    process.InputImage = null;
                    UpdateInputs(process);
                    // 不同节点跳过的方式不同
@@ -589,9 +539,10 @@
        [Node("相机取图", "取像工具", "Basic", "相机取图")]
        public void 相机取图(FlowNode node) { RunNodeAsync(node); }
        [Node("Halcon2D斑点工具", "Halcon2D工具", "Basic", "Halcon2D斑点工具")]
        [Node("Halcon2D斑点工具", "Haclon2D工具", "Basic", "Halcon2D斑点工具")]
        public void Halcon2D斑点工具(FlowNode node) { RunNodeAsync(node); }
        #endregion
LB_SmartVision/ProcessRun/ProcessRunBll.cs
@@ -121,12 +121,12 @@
        /// </summary>
        public double RunTime = 0;
        public bool GetImage(Forms.Pages.SettingPage.Layout layout, out HImage InputImage, out HImage RecordImage)
        public bool GetImage(Forms.Pages.SettingPage.Layout layout, out HObject InputImage, out HObject RecordImage)
        {
            return ProcessContext.GetImage(layout, out InputImage, out RecordImage);
        }
        public bool GetImage(out HImage InputImage, out HImage RecordImage)
        public bool GetImage(out HObject InputImage, out HObject RecordImage)
        {
            InputImage = null;
            RecordImage = null;
LB_SmartVision/VisionForm.cs
@@ -1437,8 +1437,8 @@
                        catch { }
                    }
                    // 生成图片并显示到控件中
                    HImage InputImage = null;
                    HImage RecordImage = null;
                    HObject InputImage = null;
                    HObject RecordImage = null;
                    foreach (var layout in GlobalVar.dicLayout.Values
                                .Where(layout => layout.ProcessName == ProcessName)
LB_VisionControl/UserHSmartWindowControl.cs
@@ -1,4 +1,5 @@
using HalconDotNet;
using Sunny.UI.Win32;
using System.Diagnostics;
namespace LB_VisionControl
@@ -32,11 +33,11 @@
        /// </summary>
        public bool bAutoSize = true;
        private HImage _hImage = null;
        private HObject _hImage = null;
        /// <summary>
        /// 显示图片(异步)
        /// </summary>
        public HImage hImage
        public HObject hImage
        {
            get
            {
@@ -273,10 +274,10 @@
        /// <param name="ho_image"></param>
        /// <param name="hWindow"></param>
        /// <param name="autoSize"></param>
        public async void ShowHoImageAsync(HImage ho_image, HWindow hWindow, bool autoSize = true)
        public async void ShowHoImageAsync(HObject ho_image, HWindow hWindow, bool autoSize = true)
        {
            if (ho_image == null || !ho_image.IsInitialized())
                hWindow.ClearWindow();
                HOperatorSet.ClearWindow(hWindow);
            else
                await ShowImageAsync(hWindow, ho_image, autoSize);
        }
@@ -286,10 +287,10 @@
        /// </summary>
        /// <param name="ho_image"></param>
        /// <param name="autoSize"></param>
        public void ShowHoImage(HImage ho_image, bool autoSize = true)
        public void ShowHoImage(HObject ho_image, bool autoSize = true)
        {
            _hImage = ho_image;
            hWindowControl.HalconWindow.ClearWindow();
            HOperatorSet.ClearWindow(hWindowControl.HalconWindow);
            if (ho_image == null)
                return;
@@ -343,7 +344,7 @@
            return;
        }
        private async Task<bool> ShowImageAsync(HWindow hWindow, HImage ho_image, bool autoSize = true)
        private async Task<bool> ShowImageAsync(HWindow hWindow, HObject ho_image, bool autoSize = true)
        {
            return await Task.Run(() =>
            {
@@ -351,7 +352,7 @@
                {
                    try
                    {
                        hWindow.ClearWindow();
                        HOperatorSet.ClearWindow(hWindow);
                    }
                    catch { return false; }
                    return true;
@@ -359,11 +360,11 @@
                try
                {
                    hWindow.ClearWindow();
                    HOperatorSet.ClearWindow(hWindow);
                    if (autoSize)
                    {
                        ho_image.GetImageSize(out HTuple imgWidth, out HTuple imgHeight);
                        HOperatorSet.GetImageSize(ho_image, out HTuple imgWidth, out HTuple imgHeight);
                        if (imgWidth.Length > 0)
                        {
                            hWindow.GetWindowExtents(out int winRow, out int winCol, out int winWidth, out int winHeight);
@@ -395,7 +396,7 @@
                        }
                    }
                    hWindow.DispObj(ho_image);
                    HOperatorSet.DispObj(ho_image, hWindow);
                }
                catch { return false; }
                return true;
@@ -421,7 +422,7 @@
            try
            {
                if (ho_object != null && ho_object.IsInitialized())
                    this.hWindowControl.HalconWindow.DispObj(ho_object);
                    HOperatorSet.DispObj(ho_object, this.hWindowControl.HalconWindow);
            }
            catch { }
        }
@@ -433,7 +434,7 @@
                if (ho_object != null && ho_object.IsInitialized())
                {
                    SetColor(color);
                    this.hWindowControl.HalconWindow.DispObj(ho_object);
                    HOperatorSet.DispObj(ho_object, this.hWindowControl.HalconWindow);
                }
            }
            catch { }
@@ -447,7 +448,7 @@
                {
                    string color = result ? "green" : "red";
                    SetColor(color);
                    this.hWindowControl.HalconWindow.DispObj(ho_object);
                    HOperatorSet.DispObj(ho_object, this.hWindowControl.HalconWindow);
                }
            }
            catch { }
@@ -488,7 +489,7 @@
                if (this.color != color)
                {
                    this.hWindowControl.HalconWindow.SetColor( color);
                    HOperatorSet.SetColor(this.hWindowControl.HalconWindow, color);
                    this.color = color;
                }
            }
LB_VisionFlowNode/FlowPanel.cs
@@ -304,7 +304,7 @@
            context.CurrentBranchName = $"{currentNode.Text}-Branch{currentNode.BranchIndex}";
            bool result = Context.ExecuteNode(currentNode);
#if DEBUG
            Debug.WriteLine($"执行节点[{currentNode.Text}],结果为{result}");
            Debug.WriteLine(DateTime.Now.ToString("[yyyy:MM:dd:HH:mm:ss:fff] ") + $"执行节点[{currentNode.Text}],结果为{result}");
#endif
            context.BranchResults.TryAdd(context.CurrentBranchName, currentNode.Result);
            currentNode.Result = result;
LB_VisionProcesses/Alogrithms/BaseAlgorithm/TAlgorithm.cs
@@ -41,7 +41,7 @@
        /// <summary>
        /// 读写锁
        /// </summary>
        public readonly object lockObj = new object();
        public static readonly object lockObj = new object();
        /// <summary>
        /// 裁切图片为hoDomainImage(保留原坐标系,其余填充为空)
@@ -64,7 +64,7 @@
                {
                    if (InputImage is Bitmap)
                    {
                        Bitmap2Mat((Bitmap)InputImage, out Mat src);
                        TAlgorithm.Bitmap2Mat((Bitmap)InputImage, out Mat src);
                        if (Params.Fixture == null)
                            Params.Fixture = new Fixture();
@@ -96,7 +96,7 @@
                                // 4. 创建与原图大小相同的Mat,并初始化无效值
                                image = new Mat(src.Size(), src.Type());
                                ((Mat)image).SetTo(GetInvalidValueForMat(src)); // 全部初始化为无效值
                                ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // 全部初始化为无效值
                                // 5. 创建遮罩:在result上绘制旋转矩形(白色填充)
                                using (Mat cropped = new Mat(src, boundingRect))
@@ -113,7 +113,7 @@
                                // 2. 创建与原图大小相同的Mat,并初始化无效值
                                image = new Mat(src.Size(), src.Type());
                                ((Mat)image).SetTo(GetInvalidValueForMat(src)); // 全部初始化为无效值
                                ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // 全部初始化为无效值
                                // 3. 创建圆形遮罩
                                using (Mat mask = Mat.Zeros(src.Rows, src.Cols, MatType.CV_8UC1))
@@ -127,8 +127,39 @@
                                image = ((Bitmap)InputImage)?.Clone();
                                return true;
                        }
                        Mat2Bitmap((Mat)image, out Bitmap bmp);
                        TAlgorithm.Mat2Bitmap((Mat)image, out Bitmap bmp);
                        image = bmp;
                        return true;
                    }
                    else if (InputImage is HObject ho_image)
                    {
                        if (!ho_image.IsInitialized())
                            return false;
                        if (Params.Fixture == null)
                            Params.Fixture = new Fixture();
                        HObject hoDomainImage = null;
                        switch (Params.ROI?.GetType().Name)
                        {
                            case "HRectangle2":
                                HOperatorSet.GenRectangle2(out HObject hRectangle2, (HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column)
                                    , (HTuple)(Params.ROI.Phi + Params.Fixture.Phi), (HTuple)((HRectangle2)Params.ROI).SemiLength1, (HTuple)((HRectangle2)Params.ROI).SemiLength2);
                                HOperatorSet.ReduceDomain(ho_image, hRectangle2, out hoDomainImage);
                                break;
                            case "HCircle":
                                HOperatorSet.GenCircle(out HObject hCircle, (HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column)
                                    , (HTuple)((HCircle)Params.ROI).Radius);
                                HOperatorSet.ReduceDomain(ho_image, hCircle, out hoDomainImage);
                                break;
                            case "ROI":
                            default:
                                image = ho_image.CopyObj(1, -1);
                                return true;
                        }
                        image = hoDomainImage;
                        return true;
                    }
                    else if (InputImage is Mat)
@@ -162,7 +193,7 @@
                                // 4. 创建与原图大小相同的Mat,并初始化无效值
                                image = new Mat(src.Size(), src.Type());
                                ((Mat)image).SetTo(GetInvalidValueForMat(src)); // 全部初始化为无效值
                                ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // 全部初始化为无效值
                                // 5. 创建遮罩:在result上绘制旋转矩形(白色填充)
                                using (Mat cropped = new Mat(src, boundingRect))
@@ -179,7 +210,7 @@
                                // 2. 创建与原图大小相同的Mat,并初始化无效值
                                image = new Mat(src.Size(), src.Type());
                                ((Mat)image).SetTo(GetInvalidValueForMat(src)); // 全部初始化为无效值
                                ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // 全部初始化为无效值
                                // 3. 创建圆形遮罩
                                using (Mat mask = Mat.Zeros(src.Rows, src.Cols, MatType.CV_8UC1))
@@ -213,112 +244,32 @@
            }
        }
        public virtual bool ReduceDomainImage(object InputImage, ref HImage image)
        {
            image = null;
            if (InputImage == null)
            {
                image = null;
                Msg = "输入图片为空";
                Result = false;
                return false;
            }
            lock (InputImage)
            {
                try
                {
                    if (InputImage is HImage ho_image)
                    {
                        if (!ho_image.IsInitialized())
                            return false;
                        if (Params.Fixture == null)
                            Params.Fixture = new Fixture();
                        HImage hoDomainImage = null;
                        switch (Params.ROI?.GetType().Name)
                        {
                            case "HRectangle2":
                                using (HRegion hRectangle2 = new HRegion())
                                {
                                    hRectangle2.GenRectangle2((HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column)
                                        , (HTuple)(Params.ROI.Phi + Params.Fixture.Phi), (HTuple)((HRectangle2)Params.ROI).SemiLength1, (HTuple)((HRectangle2)Params.ROI).SemiLength2);
                                    hoDomainImage = ho_image.ReduceDomain(hRectangle2);
                                }
                                break;
                            case "HCircle":
                                using (HRegion hCircle = new HRegion())
                                {
                                    hCircle.GenCircle((HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column)
                                    , (HTuple)((HCircle)Params.ROI).Radius);
                                    hoDomainImage = ho_image.ReduceDomain(hCircle);
                                }
                                break;
                            case "ROI":
                            default:
                                image = ho_image.CopyObj(1, -1);
                                return true;
                        }
                        image = hoDomainImage;
                        return true;
                    }
                    else
                    {
                        image = null;
                        Msg = $"输入格式不正确{InputImage.GetType()}";
                        Result = false;
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    image = null;
                    Msg = $"裁剪区域失败,原因是:{ex.ToString()}";
                    Result = false;
                    return false;
                }
            }
        }
        public override void Dispose()
        {
            if (InputImage != null)
            {
                if (InputImage is HObject)
                {
                    ((HObject)InputImage).Dispose();
                }
                else if (InputImage is Mat)
                {
                    ((Mat)InputImage).Dispose();
                }
                else if (InputImage is Bitmap)
                {
                    ((Bitmap)InputImage).Dispose();
                }
                InputImage = null;
            }
            if (OutputImage != null)
            {
                if (OutputImage is HObject)
                {
                    ((HObject)OutputImage).Dispose();
                }
                else if (OutputImage is Mat)
                {
                    ((Mat)OutputImage).Dispose();
                }
                else if (OutputImage is Bitmap)
                {
                    ((Bitmap)OutputImage).Dispose();
                }
                OutputImage = null;
            }
            if (Record != null)
            {
                Record.Dispose();
@@ -336,18 +287,13 @@
                if (InputImage != null)
                {
                    if (InputImage is HObject ho_image && ho_image.IsInitialized())
                    {
                        obj.InputImage = ho_image.CopyObj(1, -1);
                    }
                    else if (InputImage is Mat mat && !mat.Empty())
                    {
                        obj.InputImage = mat.Clone();
                    }
                    else if (InputImage is Bitmap bitmap)
                    {
                        obj.InputImage = bitmap.Clone();
                    }
                }
                return obj;
            }
            catch { return (TAlgorithm)MemberwiseClone(); }
@@ -357,32 +303,17 @@
        {
            Result = true;
            bCompleted = false;
            Msg = string.Empty;
            //if (InputImage != null)
            //{
            //    if (InputImage is HObject)
            //    {
            //        ((HObject)InputImage).Dispose();
            //    }
            //    else if (InputImage is Mat)
            //    {
            //        ((Mat)InputImage).Dispose();
            //    }
            //    else if (InputImage is Bitmap)
            //    {
            //        ((Bitmap)InputImage).Dispose();
            //    }
            //    InputImage = null;
            //}
            Msg = "";
            OutputImage = null;
            if (Record != null)
            {
                Record.Dispose();
            }
        }
        public override bool Run()
        {
            DateTime StartTime = DateTime.Now;
            InitRunParams();
            HOperatorSet.GenEmptyObj(out HObject EmptyObj);
            OutputImage = EmptyObj;
@@ -400,6 +331,7 @@
                Thread.Sleep(30);
            }
            Msg = "运行超时";
            Result = false;
            RunTime = (DateTime.Now - StartTime).TotalMilliseconds;
@@ -425,9 +357,8 @@
            try
            {
                if (string.IsNullOrEmpty(fullPath))
                {
                    return false;
                }
                if (!fullPath.Contains(".json"))
                {
                    Debug.WriteLine("文件路径不完整");
@@ -438,6 +369,7 @@
                    Debug.WriteLine("文件路径不完整");
                    return false;
                }
                // 获取不带文件名的目录路径
                string directoryPath = Path.GetDirectoryName(fullPath);
                strProcessName = Path.GetFileNameWithoutExtension(fullPath);
@@ -448,6 +380,7 @@
                    Save(directoryPath);
                    return true;
                }
                string strJson = string.Empty;
                using (StreamReader streamReader = new StreamReader(fullPath, Encoding.UTF8))
                {
@@ -456,9 +389,8 @@
                }
                Params = JsonConvert.DeserializeObject<ProcessParams>(strJson);
                if (Params == null)
                {
                    return false;
                }
                Params.FixDeserializedData();
                return true;
            }
@@ -521,20 +453,20 @@
                return value;
        }
        public static HImage Bitmap2HImage(Bitmap bmp)
        public static void Bitmap2HObject(Bitmap bmp, out HObject image)
        {
            BitmapData srcBmpData;
            HImage image = null;
            try
            {
                if (bmp.Tag == null || bmp == null || bmp.Width == 0 || bmp.Height == 0)
                if (bmp == null || bmp.Width == 0 || bmp.Height == 0)
                {
                    image = null;
                    return image;
                    return;
                }
                lock (bmp)
                {
                    image = new HImage();
                    switch (bmp.PixelFormat)
                    {
                        case PixelFormat.Format24bppRgb:
@@ -543,41 +475,35 @@
                            int width = bmp.Width;
                            int height = bmp.Height;
                            int stride = srcBmpData.Stride;
                            if (stride == width * 3)
                            {
                                image.GenImageInterleaved(srcBmpData.Scan0, "bgr", bmp.Width, bmp.Height, 0, "byte", 0, 0, 0, 0, -1, 0);
                            }
                                HOperatorSet.GenImageInterleaved(out image, srcBmpData.Scan0, "bgr", bmp.Width, bmp.Height, 0, "byte", 0, 0, 0, 0, -1, 0);
                            else
                            {
                                image = HandleStrideAlignmentBest(srcBmpData.Scan0, width, height, stride);
                            }
                            bmp.UnlockBits(srcBmpData);
                            break;
                        default:
                            srcBmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
                            image.GenImage1("byte", bmp.Width, bmp.Height, srcBmpData.Scan0);
                            HOperatorSet.GenImage1(out image, "byte", bmp.Width, bmp.Height, srcBmpData.Scan0);
                            bmp.UnlockBits(srcBmpData);
                            break;
                    }
                }
                return image;
                return;
            }
            catch
            {
                if (image != null)
                {
                    image.Dispose();
                }
                image = null;
                return image;
                return;
            }
        }
        private static HImage HandleStrideAlignmentBest(IntPtr scan0, int width, int height, int stride)
        private static HObject HandleStrideAlignmentBest(IntPtr scan0, int width, int height, int stride)
        {
            int expectedStride = width * 3;
            byte[] alignedData = new byte[width * height * 3];
            HImage image = new HImage();
            unsafe
            {
                byte* srcPtr = (byte*)scan0;
@@ -595,31 +521,31 @@
                            expectedStride
                        );
                    }
                    image.GenImageInterleaved(new IntPtr(dstPtr), "bgr", width, height, 0, "byte", width, height, 0, 0, -1, 0);
                    return image;
                    HOperatorSet.GenImageInterleaved(out HObject ho_img, new IntPtr(dstPtr), "bgr", width, height, 0, "byte", width, height, 0, 0, -1, 0);
                    return ho_img;
                }
            }
        }
        public static unsafe void HImage2Bitmap(HImage hImage, out Bitmap bmp)
        public static unsafe void HObject2Bitmap(HObject hObject, out Bitmap bmp)
        {
            try
            {
                if (hImage == null || !hImage.IsInitialized())
                if (hObject == null || !hObject.IsInitialized())
                {
                    bmp = null;
                    return;
                }
                // 获取图像信息
                hImage.GetImageSize(out HTuple width, out HTuple height);
                HTuple channels = hImage.CountChannels();
                HOperatorSet.GetImageSize(hObject, out HTuple width, out HTuple height);
                HOperatorSet.CountChannels(hObject, out HTuple channels);
                if (channels.I == 1)
                {
                    // 灰度图处理
                    HTuple ptr, type;
                    ptr = hImage.GetImagePointer1(out type, out width, out height);
                    HOperatorSet.GetImagePointer1(hObject, out ptr, out type, out width, out height);
                    bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
@@ -648,7 +574,7 @@
                {
                    // 彩色图处理(BGR顺序)
                    HTuple ptrR, ptrG, ptrB, type;
                    hImage.GetImagePointer3(out ptrR, out ptrG, out ptrB, out type, out width, out height);
                    HOperatorSet.GetImagePointer3(hObject, out ptrR, out ptrG, out ptrB, out type, out width, out height);
                    bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
                    BitmapData bmpData = bmp.LockBits(
@@ -685,20 +611,20 @@
            }
        }
        public static HImage Mat2HImage(Mat mat)
        public static void Mat2HObject(Mat mat, out HObject image)
        {
            HImage image = null;
            try
            {
                if (mat == null || mat.Empty())
                {
                    return image;
                    image = null;
                    return;
                }
                if (mat.Type() == MatType.CV_8UC3) // 彩色图像 (BGR)
                {
                    image = new HImage();
                    image.GenImageInterleaved(
                    HOperatorSet.GenImageInterleaved(
                        out image,
                        mat.Data,
                        "bgr",
                        mat.Width,
@@ -709,8 +635,8 @@
                }
                else if (mat.Type() == MatType.CV_8UC1) // 灰度图像
                {
                    image = new HImage();
                    image.GenImage1(
                    HOperatorSet.GenImage1(
                        out image,
                        "byte",
                        mat.Width,
                        mat.Height,
@@ -719,13 +645,14 @@
                else
                {
                    throw new ArgumentException($"Mat2HObject不支持的图像格式:{mat.Type()}");
                    return;
                }
                return image;
                return;
            }
            catch
            {
                image = null;
                return image;
                return;
            }
        }
@@ -1311,10 +1238,10 @@
                HOperatorSet.GenImageConst(out image, "real", hv_xMax + 1, hv_yMax + 1);
                HOperatorSet.SetGrayval(image, hv_y, hv_x, hv_z);
                //hoperatorset.getimagesize(ho_image, out htuple hv_width, out htuple hv_height);
                //hoperatorset.genrectangle1(out hobject ho_rectangle, 0, 0, hv_height - 1, hv_width - 1);
                //hoperatorset.getregionpoints(ho_rectangle, out htuple hv_rows, out htuple hv_columns);
                //hoperatorset.getgrayval(ho_image, hv_rows, hv_columns, out htuple hv_z);
                //HOperatorSet.GetImageSize(ho_Image, out HTuple hv_Width, out HTuple hv_Height);
                //HOperatorSet.GenRectangle1(out HObject ho_Rectangle, 0, 0, hv_Height - 1, hv_Width - 1);
                //HOperatorSet.GetRegionPoints(ho_Rectangle, out HTuple hv_Rows, out HTuple hv_Columns);
                //HOperatorSet.GetGrayval(ho_Image, hv_Rows, hv_Columns, out HTuple hv_Z);
            }
            catch { image = null; }
        }
@@ -1325,7 +1252,7 @@
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        /// <returns></returns>
        public double GetDistanceP2P(HPoint startPoint, HPoint endPoint)
        public static double GetDistanceP2P(HPoint startPoint, HPoint endPoint)
        {
            try
            {
@@ -1334,12 +1261,12 @@
            catch { return 9994; }
        }
        public double GetDistanceP2P(Point startPoint, Point endPoint)
        public static double GetDistanceP2P(Point startPoint, Point endPoint)
        {
            return GetDistanceP2P(new HPoint(startPoint), new HPoint(endPoint));
        }
        public double DistanceP2P(double startX, double startY, double endX, double endY)
        public static double DistanceP2P(double startX, double startY, double endX, double endY)
        {
            return GetDistanceP2P(new HPoint(startX, startY), new HPoint(endX, endY));
        }
@@ -1350,17 +1277,17 @@
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        /// <returns></returns>
        public HPoint GetMidPoint(HPoint startPoint, HPoint endPoint)
        public static HPoint GetMidPoint(HPoint startPoint, HPoint endPoint)
        {
            return new HPoint((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2);
        }
        public Point GetMidPoint(Point startPoint, Point endPoint)
        public static Point GetMidPoint(Point startPoint, Point endPoint)
        {
            return new Point((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2);
        }
        public System.Drawing.Point GetMidPoint(System.Drawing.Point startPoint, System.Drawing.Point endPoint)
        public static System.Drawing.Point GetMidPoint(System.Drawing.Point startPoint, System.Drawing.Point endPoint)
        {
            return new System.Drawing.Point((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2);
        }
@@ -1371,7 +1298,7 @@
        /// <param name="point"></param>
        /// <param name="segment"></param>
        /// <returns></returns>
        public bool IsPointOnSegment(HPoint pt, HSegment segment, double tolerance = 1e-3)
        public static bool IsPointOnSegment(HPoint pt, HSegment segment, double tolerance = 1e-3)
        {
            // 计算直线方程的系数
            double A = segment.EndY - segment.StartX;
@@ -1394,7 +1321,7 @@
            return false;
        }
        public bool IsPointOnSegment(double px, double py, double x1, double y1, double x2, double y2)
        public static bool IsPointOnSegment(double px, double py, double x1, double y1, double x2, double y2)
        {
            return IsPointOnSegment(new HPoint(px, py), new HSegment(x1, y1, x2, y2));
        }
@@ -1419,7 +1346,7 @@
            catch { return false; }
        }
        public bool IsPointNearRectangleSilde(HPoint pt, HRectangle2 rect, double tolerance = 100)
        public static bool IsPointNearRectangleSilde(HPoint pt, HRectangle2 rect, double tolerance = 100)
        {
            return IsPointNearRectangleSilde(new System.Drawing.Point((int)pt.X, (int)pt.Y), new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), tolerance);
        }
@@ -1431,21 +1358,21 @@
        /// <param name="pt2"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public bool IsPointNearPoint(HPoint pt1, HPoint pt2, double tolerance = 100)
        public static bool IsPointNearPoint(HPoint pt1, HPoint pt2, double tolerance = 100)
        {
            if (GetDistanceP2P(pt1, pt2) <= tolerance)
                return true;
            return false;
        }
        public bool IsPointNearPoint(Point pt1, Point pt2, double tolerance = 100)
        public static bool IsPointNearPoint(Point pt1, Point pt2, double tolerance = 100)
        {
            if (GetDistanceP2P(pt1, pt2) <= tolerance)
                return true;
            return false;
        }
        public bool IsPointNearPoint(double x1, double y1, double x2, double y2, int tolerance = 100)
        public static bool IsPointNearPoint(double x1, double y1, double x2, double y2, int tolerance = 100)
        {
            return IsPointNearPoint(new HPoint(x1, y1), new HPoint(x2, y2), tolerance);
        }
@@ -1458,7 +1385,7 @@
        /// <param name="corner"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public bool IsPointNearRectangleCorner(Point pt, Rectangle rect, out string corner, double tolerance = 10)
        public static bool IsPointNearRectangleCorner(Point pt, Rectangle rect, out string corner, double tolerance = 10)
        {
            try
            {
@@ -1497,7 +1424,7 @@
            catch { corner = ""; return false; }
        }
        public bool IsPointNearRectangleCorner(HPoint pt, HRectangle2 rect, out string corner, double tolerance = 10)
        public static bool IsPointNearRectangleCorner(HPoint pt, HRectangle2 rect, out string corner, double tolerance = 10)
        {
            try
            {
@@ -1545,7 +1472,7 @@
        /// <param name="p3">线2起始点</param>
        /// <param name="p4"></param>
        /// <returns></returns>
        public Point2d? GetLineIntersection(Point2d p1, Point2d p2, Point2d p3, Point2d p4, bool bOnSegment = false)
        public static Point2d? GetLineIntersection(Point2d p1, Point2d p2, Point2d p3, Point2d p4, bool bOnSegment = false)
        {
            // 直线1的向量
            double x1 = p1.X, y1 = p1.Y;
@@ -1582,7 +1509,7 @@
        #region Halcon
        // Chapter: Graphics / Output
        // Short Description: Display 3D object models 
        public void visualize_object_model_3d(HTuple hv_WindowHandle, HTuple hv_ObjectModel3D,
        public static void visualize_object_model_3d(HTuple hv_WindowHandle, HTuple hv_ObjectModel3D,
            HTuple hv_CamParam, HTuple hv_PoseIn, HTuple hv_GenParamName, HTuple hv_GenParamValue,
            HTuple hv_Title, HTuple hv_Label, HTuple hv_Information, out HTuple hv_PoseOut)
        {
@@ -3310,7 +3237,7 @@
        // Chapter: Calibration / Camera Parameters
        // Short Description: Set the value of a specified camera parameter in the camera parameter tuple. 
        public void set_cam_par_data(HTuple hv_CameraParamIn, HTuple hv_ParamName, HTuple hv_ParamValue,
        public static void set_cam_par_data(HTuple hv_CameraParamIn, HTuple hv_ParamName, HTuple hv_ParamValue,
            out HTuple hv_CameraParamOut)
        {
            // Local iconic variables 
@@ -3414,7 +3341,7 @@
            }
        }
        public void gen_arrow_contour_xld(out HObject ho_Arrow, HTuple hv_Row1, HTuple hv_Column1,
        public static void gen_arrow_contour_xld(out HObject ho_Arrow, HTuple hv_Row1, HTuple hv_Column1,
            HTuple hv_Row2, HTuple hv_Column2, HTuple hv_HeadLength, HTuple hv_HeadWidth)
        {
            // Stack for temporary objects 
@@ -3588,7 +3515,7 @@
            }
        }
        public void get_rect2_vertex(HTuple hv_Row, HTuple hv_Column, HTuple hv_Phi, HTuple hv_Length1,
        public static void get_rect2_vertex(HTuple hv_Row, HTuple hv_Column, HTuple hv_Phi, HTuple hv_Length1,
            HTuple hv_Length2, out HTuple hv_TopLeft_Row, out HTuple hv_TopLeft_Col, out HTuple hv_TopRight_Row,
            out HTuple hv_TopRight_Col, out HTuple hv_LowLeft_Row, out HTuple hv_LowLeft_Col,
            out HTuple hv_LowRight_Row, out HTuple hv_LowRight_Col)
@@ -3795,7 +3722,7 @@
            }
        }
        public void pts_to_best_line(out HObject ho_LineXld, HTuple hv_Rows, HTuple hv_Columns,
        public static void pts_to_best_line(out HObject ho_LineXld, HTuple hv_Rows, HTuple hv_Columns,
            HTuple hv_IgnoreNum, out HTuple hv_Row1, out HTuple hv_Column1, out HTuple hv_Row2,
            out HTuple hv_Column2)
        {
@@ -3881,7 +3808,7 @@
            }
        }
        public (double, double) CalculateTailValues(HTuple minValue, HTuple maxValue, HTuple mean, HTuple deviation, double tailPercentage = 0.3)
        public static (double, double) CalculateTailValues(HTuple minValue, HTuple maxValue, HTuple mean, HTuple deviation, double tailPercentage = 0.3)
        {
            // 计算低尾灰度值
            double lowTailValue = minValue.TupleReal() + (mean.TupleReal() - minValue.TupleReal()) * tailPercentage;
@@ -3914,7 +3841,7 @@
        /// <param name="hv_Column2">结束横坐标</param>
        /// <param name="hv_ResultRow">结果点集合纵坐标</param>
        /// <param name="hv_ResultColumn">结果点集合横坐标</param>
        public void Rake(HObject ho_Image, out HObject ho_Regions, HTuple hv_Elements,
        public static void Rake(HObject ho_Image, out HObject ho_Regions, HTuple hv_Elements,
            HTuple hv_DetectHeight, HTuple hv_DetectWidth, HTuple hv_Sigma, HTuple hv_Threshold,
            HTuple hv_Transition, HTuple hv_Select, HTuple hv_Row1, HTuple hv_Column1, HTuple hv_Row2,
            HTuple hv_Column2, out HTuple hv_ResultRow, out HTuple hv_ResultColumn)
@@ -5110,7 +5037,7 @@
            catch { }
        }
        public void scale_gray_map(HObject ho_Image, out HObject ho_Image1, HTuple hv_Min, HTuple hv_Max)
        public static void scale_gray_map(HObject ho_Image, out HObject ho_Image1, HTuple hv_Min, HTuple hv_Max)
        {
            HTuple hv_Mult = new HTuple(), hv_Add = new HTuple();
            HOperatorSet.GenEmptyObj(out ho_Image1);
@@ -5197,7 +5124,7 @@
        #region OpenCVSharp
        // 根据Mat类型返回对应的无效值
        public Scalar GetInvalidValueForMat(Mat mat)
        public static Scalar GetInvalidValueForMat(Mat mat)
        {
            MatType type = mat.Type();
            if (type == MatType.CV_8UC1 || type == MatType.CV_8UC3)
@@ -5210,7 +5137,7 @@
                return new Scalar(0); // 对于8位无符号类型,0是安全的无效值
        }
        public void RGB2XYZ(double sR, double sG, double sB, out double X, out double Y, out double Z)
        public static void RGB2XYZ(double sR, double sG, double sB, out double X, out double Y, out double Z)
        {
            // 输入的颜色值 (sR, sG, sB) 应为 0 到 255 之间的值
@@ -5241,7 +5168,7 @@
            Z = Math.Round(var_Z / (var_X + var_Y + var_Z), 3);
        }
        public void ExtractFrames(string videoPath, string outputDir)
        public static void ExtractFrames(string videoPath, string outputDir)
        {
            // 检查视频文件是否存在
            if (!File.Exists(videoPath))
LB_VisionProcesses/Alogrithms/BaseAlgorithm/TAlgorithmEdit.cs
@@ -53,36 +53,27 @@
            get
            {
                if (Subject == null)
                {
                    return null;
                }
                return Subject.InputImage;
            }
            set
            {
                Subject.InputImage = value;
                if (InputImage == null)
                {
                    return;
                }
                if (InputImage is HImage)
                {
                    inputImageHSmartWindowControl.ShowHoImage((HImage)value);
                }
                if (InputImage == null)
                    return;
                if (InputImage is HObject)
                    inputImageHSmartWindowControl.ShowHoImage((HObject)value);
                else if (InputImage is Bitmap)
                {
                    using (HImage image = TAlgorithm.Bitmap2HImage((Bitmap)value))
                    {
                        inputImageHSmartWindowControl.ShowHoImage(image);
                    }
                    TAlgorithm.Bitmap2HObject((Bitmap)value, out HObject image);
                    inputImageHSmartWindowControl.ShowHoImage(image);
                }
                else if (InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)value))
                    {
                        inputImageHSmartWindowControl.ShowHoImage(image);
                    }
                    TAlgorithm.Mat2HObject((Mat)value, out HObject image);
                    inputImageHSmartWindowControl.ShowHoImage(image);
                }
            }
        }
LB_VisionProcesses/Alogrithms/BaseAlgorithm/TestTool/TestToolEdit.cs
@@ -89,7 +89,7 @@
                stxtInput.Text = Subject.Params.Inputs["输入"].ToString();
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                    inputImageHSmartWindowControl.ShowHoImage((HImage)Subject.InputImage);
                    inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
@@ -179,21 +179,17 @@
                {
                    if (Subject.OutputImage is Mat)
                    {
                        using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.OutputImage))
                        {
                            recordImageHSmartWindowControl.ShowHoImage(image);
                        }
                        TAlgorithm.Mat2HObject((Mat)Subject.OutputImage, out HObject image);
                        recordImageHSmartWindowControl.ShowHoImage(image);
                    }
                    else if (Subject.OutputImage is Bitmap)
                    {
                        using (HImage image = TAlgorithm.Bitmap2HImage((Bitmap)Subject.OutputImage))
                        {
                            recordImageHSmartWindowControl.ShowHoImage(image);
                        }
                        TAlgorithm.Bitmap2HObject((Bitmap)Subject.OutputImage, out HObject image);
                        recordImageHSmartWindowControl.ShowHoImage(image);
                    }
                    else if (Subject.OutputImage is HImage)
                    else if (Subject.OutputImage is HObject)
                    {
                        recordImageHSmartWindowControl.ShowHoImage((HImage)Subject.OutputImage);
                        recordImageHSmartWindowControl.ShowHoImage((HObject)Subject.OutputImage);
                    }
                }
                //先判断子类再判断父类
LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobTool.cs
@@ -89,15 +89,12 @@
                            BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
                            hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0);
                            ((Bitmap)InputImage).UnlockBits(srcBmpData);
                            ((Bitmap)InputImage).Dispose();
                            InputImage = null;
                            InputImage = hImage.Clone();
                        }
                    }
                    catch (Exception ex)
                    {
                        Msg = "转图出错:" + ex.Message;
                        Result = false;
                        return;
                    }
                }
                if (!(InputImage is HObject))
@@ -108,7 +105,7 @@
                }
                #region 裁剪区域
                HImage DomainImage = null;
                object DomainImage = null;
                if (!ReduceDomainImage(InputImage, ref DomainImage))
                {
                    Msg = "裁剪区域失败";
LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobToolEdit.Designer.cs
@@ -1274,8 +1274,8 @@
            // 
            // HBlobToolEdit
            // 
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(splitContainer1);
            Controls.Add(BtmStatusStrip);
            Controls.Add(TopToolStrip);
LB_VisionProcesses/Alogrithms/Halcon/2D/HBlobTool/HBlobToolEdit.cs
@@ -216,8 +216,8 @@
                }
                catch { }
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                    inputImageHSmartWindowControl.ShowHoImage((HImage)Subject.InputImage);
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                    inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
@@ -308,14 +308,12 @@
                UpdataOutputs();
                imgTabControl.SelectedTab = tabPageRecordImage;
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                    HOperatorSet.GetImageSize((HObject)Subject.InputImage, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                }
                //先判断子类再判断父类
                if (Subject.Record != null && Subject.Record is MsgRecord msgRecord)
                {
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dTool.cs
@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -64,27 +63,6 @@
                        Msg = "输入图片为空";
                        Result = false;
                        return;
                    }
                    if (InputImage is Bitmap)
                    {
                        try
                        {
                            using (HImage hImage = new HImage())
                            {
                                Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height);
                                BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
                                hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0);
                                ((Bitmap)InputImage).UnlockBits(srcBmpData);
                                ((Bitmap)InputImage).Dispose();
                                InputImage = hImage.Clone();
                            }
                        }
                        catch (Exception ex)
                        {
                            Msg = "转图出错:" + ex.Message;
                            Result = false;
                            return;
                        }
                    }
                    if (!(InputImage is HObject))
                    {
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dToolEdit.Designer.cs
@@ -584,8 +584,8 @@
            // 
            // HFindCode2dToolEdit
            // 
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(MainTableLayoutPanel);
            Controls.Add(BtmStatusStrip);
            Controls.Add(TopToolStrip);
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dToolEdit.cs
@@ -106,13 +106,8 @@
                dtxtMinCount.Text = Subject.Params.Inputs["MinCount"].ToString();
                dtxtMaxCount.Text = Subject.Params.Inputs["MaxCount"].ToString();
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        inputImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                }
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                    inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
@@ -198,13 +193,10 @@
                UpdataOutputs();
                imgTabControl.SelectedTab = tabPageRecordImage;
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                {
                    using (HImage hImage= (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                    HOperatorSet.GetImageSize((HObject)Subject.InputImage, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                }
                //先判断子类再判断父类
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindCode2dTool/HFindCode2dToolEdit.resx
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Microsoft ResX Schema
    Version 2.0
@@ -48,7 +48,7 @@
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
@@ -117,13 +117,10 @@
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <metadata name="lblMsgToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
  <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>156, 17</value>
  </metadata>
  <metadata name="BtmStatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>287, 17</value>
    <value>148, 17</value>
  </metadata>
</root>
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineTool.cs
@@ -3,7 +3,6 @@
using LB_VisionProcesses.Alogrithms.Halcon;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -62,33 +61,7 @@
                    Result = false;
                    return;
                }
                if (InputImage is Bitmap)
                {
                    try
                    {
                        using (HImage hImage = new HImage())
                        {
                            Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height);
                            BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
                            hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0);
                            ((Bitmap)InputImage).UnlockBits(srcBmpData);
                            ((Bitmap)InputImage).Dispose();
                            InputImage = hImage.Clone();
                        }
                    }
                    catch (Exception ex)
                    {
                        Msg = "转图出错:" + ex.Message;
                        Result = false;
                        return;
                    }
                }
                if (!(InputImage is HObject))
                {
                    Msg = "输入图片格式不为Mat";
                    Result = false;
                    return;
                }
                #region 裁剪区域
                if (!(Params.ROI is HSegment))
                {
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineToolEdit.Designer.cs
@@ -47,7 +47,6 @@
            label13 = new Label();
            cmbTransition = new ComboBox();
            cmbSelect = new ComboBox();
            btnShowROI = new Button();
            pnlInputImage = new Panel();
            TopToolStrip = new ToolStrip();
            btnRun = new ToolStripButton();
@@ -86,6 +85,7 @@
            tabPageInputImage = new TabPage();
            tabPageRecordImage = new TabPage();
            pnlRecordImage = new Panel();
            btnShowROI = new Button();
            tablePanelParas.SuspendLayout();
            TopToolStrip.SuspendLayout();
            BtmStatusStrip.SuspendLayout();
@@ -321,17 +321,6 @@
            cmbSelect.Name = "cmbSelect";
            cmbSelect.Size = new Size(103, 25);
            cmbSelect.TabIndex = 14;
            //
            // btnShowROI
            //
            btnShowROI.Dock = DockStyle.Fill;
            btnShowROI.Location = new Point(3, 207);
            btnShowROI.Name = "btnShowROI";
            btnShowROI.Size = new Size(84, 45);
            btnShowROI.TabIndex = 15;
            btnShowROI.Text = "显示找线区域";
            btnShowROI.UseVisualStyleBackColor = true;
            btnShowROI.Click += btnShowROI_Click;
            // 
            // pnlInputImage
            // 
@@ -765,10 +754,21 @@
            pnlRecordImage.Size = new Size(607, 510);
            pnlRecordImage.TabIndex = 45;
            // 
            // btnShowROI
            //
            btnShowROI.Dock = DockStyle.Fill;
            btnShowROI.Location = new Point(3, 207);
            btnShowROI.Name = "btnShowROI";
            btnShowROI.Size = new Size(84, 45);
            btnShowROI.TabIndex = 15;
            btnShowROI.Text = "显示找线区域";
            btnShowROI.UseVisualStyleBackColor = true;
            btnShowROI.Click += btnShowROI_Click;
            //
            // HFindLineToolEdit
            // 
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(MainTableLayoutPanel);
            Controls.Add(BtmStatusStrip);
            Controls.Add(TopToolStrip);
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineToolEdit.cs
@@ -144,13 +144,7 @@
                cmbSelect.Text = Subject.Params.Inputs["边缘位置"].ToString();
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        //hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        inputImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                }
                    inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
@@ -260,13 +254,10 @@
                UpdataOutputs();
                imgTabControl.SelectedTab = tabPageRecordImage;
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                    HOperatorSet.GetImageSize((HObject)Subject.InputImage, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                }
                //先判断子类再判断父类
@@ -402,14 +393,8 @@
                    inputImageHSmartWindowControl.ClearObj();
                    if (Subject.InputImage != null && Subject.InputImage is HImage)
                    {
                        using (HImage hImage = (HImage)Subject.InputImage)
                        {
                            hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                            inputImageHSmartWindowControl.ShowHoImage(hImage);
                        }
                    }
                    if (Subject.InputImage != null && Subject.InputImage is HObject)
                        inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                    int hv_Elements = Convert.ToInt16(itxtCaliperCount.Text);
                    double hv_DetectHeight = Convert.ToDouble(dtxtCaliperHeight.Text);
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindLineTool/HFindLineToolEdit.resx
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Microsoft ResX Schema
    Version 2.0
@@ -48,7 +48,7 @@
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
@@ -117,13 +117,10 @@
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <metadata name="lblMsgToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
  <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>156, 17</value>
  </metadata>
  <metadata name="BtmStatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>287, 17</value>
    <value>129, 17</value>
  </metadata>
</root>
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelTool.cs
@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -93,27 +92,6 @@
                        Msg = "输入图片为空";
                        Result = false;
                        return;
                    }
                    if (InputImage is Bitmap)
                    {
                        try
                        {
                            using (HImage hImage = new HImage())
                            {
                                Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height);
                                BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
                                hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0);
                                ((Bitmap)InputImage).UnlockBits(srcBmpData);
                                ((Bitmap)InputImage).Dispose();
                                InputImage = hImage.Clone();
                            }
                        }
                        catch (Exception ex)
                        {
                            Msg = "转图出错:" + ex.Message;
                            Result = false;
                            return;
                        }
                    }
                    if (!(InputImage is HObject))
                    {
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelToolEdit.Designer.cs
@@ -1685,8 +1685,8 @@
            // 
            // HFindModelToolEdit
            // 
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(MainTableLayoutPanel);
            Controls.Add(BtmStatusStrip);
            Controls.Add(TopToolStrip);
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelToolEdit.cs
@@ -448,15 +448,9 @@
                    }
                }
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        inputImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                    inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                }
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
                {
@@ -569,13 +563,10 @@
                UpdataOutputs();
                imgTabControl.SelectedTab = tabPageRecordImage;
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                    HOperatorSet.GetImageSize((HObject)Subject.InputImage, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                }
                //先判断子类再判断父类
@@ -1300,18 +1291,15 @@
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            if (InputImage != null && InputImage is HImage)
            if (InputImage != null && InputImage is HObject)
            {
                imgTabControl.SelectedTab = tabPageModelImage;
                using (HImage hImage = (HImage)Subject.InputImage)
                {
                    hImage.GetImageSize(out HTuple hv_imageWidth, out HTuple hv_imageHeight);
                    createModelImageHSmartWindowControl.ShowHoImage(hImage);
                    createModelImageHSmartWindowControl.bAollowDraw = true;
                    createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2
                        , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                }
                HOperatorSet.GetImageSize((HObject)InputImage, out HTuple hv_imageWidth, out HTuple hv_imageHeight);
                createModelImageHSmartWindowControl.ShowHoImage((HObject)InputImage);
                createModelImageHSmartWindowControl.bAollowDraw = true;
                createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2
                    , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
            }
        }
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindModelTool/HFindModelToolEdit.resx
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Microsoft ResX Schema
    Version 2.0
@@ -48,7 +48,7 @@
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelTool.cs
@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -88,27 +87,6 @@
                        Msg = "输入图片为空";
                        Result = false;
                        return;
                    }
                    if (InputImage is Bitmap)
                    {
                        try
                        {
                            using (HImage hImage = new HImage())
                            {
                                Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height);
                                BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
                                hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0);
                                ((Bitmap)InputImage).UnlockBits(srcBmpData);
                                ((Bitmap)InputImage).Dispose();
                                InputImage = hImage.Clone();
                            }
                        }
                        catch (Exception ex)
                        {
                            Msg = "转图出错:"+ ex.Message;
                            Result = false;
                            return;
                        }
                    }
                    if (!(InputImage is HObject))
                    {
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelToolEdit.Designer.cs
@@ -197,7 +197,7 @@
            tabPage1.Controls.Add(splitContainer1);
            tabPage1.Location = new Point(4, 26);
            tabPage1.Name = "tabPage1";
            tabPage1.Padding = new Padding(3);
            tabPage1.Padding = new Padding(3, 3, 3, 3);
            tabPage1.Size = new Size(403, 516);
            tabPage1.TabIndex = 0;
            tabPage1.Text = "输入参数";
@@ -422,8 +422,8 @@
            tabPage2.Controls.Add(tableLayoutResults);
            tabPage2.Location = new Point(4, 26);
            tabPage2.Name = "tabPage2";
            tabPage2.Padding = new Padding(3);
            tabPage2.Size = new Size(403, 516);
            tabPage2.Padding = new Padding(3, 3, 3, 3);
            tabPage2.Size = new Size(404, 519);
            tabPage2.TabIndex = 1;
            tabPage2.Text = "输出结果";
            tabPage2.UseVisualStyleBackColor = true;
@@ -458,7 +458,7 @@
            tableLayoutResults.RowStyles.Add(new RowStyle(SizeType.Percent, 10F));
            tableLayoutResults.RowStyles.Add(new RowStyle(SizeType.Percent, 10F));
            tableLayoutResults.RowStyles.Add(new RowStyle(SizeType.Percent, 10F));
            tableLayoutResults.Size = new Size(397, 510);
            tableLayoutResults.Size = new Size(398, 513);
            tableLayoutResults.TabIndex = 1;
            // 
            // label5
@@ -510,7 +510,7 @@
            dtxtCenterX.Margin = new Padding(2, 3, 2, 3);
            dtxtCenterX.Name = "dtxtCenterX";
            dtxtCenterX.ReadOnly = true;
            dtxtCenterX.Size = new Size(293, 23);
            dtxtCenterX.Size = new Size(294, 23);
            dtxtCenterX.TabIndex = 5;
            // 
            // dtxtCenterY
@@ -520,7 +520,7 @@
            dtxtCenterY.Margin = new Padding(2, 3, 2, 3);
            dtxtCenterY.Name = "dtxtCenterY";
            dtxtCenterY.ReadOnly = true;
            dtxtCenterY.Size = new Size(293, 23);
            dtxtCenterY.Size = new Size(294, 23);
            dtxtCenterY.TabIndex = 6;
            // 
            // dtxtAngle
@@ -530,7 +530,7 @@
            dtxtAngle.Margin = new Padding(2, 3, 2, 3);
            dtxtAngle.Name = "dtxtAngle";
            dtxtAngle.ReadOnly = true;
            dtxtAngle.Size = new Size(293, 23);
            dtxtAngle.Size = new Size(294, 23);
            dtxtAngle.TabIndex = 7;
            // 
            // label8
@@ -550,7 +550,7 @@
            dtxtScore.Location = new Point(103, 156);
            dtxtScore.Name = "dtxtScore";
            dtxtScore.ReadOnly = true;
            dtxtScore.Size = new Size(291, 23);
            dtxtScore.Size = new Size(292, 23);
            dtxtScore.TabIndex = 9;
            // 
            // dtxtCount
@@ -588,7 +588,7 @@
            tabPageInputImage.Controls.Add(pnlInputImage);
            tabPageInputImage.Location = new Point(4, 26);
            tabPageInputImage.Name = "tabPageInputImage";
            tabPageInputImage.Padding = new Padding(3);
            tabPageInputImage.Padding = new Padding(3, 3, 3, 3);
            tabPageInputImage.Size = new Size(613, 516);
            tabPageInputImage.TabIndex = 0;
            tabPageInputImage.Text = "输入图像";
@@ -598,7 +598,7 @@
            // 
            pnlInputImage.Dock = DockStyle.Fill;
            pnlInputImage.Location = new Point(3, 3);
            pnlInputImage.Margin = new Padding(4);
            pnlInputImage.Margin = new Padding(4, 4, 4, 4);
            pnlInputImage.Name = "pnlInputImage";
            pnlInputImage.Size = new Size(607, 510);
            pnlInputImage.TabIndex = 44;
@@ -608,8 +608,8 @@
            tabPageRecordImage.Controls.Add(pnlRecordImage);
            tabPageRecordImage.Location = new Point(4, 26);
            tabPageRecordImage.Name = "tabPageRecordImage";
            tabPageRecordImage.Padding = new Padding(3);
            tabPageRecordImage.Size = new Size(613, 516);
            tabPageRecordImage.Padding = new Padding(3, 3, 3, 3);
            tabPageRecordImage.Size = new Size(613, 519);
            tabPageRecordImage.TabIndex = 1;
            tabPageRecordImage.Text = "结果图像";
            tabPageRecordImage.UseVisualStyleBackColor = true;
@@ -618,15 +618,15 @@
            // 
            pnlRecordImage.Dock = DockStyle.Fill;
            pnlRecordImage.Location = new Point(3, 3);
            pnlRecordImage.Margin = new Padding(4);
            pnlRecordImage.Margin = new Padding(4, 4, 4, 4);
            pnlRecordImage.Name = "pnlRecordImage";
            pnlRecordImage.Size = new Size(607, 510);
            pnlRecordImage.Size = new Size(607, 513);
            pnlRecordImage.TabIndex = 45;
            // 
            // HFindMultiModelToolEdit
            // 
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(MainTableLayoutPanel);
            Controls.Add(BtmStatusStrip);
            Controls.Add(TopToolStrip);
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelToolEdit.cs
@@ -137,14 +137,9 @@
                dtxtMinCount.Text = Subject.Params.Inputs["MinCount"].ToString();
                dtxtMaxCount.Text = Subject.Params.Inputs["MaxCount"].ToString();
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        inputImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                }
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                    inputImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
                {
@@ -254,13 +249,10 @@
                UpdataOutputs();
                imgTabControl.SelectedTab = tabPageRecordImage;
                if (Subject.InputImage != null && Subject.InputImage is HImage)
                if (Subject.InputImage != null && Subject.InputImage is HObject)
                {
                    using (HImage hImage = (HImage)Subject.InputImage)
                    {
                        hImage.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(hImage);
                    }
                    HOperatorSet.GetImageSize((HObject)Subject.InputImage, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage((HObject)Subject.InputImage);
                }
                //先判断子类再判断父类
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HFindMultiModelToolEdit.resx
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Microsoft ResX Schema
    Version 2.0
@@ -48,7 +48,7 @@
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
LB_VisionProcesses/Alogrithms/Halcon/2D/HFindMultiModelTool/HMulitModelControl.Designer.cs
@@ -167,8 +167,8 @@
            // 
            // HMulitModelControl
            // 
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(tableLayoutPanel1);
            Name = "HMulitModelControl";
            Size = new Size(399, 157);
LB_VisionProcesses/Alogrithms/OpenCvSharp/BlobTool/BlobToolEdit.cs
@@ -120,11 +120,10 @@
                if (Subject.InputImage != null && Subject.InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage))
                    {
                        inputImageHSmartWindowControl.ShowHoImage(image);
                    }
                    TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image);
                    inputImageHSmartWindowControl.ShowHoImage(image);
                }
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
                {
@@ -216,11 +215,9 @@
                if (Subject.InputImage != null && Subject.InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage))
                    {
                        HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(image);
                    }
                    TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image);
                    HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage(image);
                }
                //先判断子类再判断父类
@@ -228,11 +225,10 @@
                {
                    recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true);
                    recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false);
                    for (int i = 0; i < msgRecord.Msg.Length; i++)
                    {
                        recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i]
                            , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]);
                    }
                }
                else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord)
                {
@@ -306,34 +302,32 @@
                    HTuple hv_imageHeight = 0;
                    if (InputImage != null && InputImage is Mat)
                    {
                        using (HImage image = TAlgorithm.Mat2HImage((Mat)InputImage))
                        {
                            image.GetImageSize(out hv_imageWidth, out hv_imageHeight);
                            switch (type)
                            {
                                case RoiType.Rectangle2:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0
                                        , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                                    break;
                                case RoiType.Circle:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4);
                                    break;
                                //case RoiType.Ellipse:
                                //    inputImageHSmartWindowControl.oRoi
                                //        = new HEllipse(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2,0, hv_imageHeight.TupleReal() / 4, hv_imageWidth.TupleReal() / 4);
                                //    break;
                                //case RoiType.Segment:
                                //    inputImageHSmartWindowControl.oRoi
                                //        = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                                //    break;
                                case RoiType.None:
                                default:
                                    inputImageHSmartWindowControl.oRoi = null;
                                    break;
                            }
                        }
                        TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image);
                        HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight);
                    }
                    switch (type)
                    {
                        case RoiType.Rectangle2:
                            inputImageHSmartWindowControl.oRoi
                                = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0
                                , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                            break;
                        case RoiType.Circle:
                            inputImageHSmartWindowControl.oRoi
                                = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4);
                            break;
                        //case RoiType.Ellipse:
                        //    inputImageHSmartWindowControl.oRoi
                        //        = new HEllipse(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2,0, hv_imageHeight.TupleReal() / 4, hv_imageWidth.TupleReal() / 4);
                        //    break;
                        //case RoiType.Segment:
                        //    inputImageHSmartWindowControl.oRoi
                        //        = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                        //    break;
                        case RoiType.None:
                        default:
                            inputImageHSmartWindowControl.oRoi = null;
                            break;
                    }
                }
            }
LB_VisionProcesses/Alogrithms/OpenCvSharp/FindLineTool/FindLineToolEdit.cs
@@ -144,62 +144,61 @@
                if (Subject.InputImage != null && Subject.InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage))
                    TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image);
                    inputImageHSmartWindowControl.ShowHoImage(image);
                }
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
                {
                    switch (type)
                    {
                        inputImageHSmartWindowControl.ShowHoImage(image);
                        Type type = Subject.Params.ROI?.GetType();
                        if (Subject.Params.ROI != null)
                        {
                            switch (type)
                            {
                                case Type t when t == typeof(HRectangle2):
                                    cmbTypeRoi.Text = RoiType.Rectangle2.ToString();
                                    break;
                                case Type t when t == typeof(HCircle):
                                    cmbTypeRoi.Text = RoiType.Circle.ToString();
                                    break;
                                case Type t when t == typeof(HSegment):
                                    cmbTypeRoi.Text = RoiType.Segment.ToString();
                                    break;
                                default:
                                    cmbTypeRoi.Text = RoiType.None.ToString();
                                    break;
                            }
                            if (cmbTypeRoi.Text.ToString() != "None")
                                ckbDrawRoi.Checked = true;
                            else
                                ckbDrawRoi.Checked = false;
                            inputImageHSmartWindowControl.oRoi = Subject.Params.ROI;
                        }
                        if (Subject.Params.Fixture != null)
                            cmbFixture.Text = Subject.Params.Fixture.strName;
                        else
                            cmbFixture.Text = "";
                        switch (type)
                        {
                            case Type t when t == typeof(HRectangle2):
                                inputImageHSmartWindowControl.oRoi
                                     = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                                     , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height);
                                break;
                            case Type t when t == typeof(HCircle):
                                inputImageHSmartWindowControl.oRoi
                                = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                                , ((HCircle)Subject.Params.ROI).Radius);
                                break;
                            case Type t when t == typeof(HSegment):
                                inputImageHSmartWindowControl.oRoi
                                = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y
                                , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y);
                                break;
                            default:
                                inputImageHSmartWindowControl.oRoi = null;
                                break;
                        }
                        case Type t when t == typeof(HRectangle2):
                            cmbTypeRoi.Text = RoiType.Rectangle2.ToString();
                            break;
                        case Type t when t == typeof(HCircle):
                            cmbTypeRoi.Text = RoiType.Circle.ToString();
                            break;
                        case Type t when t == typeof(HSegment):
                            cmbTypeRoi.Text = RoiType.Segment.ToString();
                            break;
                        default:
                            cmbTypeRoi.Text = RoiType.None.ToString();
                            break;
                    }
                    if (cmbTypeRoi.Text.ToString() != "None")
                        ckbDrawRoi.Checked = true;
                    else
                        ckbDrawRoi.Checked = false;
                    inputImageHSmartWindowControl.oRoi = Subject.Params.ROI;
                }
                if (Subject.Params.Fixture != null)
                    cmbFixture.Text = Subject.Params.Fixture.strName;
                else
                    cmbFixture.Text = "";
                switch (type)
                {
                    case Type t when t == typeof(HRectangle2):
                        inputImageHSmartWindowControl.oRoi
                             = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                             , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height);
                        break;
                    case Type t when t == typeof(HCircle):
                        inputImageHSmartWindowControl.oRoi
                        = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                        , ((HCircle)Subject.Params.ROI).Radius);
                        break;
                    case Type t when t == typeof(HSegment):
                        inputImageHSmartWindowControl.oRoi
                        = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y
                        , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y);
                        break;
                    default:
                        inputImageHSmartWindowControl.oRoi = null;
                        break;
                }
            }));
        }
@@ -259,27 +258,27 @@
                if (Subject.InputImage != null && Subject.InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage))
                    {
                        image.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(image);
                        //先判断子类再判断父类
                        if (Subject.Record != null && Subject.Record is MsgRecord msgRecord)
                        {
                            recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true);
                            recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false);
                            for (int i = 0; i < msgRecord.Msg.Length; i++)
                                recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i]
                                    , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]);
                        }
                        else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord)
                        {
                            recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true);
                            recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false);
                        }
                    }
                    TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image);
                    HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage(image);
                }
                //先判断子类再判断父类
                if (Subject.Record != null && Subject.Record is MsgRecord msgRecord)
                {
                    recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true);
                    recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false);
                    for (int i = 0; i < msgRecord.Msg.Length; i++)
                        recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i]
                            , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]);
                }
                else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord)
                {
                    recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true);
                    recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false);
                }
                GC.Collect();
            }));
        }
@@ -346,30 +345,28 @@
                    HTuple hv_imageHeight = 0;
                    if (InputImage != null && InputImage is Mat)
                    {
                        using (HImage image=TAlgorithm.Mat2HImage((Mat)InputImage))
                        {
                            image.GetImageSize(out hv_imageWidth, out hv_imageHeight);
                            switch (type)
                            {
                                case RoiType.Rectangle2:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0
                                        , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                                    break;
                                case RoiType.Circle:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4);
                                    break;
                                case RoiType.Segment:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                                    break;
                                case RoiType.None:
                                default:
                                    inputImageHSmartWindowControl.oRoi = null;
                                    break;
                            }
                        }
                        TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image);
                        HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight);
                    }
                    switch (type)
                    {
                        case RoiType.Rectangle2:
                            inputImageHSmartWindowControl.oRoi
                                = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0
                                , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                            break;
                        case RoiType.Circle:
                            inputImageHSmartWindowControl.oRoi
                                = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4);
                            break;
                        case RoiType.Segment:
                            inputImageHSmartWindowControl.oRoi
                                = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                            break;
                        case RoiType.None:
                        default:
                            inputImageHSmartWindowControl.oRoi = null;
                            break;
                    }
                }
            }
@@ -400,26 +397,25 @@
                    if (InputImage != null && InputImage is Mat)
                    {
                        using (HImage image = TAlgorithm.Mat2HImage((Mat)InputImage))
                        {
                            inputImageHSmartWindowControl.ShowHoImage(image);
                            int hv_Elements = Convert.ToInt16(itxtCaliperCount.Text);
                            double hv_DetectHeight = Convert.ToDouble(dtxtCaliperHeight.Text);
                            double hv_DetectWidth = Convert.ToDouble(dtxtCaliperWidth.Text);
                            double hv_Row1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginRow + Subject.Params.Fixture.Row);
                            double hv_Column1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginColumn + Subject.Params.Fixture.Column);
                            double hv_Row2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndRow + Subject.Params.Fixture.Row);
                            double hv_Column2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndColumn + Subject.Params.Fixture.Column);
                            TAlgorithm.GetRakeRegions(null, out HObject ho_Regions, hv_Elements, hv_DetectHeight, hv_DetectWidth
                                , new HTuple(), new HTuple(), new HTuple(), new HTuple()
                                , hv_Row1, hv_Column1, hv_Row2, hv_Column2
                                , out HTuple hv_ResultRow, out HTuple hv_ResultColumn);
                            inputImageHSmartWindowControl.DispObj(ho_Regions);
                        }
                        TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image);
                        inputImageHSmartWindowControl.ShowHoImage(image);
                    }
                    int hv_Elements = Convert.ToInt16(itxtCaliperCount.Text);
                    double hv_DetectHeight = Convert.ToDouble(dtxtCaliperHeight.Text);
                    double hv_DetectWidth = Convert.ToDouble(dtxtCaliperWidth.Text);
                    double hv_Row1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginRow + Subject.Params.Fixture.Row);
                    double hv_Column1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginColumn + Subject.Params.Fixture.Column);
                    double hv_Row2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndRow + Subject.Params.Fixture.Row);
                    double hv_Column2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndColumn + Subject.Params.Fixture.Column);
                    TAlgorithm.GetRakeRegions(null, out HObject ho_Regions, hv_Elements, hv_DetectHeight, hv_DetectWidth
                        , new HTuple(), new HTuple(), new HTuple(), new HTuple()
                        , hv_Row1, hv_Column1, hv_Row2, hv_Column2
                        , out HTuple hv_ResultRow, out HTuple hv_ResultColumn);
                    inputImageHSmartWindowControl.DispObj(ho_Regions);
                }
                catch { }
            }));
LB_VisionProcesses/Alogrithms/OpenCvSharp/FindModelTool/FindModelToolEdit.cs
@@ -241,66 +241,64 @@
                if (Subject.InputImage != null && Subject.InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage))
                    {
                        inputImageHSmartWindowControl.ShowHoImage(image);
                        Type type = Subject.Params.ROI?.GetType();
                        if (Subject.Params.ROI != null)
                        {
                            switch (type)
                            {
                                case Type t when t == typeof(HRectangle2):
                                    cmbTypeRoi.Text = RoiType.Rectangle2.ToString();
                                    break;
                                case Type t when t == typeof(HCircle):
                                    cmbTypeRoi.Text = RoiType.Circle.ToString();
                                    break;
                                case Type t when t == typeof(HSegment):
                                    cmbTypeRoi.Text = RoiType.Segment.ToString();
                                    break;
                                default:
                                    cmbTypeRoi.Text = RoiType.None.ToString();
                                    break;
                            }
                            if (cmbTypeRoi.Text.ToString() != "None")
                                ckbDrawRoi.Checked = true;
                            else
                                ckbDrawRoi.Checked = false;
                            inputImageHSmartWindowControl.oRoi = Subject.Params.ROI;
                        }
                        if (Subject.Params.Fixture != null)
                            cmbFixture.Text = Subject.Params.Fixture.strName;
                        else
                            cmbFixture.Text = "";
                        switch (type)
                        {
                            case Type t when t == typeof(HRectangle2):
                                inputImageHSmartWindowControl.oRoi
                                     = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                                     , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height);
                                break;
                            case Type t when t == typeof(HCircle):
                                inputImageHSmartWindowControl.oRoi
                                = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                                , ((HCircle)Subject.Params.ROI).Radius);
                                break;
                            case Type t when t == typeof(HSegment):
                                inputImageHSmartWindowControl.oRoi
                                = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y
                                , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y);
                                break;
                            default:
                                inputImageHSmartWindowControl.oRoi = null;
                                break;
                        }
                        ShowModel(((FindModelTool)Subject).ModelID);
                    }
                    TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image);
                    inputImageHSmartWindowControl.ShowHoImage(image);
                }
                Type type = Subject.Params.ROI?.GetType();
                if (Subject.Params.ROI != null)
                {
                    switch (type)
                    {
                        case Type t when t == typeof(HRectangle2):
                            cmbTypeRoi.Text = RoiType.Rectangle2.ToString();
                            break;
                        case Type t when t == typeof(HCircle):
                            cmbTypeRoi.Text = RoiType.Circle.ToString();
                            break;
                        case Type t when t == typeof(HSegment):
                            cmbTypeRoi.Text = RoiType.Segment.ToString();
                            break;
                        default:
                            cmbTypeRoi.Text = RoiType.None.ToString();
                            break;
                    }
                    if (cmbTypeRoi.Text.ToString() != "None")
                        ckbDrawRoi.Checked = true;
                    else
                        ckbDrawRoi.Checked = false;
                    inputImageHSmartWindowControl.oRoi = Subject.Params.ROI;
                }
                if (Subject.Params.Fixture != null)
                    cmbFixture.Text = Subject.Params.Fixture.strName;
                else
                    cmbFixture.Text = "";
                switch (type)
                {
                    case Type t when t == typeof(HRectangle2):
                        inputImageHSmartWindowControl.oRoi
                             = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                             , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height);
                        break;
                    case Type t when t == typeof(HCircle):
                        inputImageHSmartWindowControl.oRoi
                        = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y
                        , ((HCircle)Subject.Params.ROI).Radius);
                        break;
                    case Type t when t == typeof(HSegment):
                        inputImageHSmartWindowControl.oRoi
                        = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y
                        , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y);
                        break;
                    default:
                        inputImageHSmartWindowControl.oRoi = null;
                        break;
                }
                ShowModel(((FindModelTool)Subject).ModelID);
            }));
        }
@@ -359,27 +357,25 @@
                if (Subject.InputImage != null && Subject.InputImage is Mat)
                {
                    using (HImage image = TAlgorithm.Mat2HImage((Mat)Subject.InputImage))
                    {
                        image.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                        recordImageHSmartWindowControl.ShowHoImage(image);
                        //先判断子类再判断父类
                        if (Subject.Record != null && Subject.Record is MsgRecord msgRecord)
                        {
                            recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true);
                            recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false);
                    TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image);
                    HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight);
                    recordImageHSmartWindowControl.ShowHoImage(image);
                }
                            for (int i = 0; i < msgRecord.Msg.Length; i++)
                                recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i]
                                    , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]);
                        }
                        else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord)
                        {
                            recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true);
                            recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false);
                        }
                //先判断子类再判断父类
                if (Subject.Record != null && Subject.Record is MsgRecord msgRecord)
                {
                    recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true);
                    recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false);
                    }
                    for (int i = 0; i < msgRecord.Msg.Length; i++)
                        recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i]
                            , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]);
                }
                else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord)
                {
                    recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true);
                    recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false);
                }
                GC.Collect();
@@ -502,30 +498,28 @@
                    HTuple hv_imageHeight = 0;
                    if (InputImage != null && InputImage is Mat)
                    {
                        using (HImage image = TAlgorithm.Mat2HImage((Mat)InputImage))
                        {
                            HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight);
                            switch (type)
                            {
                                case RoiType.Rectangle2:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0
                                        , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                                    break;
                                case RoiType.Circle:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4);
                                    break;
                                case RoiType.Segment:
                                    inputImageHSmartWindowControl.oRoi
                                        = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                                    break;
                                case RoiType.None:
                                default:
                                    inputImageHSmartWindowControl.oRoi = null;
                                    break;
                            }
                        }
                        TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image);
                        HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight);
                    }
                    switch (type)
                    {
                        case RoiType.Rectangle2:
                            inputImageHSmartWindowControl.oRoi
                                = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0
                                , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                            break;
                        case RoiType.Circle:
                            inputImageHSmartWindowControl.oRoi
                                = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4);
                            break;
                        case RoiType.Segment:
                            inputImageHSmartWindowControl.oRoi
                                = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                            break;
                        case RoiType.None:
                        default:
                            inputImageHSmartWindowControl.oRoi = null;
                            break;
                    }
                }
            }
@@ -1102,14 +1096,13 @@
            if (InputImage != null && InputImage is Mat)
            {
                imgTabControl.SelectedTab = tabPageModelImage;
                using (HImage hoDomainImage = TAlgorithm.Mat2HImage((Mat)InputImage))
                {
                    HOperatorSet.GetImageSize(hoDomainImage, out HTuple hv_imageWidth, out HTuple hv_imageHeight);
                    createModelImageHSmartWindowControl.ShowHoImage(hoDomainImage);
                    createModelImageHSmartWindowControl.bAollowDraw = true;
                    createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2
                        , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
                }
                TAlgorithm.Mat2HObject((Mat)InputImage, out HObject hoDomainImage);
                HOperatorSet.GetImageSize(hoDomainImage, out HTuple hv_imageWidth, out HTuple hv_imageHeight);
                createModelImageHSmartWindowControl.ShowHoImage((HObject)hoDomainImage);
                createModelImageHSmartWindowControl.bAollowDraw = true;
                createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2
                    , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4);
            }
        }
@@ -1120,6 +1113,7 @@
                if (InputImage != null && InputImage is Mat)
                {
                    double result = 0;
                    if (Enum.TryParse(cmbModelType.Text, out ModelType modelType))
                    {
                        string NumLevels = this.dtxtModelParam1.Text;
@@ -1137,83 +1131,75 @@
                        string Contrast = this.dtxtModelParam11.Text;
                        int MinContrast = Convert.ToInt16(this.dtxtModelParam12.Text);
                        HRectangle2 ROI = (HRectangle2)createModelImageHSmartWindowControl.oRoi;
                        using (HRegion hRectangle = new HRegion())
                        HOperatorSet.GenRectangle2(out HObject hRectangle, ROI.Row, ROI.Column, ROI.Phi, ROI.SemiLength1, ROI.SemiLength2);
                        TAlgorithm.Mat2HObject((Mat)InputImage, out HObject hoDomainImage);
                        HTuple hv_Channels = new HTuple();
                        //判断是否为灰度图
                        using (HDevDisposeHelper dh = new HDevDisposeHelper())
                        {
                            hRectangle.GenRectangle2(ROI.Row, ROI.Column, ROI.Phi, ROI.SemiLength1, ROI.SemiLength2);
                            using (HImage hoDomainImage = TAlgorithm.Mat2HImage((Mat)InputImage))
                            try
                            {
                                HTuple hv_Channels = new HTuple();
                                //判断是否为灰度图
                                using (HDevDisposeHelper dh = new HDevDisposeHelper())
                                {
                                    try
                                    {
                                        //hv_Channels = hoDomainImage.CountChannels();
                                        //if (hv_Channels.TupleInt() != 1)
                                        //    HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage);
                                HOperatorSet.CountChannels(hoDomainImage, out hv_Channels);
                                if (hv_Channels.TupleInt() != 1)
                                    HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage);
                                        ////转换后再次检查是否为灰度图
                                        //HOperatorSet.CountChannels(hoDomainImage, out hv_Channels);
                                        //if (hv_Channels.TupleInt() != 1)
                                        //    HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage);
                                    }
                                    catch { }
                                }
                                HObject hoImageReduced = hoDomainImage.Rgb1ToGray().ReduceDomain(hRectangle);
                                HOperatorSet.CropDomain(hoImageReduced, out hoImageReduced);
                                TAlgorithm.HObject2Mat(hoImageReduced, out Mat hoModelImage);
                                bool bCreateModel = false;
                                switch (modelType)
                                {
                                    case ModelType.灰度匹配:
                                        bCreateModel = ((FindModelTool)Subject).CreateModel
                                            (hoModelImage, modelType, NumLevels
                                            , AngleStart, AngleExtent, AngleStep
                                            , ScaleRMin, ScaleRMax, "auto"
                                            , ScaleCMin, ScaleCMax, "auto"
                                            , Optimization, Metric, Contrast, MinContrast);
                                        break;
                                    default:
                                        bCreateModel = ((FindModelTool)Subject).CreateModel
                                            (hoModelImage, modelType, NumLevels
                                            , AngleStart, AngleExtent, AngleStep
                                            , ScaleRMin, ScaleRMax, "auto"
                                            , ScaleCMin, ScaleCMax, "auto"
                                            , Optimization, Metric, Contrast, MinContrast);
                                        break;
                                }
                                if (bCreateModel)
                                {
                                    using (HObject ho_ModelContours = new HObject())
                                    {
                                        //switch (((FindModelTool)Subject).ModelID.Type)
                                        //{
                                        //    case ModelType.局部变形模板:
                                        //        HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1);
                                        //        break;
                                        //    case ModelType.各向异形模板:
                                        //    default:
                                        //        HOperatorSet.GetShapeModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1);
                                        //        break;
                                        //}
                                        //HOperatorSet.GetImageSize(((HFindModelTool)Subject).ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height);
                                        //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D);
                                        //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D);
                                        //建模成功导航到子页
                                        parasTabControl.SelectedTab = tabPageRunParas;
                                        //modelImageHSmartWindowControl.ShowHoImage(((HFindModelTool)Subject).ModelID.hoImage);
                                        using (HImage modelImage = TAlgorithm.Mat2HImage(((FindModelTool)Subject).ModelID.hoImage))
                                        {
                                            modelImageHSmartWindowControl.ShowHoImage(modelImage);
                                            modelImageHSmartWindowControl.DispObj(ho_ModelContours, false);
                                            modelImageHSmartWindowControl.ShowMsg("创建模板成功", true);
                                        }
                                    }
                                }
                                //转换后再次检查是否为灰度图
                                HOperatorSet.CountChannels(hoDomainImage, out hv_Channels);
                                if (hv_Channels.TupleInt() != 1)
                                    HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage);
                            }
                            catch { }
                        }
                        HOperatorSet.ReduceDomain(hoDomainImage, hRectangle, out HObject hoImageReduced);
                        HOperatorSet.CropDomain(hoImageReduced, out hoImageReduced);
                        TAlgorithm.HObject2Mat(hoImageReduced, out Mat hoModelImage);
                        bool bCreateModel = false;
                        switch (modelType)
                        {
                            case ModelType.灰度匹配:
                                bCreateModel = ((FindModelTool)Subject).CreateModel
                                    (hoModelImage, modelType, NumLevels
                                    , AngleStart, AngleExtent, AngleStep
                                    , ScaleRMin, ScaleRMax, "auto"
                                    , ScaleCMin, ScaleCMax, "auto"
                                    , Optimization, Metric, Contrast, MinContrast);
                                break;
                            default:
                                bCreateModel = ((FindModelTool)Subject).CreateModel
                                    (hoModelImage, modelType, NumLevels
                                    , AngleStart, AngleExtent, AngleStep
                                    , ScaleRMin, ScaleRMax, "auto"
                                    , ScaleCMin, ScaleCMax, "auto"
                                    , Optimization, Metric, Contrast, MinContrast);
                                break;
                        }
                        if (bCreateModel)
                        {
                            HObject ho_ModelContours = new HObject();
                            //switch (((FindModelTool)Subject).ModelID.Type)
                            //{
                            //    case ModelType.局部变形模板:
                            //        HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1);
                            //        break;
                            //    case ModelType.各向异形模板:
                            //    default:
                            //        HOperatorSet.GetShapeModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1);
                            //        break;
                            //}
                            //HOperatorSet.GetImageSize(((HFindModelTool)Subject).ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height);
                            //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D);
                            //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D);
                            //建模成功导航到子页
                            parasTabControl.SelectedTab = tabPageRunParas;
                            //modelImageHSmartWindowControl.ShowHoImage(((HFindModelTool)Subject).ModelID.hoImage);
                            TAlgorithm.Mat2HObject(((FindModelTool)Subject).ModelID.hoImage, out HObject modelImage);
                            modelImageHSmartWindowControl.ShowHoImage(modelImage);
                            modelImageHSmartWindowControl.DispObj(ho_ModelContours, false);
                            modelImageHSmartWindowControl.ShowMsg("创建模板成功", true);
                        }
                    }
                }
@@ -1229,32 +1215,27 @@
                if (ModelID != null && ModelID.Width > 0)
                {
                    //HOperatorSet.GenEmptyObj(out HObject ho_ModelContours);
                    using (HRegion ho_ModelContours = new HRegion())
                    {
                        //switch (ModelID.Type)
                        //{
                        //    case ModelType.各向异形模板:
                        //        HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ModelID.hvModel, 1);
                        //        break;
                        //    default:
                        //        HOperatorSet.GetShapeModelContours(out ho_ModelContours, ModelID.hvModel, 1);
                        //        break;
                        //}
                    HOperatorSet.GenEmptyObj(out HObject ho_ModelContours);
                    //switch (ModelID.Type)
                    //{
                    //    case ModelType.各向异形模板:
                    //        HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ModelID.hvModel, 1);
                    //        break;
                    //    default:
                    //        HOperatorSet.GetShapeModelContours(out ho_ModelContours, ModelID.hvModel, 1);
                    //        break;
                    //}
                        //HOperatorSet.GetImageSize(ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height);
                        //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D);
                        //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D);
                    //HOperatorSet.GetImageSize(ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height);
                    //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D);
                    //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D);
                        modelImageHSmartWindowControl.ClearObj();
                        using (HImage hoImage = TAlgorithm.Mat2HImage(ModelID.hoImage))
                        {
                            //modelImageHSmartWindowControl.ShowHoImage(ModelID.hoImage);
                            modelImageHSmartWindowControl.ShowHoImage(hoImage);
                            modelImageHSmartWindowControl.DispObj(ho_ModelContours, false);
                            modelImageHSmartWindowControl.ShowMsg("创建模板成功", true);
                        }
                    }
                    modelImageHSmartWindowControl.ClearObj();
                    TAlgorithm.Mat2HObject(ModelID.hoImage, out HObject hoImage);
                    //modelImageHSmartWindowControl.ShowHoImage(ModelID.hoImage);
                    modelImageHSmartWindowControl.ShowHoImage(hoImage);
                    modelImageHSmartWindowControl.DispObj(ho_ModelContours, false);
                    modelImageHSmartWindowControl.ShowMsg("创建模板成功", true);
                }
            }
            catch { }
LB_VisionProcesses/IProcess.cs
@@ -155,12 +155,12 @@
        /// <summary>
        /// 输入图片
        /// </summary>
        public object InputImage;
        public object InputImage = null;
        /// <summary>
        /// 输出图片
        /// </summary>
        public object OutputImage;
        public object OutputImage = null;
        /// <summary>
        /// 结果区域
LB_VisionProcesses/Processes/BaseProcess.cs
@@ -21,8 +21,8 @@
            DateTime StartTime = DateTime.Now;
            InitRunParams();
            HOperatorSet.GenEmptyObj(out HObject EmptyObj);
            OutputImage = EmptyObj;
            //HOperatorSet.GenEmptyObj(out HObject EmptyObj);
            //OutputImage = EmptyObj;
            #region 运行逻辑