Beispiel #1
0
        public void ReadXml(XmlReader r)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                switch (r.Name)
                {
                case "SimilarityThreshold":
                    SimilarityThreshold = double.Parse(r.ReadElementContentAsString(), CultureInfo.InvariantCulture);
                    break;

                case "TemplateUpdateThreshold":
                    TemplateUpdateThreshold = double.Parse(r.ReadElementContentAsString(), CultureInfo.InvariantCulture);
                    break;

                case "SearchWindow":
                    if (r.MoveToAttribute("unit"))
                    {
                        SearchWindowUnit = (TrackerParameterUnit)Enum.Parse(typeof(TrackerParameterUnit), r.ReadContentAsString());
                    }

                    r.ReadStartElement();
                    SearchWindow = XmlHelper.ParseSize(r.ReadContentAsString());
                    r.ReadEndElement();
                    break;

                case "BlockWindow":
                    if (r.MoveToAttribute("unit"))
                    {
                        BlockWindowUnit = (TrackerParameterUnit)Enum.Parse(typeof(TrackerParameterUnit), r.ReadContentAsString());
                    }

                    r.ReadStartElement();
                    BlockWindow = XmlHelper.ParseSize(r.ReadContentAsString());
                    r.ReadEndElement();
                    break;

                case "RefinementNeighborhood":
                    RefinementNeighborhood = int.Parse(r.ReadElementContentAsString(), CultureInfo.InvariantCulture);
                    break;

                case "ResetOnMove":
                    ResetOnMove = XmlHelper.ParseBoolean(r.ReadElementContentAsString());
                    break;

                default:
                    string outerXml = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in XML: {0}", outerXml);
                    break;
                }
            }

            r.ReadEndElement();

            SimilarityThreshold     = Math.Min(1.0, SimilarityThreshold);
            TemplateUpdateThreshold = Math.Min(1.0, TemplateUpdateThreshold);

            if (BlockWindow.Width >= SearchWindow.Width || BlockWindow.Height >= SearchWindow.Height)
            {
                BlockWindow = new Size(SearchWindow.Width / 2, SearchWindow.Height / 2);
            }
        }