Compartir a través de


Reconocimiento de entradas manuscritas

En esta sección se tratan los principios de reconocimiento relativos a la entrada de lápiz digital en la plataforma WPF.

Soluciones de reconocimiento

En el ejemplo siguiente se muestra cómo reconocer la entrada de lápiz usando InkAnalyzer.

NotaNota

En este ejemplo se requiere que los reconocedores de escritura a mano estén instalados en el sistema.

Cree un nuevo proyecto de aplicación de WPF en Visual Studio 2005 denominado InkRecognition. Reemplace el contenido del archivo Window1.xaml por el siguiente código XAML: Este código representa la interfaz de usuario de la aplicación.

<Window x:Class="InkRecognition.Window1"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://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>

Agregue una referencia a los ensamblados de análisis de entrada de lápiz de WPF IAWinFX.dll, IACore.dll e IALoader.dll, que se encuentran en \Archivos de programa\Reference Assemblies\Microsoft\Tablet PC\v1.7. Reemplace el contenido del archivo de código subyacente por el código siguiente:

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

using System.Windows;
using System.Windows.Ink;

namespace InkRecognition
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>

    public partial class Window1 : Window
    {

        public Window1()
        {
            InitializeComponent();
        }

        // Recognizes handwriting by using RecognizerContext
        private void buttonClick(object sender, RoutedEventArgs e)
        {
            InkAnalyzer theInkAnalyzer = new InkAnalyzer();

            theInkAnalyzer.AddStrokes(theInkCanvas.Strokes);

            AnalysisStatus status = theInkAnalyzer.Analyze();

            if (status.Successful)
            {
                textBox1.Text = theInkAnalyzer.GetRecognizedString();
            }
            else
            {
                MessageBox.Show("Recognition Failed");
            }
        }

    }
}

Vea también

Referencia

InkAnalyzer

AnalysisStatus

InkCanvas