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("读取失败"); } }
public static void Save() { Common.SerializableHelper <MFlexHelper> helper = new Common.SerializableHelper <MFlexHelper>(MFlexHelper.Instance); helper.JsonSerialize(PathDefine.sPathConfigure + "MFlex.json"); if (MFlexHelper.Instance.CodeFunc != string.Empty) { MFlexHelper.Instance.CodeBean = VisionFlow.Load(VisionToolCtrl.sPathVision + MFlexHelper.Instance.CodeFunc); } }
public static bool Load() { if (File.Exists(PathDefine.sPathConfigure + "MFlex.json")) { Common.SerializableHelper <MFlexHelper> helper = new Common.SerializableHelper <MFlexHelper>(); var temp = helper.DeJsonSerialize(PathDefine.sPathConfigure + "MFlex.json"); if (temp != null) { MFlexHelper.Instance = temp; if (MFlexHelper.Instance.CodeFunc != string.Empty) { MFlexHelper.Instance.CodeBean = VisionFlow.Load(VisionToolCtrl.sPathVision + MFlexHelper.Instance.CodeFunc); } return(true); } } return(false); }