Compartilhar via


Recognize Method

Recognize Method

Performs recognition on an InkStrokes collection and returns recognition results.

Declaration

[C++]

HRESULT Recognize(
    [in, out] InkRecognitionStatus* recognitionStatus,
    [out, retval] IInkRecognitionResult **RecognitionResult
);

[Microsoft® Visual Basic® 6.0]

Public Function Recognize( _
    recognitionStatus As InkRecognitionStatus _
) As IInkRecognitionResult

Parameters

recognitionStatus

[in, out] The most recent InkRecognitionStatus value.

RecognitionResult

[out] Returns the IInkRecognitionResult results of a recognized collection of strokes or returns NULL (Nothing in Visual Basic 6.0) if the recognizer could not compute a result for the ink.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
E_UNEXPECTED Unexpected parameter or property type.
E_INK_EXCEPTION An exception occurred inside the method.
E_OUTOFMEMORY Cannot allocate memory operation.

Remarks

This method performs recognition synchronously. To start background or asynchronous recognition, call the BackgroundRecognize or BackgroundRecognizeWithAlternates methods.

You must use a try/catch block when calling Recognize because an exception is thrown when the InkDisp object contains no strokes or only deleted strokes.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example shows a button handler that recognizes the ink in its InkRecognizerContext, and displays it in a text box if no errors occurred.

Option Explicit
Dim theInkCollector As InkCollector
Dim theRecognizerContext As New InkRecognizerContext

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
End Sub

Private Sub Command1_Click()
    Set theRecognizerContext.Strokes = theInkCollector.Ink.Strokes
    theRecognizerContext.EndInkInput
    Dim theRecognitionStatus As InkRecognitionStatus
    Dim theRecognitionResult As IInkRecognitionResult
    On Error Resume Next
    Set theRecognitionResult = theRecognizerContext.Recognize(theRecognitionStatus)
    If Err.Number <> 0 Then
        Text1.Text = "Recognize failed: " & Err.Description
    Else
        If InkRecognitionStatus.IRS_NoError = theRecognitionStatus Then
            Text1.Text = theRecognitionResult.TopString
        Else
            'Handle the error conditions here.
            Text1.Text = ""
        End If
    End If
End Sub

Applies To