다음을 통해 공유


RecognitionAlternate.ConfidenceAlternates 속성

업데이트: 2007년 11월

현재 대체 항목이 더 작은 대체 항목 컬렉션으로 분할된 위치의 대체 항목 컬렉션을 가져옵니다.

네임스페이스:  Microsoft.Ink
어셈블리:  Microsoft.Ink(Microsoft.Ink.dll)

구문

‘선언
Public ReadOnly Property ConfidenceAlternates As RecognitionAlternates
‘사용 방법
Dim instance As RecognitionAlternate
Dim value As RecognitionAlternates

value = instance.ConfidenceAlternates
public RecognitionAlternates ConfidenceAlternates { get; }
public:
property RecognitionAlternates^ ConfidenceAlternates {
    RecognitionAlternates^ get ();
}
/** @property */
public RecognitionAlternates get_ConfidenceAlternates()
public function get ConfidenceAlternates () : RecognitionAlternates

속성 값

형식: Microsoft.Ink.RecognitionAlternates
현재 대체 항목이 신뢰 수준 경계에 따라 대체 항목 컬렉션으로 분할된 위치의 대체 항목 컬렉션입니다.

설명

신뢰 수준으로 나뉜 경계에 따라 대체 항목이 더 작은 대체 항목으로 분할되면 ConfidenceAlternates 속성에 컬렉션이 만들어집니다. 이 컬렉션의 각 대체 항목은 신뢰 수준이 동일한 인접 인식 세그먼트로 구성됩니다.

g 매개 변수를 GUID(Globally Unique Identifier)인 ConfidenceLevel로 설정하여 AlternatesWithConstantPropertyValues 메서드를 호출하는 대신 이 속성을 사용할 수 있습니다. 대체 항목의 속성에 대한 자세한 내용은 RecognitionProperty 개체를 참조하십시오.

참고

RecognitionAlternate를 생성한 Recognizer에서 신뢰 수준을 지원하지 않으면 이 속성은 예외를 throw합니다.

Microsoft® 인식기 중 Microsoft English (US) Handwriting Recognizer 및 Microsoft Gesture Recognizer에서만 신뢰 수준을 지원합니다. 타사 인식기에서는 신뢰 수준을 지원하지 않을 수도 있습니다.

예제

이 C# 예제에서는 Button 컨트롤인 theButton이 추가된 ConfidenceAlternatesForm이라는 폼에 이벤트 처리기를 정의합니다. 또한 잉크를 수집하고 인식을 수행하는 데 사용되는 theInkCollector라는 InkCollector, theRecognizerContext라는 RecognizerContext 및 theRecognitionResult라는 RecognitionResult를 정의합니다.

폼의 로드 이벤트에 대한 이벤트 처리기에서는 잉크 수집기를 만들고 영어(US) 언어에 대한 인식기 컨텍스트를 가져옵니다.

단추의 클릭 이벤트에 대한 이벤트 처리기는 잉크 수집기의 스트로크에 대해 인식을 수행하고 신뢰 경계에 따라 스트로크를 나눈 다음 신뢰 수준에 따라 스트로크에 색을 입힙니다.

