Beispiel #1
0
        public string Recognize()
        {
            using (MemoryStream ms = new MemoryStream()) {
                // Build an inkCollector containing the strokes
                canvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext context = recognizer.CreateRecognizerContext()) {
                    RecognitionStatus status;
                    context.Factoid = Factoid.WordList; // Magic smoke for name recognition
                    context.Strokes = ink.Strokes;

                    // Cannot do if there are no strokes
                    if (ink.Strokes.Count > 0)
                    {
                        var results = context.Recognize(out status);
                        if (status == RecognitionStatus.NoError)
                        {
                            return(results.ToString());
                        }
                    }
                }
            }

            return("");
        }
Beispiel #2
0
        private void Recognise()
        {
            if (inkCanvas.Strokes.Count == 0)
            {
                tbRecognised.Text = string.Empty;
                return;
            }

            using (MemoryStream ms = new MemoryStream())
            {
                inkCanvas.Strokes.Save(ms);
                var ink = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext context = jpnRecognizer.CreateRecognizerContext())
                {
                    context.Strokes = ink.Strokes;
                    var result = context.Recognize(out var status);
                    if (status == RecognitionStatus.NoError)
                    {
                        tbRecognised.Text = result.TopString;
                    }
                    else
                    {
                        MessageBox.Show("Recognition failed");
                    }
                }
            }
        }
Beispiel #3
0
        private void ink_()
        {
            Recognizers recos       = new Recognizers();
            Recognizer  chineseReco = recos.GetDefaultRecognizer();

            rct = chineseReco.CreateRecognizerContext();
        }
Beispiel #4
0
        private void HandwritingPad_Load(object sender, EventArgs e)
        {
            ic         = new InkCollector(PicInkPad.Handle);
            ic.Enabled = true;
            Recognizers recos       = new Recognizers();
            Recognizer  chineseReco = recos.GetDefaultRecognizer();

            rct         = chineseReco.CreateRecognizerContext();
            rct.Strokes = ic.Ink.Strokes;
        }
Beispiel #5
0
        private void ink_Here()
        {
            Recognizers recos       = new Recognizers();
            Recognizer  chineseReco = recos.GetDefaultRecognizer();

            rct = chineseReco.CreateRecognizerContext();
            rct.RecognitionFlags = Microsoft.Ink.RecognitionModes.WordMode;

            this.rct.RecognitionWithAlternates += new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates);
        }
Beispiel #6
0
        /// <summary>
        /// Sets the recognizer engine used to convert strokes to text.
        /// </summary>
        /// <param name="engineId">The GUID of the recognizer engine.</param>
        /// <exception cref="ArgumentException">
        /// Thrown if the engine is invalid or does not exist.
        /// </exception>
        public void SetEngine(Guid engineId)
        {
            EnsureNotDisposed();
            _recognizerContext?.Dispose();
            Recognizer engineImpl = _recognizers
                                    .Cast <Recognizer>()
                                    .FirstOrDefault(x => x.Id == engineId);

            if (engineImpl == null)
            {
                throw new ArgumentException("Engine not found: " + engineId);
            }
            _recognizerContext = engineImpl.CreateRecognizerContext();
        }