示例#1
0
        /// <summary>
        /// Construct the training data for the combo recognizer.
        /// </summary>
        /// <param name="testData">the data to test on</param>
        /// <param name="rubine">the rubine recognizer</param>
        /// <param name="dollar">the dollar recognizer</param>
        /// <param name="zernike">the zernike recognizer</param>
        /// <param name="image">the image recognizer</param>
        /// <returns>a list of tuples (s,f) where s is a shape type and f is a set of features</returns>
        private static List <KeyValuePair <ShapeType, Dictionary <string, object> > > TrainingDataCombo(
            List <Shape> testData,
            RubineRecognizerUpdateable rubine,
            DollarRecognizer dollar,
            ZernikeMomentRecognizerUpdateable zernike,
            ImageRecognizer image)
        {
            List <KeyValuePair <ShapeType, Dictionary <string, object> > > data = new List <KeyValuePair <ShapeType, Dictionary <string, object> > >();

            foreach (Shape shape in testData)
            {
                string z = zernike.Recognize(shape.SubstrokesL);

                List <ShapeType> img = image.Recognize(shape.SubstrokesL);

                List <string> r    = new List <string>();
                List <string> dAvg = new List <string>();
                List <string> d    = new List <string>();

                foreach (Substroke s in shape.SubstrokesL)
                {
                    r.Add(rubine.Recognize(s));
                    dAvg.Add(dollar.RecognizeAverage(s));
                    d.Add(dollar.Recognize(s));
                }

                Dictionary <string, object> features = ComboRecognizer.GetFeatures(shape.SubstrokesL.Count, z, img, r, dAvg, d);
                data.Add(new KeyValuePair <ShapeType, Dictionary <string, object> >(shape.Type, features));
            }

            return(data);
        }
        public Dictionary <string, object> GetIndRecognitionResults(Shape shape, out double believedOrientation)
        {
            List <Substroke> strokes = shape.SubstrokesL;
            int shapeHash            = shape.GetHashCode();

            int numStrokes = strokes.Count;

            List <string>    DollarAvgResults = new List <string>(numStrokes);
            List <string>    DollarResults    = new List <string>(numStrokes);
            List <string>    RubineResults    = new List <string>(numStrokes);
            List <ShapeType> ImageResults;
            string           ZernikeResult;

            ZernikeResult = _zernike.Recognize(strokes);
            ImageResults  = _image.Recognize(strokes);

            foreach (Substroke s in strokes)
            {
                int    hash = s.Id.GetHashCode();
                string res;

                res = _dollar.RecognizeAverage(s);
                DollarAvgResults.Add(res);

                res = _dollar.Recognize(s);
                DollarResults.Add(res);

                res = _rubine.Recognize(s);
                RubineResults.Add(res);
            }

            Dictionary <string, object> features = GetFeatures(numStrokes, ZernikeResult, ImageResults, RubineResults, DollarAvgResults, DollarResults);

            believedOrientation = 0.0;

            return(features);
        }