Exemplo n.º 1
0
        public void Run(Sketch originalSketch)
        {
            //
            Sketch     transformedSketch = Normalize(originalSketch);
            SketchPair input             = new SketchPair(originalSketch, transformedSketch);

            //
            List <Tuple <string, double> > results = new List <Tuple <string, double> >();

            foreach (SketchPair template in myTemplates)
            {
                double distance1 = SketchTools.Distance(input.Transformed, template.Transformed);
                double distance2 = SketchTools.Distance(input.Transformed, template.Transformed);
                double distance  = ToScore(Math.Min(distance1, distance2));

                results.Add(new Tuple <string, double>(template.Transformed.Label, distance));
            }
            results.Sort((x, y) => y.Item2.CompareTo(x.Item2));

            //
            myLabels = new List <string>();
            myScores = new List <double>();
            for (int i = 0; i < results.Count; ++i)
            {
                string label = results[i].Item1;
                double score = results[i].Item2;

                myLabels.Add(label);
                myScores.Add(score);
            }
        }
Exemplo n.º 2
0
        public void Train(List <Sketch> originalSketches, List <Sketch> transformedSketches)
        {
            myTemplates = new List <SketchPair>();

            for (int i = 0; i < originalSketches.Count; ++i)
            {
                SketchPair template = new SketchPair(originalSketches[i], transformedSketches[i]);
                myTemplates.Add(template);
            }
        }