注册4年,第一次发了随笔。我的博客将主要涉及到visionPro软件的学习,labview数据采集方面的思考,c#及VS的学习
此随笔系列主要是关于VisionPro(以后简称VP)的学习及使用。
近日我的项目涉及到视觉检测,机缘之下,得到一个VP的加密狗,至此,开始我的学习之路
-----------------------------------------------------------分界线----------------------------------------------------------------
2020/1/3续 尝试将quickbuild视觉的工具封装好之后,用VS打开,可以编辑界面
-----------------------------------------------------------分界线----------------------------------------------------------------
2020/4/3
灰度值 :范围一般从0到255,白色为255,黑色为0,
上图这张全黑图片在VisonPro里不能使用PMA工具训练,全黑没有灰度 不能计算 那全白呢 (试一下看看-----试过了不行)
PatInspect工具检测缺陷
2020/4/8
在c#中接入VisionPro,测量并读出结果 代码如下,参考“代码狗”的工业视觉教程,在visionpro8.3,visual studio2012 .net framework4.5下实现 例子放在压缩包里
博客园上传不了 有20M,放在云盘,自取,
链接:https://pan.baidu.com/s/14Xhq1eDdhEngKQbTUYwnSA
提取码:7vac
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Cognex.VisionPro; using Cognex.VisionPro.QuickBuild; using Cognex.VisionPro.Blob; using Cognex.VisionPro.ToolGroup; using Cognex.VisionPro.Caliper; using Cognex.VisionPro.Implementation.Internal; namespace WindowsFormsApplication1 { public partial class Form1 : Form { CogJobManager myjobmanager; CogBlobResultCollection myblobresult; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { myjobmanager = (CogJobManager)CogSerializer.LoadObjectFromFile(Application.StartupPath + "/缺陷检测.vpp"); } private void button2_Click(object sender, EventArgs e) { myjobmanager.Job(0).Run(); CogToolGroup ctg = myjobmanager.Job(0).VisionTool as CogToolGroup; CogBlobTool cb = ctg.Tools["CogBlobTool1"] as CogBlobTool;//因为把[]写成(),耽误了一下午 myblobresult = cb.Results.GetBlobs(); int x = myblobresult.Count; label1.Text = x.ToString(); foreach (CogBlobResult blobResult in myblobresult)//参考VP中的“CogBlob Class”的代码,因为斑点有多个,是一个集合 所以需要foreach { double y = blobResult.Area; double z = blobResult.CenterOfMassY; label2.Text = y.ToString("0.00"); label3.Text = z.ToString("0.00"); } #region"在c#中输出VisionPro图像,参考“代码狗的博客中的代码”,VisionPro的参考文档中也提及 ICogRecord myrdp = ctg.CreateLastRunRecord();//job中的工具组创建结果图像 cogRecordDisplay1.Record = myrdp.SubRecords[4];//取出序号为1的图像,从0开始 cogRecordDisplay1.AutoFit = true;//图像显示控件图像自适应大小 #region } } }
https://www.daimadog.com/1443.html关于工业视觉的教程