判断隔离纸到钢壳边缘的距离,燕尾是否超标

方法如下:
在这里插入图片描述
方法1:通过找圆工具上的点求解隔离纸边缘点-钢壳边缘点的距离。

#region namespace imports
using System;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Cognex.VisionPro;
using Cognex.VisionPro.ToolBlock;
using Cognex.VisionPro3D;
using Cognex.VisionPro.PMAlign;
using Cognex.VisionPro.CalibFix;
using Cognex.VisionPro.Blob;
using Cognex.VisionPro.Caliper;
using Cognex.VisionPro.Dimensioning;
using System.Linq;
using System.Threading;
#endregion

public class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{
  #region Private Member Variables
  private Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;
  #endregion

  /// <summary>
  /// Called when the parent tool is run.
  /// Add code here to customize or replace the normal run behavior.
  /// </summary>
  /// <param name="message">Sets the Message in the tool's RunStatus.</param>
  /// <param name="result">Sets the Result in the tool's RunStatus</param>
  /// <returns>True if the tool should run normally,
  ///          False if GroupRun customizes run behavior</returns>
  ///
  #region

  CogGraphicCollection gc;
  CogGraphicCollection gc1;
  CogGraphicLabel label1;
  CogGraphicLabel label2;
  CogGraphicLabel label3;
  CogGraphicLabel label4;
  CogGraphicLabel label5;
  CogGraphicLabel label6;
  CogRectangleAffine rect;


  //  int s = 0;

  //计算圆心度所需变量
  double Min_Distance = 0.0;
  double Max_Distance = 0.0;
  //double Minus_Value = 0;
  //double Point_CenterD = 0;

  //double InputRMSCircle = 0;

  //  int s = 0;

  #endregion

