private static void DoWork(object data)
        {
            List <Shape> shapes = (List <Shape>)data;

            double        totalscore = 0.0;
            ImageTemplate template1  = new ImageTemplate(shape1, GetShapeParts(shape1), new SymbolInfo(), matrix);

            foreach (Shape shape2 in shapes)
            {
                if (shape1 != shape2)
                {
                    ImageTemplate template2 = new ImageTemplate(shape2, GetShapeParts(shape2), new SymbolInfo(), matrix);
                    totalscore += template1.Recognize(template2).Score;
                }
            }


            m_TotalScore += totalscore;
        }
Exemple #2
0
        private void RecognizeSymbol()
        {
            List <Sketch.Substroke> subs   = new List <Sketch.Substroke>();
            List <Point>            points = new List <Point>();

            foreach (Stroke s in m_InkOverlay.Ink.Strokes)
            {
                subs.Add(m_Sketch.GetSketchSubstrokeByInkId(s.Id));
                foreach (Point pt in s.GetPoints())
                {
                    points.Add(pt);
                }
            }


            //Rectangle bbox = m_InkOverlay.Ink.GetBoundingBox();
            //ImageSymbol complete = new ImageSymbol(points.ToArray(), bbox);
            Dictionary <Sketch.Substroke, GatePart> strokeResults = RecognizeStrokesDollar(subs);
            ImageTemplate unknown = new ImageTemplate(subs);
            string        best    = unknown.Recognize(m_ImageTemplates, strokeResults);

            MessageBox.Show(best);

            foreach (Stroke s in m_InkOverlay.Ink.Strokes)
            {
            }



            /*
             * List<Sketch.Substroke> subs = new List<Sketch.Substroke>();
             * foreach (Stroke s in m_InkOverlay.Ink.Strokes)
             *  subs.Add(m_Sketch.GetSketchSubstrokeByInkId(s.Id));
             *
             * BitmapSymbol unknown = new BitmapSymbol(subs);
             * List<ImageScore> results = unknown.FindBestMatches(m_CompleteSymbols,
             *  10, allowedRotation, rotations);
             * VisualizeSearch vsForm = new VisualizeSearch(unknown, results);
             * vsForm.Show();
             * vsForm.moveChildren();
             *
             * if (results.Count == 0)
             *  return;
             *
             * label1.Text = results[0].SymbolType;
             *
             * Rectangle box = m_InkOverlay.Ink.Strokes.GetBoundingBox();
             *
             * foreach (Sketch.Substroke s in subs)
             * {
             *  BitmapSymbol us = new BitmapSymbol(s, box);
             *  List<ImageScore> rs = us.FindBestMatches(m_PartialSymbols, 10, allowedRotation, rotations);
             *  MessageBox.Show(rs[0].SymbolType);
             *  VisualizeSearch visualizeForm = new VisualizeSearch(us, rs);
             *  visualizeForm.Show();
             *  visualizeForm.moveChildren();
             * }
             */

            m_InkOverlay.Ink.DeleteStrokes();
            this.Refresh();
        }