/// <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 async override void TouchesEnded(Foundation.NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); AddPoint(touches); // Start the recognition var item = recognizer.Recognize(allPoints); string display = string.Format("{0} - {1}, {2}", item.Name, item.Score, item.IndicativeAngleInDegrees); NavigationItem.Prompt = display; UILabel lbl = new UILabel(); lbl.Frame = new CGRect(item.BoundingRectangle.X, item.BoundingRectangle.Y, item.BoundingRectangle.Width, item.BoundingRectangle.Height); lbl.BackgroundColor = UIColor.FromRGBA(0, 0, 255, 100); lbl.Lines = 0; lbl.LineBreakMode = UILineBreakMode.CharacterWrap; lbl.Text = display; Add(lbl); await Task.Delay(4000); await UIView.AnimateAsync(0.4, () => { lbl.Alpha = 0; }); lbl.RemoveFromSuperview(); }
/// <summary> /// Checks this the vectors, and will fail the cast if the vector count is too small. /// </summary> void Check() { SaveList(); print(rawVectors.Count); if (rawVectors.Count >= 40) { player.CastSpell(dollarR.Recognize(rawVectors.ToArray())); } else { player.CastSpell(); } rawVectors = new HashSet <Vector2>(); }
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); }