次の方法で共有


手書き認識

更新 : 2007 年 11 月

ここでは、WPF プラットフォームでのデジタル インクに関連した認識の基礎について説明します。

認識ソリューション

InkAnalyzer を使用してインクを認識する方法を次の例に示します。

ms754080.alert_note(ja-jp,VS.90).gifメモ :

このサンプルでは、手書き認識エンジンをシステムにインストールする必要があります。

Visual Studio 2005 で、InkRecognition という新しい WPF アプリケーション プロジェクトを作成します。Window1.xaml ファイルの内容を次の XAML コードに置き換えます。このコードは、アプリケーションのユーザー インターフェイスを表示します。

<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>

WPF インク分析アセンブリ (IAWinFX.dll、IACore.dll、および IALoader.dll) への参照を追加します。これらのファイルは、\Program Files\Reference Assemblies\Microsoft\Tablet PC\v1.7 にあります。この分離コード ファイルの内容を次のコードに置き換えます。

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");
            }
        }

    }
}

参照

参照

InkAnalyzer

AnalysisStatus

InkCanvas