  public override bool GroupRun(ref string message, ref CogToolResultConstants result)
  {
    // To let the execution stop in this script when a debugger is attached, uncomment the following lines.
    //#if DEBUG
    //if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break();
    //#endif

    #region 显示运行

    mToolBlock.Outputs["Result"].Value = 1;
    //mToolBlock.Outputs["Area"].Value = 0;
    mToolBlock.Outputs["bStatus"].Value = false;
    //mToolBlock.Outputs["DistanceMax"].Value = 0;
    //mToolBlock.Outputs["DistanceMin"].Value = 0;
    mToolBlock.Outputs["GraphicCollection"].Value = null;
    mToolBlock.Outputs["GraphicCollection1"].Value = null;

    //数组下标对应0 1 2 3 4:产品定位NG或OK 两圆距离计算OK或NG  卡尺燕尾判断OK或NG
    int[] AllResult = new int[4];

    bool DecideResult = false;

    CogFindCircleTool Pat1 = (CogFindCircleTool) mToolBlock.Tools["外圆定位"];

    CogFixtureTool Fix = (CogFixtureTool) mToolBlock.Tools["矫正坐标系"];

    CogFindCircleTool FindCircle = (CogFindCircleTool) mToolBlock.Tools["外圆"];

    CogFindCircleTool FindCircle1 = (CogFindCircleTool) mToolBlock.Tools["隔离管外圆"];

    CogDistancePointPointTool PointP_Distance = (CogDistancePointPointTool) mToolBlock.Tools["两圆距离"];

    CogCaliperTool YanWeiCaliper = (CogCaliperTool) mToolBlock.Tools["卡尺燕尾"];

    if (gc == null) gc = new CogGraphicCollection(); gc.Clear();
    if (gc1 == null) gc1 = new CogGraphicCollection(); gc1.Clear();
    if (label1 == null) label1 = new CogGraphicLabel();
    if (label2 == null) label2 = new CogGraphicLabel();
    if (label3 == null) label3 = new CogGraphicLabel();
    if (label4 == null) label4 = new CogGraphicLabel();
    if (label5 == null) label5 = new CogGraphicLabel();
    if (label6 == null) label6 = new CogGraphicLabel();

    if (rect == null) rect = new CogRectangleAffine();

    label1.Font = new Font("宋体", 16);
    label1.SelectedSpaceName = "#";
    label1.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label2.Font = new Font("宋体", 16);
    label2.SelectedSpaceName = "#";
    label2.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label3.Font = new Font("宋体", 16);
    label3.SelectedSpaceName = "#";
    label3.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label4.Font = new Font("宋体", 16);
    label4.SelectedSpaceName = "#";
    label4.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label5.Font = new Font("宋体", 16);
    label5.SelectedSpaceName = "#";
    label5.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label6.Font = new Font("宋体", 16);
    label6.SelectedSpaceName = "#";
    label6.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;

    Pat1.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    Pat1.Run();

    if (Pat1.Results != null && Pat1.Results.Count > 0)
    {
      label1.SetXYText(100, 50, "产品定位OK");
      label1.Color = CogColorConstants.Green;
      gc.Add(label1);
      AllResult[0] = 0;
      //mToolBlock.Outputs["Result"].Value = 0;

      Cognex.VisionPro.CogTransform2DLinear liner = new Cognex.VisionPro.CogTransform2DLinear();
      liner.TranslationX = Pat1.Results.GetCircle().CenterX;
      liner.TranslationY = Pat1.Results.GetCircle().CenterY;
      Fix.InputImage = (ICogImage) mToolBlock.Inputs["InputImage"].Value;
      Fix.RunParams.UnfixturedFromFixturedTransform = liner;
      Fix.Run();
    }
    else
    {
      label1.SetXYText(100, 50, "产品定位NG");
      label1.Color = CogColorConstants.Red;
      gc.Add(label1);
      AllResult[0] = 1;
      //mToolBlock.Outputs["Result"].Value = 1;
    }

    #endregion

    #region 计算圆与卡尺工具的距离
    FindCircle.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    FindCircle.Run();

    FindCircle1.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    FindCircle1.Run();

    PointP_Distance.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;

    YanWeiCaliper.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    YanWeiCaliper.Run();

    double x1 = FindCircle.Results.GetCircle().CenterX;
    double y1 = FindCircle.Results.GetCircle().CenterY;
    double r = 0.0;

    double rotationAngleDegrees = 3.0;

    double[] SaveDistance = new double[FindCircle.Results.Count];

    if (FindCircle.Results.Count > 0 )//圆的卡尺工具数量相同且与卡尺工具循环次数需要相同
    {
      try
      {
        for (int i = 0; i < FindCircle.Results.Count; i++)
        {
          gc.Add(FindCircle.Results[i].CreateResultGraphics(CogFindCircleResultGraphicConstants.DataPoint));
          if (FindCircle.Results[i].Used)//没有找到的点过滤点,不是过滤的红色点
          {
            double rotationAngleRadians = CogMisc.DegToRad(rotationAngleDegrees * i);

            //仿射矩形 五个参数 第一个:起始点X 第二个参数 起始点Y 第三个参数 矩形宽 第四个参数 矩形高 第五个参数旋转角度
            rect.SetOriginLengthsRotationSkew(x1, y1, 400, 10, r + rotationAngleRadians, 0);

            YanWeiCaliper.Region = rect;

            gc.Add(YanWeiCaliper.Results[0].CreateResultGraphics(CogCaliperResultGraphicConstants.Edges));

            //SaveWidth[i] = YanWeiCaliper.Results[0].Width;

            //将每个边缘点到圆心的距离存double数组中
            PointP_Distance.StartX = FindCircle.Results[i].X;//筒管外圆
            PointP_Distance.StartY = FindCircle.Results[i].Y;

            YanWeiCaliper.Run();
            PointP_Distance.EndX = YanWeiCaliper.Results[0].PositionX;//卡尺找的点
            PointP_Distance.EndY = YanWeiCaliper.Results[0].PositionY;
            PointP_Distance.Run();
            SaveDistance[i] = PointP_Distance.Distance;//隔离纸到壁管的距离
          }
        }


        ArrayList List_SaveDistance = new ArrayList(SaveDistance);
        List_SaveDistance.Sort();


        int k = 0;
        if (k < List_SaveDistance.Count)
        {
          do
          {
            Min_Distance = Convert.ToDouble(List_SaveDistance[k]);
            k++;
          } while (Convert.ToDouble(List_SaveDistance[k].ToString()) == 0);
        }

        Min_Distance = Convert.ToDouble(List_SaveDistance[k]);
        Max_Distance = Convert.ToDouble(List_SaveDistance[List_SaveDistance.Count - 1]);
        if (Convert.ToDouble(Min_Distance.ToString()) < Convert.ToDouble(mToolBlock.Inputs["MinYanWeiKuanDu"].Value.ToString()))
        {
          label2.SetXYText(100, 150, "隔离纸至管壁检测:" + Min_Distance.ToString());
          label2.Color = CogColorConstants.Green;
          gc.Add(label2);
          mToolBlock.Outputs["YanWei_DistanceMin"].Value = Min_Distance.ToString();
          AllResult[1] = 0;
        }
        else
        {
          AllResult[1] = 1;
          //mToolBlock.Outputs["Result"].Value = 1;
          label2.SetXYText(100, 150, "隔离纸至管壁检测:NG  " + Min_Distance.ToString());
          label2.Color = CogColorConstants.Red;
          gc.Add(label2);
          mToolBlock.Outputs["YanWei_DistanceMin"].Value = Min_Distance.ToString();
        }
      }
      catch (Exception e)
      {
        //MessageBox.Show(e.ToString());
        mToolBlock.Outputs["Result"].Value = 1;
      }

    }
    else
    {
      //mToolBlock.Outputs["Result"].Value = 1;
      AllResult[1] = 1;
      label2.SetXYText(100, 100, "找圆NG");
      label2.Color = CogColorConstants.Red;
      gc.Add(label1);
    }
    #endregion

    #region 通过找圆工具判断隔离管有无
    if (FindCircle1.Results.Count > 0)
    {
      label3.SetXYText(100, 250, "有隔离管: OK");
      label3.Color = CogColorConstants.Green;
      gc.Add(label3);
      AllResult[2] = 0;
    }
    else
    {
      label3.SetXYText(100, 250, "无隔离管: NG");
      label3.Color = CogColorConstants.Red;
      gc.Add(label3);
      //mToolBlock.Outputs["Result"].Value = 1;
      AllResult[2] = 1;
    }
    #endregion

    foreach (var item in AllResult)
    {
      if (item == 1)
      {
        DecideResult = true;
        break;
      }
    }

    if (DecideResult)
    {
      mToolBlock.Outputs["Result"].Value = 1;
    }
    else
    {
      mToolBlock.Outputs["Result"].Value = 0;
    }

    string AllResultString = string.Join(",", AllResult);
    Console.WriteLine(AllResultString);
    mToolBlock.Outputs["AllResult"].Value = AllResultString;
    //mToolBlock.Outputs["YanWeiDistanceMin"].Value = Min_Distance;//最小值
    mToolBlock.Outputs["bStatus"].Value = true;
    mToolBlock.Outputs["GraphicCollection"].Value = gc;
    //    mToolBlock.Outputs["GraphicCollection1"].Value = gc1;

    return false;
  }

