1.案例:充电器镭雕字符缺陷检测 并显示NG/OK结果
#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.PatInspect;
using Cognex.VisionPro.Blob;
#endregionpublic class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{
#region Private Member Variables
private Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;
//声明blob
private CogBlobTool mBlob;
//声明文本
private CogGraphicLabel mLabel;
#endregion//GroupRun 方法
public override bool GroupRun(ref string message, ref CogToolResultConstants result)
{
//映射blob
mBlob = mToolBlock.Tools["CogBlobTool1"]as CogBlobTool;
//遍历block工具
foreach(ICogTool tool in mToolBlock.Tools)
mToolBlock.RunTool(tool, ref message, ref result);
//判断blob结果个数 创建对应文本内容
if(mBlob.Results.GetBlobs().Count == 0)
{
mLabel = new CogGraphicLabel();
mLabel.Color = CogColorConstants.Green;
mLabel.SetXYText(200, 200, "Result:OK");
}
else
{
&n