void ShowResult(ResultInspection result) { try { bool existed = System.IO.File.Exists(result.ImagePath); if (result.ImagePath == null) { Log.L_I.WriteError("ResultDisplay", "Path null"); return; } if (!System.IO.File.Exists(result.ImagePath)) { Log.L_I.WriteError("ResultDisplay", "Not Exist:" + result.ImagePath); return; } g_UCSingleResult.ClearShapeHalWin(); g_UCSingleResult.LoadLocalImage(result.ImagePath); List <double[]> list = CreatRect1(result); foreach (double[] value in list) { g_UCSingleResult.DispRectangle1(value, 1, "red", "margin"); } } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); } }
void g_UCRecord_DGRecordSelChanged_event(int i) { try { ResultInspection result = ResultInspCell_L[i]; ShowResult(result); } catch (Exception ex) { Log.L_I.WriteError(g_NameClass, ex); } }
void ShowResult_Sample(ResultInspection result, BaseUCDisplayCamera baseUCDisplayCamera) { try { baseUCDisplayCamera.ClearShapeHalWin(); baseUCDisplayCamera.LoadLocalImage(result.ImagePath); if (result.ImagePath != null && System.IO.File.Exists(result.ImagePath)) { List <double[]> list = CreatRect1(result); foreach (double[] value in list) { baseUCDisplayCamera.DispRectangle1(value, 1, "red", "margin"); } } } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); } }
/// <summary> /// 加载本地记录的缺陷,同时初始化界面列表和缺陷列表,包括sample和local的 /// </summary> public void LoadSampleDefect_XML(int sideIndex) { SampleResult_list.Clear(); SampleInfo_list.Clear(); LocalInfo_list.Clear(); LocalResult_list.Clear(); xmlDoc.Load(SampleDefectPath_XML); XmlNode root = xmlDoc.SelectSingleNode("defect_info"); XmlNodeList xnl = root.SelectSingleNode("Side" + sideIndex).ChildNodes; int i = 0; //获得img foreach (XmlNode xn in xnl) { ResultInspection resultInspection = new ResultInspection(); VModel vModel = new VModel(); string imagePath = SampleImagePath + sideIndex + @"\" + i + @".jpg"; resultInspection.ImagePath = vModel.FileName = imagePath; LocalInfo_list.Add(new VModel() { Index = i, FileName = imagePath }); LocalResult_list.Add(new ResultInspection()); SampleInfo_list.Add(vModel); SampleResult_list.Add(resultInspection); //获得defect foreach (XmlNode xn_defect in xn.ChildNodes) { //获取缺陷种类 string kind = ((XmlElement)xn_defect).GetAttribute("kind"); if (kind == "贝壳") { vModel.Shell = true; } else if (kind == "破角") { vModel.Cornor = true; } else if (kind == "凸边") { vModel.Convex = true; } FaultInfo faultInfo = new FaultInfo() { FaultType_E = (FaultType_Enum)Enum.Parse(typeof(FaultType_Enum), kind), PosFalut = new Point2D() }; //获取具体的缺陷参数 foreach (XmlNode xn_data in xn_defect.ChildNodes) { if (xn_data.Name == "Width") { faultInfo.WidthFault = double.Parse(xn_data.InnerText); } if (xn_data.Name == "Depth") { faultInfo.DepthFault = double.Parse(xn_data.InnerText); } if (xn_data.Name == "X") { faultInfo.PosFalut.DblValue1 = double.Parse(xn_data.InnerText); } if (xn_data.Name == "Y") { faultInfo.PosFalut.DblValue2 = double.Parse(xn_data.InnerText); } } resultInspection.SingleFalutInfo_L.Add(faultInfo); } ++i; } }