Compartir a través de


RecognitionAlternate.ConfidenceAlternates (Propiedad)

Actualización: noviembre 2007

Obtiene la colección de alternativas en la que la alternativa actual se divide en una colección de alternativas menores.

Espacio de nombres:  Microsoft.Ink
Ensamblado:  Microsoft.Ink (en Microsoft.Ink.dll)

Sintaxis

'Declaración
Public ReadOnly Property ConfidenceAlternates As RecognitionAlternates
'Uso
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

Valor de propiedad

Tipo: Microsoft.Ink.RecognitionAlternates
La colección de alternativas en la que la alternativa actual se divide, según los límites del nivel de confianza, en una colección de alternativas.

Comentarios

Se crea la colección de la propiedad ConfidenceAlternates cuando una alternativa se divide en alternativas menores basadas en los límites que existen debido a la ruptura del nivel de confianza. Cada alternativa de la colección está formada por el segmento de reconocimiento adyacente con el mismo nivel de confianza.

Esta propiedad es una alternativa a llamar al método AlternatesWithConstantPropertyValues con su parámetro g establecido en el identificador único global (GUID), ConfidenceLevel. Para obtener más información sobre las propiedades de las alternativas, vea el objeto RecognitionProperty.

Nota

Esta propiedad produce una excepción si el objeto Recognizer que generó el objeto RecognitionAlternate no admite los niveles de confianza.

De los reconocedores de Microsoft®, sólo el Reconocedor de escritura a mano para inglés (EE.UU.) y el Reconocedor de movimiento de Microsoft admiten niveles de confianza. Los reconocedores de terceros pueden admitir o no niveles de confianza.

Ejemplos

En este ejemplo de C# se definen los controladores de eventos de un formulario, ConfidenceAlternatesForm, al que se ha agregado un control ButtontheButton. En el ejemplo se define también un objeto InkCollector, theInkCollector, un objeto RecognizerContext, theRecognizerContext y un objeto RecognitionResult, theRecognitionResult, que se utilizan para recopilar la entradas manuscrita y llevar a cabo el reconocimiento.

El controlador de eventos del evento de carga del formulario crea un recopilador de entrada manuscrita y obtiene un contexto de reconocedor para el idioma inglés (EE.UU.).

El controlador del evento de clic del botón lleva a cabo el reconocimiento de los trazos en el recopilador de entrada manuscrita, divide los trazos según el límite de confianza y colorea los trazos en función de su nivel de confianza.

[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;
}

En este ejemplo de Microsoft Visual Basic® .NET se definen los controladores de eventos de un formulario, ConfidenceAlternatesForm, al que se ha agregado un control ButtontheButton, . En el ejemplo se define también un objeto InkCollector, theInkCollector, un objeto RecognizerContext, theRecognizerContext y un objeto RecognitionResult, theRecognitionResult, que se utilizan para recopilar la entradas manuscrita y llevar a cabo el reconocimiento.

El controlador de eventos del evento de carga del formulario crea un recopilador de entrada manuscrita y obtiene un contexto de reconocedor para el idioma inglés (EE.UU.).

El controlador del evento de clic del botón lleva a cabo el reconocimiento de los trazos en el recopilador de entrada manuscrita, divide los trazos según los límites de confianza y colorea los trazos en función de su nivel de confianza.

[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

Plataformas

Windows Vista

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Información de versión

.NET Framework

Compatible con: 3.0

Vea también

Referencia

RecognitionAlternate (Clase)

RecognitionAlternate (Miembros)

Microsoft.Ink (Espacio de nombres)

RecognitionAlternates

Recognizer

RecognitionAlternate.AlternatesWithConstantPropertyValues

RecognitionAlternate.Confidence

RecognitionAlternate.LineAlternates