예제 #1
0
        private void FrmMain_Shown(object sender, EventArgs e)
        {
            this.list = Ptma.LoadFromPath("config.xml");
            for (int i = 0; i < list.Count; i++)
            {
                TrainedTemplate trainedTemplate = new TrainedTemplate();
                trainedTemplate.templateImage = Cv2.ImRead(list[i].imageSrc, OpenCvSharp.LoadMode.Color);

                SURF featureDetector = new SURF();
                //获取模板图的特征点
                KeyPoint[] templateKeyPoints = featureDetector.Detect(trainedTemplate.templateImage);
                //提取模板图的特征点
                Mat  templateDescriptors = new Mat(trainedTemplate.templateImage.Rows, trainedTemplate.templateImage.Cols, trainedTemplate.templateImage.Type());
                SURF descriptorExtractor = new SURF();
                descriptorExtractor.Compute(trainedTemplate.templateImage, ref templateKeyPoints, templateDescriptors);
                trainedTemplate.templateDescriptors = templateDescriptors;
                trainedTemplate.templateKeyPoints   = templateKeyPoints;
                this.toolList.Add(trainedTemplate);
            }
            this.dgvMain.DataSource = this.list;

            Thread bgThread = new Thread(CaptureAndAnalyse);

            bgThread.IsBackground = true;
            bgThread.Start();
        }
예제 #2
0
파일: Ptma.cs 프로젝트: schifflee/YYSTool
        public static List <Ptma> LoadFromXML(String xmlDoc)
        {
            List <Ptma> list = new List <Ptma>();
            XmlDocument xml  = new XmlDocument();

            xml.LoadXml(xmlDoc);
            XmlNodeList ptmaNodesList = xml.SelectNodes("list/pmat");

            foreach (XmlNode node in ptmaNodesList)
            {
                Ptma obj = new Ptma();
                obj.name     = node.Attributes["name"].Value;
                obj.text     = node.Attributes["text"].Value;
                obj.image    = MakeThumbnail(node.Attributes["image"].Value, 40, 40, "H");
                obj.imageSrc = node.Attributes["image"].Value;
                obj.enable   = int.Parse(node.Attributes["enable"].Value);
                obj._dx      = int.Parse(node.Attributes["_dx"].Value);
                obj._dy      = int.Parse(node.Attributes["_dy"].Value);
                obj.dx       = int.Parse(node.Attributes["dx"].Value);
                obj.dy       = int.Parse(node.Attributes["dy"].Value);
                obj.opt      = Properties.Resources.start_40;
                list.Add(obj);
            }
            return(list);
        }