近期用到的代码记录

using System;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Cognex.VisionPro;
using Cognex.VisionPro.ToolBlock;
using System.Collections.Generic;
public class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{
 
  private Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;
  double[] AreaPosition = new double[]{1,2,2};
  string AreaStr = "2";
  public override bool GroupRun(ref string message, ref CogToolResultConstants result)
  {
    foreach(ICogTool tool in mToolBlock.Tools)
      mToolBlock.RunTool(tool, ref message, ref result);
    return false;
  }
 
  public override void Initialize(Cognex.VisionPro.ToolGroup.CogToolGroup host)
  {
    base.Initialize(host);
    this.mToolBlock = ((Cognex.VisionPro.ToolBlock.CogToolBlock)(host));
    if(AreaPosition== null)
    {
      AreaPosition = new double[]{1,2,2};
    }
    CogToolBlockTerminal m = new CogToolBlockTerminal("Area", AreaPosition.GetType());
    m.Value = AreaPosition;
    mToolBlock.Outputs.Add(m);
    CogToolBlockTerminal mw = new CogToolBlockTerminal("AreaStr", AreaStr.GetType());
    mw.Value = "张";
    mToolBlock.Outputs.Add(mw);
  
  }
}

 

read_image (Image, '拟合矩形/9_20267_2915dddc975d7f4.jpg')
dev_close_window ()
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_display (Image)
rgb1_to_gray (Image, GrayImage)
binary_threshold (GrayImage, Region, 'max_separability', 'dark', UsedThreshold)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 7324.84, 48089.2)
threshold (GrayImage, Regions, 0, 100)
connection (Regions, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 636.94, 83439.5)
difference (SelectedRegions, SelectedRegions1, RegionDifference)
opening_circle (RegionDifference, RegionOpening, 3.5)
gen_contour_region_xld (RegionOpening, Contours, 'border')
fit_rectangle2_contour_xld (Contours, 'regression', -1, 0, 0, 3, 2, Row, Column, Phi, Length1, Length2, PointOrder)
gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
dev_display (Image)
dev_display (Rectangle)

你可能感兴趣的:(工作记录,工作记录)