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

传感器测量(图片流程)

效果图

 

 

 

 

重点工具使用流程

CogFindLineTool工具

步骤一:使用找线工具将传感器左边特征给寻找出来;

 步骤二:使用找线工具将传感器右边特征给寻找出来;

 步骤三:使用找线工具将传感器上边特征给寻找出来;

 步骤四:使用找线工具将传感器下边特征给寻找出来;

CogIntersectLineLineTool工具

步骤一:将左边直线和上直线进行交叉处理;

 步骤二:将右边直线和上直线进行交叉处理;

 步骤三:将左边直线和下直线进行交叉处理;

步骤四:将右边直线和下直线进行交叉处理; 

CogCreateSegmentTool工具

步骤一:将右边直线和上直线进行交叉与左边直线和下直线进行交叉,实现右倾斜进行测量···

 步骤二:将右边直线和上直线进行交叉和右边直线和下直线进行交叉,实现右倾斜进行测量···

CogIntersectSegmentSegmentTool工具

将CogCreateSegmentTool工具1和CogCreateSegmentTool工具2计算两条线段(Segment)的交点坐标,然后计算出传感器所需要的宽高。

传感器脚本

#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.Caliper;
using Cognex.VisionPro.Dimensioning;
#endregionpublic class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{#region Private Member Variablesprivate Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;private CogDistanceSegmentLineTool width;private CogDistanceSegmentLineTool length;private CogGraphicLabel widthLabel;private CogGraphicLabel lengthLabel;#endregion/// <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){width = new CogDistanceSegmentLineTool();length = new CogDistanceSegmentLineTool();widthLabel = new CogGraphicLabel();lengthLabel = new CogGraphicLabel();// 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// Run each tool using the RunTool functionforeach(ICogTool tool in mToolBlock.Tools)mToolBlock.RunTool(tool, ref message, ref result);width = mToolBlock.Tools["CogDistanceSegmentLineTool_width"]as CogDistanceSegmentLineTool;length = mToolBlock.Tools["CogDistanceSegmentLineTool_length"]as CogDistanceSegmentLineTool;widthLabel.Color = CogColorConstants.Green;lengthLabel.Color = CogColorConstants.Green;widthLabel.SetXYText(200, 200, "width:" + width.Distance.ToString("0.00"));lengthLabel.SetXYText(200, 250, "length:" + length.Distance.ToString("0.00"));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){mToolBlock.AddGraphicToRunRecord(widthLabel, lastRecord, "CogImageConvertTool1.OutputImage", "script");mToolBlock.AddGraphicToRunRecord(lengthLabel, lastRecord, "CogImageConvertTool1.OutputImage", "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}

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

相关文章:

  • ECharts学习之 toolbox 工具栏
  • 大模型数据预处理方法总结
  • 旋转磁体产生的场-对导航姿态的影响
  • 数据库--回表
  • Spring Security基础入门
  • 电子处方模块开发避坑指南:从互联网医院系统源码实践出发
  • vuex持久化vuex-persistedstate,存储的数据刷新页面后导致数据丢失
  • 【解决】Android Gradle Sync 报错 Could not read workspace metadata
  • 【C/C++】深入理解指针(四)
  • MuJoCo 机械臂 PPO 强化学习逆向运动学(IK)
  • 工会考试精选题目及答案分享
  • 2025年3月电子学会青少年机器人技术(六级)等级考试试卷-实际操作
  • 【操作系统间文件共享_Samba】三、Samba 在实际场景中的应用案例与故障排除
  • 虚拟滚动组件优化记录
  • Linux基础使用-笔记
  • MQTT 之 EMQX
  • 运维的概述
  • 大数据去重
  • 【element plus】解决报错error:ResizeObserver loop limit exceeded的问题
  • 长城智驾重复造轮子
  • LLM微调与LoRA技术
  • 深入探索RAG(检索增强生成)模型的优化技巧
  • 数字人接大模型第一步:表情同步
  • 【Java Card】CLEAR_ON_DESELECT和CLEAR_ON_RESET的区别
  • 卷积神经网络(二)
  • 10.接口而非实现编程
  • 2024武汉邀请赛B.Countless Me
  • 常见的限流算法
  • 对patch深入理解下篇:Patch+LSTM实现以及改进策略整理
  • web 分页查询 分页插件 批量删除