[C#]

// Declare ink elements and create drawing attributes.
Microsoft.Ink.InkCollector theInkCollector = null;
Microsoft.Ink.RecognizerContext theRecognizerContext = null;
Microsoft.Ink.RecognitionResult theRecognitionResult = null;

Microsoft.Ink.DrawingAttributes theStrongDA =
    new DrawingAttributes(Color.Green);
Microsoft.Ink.DrawingAttributes theIntermediateDA =
    new DrawingAttributes(Color.Goldenrod);
Microsoft.Ink.DrawingAttributes thePoorDA =
    new DrawingAttributes(Color.Red);

// Event handler for the form's Load event.
private void ConfidenceAlternatesForm_Load(object sender, System.EventArgs e)
{
    // Create the ink collector.
    this.theInkCollector = new Microsoft.Ink.InkCollector(this.Handle);
    this.theInkCollector.Enabled = true;

    // Get a recognizer context for the English (US) recognizer.
    foreach (Recognizer theRecognizer in new Recognizers())
    {
        foreach (short lcid in theRecognizer.Languages)
        {
            // 0409 is the LCID for the en-us language.
            if (0x0409 == lcid)
            {
                this.theRecognizerContext = theRecognizer.CreateRecognizerContext();
                break;
            }
        }
        if (null != theRecognizerContext)
        {
            break;
        }
    }
    // Throw an exception if the recognizer is not found.
    if (null == theRecognizerContext)
    {
        throw new ApplicationException("No recognizer found");
    }
}

// Event handler for the button's Click event.
private void theButton_Click(object sender, System.EventArgs e)
{
    // Check for ink before performing recognition.
    if (0 == this.theInkCollector.Ink.Strokes.Count)
    {
        System.Windows.Forms.MessageBox.Show("No ink to recognize.");
        return;
    }

    // Perform recognition on the strokes currently in the ink collector.
    Microsoft.Ink.RecognitionStatus theRecognitionStatus;
    this.theRecognizerContext.Strokes = this.theInkCollector.Ink.Strokes;
    this.theRecognitionResult =
        this.theRecognizerContext.Recognize(out theRecognitionStatus);

    // Check the recognition status.
    if (Microsoft.Ink.RecognitionStatus.NoError != theRecognitionStatus)
    {
        System.Windows.Forms.MessageBox.Show(
            "There was an error recognizing the ink.");
        return;
    }

    // Check for a recognition result.
    if (null == this.theRecognitionResult)
    {
        System.Windows.Forms.MessageBox.Show(
            "No recognition result available.");
        return;
    }

    // Get the confidence alternates collection for the top alternate.
    Microsoft.Ink.RecognitionAlternates theConfidenceAlternates =
        this.theRecognitionResult.TopAlternate.ConfidenceAlternates;

    using (System.Drawing.Graphics g = this.CreateGraphics())
    {
        // Clear the drawing surface
        g.Clear(this.BackColor);

        // For each confidence alternate in the collection:
        foreach(Microsoft.Ink.RecognitionAlternate theAlternate
                    in theConfidenceAlternates)
        {
            // Update the drawing attributes.
            switch (theAlternate.Confidence)
            {
                case Microsoft.Ink.RecognitionConfidence.Strong:
                    theAlternate.Strokes.ModifyDrawingAttributes(
                        theStrongDA);
                    break;
                case Microsoft.Ink.RecognitionConfidence.Intermediate:
                    theAlternate.Strokes.ModifyDrawingAttributes(
                        theIntermediateDA);
                    break;
                case Microsoft.Ink.RecognitionConfidence.Poor:
                    theAlternate.Strokes.ModifyDrawingAttributes(
                        thePoorDA);
                    break;
            }
        }
        // Redraw the ink.
        this.theInkCollector.Renderer.Draw(g, this.theRecognitionResult.Strokes);
    }
}

// Event handler for the form's Closed event.
private void ConfidenceAlternatesForm_Closed(object sender, System.EventArgs e)
{
    // Free the resources for the ink collector, recognizer context, and pens.
    this.theInkCollector.Dispose();
    this.theInkCollector = null;
    this.theRecognizerContext.Dispose();
    this.theRecognizerContext = null;
}

이 Microsoft Visual Basic® .NET 예제에서는 Button 컨트롤인 theButton이 추가된 ConfidenceAlternatesForm이라는 폼에 이벤트 처리기를 정의합니다. 또한 잉크를 수집하고 인식을 수행하는 데 사용되는 theInkCollector라는 InkCollector, theRecognizerContext라는 RecognizerContext 및 theRecognitionResult라는 RecognitionResult를 정의합니다.

폼의 로드 이벤트에 대한 이벤트 처리기에서는 잉크 수집기를 만들고 영어(US) 언어에 대한 인식기 컨텍스트를 가져옵니다.

단추의 클릭 이벤트에 대한 이벤트 처리기는 잉크 수집기의 스트로크에 대해 인식을 수행하고 신뢰 경계에 따라 스트로크를 나눈 다음 신뢰 수준에 따라 스트로크에 색을 입힙니다.

[Visual Basic]

' Declare ink elements and create drawing attributes.
Dim theInkCollector As Microsoft.Ink.InkCollector
Dim theRecognizerContext As Microsoft.Ink.RecognizerContext
Dim theRecognitionResult As Microsoft.Ink.RecognitionResult

Dim theStrongDA As Microsoft.Ink.DrawingAttributes = New DrawingAttributes(Color.Green)
Dim theIntermediateDA As Microsoft.Ink.DrawingAttributes = New DrawingAttributes(Color.Goldenrod)
Dim thePoorDA As Microsoft.Ink.DrawingAttributes = New DrawingAttributes(Color.Red)

' Event handler for the form's Load event.
Private Sub ConfidenceAlternatesForm_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

    ' Create the ink collector.
    Me.theInkCollector = New Microsoft.Ink.InkCollector(Me.Handle)
    Me.theInkCollector.Enabled = True

    ' Get a recognizer context for the English (US) recognizer.
    For Each theRecognizer As Recognizer In New Recognizers
        For Each lcid As Short In theRecognizer.Languages
            ' 0409 is the LCID for the en-us language.
            If &H409 = lcid Then
                Me.theRecognizerContext = theRecognizer.CreateRecognizerContext()
                Exit For
            End If
        Next
        If Not (theRecognizerContext Is Nothing) Then
            Exit For
        End If
    Next
    ' Throw an exception if the recognizer is not found.
    If theRecognizerContext Is Nothing Then
        Throw New ApplicationException("No recognizer found")
    End If
End Sub

' Event handler for the "Recognize" button's Click event.
Private Sub theButton_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles theButton.Click

    ' Check for ink before performing recognition.
    If Me.theInkCollector.Ink.Strokes.Count = 0 Then
        System.Windows.Forms.MessageBox.Show("No ink to recognize.")
        Return
    End If

    ' Perform recognition on the strokes currently in the ink collector.
    Dim theRecognitionStatus As Microsoft.Ink.RecognitionStatus
    Me.theRecognizerContext.Strokes = Me.theInkCollector.Ink.Strokes
    Me.theRecognitionResult = _
        Me.theRecognizerContext.Recognize(theRecognitionStatus)

    ' Check for a recognition result.
    If (Me.theRecognitionResult Is Nothing) Then
        System.Windows.Forms.MessageBox.Show("No recognition result available.")
        Return
    End If

    ' Get the confidence alternates collection for the top alternate.
    Dim theConfidenceAlternates As Microsoft.Ink.RecognitionAlternates = _
        Me.theRecognitionResult.TopAlternate.ConfidenceAlternates

    ' Create a temporary graphics object.
    Dim g As System.Drawing.Graphics = Me.CreateGraphics()

    ' Clear the drawing surface
    g.Clear(Me.BackColor)

    ' For each confidence alternate in the collection:
    For Each theAlternate As Microsoft.Ink.RecognitionAlternate _
                In theConfidenceAlternates

        ' Update the drawing attributes.
        Select Case theAlternate.Confidence
            Case RecognitionConfidence.Strong
                theAlternate.Strokes.ModifyDrawingAttributes(theStrongDA)
            Case RecognitionConfidence.Intermediate
                theAlternate.Strokes.ModifyDrawingAttributes(theIntermediateDA)
            Case RecognitionConfidence.Poor
                theAlternate.Strokes.ModifyDrawingAttributes(thePoorDA)
        End Select
    Next

    ' Redraw the ink.
    Me.theInkCollector.Renderer.Draw(g, Me.theRecognitionResult.Strokes)

    ' Dispose of the graphics object.
    g.Dispose()
End Sub

' Event handler for the form's Closed event.
Private Sub ConfidenceAlternatesForm_Closed(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Closed

    ' Free the resources for the ink collector and recognizer context.
    Me.theInkCollector.Dispose()
    Me.theInkCollector = Nothing
    Me.theRecognizerContext.Dispose()
    Me.theRecognizerContext = Nothing
End Sub

플랫폼

Windows Vista

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

RecognitionAlternate 클래스

RecognitionAlternate 멤버

Microsoft.Ink 네임스페이스

RecognitionAlternates

Recognizer

RecognitionAlternate.AlternatesWithConstantPropertyValues

RecognitionAlternate.Confidence

RecognitionAlternate.LineAlternates