当前位置: 首页 > ops >正文

VisionPro_T恤缺陷检测_机器视觉案例

找到T恤缺陷并标记:效果

1.添加T恤图片

2.添加CogToolBlock,方便后续添加代码

3.进入CogToolBlock,先使用CogImageConvertTool将图片转为灰度图在进行后续操作

4.对T恤logo进行模板匹配和定位

附加连线图

将logo框选

定位按照下图链接并运行

5.使用CogPatInspectTool进行图像训练和比较

******找到logo好的图片进行训练(重要)

6.添加CogBlobTool工具找到缺陷的地方

所有线链接好

打开CogBlobTool

7.工具使用完成,以下为代码部分:(图片红框部分为添加的代码)下面有完整代码

#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.PMAlign;
using Cognex.VisionPro.CalibFix;
using Cognex.VisionPro.PatInspect;
using Cognex.VisionPro.Blob;
#endregionpublic class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{#region Private Member Variablesprivate Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;#endregionCogGraphicCollection  col = new CogGraphicCollection();/// <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();// #endifcol.Clear();CogBlobTool a= mToolBlock.Tools["CogBlobTool1"] as CogBlobTool;// Run each tool using the RunTool functionforeach(ICogTool tool in mToolBlock.Tools)mToolBlock.RunTool(tool, ref message, ref result);for(int i = 0;i < a.Results.GetBlobs().Count;i++){CogPolygon b = a.Results.GetBlobs()[i].GetBoundary(); b.LineWidthInScreenPixels = 4;b.Color = CogColorConstants.Red;col.Add(b);}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, "CogImageConvertTool1.InputImage", "");}}#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}

完成__HH牛码__VisionPro 机器视觉案例篇

http://www.xdnf.cn/news/8116.html

相关文章:

  • visual studio重新安装如何修改共享组件、工具和SDK路径方案
  • 蓝桥杯 11. 保卫国王大道
  • 第二十二次博客打卡
  • YOLO学习笔记 | YOLO11对象检测,实例分割,姿态评估的TensorRT部署c++
  • Python与自动驾驶数据集处理:构建智能驾驶的基石
  • 基于亚博K210开发板——神经网络加速器
  • MacBookPro上macOS安装第三方应用报错解决方案:遇到:“无法打开“XXX”,因为Apple无法检查其是否包含恶意软件 问题如何解决
  • c#基础04(类型转换)
  • Qt网络编程
  • 复合增长率10.1%!2025 小型电动 VTOL 无人机市场报告深度解读
  • Python包管理新篇章!解析uv工具的高效解决方案
  • 树 Part 8
  • 分贝计如何帮助改善睡眠环境
  • 【推理加速】TensorRT C++ 部署YOLO11全系模型
  • MySQL 单表与多表操作详解
  • Ubuntu Desktop 24.04 常用软件安装步骤
  • Ubuntu 新建用户
  • 体育直播网站如何实现实时数据
  • 卷积神经网络基础(十一)
  • 记录:RK3588无法显示开机logo问题
  • React 第四十六节 Router中useInRouterContext的使用详细介绍及注意事项
  • docker-安装部署于macOS11
  • windows安装clamav
  • 多模态大语言模型arxiv论文略读(八十九)
  • LeetCode 404.左叶子之和的递归求解:终止条件与递归逻辑的深度剖析
  • C++学习:六个月从基础到就业——多线程编程:并发容器与无锁编程
  • Intel oneAPI对OpenCL 的支持
  • 什么是特征工程?
  • Java异常分类与Spring事务回滚机制深度剖析
  • 电子电路:为什么会产生电流超前或者滞后于电压的情况?