VisionPro打开相机,实时,关闭实时,图像显示操作
private string path = AppDomain.CurrentDomain.BaseDirectory + "ToolBlock.vpp"; private string path1 = AppDomain.CurrentDomain.BaseDirectory + "CogAcqFifoTool.vpp"; private string path2 = AppDomain.CurrentDomain.BaseDirectory + "CogToolBlockTool.vpp"; private CogToolBlock tb; private CogToolBlock tb1; private CogAcqFifoTool acq; private CogAcqFifoTool acq1; public Form1() { InitializeComponent(); //序列化CogFifoTool 工具 tb = CogSerializer.LoadObjectFromFile(path) as CogToolBlock; //加载到CogToolBlockEdit控件中 cogToolBlockEditV21.Subject = tb; // 转换成取像 acq = tb.Tools[0] as CogAcqFifoTool; } private void button1_Click(object sender, EventArgs e) { acq.Run(); cogRecordDisplay1.Image = acq.OutputImage; cogRecordDisplay1.Fit(); } private void button2_Click(object sender, EventArgs e) { //初始化相机工具 acq1 = CogSerializer.LoadObjectFromFile(path1) as CogAcqFifoTool; acq1.Run(); cogRecordDisplay1.Image = acq1.OutputImage; cogRecordDisplay1.Fit(); } private void btnLive_Click(object sender, EventArgs e) { //相机实时状态 if (cogRecordDisplay1.LiveDisplayRunning) { cogRecordDisplay1.StopLiveDisplay(); btnLive.BackColor = Color.Gray; } else { cogRecordDisplay1.StartLiveDisplay(acq.Operator, true); btnLive.BackColor = Color.Green; } // cogRecordDisplay1.StartLiveDisplay(acq.Operator); } private void btnStop_Click(object sender, EventArgs e) { //关闭实时状态 cogRecordDisplay1.StopLiveDisplay(); } private void button3_Click(object sender, EventArgs e) { acq.Run(); tb1.Inputs["InputImage"].Value = acq.OutputImage; tb1.Run(); cogRecordDisplay1.Record = tb1.CreateLastRunRecord().SubRecords[1]; //显示运行记录 //cogRecordDisplay1.Image = acq.OutputImage; //cogRecordDisplay1.Record = tb1.CreateLastRunRecord(); } private void Form1_Load(object sender, EventArgs e) { tb1 = CogSerializer.LoadObjectFromFile(path2) as CogToolBlock; cogToolBlockEditV22.Subject = tb1; }
不要去跟随消逝的虚无