Visonpro 检测是否有缺齿
一、效果展示

二、上面是原展开工具CogPolarUnwrapTool;
第二种方法: 用Blob 和 CogCopyRegionTool


三、 用预处理工具 加减常数,让图片变得更亮点

四、圆展开工具
五、模板匹配

六、代码分解
1.创建集合和文子显示工具
CogGraphicCollection dt = new CogGraphicCollection();CogGraphicLabel Label;
2.加载工具,并实例化一个List集合
dt.Clear();CogPolarUnwrapTool polar = mToolBlock.Tools["CogPolarUnwrapTool1"]as CogPolarUnwrapTool;CogPMAlignTool pma = mToolBlock.Tools["CogPMAlignTool1"]as CogPMAlignTool;List<double> listX = new List<double>();
3.定义图标中的坐标吗,添加集合,排序
double total = 0;double x, y;for(int i = 0;i < pma.Results.Count;i++){listX.Add(pma.Results[i].GetPose().TranslationX);total += pma.Results[i].GetPose().TranslationY;}y = total / pma.Results.Count;listX.Sort();
4.进行传参,找出之前的x和y坐标系,并用参数接收是否存在缺失
int a = 0;for(int i = 0;i < listX.Count - 1;i++){if((listX[i + 1] - listX[i]) > 50){x = (listX[i + 1] + listX[i]) / 2;y = total / pma.Results.Count;double lastx,lasty;polar.RunParams.GetInputPointFromOutputPoint(polar.InputImage, polar.Region, x, y, out lastx, out lasty);dt.Add(Create(lastx, lasty));a++;}}
5.进行判断是否缺失
Label = new CogGraphicLabel();if(a > 0){Label.SetXYText(100, 100, "缺失"+a);Label.Color = CogColorConstants.Red;Label.Font = new Font("楷体", 30);dt.Add(Label);}else{Label.SetXYText(100, 100, "OK");Label.Color = CogColorConstants.Green;Label.Font = new Font("楷体", 30);dt.Add(Label);}
6.将上面传入圆展开的x,y坐标,进行创建圆
private CogCircle Create(double x, double y){CogCircle co = new CogCircle();co.CenterX = x;co.CenterY = y;co.Radius = 20;co.LineWidthInScreenPixels = 6;co.Color = CogColorConstants.Red;dt.Add(co);return co;}
7.输出
for(int i = 0;i < dt.Count;i++){mToolBlock.AddGraphicToRunRecord(dt[i], lastRecord, "CogIPOneImageTool1.InputImage", "");}
8.代码All
#region namespace imports
using System;
using System.Collections;
using System.Collections.Generic;
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;
#endregionpublic class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{#region Private Member Variablesprivate Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;#endregionCogGraphicCollection dt = new CogGraphicCollection();CogGraphicLabel Label;/// <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();// #endifdt.Clear();CogPolarUnwrapTool polar = mToolBlock.Tools["CogPolarUnwrapTool1"]as CogPolarUnwrapTool;CogPMAlignTool pma = mToolBlock.Tools["CogPMAlignTool1"]as CogPMAlignTool;List<double> listX = new List<double>();// Run each tool using the RunTool functionforeach(ICogTool tool in mToolBlock.Tools)mToolBlock.RunTool(tool, ref message, ref result);double total = 0;double x, y;for(int i = 0;i < pma.Results.Count;i++){listX.Add(pma.Results[i].GetPose().TranslationX);total += pma.Results[i].GetPose().TranslationY;}y = total / pma.Results.Count;listX.Sort();int a = 0;for(int i = 0;i < listX.Count - 1;i++){if((listX[i + 1] - listX[i]) > 50){x = (listX[i + 1] + listX[i]) / 2;y = total / pma.Results.Count;double lastx,lasty;polar.RunParams.GetInputPointFromOutputPoint(polar.InputImage, polar.Region, x, y, out lastx, out lasty);dt.Add(Create(lastx, lasty));a++;}}Label = new CogGraphicLabel();if(a > 0){Label.SetXYText(100, 100, "缺失"+a);Label.Color = CogColorConstants.Red;Label.Font = new Font("楷体", 30);dt.Add(Label);}else{Label.SetXYText(100, 100, "OK");Label.Color = CogColorConstants.Green;Label.Font = new Font("楷体", 30);dt.Add(Label);}return false;}private CogCircle Create(double x, double y){CogCircle co = new CogCircle();co.CenterX = x;co.CenterY = y;co.Radius = 20;co.LineWidthInScreenPixels = 6;co.Color = CogColorConstants.Red;dt.Add(co);return co;}#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 < dt.Count;i++){mToolBlock.AddGraphicToRunRecord(dt[i], lastRecord, "CogIPOneImageTool1.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}
七、polar.RunParams.GetInputPointFromOutputPoint
该方法用于输出图像中的坐标 (x, y) 转换为输入图像中的坐标 (lastx, lasty)
polar.InputImage是输入图像对象polar.Region可能是指定的处理区域x, y是输出图像中的坐标out lastx, out lasty是输出参数,表示转换后的输入图像中的坐标。
polar.RunParams.GetInputPointFromOutputPoint(
-
polar.InputImage, // 输入图像
-
polar.Region, // 处理区域
-
x, // 输出图像中的X坐标
-
y, // 输出图像中的Y坐标
-
out lastx, // 输出:对应的输入图像中的X坐标
-
out lasty // 输出:对应的输入图像中的Y坐标 );
注意事项:
- 方法的作用:该方法的主要作用是将输出图像中的坐标映射回输入图像中的坐标,通常用于图像变换后的逆向坐标查找。
- 参数检查:确保
polar.InputImage和polar.Region已正确初始化,并且x, y坐标在有效的范围内。 - 返回值:
lastx和lasty是通过out参数返回的,因此调用后可以直接使用这两个变量获取转换后的坐标。
八、第二种方法
1.定义值

2. 工具展示

3. Blob设置


4.CogCopyReigonTool设置
添加终端链接
5.CogBlob覆盖后设置

6.代码
#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.Blob;
#endregionpublic class CogToolBlockAdvancedScript : CogToolBlockAdvancedScriptBase
{#region Private Member Variablesprivate Cognex.VisionPro.ToolBlock.CogToolBlock mToolBlock;#endregionCogGraphicLabel label = new CogGraphicLabel();/// <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();// #endifint count = (int) mToolBlock.Inputs["Count"].Value;CogBlobTool blob = mToolBlock.Tools["CogBlobTool2"]as CogBlobTool;// Run each tool using the RunTool functionforeach(ICogTool tool in mToolBlock.Tools)mToolBlock.RunTool(tool, ref message, ref result);int currentCount = blob.Results.GetBlobs().Count;int diff = count - currentCount;string res = "";label.Color = CogColorConstants.Green;label.Font = new Font("宋体", 20);if (diff > 0){res = "缺失:" + diff;label.Color = CogColorConstants.Red;}else{res = "良品";}label.SetXYText(100, 250, res);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(label, lastRecord, "CogIPOneImageTool1.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}
相关文章:
Visonpro 检测是否有缺齿
一、效果展示 二、上面是原展开工具CogPolarUnwrapTool; 第二种方法: 用Blob 和 CogCopyRegionTool 三、 用预处理工具 加减常数,让图片变得更亮点 四、圆展开工具 五、模板匹配 六、代码分解 1.创建集合和文子显示工具 CogGraphicCollec…...
第1章大型互联网公司的基础架构——1.6 RPC服务
你可能在1.1节的引言中注意到业务服务层包括HTTP服务和RPC服务,两者的定位不一样。一般来说,一个业务场景的核心逻辑都是在RPC服务中实现的,强调的是服务于后台系统内部,所谓的“微服务”主要指的就是RPC服务;而HTTP服…...
今日AI和商界事件(2025-02-15)
根据2025年2月15日的科技动态,以下是今日AI领域的重要事件及相关进展总结: 1. DeepSeek日活突破3000万,开源生态加速AI普惠 里程碑意义:开源大模型DeepSeek宣布日活跃用户数突破3000万,其R1模型凭借开源策略和低成本优…...
算法题(69):搜索插入位置
审题: 需要我们在有序数组中找到等于target值的元素的下标若没有则返回target按顺序会插入的位置的索引 思路 : 我们可以使用二分查找的方法 方法一:二分查找 和普通的二分查找不同,本题若没有找到就需要返回它按顺序插入的位置的…...
在 Linux 系统中,tc(Traffic Control) QoS 常用命令简介
在 Linux 系统中,tc(Traffic Control)命令是一个强大的工具,用于配置和管理网络流量控制。以下是 tc 命令的常用功能和基本用法: 1. 查看当前队列规则 使用以下命令查看指定网络接口上的队列规则: tc qd…...
如何画产品功能图、结构图
功能图的类型 常见的功能图包括数据流图、用例图、活动图、状态图、类图、组件图、部署图等等,不同的应用场景和目标下,需要确定不同的功能图类型。 数据流图 用例图 状态图 类图 组件图 组件图是由软件系统、组件和组件之间的关系组成的图形…...
4090单卡挑战DeepSeek r1 671b:尝试量化后的心得的分享
引言: 最近,DeepSeek-R1在完全开源的背景下,与OpenAI的O1推理模型展开了激烈竞争,引发了广泛关注。为了让更多本地用户能够运行DeepSeek,我们成功将R1 671B参数模型从720GB压缩至131GB,减少了80%ÿ…...
SpringBoot速成(12)文章分类P15-P19
1.新增文章分类 1.Postman登录不上,可以从头registe->login一个新的成员:注意,跳转多个url时,post/get/patch记得修改成controller类中对应方法上写的 2.postman运行成功: 但表中不更新:细节有问题: c是…...
C++17中的clamp函数
一、std::clamp() 其实在前面简单介绍过这个函数,但当时只是一个集中的说明,为了更好的理解std::clamp的应用,本篇再详细进行阐述一次。std::clamp在C17中其定义的方式为: template< class T > constexpr const T& cl…...
配置Open-R1,评测第三方蒸馏模型的性能1
年前DeepSeek不温不火,问题的响应极。一回车,就看模型如口吐莲花般,先是输出思维过程,虽然中间绕来绕去,但是输出回答时还是准确而简洁的。比如,用它来读当时出来的几篇文章,确实大大提升了效率…...
Chrome插件开发流程
Chrome插件开发流程可以分为以下几个主要步骤: ### 1. 确定插件功能和目标 在开始开发之前,首先需要明确插件的功能和目标。这包括: - **功能定义**:确定插件要解决的问题或提供的功能。 - **市场分析**:了解目标用户群…...
物联网行业通识:从入门到深度解析
物联网行业通识:从入门到深度解析 (图1:物联网生态示意图) 一、引言:万物互联时代的到来 根据IDC最新预测,到2025年全球物联网设备连接数将突破410亿,市场规模达1.1万亿美元。物联网ÿ…...
【做一个微信小程序】校园事件页面实现
前言 为了进一步扩展校园事件页面的功能,我们可以添加 搜索、分类筛选 和 渐变卡片色 等特性。以下是详细的方案和源码实现。 扩展功能设计 1. 搜索功能 在页面顶部添加搜索框,用户输入关键词后,筛选出匹配的事件。2. 分类筛选 在页面顶部添加分类标签(如“全部”、“活动…...
C++基础系列【14】继承与多态
博主介绍:程序喵大人 35- 资深C/C/Rust/Android/iOS客户端开发10年大厂工作经验嵌入式/人工智能/自动驾驶/音视频/游戏开发入门级选手《C20高级编程》《C23高级编程》等多本书籍著译者更多原创精品文章,首发gzh,见文末👇…...
DeepSeek-R1 大模型本地部署指南
文章目录 一、系统要求硬件要求软件环境 二、部署流程1. 环境准备2. 模型获取3. 推理代码配置4. 启动推理服务 三、优化方案1. 显存优化技术2. 性能加速方案 四、部署验证健康检查脚本预期输出特征 五、常见问题解决1. CUDA内存不足2. 分词器警告处理3. 多GPU部署 六、安全合规…...
在conda环境下,安装Pytorch和CUDA
系统 : Ubuntu20.04 显卡:NVIDIA GTX1650 显卡驱动已经装好(命令 nvidia-smi 查看显卡配置) (主要看一下第一行的参数,最大支持的CUDA版本为12.4 ) Aanconda 版本(安装指南)(似乎…...
Java里int和Integer的区别?
大家好,我是锋哥。今天分享关于【Java里int和Integer的区别?】面试题。希望对大家有帮助; Java里int和Integer的区别? 1000道 互联网大厂Java工程师 精选面试题-Java资源分享网 在 Java 中,int 和 Integer 都是用来表…...
【第13章:自监督学习与少样本学习—13.4 自监督学习与少样本学习的未来研究方向与挑战】
凌晨三点的实验室里,博士生小张盯着屏幕上的训练曲线——他设计的跨模态少样本学习模型在医疗影像诊断任务上突然出现了诡异的性能断崖。前一秒还在92%的准确率高位运行,下一秒就暴跌到47%。这个看似灾难性的现象,却意外揭开了自监督学习与少样本学习技术深藏的核心挑战… 一…...
【NLP】文本预处理
目录 一、文本处理的基本方法 1.1 分词 1.2 命名体实体识别 1.3 词性标注 二、文本张量的表示形式 2.1 one-hot编码 2.2 word2vec 模型 2.2.1 CBOW模式 2.2.2 skipgram模式 2.3 词嵌入word embedding 三、文本数据分析 3.1 标签数量分布 3.2 句子长度分布 3.3 词…...
deepseek r1从零搭建本地知识库10:嵌入模型和知识库建设
一、嵌入模型(Embedding Model)是什么? 1. 定义 嵌入模型是一种将文本、图像、音频等非结构化数据转化为**低维稠密向量(Dense Vector)**的算法模型,这些向量(通常几百到几千维)能够…...
Java 语言特性(面试系列2)
一、SQL 基础 1. 复杂查询 (1)连接查询(JOIN) 内连接(INNER JOIN):返回两表匹配的记录。 SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id d.dept_id; 左…...
Linux 文件类型,目录与路径,文件与目录管理
文件类型 后面的字符表示文件类型标志 普通文件:-(纯文本文件,二进制文件,数据格式文件) 如文本文件、图片、程序文件等。 目录文件:d(directory) 用来存放其他文件或子目录。 设备…...
Linux简单的操作
ls ls 查看当前目录 ll 查看详细内容 ls -a 查看所有的内容 ls --help 查看方法文档 pwd pwd 查看当前路径 cd cd 转路径 cd .. 转上一级路径 cd 名 转换路径 …...
django filter 统计数量 按属性去重
在Django中,如果你想要根据某个属性对查询集进行去重并统计数量,你可以使用values()方法配合annotate()方法来实现。这里有两种常见的方法来完成这个需求: 方法1:使用annotate()和Count 假设你有一个模型Item,并且你想…...
P3 QT项目----记事本(3.8)
3.8 记事本项目总结 项目源码 1.main.cpp #include "widget.h" #include <QApplication> int main(int argc, char *argv[]) {QApplication a(argc, argv);Widget w;w.show();return a.exec(); } 2.widget.cpp #include "widget.h" #include &q…...
【算法训练营Day07】字符串part1
文章目录 反转字符串反转字符串II替换数字 反转字符串 题目链接:344. 反转字符串 双指针法,两个指针的元素直接调转即可 class Solution {public void reverseString(char[] s) {int head 0;int end s.length - 1;while(head < end) {char temp …...
Caliper 配置文件解析:config.yaml
Caliper 是一个区块链性能基准测试工具,用于评估不同区块链平台的性能。下面我将详细解释你提供的 fisco-bcos.json 文件结构,并说明它与 config.yaml 文件的关系。 fisco-bcos.json 文件解析 这个文件是针对 FISCO-BCOS 区块链网络的 Caliper 配置文件,主要包含以下几个部…...
Mac下Android Studio扫描根目录卡死问题记录
环境信息 操作系统: macOS 15.5 (Apple M2芯片)Android Studio版本: Meerkat Feature Drop | 2024.3.2 Patch 1 (Build #AI-243.26053.27.2432.13536105, 2025年5月22日构建) 问题现象 在项目开发过程中,提示一个依赖外部头文件的cpp源文件需要同步,点…...
重启Eureka集群中的节点,对已经注册的服务有什么影响
先看答案,如果正确地操作,重启Eureka集群中的节点,对已经注册的服务影响非常小,甚至可以做到无感知。 但如果操作不当,可能会引发短暂的服务发现问题。 下面我们从Eureka的核心工作原理来详细分析这个问题。 Eureka的…...
20个超级好用的 CSS 动画库
分享 20 个最佳 CSS 动画库。 它们中的大多数将生成纯 CSS 代码,而不需要任何外部库。 1.Animate.css 一个开箱即用型的跨浏览器动画库,可供你在项目中使用。 2.Magic Animations CSS3 一组简单的动画,可以包含在你的网页或应用项目中。 3.An…...