  #region When the Current Run Record is Created
  /// <summary>
  /// Called when the current record may have changed and is being reconstructed
  /// </summary>
  /// <param name="currentRecord">
  /// The new currentRecord is available to be initialized or customized.</param>
  public override void ModifyCurrentRunRecord(Cognex.VisionPro.ICogRecord currentRecord)
  {
  }
  #endregion

  #region When the Last Run Record is Created
  /// <summary>
  /// Called when the last run record may have changed and is being reconstructed
  /// </summary>
  /// <param name="lastRecord">
  /// The new last run record is available to be initialized or customized.</param>
  public override void ModifyLastRunRecord(Cognex.VisionPro.ICogRecord lastRecord)
  {
  }
  #endregion

  #region When the Script is Initialized
  /// <summary>
  /// Perform any initialization required by your script here
  /// </summary>
  /// <param name="host">The host tool</param>
  public override void Initialize(Cognex.VisionPro.ToolGroup.CogToolGroup host)
  {
    // DO NOT REMOVE - Call the base class implementation first - DO NOT REMOVE
    base.Initialize(host);


    // Store a local copy of the script host
    this.mToolBlock = ((Cognex.VisionPro.ToolBlock.CogToolBlock) (host));
  }
  #endregion

}


方法2:通过卡尺工具循环搜索找到点后求解点到圆的距离
在这里插入图片描述

