[ C# Cognex ] 씨샾 코그넥스 - VisionPro (R) QuickBuild 오버레이 뷰어 Record 선택
1. VisionPro (R) QuickBuild 실행
2. Image Source 실행
3. 이미지 파일&폴더 선택
- VisionPro 도구 표시 [실행]
- CogBlobTool [추가]
- CogBlobTool [추가]
- Image Source [OutImages] -> CogBlobTool1 [InputImage]
- 작업 1회 실행 [실행]
- Windows Forms 앱 [생성]
9. CogRecordDisplay 생성
- cogRecordDisplay1
- cogRecordDisplay2
- cogRecordDisplay3
- button1 [생성]
- button1_Clisck [추가]
- Form1_Load [추가]
- Form1_FormClosing [추가]
- Cognex.VisionPro.QuickBuild.Core.dll [추가]
==========
using System;
using System.IO;
using System.Windows.Forms;
// Cognex VisionPro 사용 추가
using Cognex.VisionPro;
using Cognex.VisionPro.QuickBuild;
using Cognex.VisionPro.ToolGroup;
namespace CogOverlayViewer
{
public partial class Form1 : Form
{
// 관리자 & 직업 & 독립적인 추가
CogJobManager _myJobManager;
CogJob _myJob;
CogJobIndependent _myIndependentJob;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string szProjectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
// 레시피 세팅
_myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(szProjectPath + "\\QuickBuild1.vpp");
_myJob = _myJobManager.Job(0);
_myIndependentJob = _myJob.OwnedIndependent;
// 기존 메모리 청소
_myJobManager.UserQueueFlush();
_myJobManager.FailureQueueFlush();
_myJob.ImageQueueFlush();
_myIndependentJob.RealTimeQueueFlush();
}
private void button1_Click(object sender, EventArgs e)
{
ICogRecord icogRecord = null;
_myJobManager.Run();
// 검사 시간 기다림
while (icogRecord == null)
icogRecord = _myJobManager.UserResult();
CogToolGroup cogToolGroup = (CogToolGroup)_myJob.VisionTool;
cogRecordDisplay1.Record = cogToolGroup.Tools["Image Source"].CreateLastRunRecord().SubRecords["OutputImage"];
cogRecordDisplay1.Fit(true);
cogRecordDisplay2.Record = cogToolGroup.CreateLastRunRecord().SubRecords["Image Source.OutputImage"];
cogRecordDisplay2.Fit(true);
cogRecordDisplay3.Record = cogToolGroup.CreateLastRunRecord().SubRecords["CogBlobTool1.BlobImage"];
cogRecordDisplay3.Fit(true);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
cogRecordDisplay1.Dispose();
cogRecordDisplay2.Dispose();
cogRecordDisplay3.Dispose();
// Cog JobManager를 반드시 종료하세요!!
_myJobManager.Shutdown();
}
}
}
==========
==========
댓글
댓글 쓰기