机器视觉13-PolarUnwrap和PatInspect案例

案例1:

1.添加圆形展开工具

2.调整内外径圆环 (注意:转换方向 以3闭合圆形的地方开始  沿4箭头的方向分割圆环)

1.添加ocr工具提取字符

2.提取字符操作

3.选框范围设置要包括提取的字符(注意:不要超过图形边缘)区段设置(如果有需要)引用 ovr工具的命名空间

 

#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.ImageProcessing;
using Cognex.VisionPro.OCRMax;
#endregion

public class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{
  #region Private Member Variables
  private Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;
  #endregion
 
  //声明label字段
  CogGraphicLabel label;
  public override bool GroupRun(ref string message, ref CogToolResultConstants result)
  {

 
   CogOCRMaxTool     ocr = mToolBlock.Tools["CogOCRMaxTool1"] as CogOCRMaxTool;
    label = new CogGraphicLabel();
    
    // Run each tool using the RunTool function
    foreach(ICogTool tool in mToolBlock.Tools)
      mToolBlock.RunTool(tool, ref message, ref result);
   
    //ocr 提取字符串
    string text = ocr.LineResult.ResultString;
    //设置label的位置和内容
    label.SetXYText(200, 800, "编号:" + text);、
    //label的颜色
    label.Color = CogColorConstants.Green;
    //label的字体样式
    Font font = new Font("楷体", 20);<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值