#region namespace imports
using System;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Cognex.VisionPro;
using Cognex.VisionPro.ToolBlock;
using Cognex.VisionPro3D;
using Cognex.VisionPro.PMAlign;
using Cognex.VisionPro.CalibFix;
using Cognex.VisionPro.Blob;
using Cognex.VisionPro.Caliper;
using Cognex.VisionPro.Dimensioning;
using System.Linq;
using System.Threading;
#endregion

public class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{
  #region Private Member Variables
  private Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;
  #endregion

  /// <summary>
  /// Called when the parent tool is run.
  /// Add code here to customize or replace the normal run behavior.
  /// </summary>
  /// <param name="message">Sets the Message in the tool's RunStatus.</param>
  /// <param name="result">Sets the Result in the tool's RunStatus</param>
  /// <returns>True if the tool should run normally,
  ///          False if GroupRun customizes run behavior</returns>
  ///
  #region

  CogGraphicCollection gc;
  CogGraphicCollection gc1;
  CogGraphicLabel label1;
  CogGraphicLabel label2;
  CogGraphicLabel label3;
  CogGraphicLabel label4;
  CogGraphicLabel label5;
  CogGraphicLabel label6;
  CogRectangleAffine rect;


  //  int s = 0;

  //计算圆心度所需变量
  double Min_Distance = 0.0;
  double Max_Distance = 0.0;
  //double Minus_Value = 0;
  //double Point_CenterD = 0;

  //double InputRMSCircle = 0;

  //  int s = 0;

  #endregion

