注冊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關於工業視覺的教程