Exemplo n.º 1
0
 internal void StartRecognizing(Snapshot snapshot)
 {
     if (snapshot.Keyboard.IsDark)
     {
         return;
     }
     if (Interlocked.CompareExchange(ref RecognizingInProgress, 1, 0) == 1)
     {
         return;
     }
     Task.Run(() =>
     {
         RecognitionResults recognitionResults = new RecognitionResults();
         for (int i = 0; i < snapshot.Keyboard.Count; i++)
         {
             var rl = Recognize(snapshot.Keyboard[i], bot.Database);
             recognitionResults.Keyboard.Add(rl);
             if (rl.Kind == RecognitionLetterKind.Letter)
             {
                 recognitionResults.UsableLetters.Add(rl.Letter.ToUpper()[0]);
             }
         }
         LastRecognitionResults = recognitionResults;
         bot.Vocabulary.StartWordforming(recognitionResults);
         RecognizingInProgress = 0;
     });
 }
Exemplo n.º 2
0
 internal void SaveUnknownSnapshotLettersIntoDatabase(RecognitionResults recognitionResults)
 {
     lock (DatabaseLock)
     {
         foreach (RecognizedLetter letter in recognitionResults.Keyboard.Where(rl => rl.Kind == RecognitionLetterKind.UnknownLetter))
         {
             Database.Add(new LetterSample(letter.SnapshotLetter));
         }
         this.SaveDatabase();
     }
 }