  public override bool GroupRun(ref string message, ref CogToolResultConstants result)
  {
    // To let the execution stop in this script when a debugger is attached, uncomment the following lines.
    //#if DEBUG
    //if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break();
    //#endif

    #region 显示运行

    mToolBlock.Outputs["Result"].Value = 1;
    //mToolBlock.Outputs["Area"].Value = 0;
    mToolBlock.Outputs["bStatus"].Value = false;
    mToolBlock.Outputs["DistanceMax"].Value = 0;
    mToolBlock.Outputs["DistanceMin"].Value = 0;
    mToolBlock.Outputs["GraphicCollection"].Value = null;
    mToolBlock.Outputs["GraphicCollection1"].Value = null;

    //数组下标对应0 1 2 3 4:产品定位NG或OK 两圆距离计算OK或NG  卡尺燕尾判断OK或NG
    int[] AllResult = new int[4];

    bool DecideResult = false;

    CogFindCircleTool Pat1 = (CogFindCircleTool) mToolBlock.Tools["外圆定位"];

    CogFixtureTool Fix = (CogFixtureTool) mToolBlock.Tools["矫正坐标系"];

    CogFindCircleTool FindCircle = (CogFindCircleTool) mToolBlock.Tools["外圆"];

    CogFindCircleTool FindCircle1 = (CogFindCircleTool) mToolBlock.Tools["隔离管外圆"];

    CogDistancePointPointTool PointP_Distance = (CogDistancePointPointTool) mToolBlock.Tools["两圆距离"];

    CogCaliperTool YanWeiCaliper = (CogCaliperTool) mToolBlock.Tools["卡尺燕尾"];

    if (gc == null) gc = new CogGraphicCollection(); gc.Clear();
    if (gc1 == null) gc1 = new CogGraphicCollection(); gc1.Clear();
    if (label1 == null) label1 = new CogGraphicLabel();
    if (label2 == null) label2 = new CogGraphicLabel();
    if (label3 == null) label3 = new CogGraphicLabel();
    if (label4 == null) label4 = new CogGraphicLabel();
    if (label5 == null) label5 = new CogGraphicLabel();
    if (label6 == null) label6 = new CogGraphicLabel();

    if (rect == null) rect = new CogRectangleAffine();

    label1.Font = new Font("宋体", 16);
    label1.SelectedSpaceName = "#";
    label1.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label2.Font = new Font("宋体", 16);
    label2.SelectedSpaceName = "#";
    label2.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label3.Font = new Font("宋体", 16);
    label3.SelectedSpaceName = "#";
    label3.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label4.Font = new Font("宋体", 16);
    label4.SelectedSpaceName = "#";
    label4.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label5.Font = new Font("宋体", 16);
    label5.SelectedSpaceName = "#";
    label5.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;
    label6.Font = new Font("宋体", 16);
    label6.SelectedSpaceName = "#";
    label6.Alignment = CogGraphicLabelAlignmentConstants.BaselineLeft;

    Pat1.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    Pat1.Run();

    if (Pat1.Results != null && Pat1.Results.Count > 0)
    {
      label1.SetXYText(100, 50, "产品定位OK");
      label1.Color = CogColorConstants.Green;
      gc.Add(label1);
      AllResult[0] = 0;
      //mToolBlock.Outputs["Result"].Value = 0;

      Cognex.VisionPro.CogTransform2DLinear liner = new Cognex.VisionPro.CogTransform2DLinear();
      liner.TranslationX = Pat1.Results.GetCircle().CenterX;
      liner.TranslationY = Pat1.Results.GetCircle().CenterY;
      Fix.InputImage = (ICogImage) mToolBlock.Inputs["InputImage"].Value;
      Fix.RunParams.UnfixturedFromFixturedTransform = liner;
      Fix.Run();
    }
    else
    {
      label1.SetXYText(100, 50, "产品定位NG");
      label1.Color = CogColorConstants.Red;
      gc.Add(label1);
      AllResult[0] = 1;
      //mToolBlock.Outputs["Result"].Value = 1;
    }

    #endregion

    #region 计算圆与卡尺工具的距离
    FindCircle.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    FindCircle.Run();

    FindCircle1.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    FindCircle1.Run();

    PointP_Distance.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;

    YanWeiCaliper.InputImage = (CogImage8Grey) mToolBlock.Inputs["InputImage"].Value;
    YanWeiCaliper.Run();

    double x1 = FindCircle.Results.GetCircle().CenterX;
    double y1 = FindCircle.Results.GetCircle().CenterY;
    double SumSaveDistance = 0;
    double r = 0.0;

    double rotationAngleDegrees = 3.0;

    double[] SaveDistance = new double[FindCircle.Results.Count];

    if (FindCircle.Results.Count > 0 )//圆的卡尺工具数量相同且与卡尺工具循环次数需要相同
    {
      try
      {
        for (int i = 0; i < FindCircle.Results.Count; i++)
        {
          if (FindCircle.Results[i].Used)//没有找到的点过滤点,不是过滤的红色点
          {
            double rotationAngleRadians = CogMisc.DegToRad(rotationAngleDegrees * i);

            //仿射矩形 五个参数 第一个:起始点X 第二个参数 起始点Y 第三个参数 矩形宽 第四个参数 矩形高 第五个参数旋转角度
            rect.SetOriginLengthsRotationSkew(x1, y1, 400, 10, r + rotationAngleRadians, 0);

            YanWeiCaliper.Region = rect;

            gc.Add(YanWeiCaliper.Results[0].CreateResultGraphics(CogCaliperResultGraphicConstants.Edges));

            //SaveWidth[i] = YanWeiCaliper.Results[0].Width;

            //将每个边缘点到圆心的距离存double数组中
            PointP_Distance.StartX = FindCircle.Results[i].X;//筒管外圆
            PointP_Distance.StartY = FindCircle.Results[i].Y;

            YanWeiCaliper.Run();
            PointP_Distance.EndX = YanWeiCaliper.Results[0].PositionX;//卡尺找的点
            PointP_Distance.EndY = YanWeiCaliper.Results[0].PositionY;
            PointP_Distance.Run();
            SaveDistance[i] = PointP_Distance.Distance;//隔离纸到壁管的距离
          }
        }


        ArrayList List_SaveDistance = new ArrayList(SaveDistance);
        List_SaveDistance.Sort();


        int k = 0;
        if (k < List_SaveDistance.Count)
        {
          do
          {
            Min_Distance = Convert.ToDouble(List_SaveDistance[k]);
            k++;
          } while (Convert.ToDouble(List_SaveDistance[k].ToString()) == 0);
        }

        Min_Distance = Convert.ToDouble(List_SaveDistance[k]);
        Max_Distance = Convert.ToDouble(List_SaveDistance[List_SaveDistance.Count - 1]);
        if (Convert.ToDouble(Min_Distance.ToString()) < Convert.ToDouble(mToolBlock.Inputs["MinYanWeiKuanDu"].Value.ToString()))
        {
          label2.SetXYText(100, 150, "隔离纸至管壁检测:" + Min_Distance.ToString());
          label2.Color = CogColorConstants.Green;
          gc.Add(label2);
          mToolBlock.Outputs["YanWei_DistanceMin"].Value = Min_Distance.ToString();
          AllResult[1] = 0;
        }
        else
        {
          AllResult[1] = 1;
          //mToolBlock.Outputs["Result"].Value = 1;
          label2.SetXYText(100, 150, "隔离纸至管壁检测:NG  " + Max_Distance.ToString());
          label2.Color = CogColorConstants.Red;
          gc.Add(label2);
          mToolBlock.Outputs["YanWei_DistanceMin"].Value = Max_Distance.ToString();
        }
      }
      catch (Exception e)
      {
        //MessageBox.Show(e.ToString());
        mToolBlock.Outputs["Result"].Value = 1;
      }

    }
    else
    {
      //mToolBlock.Outputs["Result"].Value = 1;
      AllResult[1] = 1;
      label2.SetXYText(100, 100, "找圆NG");
      label2.Color = CogColorConstants.Red;
      gc.Add(label1);
    }
    #endregion

    #region 通过找圆工具判断隔离管有无
    if (FindCircle1.Results.Count > 0)
    {
      label3.SetXYText(100, 250, "有隔离管: OK");
      label3.Color = CogColorConstants.Green;
      gc.Add(label3);
      AllResult[2] = 0;
    }
    else
    {
      label3.SetXYText(100, 250, "无隔离管: NG");
      label3.Color = CogColorConstants.Red;
      gc.Add(label3);
      //mToolBlock.Outputs["Result"].Value = 1;
      AllResult[2] = 1;
    }
    #endregion

    foreach (var item in AllResult)
    {
      if (item == 1)
      {
        DecideResult = true;
        break;
      }
    }

    if (DecideResult)
    {
      mToolBlock.Outputs["Result"].Value = 1;
    }
    else
    {
      mToolBlock.Outputs["Result"].Value = 0;
    }

    string AllResultString = string.Join(",", AllResult);
    Console.WriteLine(AllResultString);
    mToolBlock.Outputs["AllResult"].Value = AllResultString;
    //mToolBlock.Outputs["YanWeiDistanceMin"].Value = Min_Distance;//最小值
    mToolBlock.Outputs["bStatus"].Value = true;
    mToolBlock.Outputs["GraphicCollection"].Value = gc;
    //    mToolBlock.Outputs["GraphicCollection1"].Value = gc1;

    return false;
  }

  #region When the Current Run Record is Created
  /// <summary>
  /// Called when the current record may have changed and is being reconstructed
  /// </summary>
  /// <param name="currentRecord">
  /// The new currentRecord is available to be initialized or customized.</param>
  public override void ModifyCurrentRunRecord(Cognex.VisionPro.ICogRecord currentRecord)
  {
  }
  #endregion

  #region When the Last Run Record is Created
  /// <summary>
  /// Called when the last run record may have changed and is being reconstructed
  /// </summary>
  /// <param name="lastRecord">
  /// The new last run record is available to be initialized or customized.</param>
  public override void ModifyLastRunRecord(Cognex.VisionPro.ICogRecord lastRecord)
  {
  }
  #endregion

  #region When the Script is Initialized
  /// <summary>
  /// Perform any initialization required by your script here
  /// </summary>
  /// <param name="host">The host tool</param>
  public override void Initialize(Cognex.VisionPro.ToolGroup.CogToolGroup host)
  {
    // DO NOT REMOVE - Call the base class implementation first - DO NOT REMOVE
    base.Initialize(host);


    // Store a local copy of the script host
    this.mToolBlock = ((Cognex.VisionPro.ToolBlock.CogToolBlock) (host));
  }
  #endregion

}


  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值