可以用visionpro的VPPVersion.exe 工具查看文件格式。 在安装路径最后一个
官方示例文件路径
简单实例
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.ImageFile;
using Cognex.VisionPro.ToolBlock;
using Cognex.VisionPro.Blob;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
CogImageFileTool mFTool;//图像文件工具
CogToolBlock tb; // ToolBlock
public Form1()
{
InitializeComponent();
mFTool = new CogImageFileTool();
mFTool.Operator.Open("coins.idb",CogImageFileModeConstants.Read);//图像来源
tb = CogSerializer.LoadObjectFromFile("TB.VPP") as CogToolBlock;//设置Vpp文件
tb.Inputs["FilterLowValue"].Value = 5050;//设置输入参数
tb.Inputs["FilterHighValue"].Value = 8050;
tb.Ran += tb_Ran; //获取结果
}
private void tb_Ran(object sender, EventArgs e)
{
//throw new NotImplementedException();
lbresult.Text = tb.Outputs["InspectionPassed"].Value.ToString();
//toolblock 工具里面的结果
CogBlobTool mBTool = tb.Tools["CogBlobTool1"] as CogBlobTool;
lbcount.Text = mBTool.Results.GetBlobs().Count.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void btnone_Click(object sender, EventArgs e)
{
mFTool.Run();//获取下一张图像
tb.Inputs["Image"].Value = mFTool.OutputImage as CogImage8Grey;//设置图形
//更换图片
tb.Run();
}
}
}