案例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;
#endregionpublic 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);<