Handwriting Recognition

This section discusses the fundamentals of recognition as it pertains to digital ink in the WPF platform.

The following example shows how to recognize ink using the InkAnalyzer.

Note Note

This sample requires that handwriting recognizers be installed on the system.

Create a new WPF application project in Visual Studio 2005 called InkRecognition. Replace the contents of the Window1.xaml file with the following XAML code. This code renders the application's user interface.

<Window x:Class="InkRecognition.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="InkRecognition" 
    >
  <Canvas Name="theRootCanvas">
    <Border
      Background="White"
      BorderBrush="Black"
      BorderThickness="2"
      Height="300"
      Width="300"
      Canvas.Top="10"
      Canvas.Left="10">
      <InkCanvas Name="theInkCanvas"></InkCanvas>
    </Border>
    <TextBox Name="textBox1"
      Height="25"
      Width="225"
      Canvas.Top="325"
      Canvas.Left="10"></TextBox>
    <Button
      Height="25"
      Width="75"
      Canvas.Top="325"
      Canvas.Left="235"
      Click="buttonClick">Recognize</Button>
  </Canvas>
</Window>

Add a reference to the WPF Ink Analysis assemblies, IAWinFX.dll, IACore.dll, and IALoader.dll, which can be found in \Program Files\Reference Assemblies\Microsoft\Tablet PC\v1.7. Replace the contents of the code behind file with the following code.

Imports System.Windows
Imports System.Windows.Ink

'/ <summary> 
'/ Interaction logic for Window1.xaml 
'/ </summary> 

Namespace InkRecognition

    Class Window1
        Inherits Window


        Public Sub New()
            InitializeComponent()

        End Sub 'New 


        ' Recognizes handwriting by using RecognizerContext 
        Private Sub buttonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim theInkAnalyzer As New InkAnalyzer()

            theInkAnalyzer.AddStrokes(theInkCanvas.Strokes)

            Dim status As AnalysisStatus = theInkAnalyzer.Analyze()

            If status.Successful Then
                textBox1.Text = theInkAnalyzer.GetRecognizedString()
            Else
                MessageBox.Show("Recognition Failed")
            End If 

        End Sub 'buttonClick
    End Class 'Window1 
End Namespace
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft