This documentation is archived and is not being maintained.

RecognitionResult.TopConfidence Property

Gets the confidence level of the TopAlternate property of the RecognitionResult object.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

public RecognitionConfidence TopConfidence { get; }

Property Value

Type: Microsoft.Ink.RecognitionConfidence
The confidence level of the TopAlternate property of the RecognitionResult object.

Of the Microsoft® recognizer, only the Microsoft English (US) Handwriting Recognizer and the Microsoft Gesture Recognizer support confidence levels. Third party recognizers may or may not support confidence levels.

In this example, synchronous recognition is handled in response to a user action such as clicking on a menu item or a button. First, the Strokes collection of a RecognizerContext object is assigned from the Strokes collection associated with an InkOverlay object, and checked for stroke count. If the Strokes collection contains at least one Stroke object, the recognition process begins with a call to the Recognize method. If recognition is successful and the TopConfidence (if supported) does not equal RecognitionConfidencePoor (i.e. it is Intermediate or Strong), the TopString is displayed by adding it to a list box.

// assign strokes collection from the collected strokes 
this.mRecognizerContext.Strokes = this.mInkOverlay.Ink.Strokes;
// check stroke count. Recognize() will throw exception if no strokes 
if (this.mRecognizerContext.Strokes.Count > 0)
{
    RecognitionStatus status;
    // perform the recognition
    RecognitionResult rResult = this.mRecognizerContext.Recognize(out status);
    // see if the recognizer used supports confidence levels 
    bool rSupportsConfidence = RecognizerSupportsConfidence(mRecognizerContext.Recognizer);
    // check status and TopConfidence (if supported) 
    if (RecognitionStatus.NoError == status &&
        ((rSupportsConfidence &&
         rResult.TopConfidence != RecognitionConfidence.Poor) ||
         !rSupportsConfidence))
    {
        listBoxRecognitionResults.Items.Add(rResult.TopString);
    }
}

The following example shows the helper method used to determine if the Recognizer supports confidence levels.

private bool RecognizerSupportsConfidence(Recognizer pRecognizer)
{
    foreach (Guid G in pRecognizer.SupportedProperties)
    {
        if (G == RecognitionProperty.ConfidenceLevel)
        {
            return true;
        }
    }
    return false;
}

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0
Show: