private void bRead_Click(object sender, EventArgs e) { try { if (this.cbCodeList.Text != string.Empty) { if (GetImage == null || GetRoi == null) { MessageBox.Show("请先打开相机界面!!!"); return; } using (VisionFlow flow = VisionFlow.Load(VisionToolCtrl.sPathVision + this.cbCodeList.Text)) { var image = GetImage?.Invoke(); var roi = GetRoi?.Invoke(); if (roi == null || roi.Count == 0 || !(roi[0].Shape is RectangleContour)) { MessageBox.Show("请在相机界面中绘制读取框!!!"); return; } var rtn = flow.Detect(image, roi[0].Shape); this.tbBarcode.Text = rtn.BarCode; } } } catch { MessageBox.Show("读取失败"); } }