您的位置:首页 > 汽车 > 时评 > 网络整合营销案例_微信小程序如何申请_温州seo网站建设_官网seo是什么意思

网络整合营销案例_微信小程序如何申请_温州seo网站建设_官网seo是什么意思

2025/8/15 19:30:56 来源:https://blog.csdn.net/C6666888/article/details/147050433  浏览:    关键词:网络整合营销案例_微信小程序如何申请_温州seo网站建设_官网seo是什么意思
网络整合营销案例_微信小程序如何申请_温州seo网站建设_官网seo是什么意思

CogPatInspectTool是康耐视中的一种模板比对的视觉检测工具,主要用于产品不良检测。其核心功能是通过将输入图像与预先训练好的模板进行对比,识别出两者之间的差异,并生成高亮差异图,从而判断产品是否存在缺陷。

效果图

CogPatInspectTool工具块概念

CogPatInspectTool通过比对输入图像与训练模板的特征差异,检测产品的不良。其特点包括:

  1. 模板比对与缺陷检测 CogPatInspectTool通过提取输入图像中特定区域的特征(如边缘、形状等),与训练好的模板进行匹配,计算两者之间的偏差。差异超过设定阈值的区域会被标记为缺陷,并以高亮形式呈现。

  2. 依赖外部工具协同工作 该工具通常需要与CogPMAlignTool(模板匹配工具)、CogFixture(定位工具)等配合使用。例如,CogPMAlignTool提供模板的位置和角度信息,CogFixture调整坐标系,确保检测区域的精确定位。

CogPatInspectTool工具应用场景

  • 工业质检:如电子元件焊接缺陷、印刷品瑕疵检测等。

  • 高精度匹配:适用于需要快速比对模板与实时图像的场景,例如零件定位后的二次质量验证。

CogPatInspectTool工具应用流程

步骤1:

名称描述
InputImage待检测的图像输入
Pose从CogPMAlignTool的输出结果中获取定位信息(如Results.Item(0).GetPose
Pattern.TrainImage训练好的模板图像。
Pattern.Origin模板的坐标系原点。

 步骤2

抓取训练图像与原点-->Current.TrainImage-->训练新模式-->统计训练当前模式:在次步骤点击当前模式会在左边区域显示训练次数-->结束统计训练;如果对这次训练不满意可以取消训练模式进行重新抓取训练结果。

步骤3:

根据图像来源进行适当调整。

步骤4:

规范化模式常见选项及定义

 

名称定义使用条件
None(无规范化不对输入图像进行任何预处理,直接使用原始图像进行模板匹配和缺陷检测。适用于光照条件稳定、图像对比度高的场景,无需额外调整。
Linear(线性规范化)通过线性变换调整图像的亮度和对比度,使图像灰度分布更均匀。适用于光照轻微变化但整体亮度分布可控的情况。
Histogram Equalization(直方图均衡化)增强图像全局对比度,通过扩展灰度分布范围突出细节。适用于低对比度图像或需要增强局部特征的场景。
Local Contrast(局部对比度增强)基于局部区域的对比度调整,抑制全局光照变化的影响。适用于光照不均匀或存在局部阴影的场景。
Adaptive Thresholding(自适应阈值)根据图像局部区域的灰度动态计算阈值,用于二值化处理。适用于光照变化显著或背景复杂的图像。
Edge-Based(基于边缘的规范化)仅保留图像边缘信息,弱化纹理和光照干扰。适用于需要依赖形状或边缘特征进行缺陷检测的场景。
Gradient Magnitude(梯度幅值规范化)计算图像梯度幅值,突出边缘和纹理变化。适用于高噪声图像或需强化边缘差异的检测任务。

使用条件与选择建议 

光照稳定性:若光照条件稳定,选择NoneLinear模式可简化计算;若光照波动较大,优先使用Local ContrastAdaptive Thresholding

图像对比度:低对比度图像需结合Histogram EqualizationEdge-Based模式以增强特征。

噪声抑制:对于高噪声环境,Gradient Magnitude模式可通过梯度计算减少噪声干扰。

实时性要求LinearEdge-Based模式计算量较低,适合实时性要求高的场景;Adaptive ThresholdingLocal Contrast可能需要更高算力 。

步骤5: 

项目:识别充电器镭雕字符检测

步骤1:

步骤2:

 

 步骤3:

 步骤4:

 脚本

#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 Variablesprivate Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;#endregion//定义图形集合 //声明图形集合  CogGraphicCollection   一些关于 图形的 都可以放进去 CogGraphicCollection col = new CogGraphicCollection();//声明 图形标签CogGraphicLabel mLabel = new CogGraphicLabel();//圆CogCircle mCircle = new CogCircle();/// <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>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//找到工具CogBlobTool blob = new CogBlobTool();blob = mToolBlock.Tools["CogBlobTool1"] as CogBlobTool;// Run each tool using the RunTool function//qingkongcol.Clear();foreach(ICogTool tool in mToolBlock.Tools)mToolBlock.RunTool(tool, ref message, ref result);//判断 是否 ng if(blob.Results.GetBlobs().Count > 0){//ok mLabel.SetXYText(200,200,"NG");mLabel.Color = CogColorConstants.Red;mLabel.Font = new Font("宋体",30);//设置颜色mCircle.Color = CogColorConstants.Red;//设置半径mCircle.Radius = 15;//设置圆心mCircle.CenterX = blob.Results.GetBlobs()[0].CenterOfMassX;mCircle.CenterY = blob.Results.GetBlobs()[0].CenterOfMassY;//设置圆线条 的像素宽度mCircle.LineWidthInScreenPixels = 2;col.Add(mCircle);col.Add(mLabel);}else{mLabel.SetXYText(200, 200, "ok");mLabel.Color = CogColorConstants.Green;mLabel.Font = new Font("宋体", 30);col.Add(mLabel);}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){for (int i = 0; i < col.Count; i++){mToolBlock.AddGraphicToRunRecord(col[i], lastRecord, "CogPMAlignTool1.InputImage", "script");} }#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 REMOVEbase.Initialize(host);// Store a local copy of the script hostthis.mToolBlock = ((Cognex.VisionPro.ToolBlock.CogToolBlock)(host));}#endregion}

注意事项

  • 模板质量:训练模板需避免模糊或光照不均,否则可能影响检测准确性。

  • 多工具协同:建议结合CogPMAlignTool进行初始定位,再使用CogPatInspectTool进行精细化缺陷检测。

  • 参数调优:需根据实际场景调整对比度阈值和检测区域,平衡误检率与漏检率。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com