1、通过VisualStudio新建一个项目
2、打开项目可以看到VisionPro控件不可用,需要到项目属性中设定目标框架为NET.Framework 4
3、将 CogRecordDisplay 控件拉入到窗体中同时添加一个 button控件
4、双击 button 按钮,写入下面代码using System;using System.觊皱筠桡Collections.Generic;usi荏鱿胫协ng System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Cognex.VisionPro.ImageFile;using System.IO;using Cognex.VisionPro;namespace WindowsFormsApplication1{ public partial class Form1 : Form { private CogImageFileTool m_ImageFileTool; public Form1() { InitializeComponent(); m_ImageFileTool = new CogImageFileTool(); } private void button1_Click(object sender, EventArgs e) { m_ImageFileTool.Operator.Open(Directory.GetCurrentDirectory() + "/测试.bmp", CogImageFileModeConstants.Read); m_ImageFileTool.Run(); cogRecordDisplay1.Image = m_ImageFileTool.OutputImage as CogImage8Grey; cogRecordDisplay1.Fit(true); } }}
5、将 测试.bmp文件放到 debug文件夹中
6、运行项目,点击 button1 按钮就可显示图像