Ejemplo n.º 1
0
        /// <summary>
        /// 创建sample时,将图片路径保存下来
        /// </summary>
        /// <param name="fileNames"></param>
        public void SetFileName(string[] fileNames)
        {
            SampleInfo_list.Clear();
            SampleResult_list.Clear();
            int i = 0;

            foreach (string item in fileNames)
            {
                SampleInfo_list.Add(new VModel()
                {
                    Index = i, FileName = item
                });
                SampleResult_list.Add(new ResultInspection {
                    ImagePath = item
                });
                ++i;
            }
        }
Ejemplo n.º 2
0
        /// <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;
            }
        }