Compartilhar via


Tablet PC: Recognition accuracy head to head: InkAnalyzer -vs- RecognizerContext

I’ve blogged about handwriting recognition using the RecognizerContext object and the new InkAnalysis (ships with Windows Vista SDK) API. One of the reasons to use InkAnalysis over RecognizerContext is the fact that using the integrated parsing technology, the ink is normalized (rotated so that it is horizontal) and then sent to the recognizers. This enables greater recognition accuracy.

So let’s take a quick look at how InkAnalyzer and RecognizerContext compare in a side by side comparison sample application. I’ve taken our asynchronous recognition InkAnalysis sample application and added RecognizerContext-based recognition to it so we can compare the results.

Screenshot of actual results:

Example Code:

//

// Basic Ink enabled Windows Forms application with

// handwriting recognition using InkAnalyzer

// Gavin Gear - https://blogs.msdn.com/gavingear

// 09/2006

//

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using Microsoft.Ink; // The managed Tablet PC API

namespace BasicInkApplication

{

    public partial class BasicInkApplication : Form

    {

        // The InkOverlay that we'll attach to our Form

        private InkOverlay inkOverlay;

        private InkAnalyzer inkAnalyzer;

        public BasicInkApplication()

        {

            InitializeComponent();

            // Create an InkOverlay object that's attached to the Form

            this.inkOverlay = new InkOverlay(this);

            // Enable the InkOverlay (default is Enabled == false)

            this.inkOverlay.Enabled = true;

            this.inkOverlay.Stroke += new InkCollectorStrokeEventHandler(inkOverlay_Stroke);

            // Create a new InkAnalyzer

            // - Associate with the InkOverlay's Ink object

            // - Send the Form "this" as the synchronizing object

            this.inkAnalyzer = new InkAnalyzer(this.inkOverlay.Ink, this);

            // Hook up to the InkAnalyzer.ResultsUpdated event

            // in order to be notified when BackgroundAnalyze() finishes

            this.inkAnalyzer.ResultsUpdated += new ResultsUpdatedEventHandler(inkAnalyzer_ResultsUpdated);

            // The InkOverlay needs to be disposed due to unmanaged resources

            // used by the InkOverlay

            this.FormClosing += new FormClosingEventHandler(BasicInkApplication_FormClosing);

        }

        void inkOverlay_Stroke(object sender, InkCollectorStrokeEventArgs e)

        {

            // We have a new stroke, add it to the InkAnalyzer

            this.inkAnalyzer.AddStroke(e.Stroke);

        }

        void BasicInkApplication_FormClosing(object sender, FormClosingEventArgs e)

        {

            this.inkOverlay.Dispose();

            this.inkAnalyzer.Dispose(); // Free the unmanaged resources

        }

        private void buttonRecognize_Click(object sender, EventArgs e)

        {

            // Kick off asynchronous analysis

     this.inkAnalyzer.BackgroundAnalyze();

        }

        void inkAnalyzer_ResultsUpdated(object sender, ResultsUpdatedEventArgs e)

        {

            // Note: Should check: e.Status.Successful == true

            // here to confirm BackgroundAnalyze() was successful

            string InkAnalysisString = this.inkAnalyzer.GetRecognizedString();

            RecognizerContext context = new RecognizerContext();

            context.Strokes = this.inkOverlay.Ink.Strokes;

            RecognitionStatus status = new RecognitionStatus();

            RecognitionResult result = context.Recognize(out status);

            MessageBox.Show(

                "Recognized string from InkAnalyzer:" + Environment.NewLine +

                InkAnalysisString + Environment.NewLine +

                "Recognized string from RecognizerContext:" + Environment.NewLine +

                result.TopString,

                "Recognition results");

            context.Dispose();

        }

    }

}

We can see from this example how using InkAnalysis for handwriting recognition results in better recognition results. It’s one of the many advancements the InkAnalysis offers over prior Tablet PC Platform SDK components.

Stay tuned for more demonstrations of new features and improvements in the InkAnalysis API.

See Ya,

Gavin

Comments

  • Anonymous
    September 14, 2006
    Gavin Gear has been posting articles about how to program for Tablet PCs. His latest article demonstrates