GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureOCR Class / GetOCRResultText Method / GetOCRResultText(String) Method
A unique result identifier of the executed OCR process obtained by the GdPictureOCR.RunOCR method.
Example





GetOCRResultText(String) Method
Returns the recognized text of the provided OCR result, identifiable by its unique ID, as a formatted string. The empty lines, if recognized, are not provided in the resulting text.
Syntax
'Declaration
 
Public Overloads Function GetOCRResultText( _
   ByVal OCRResultID As String _
) As String
 

Parameters

OCRResultID
A unique result identifier of the executed OCR process obtained by the GdPictureOCR.RunOCR method.

Return Value

The resulting recognized text of the executed OCR process. Please always use the GdPictureOCR.GetStat method to determine if this method has been successful.
Remarks
It is recommend to use the GdPictureOCR.GetStat method to identify the specific reason for the method's failure, if any.

Just to inform you that the resulting text provided by this method doesn't contain any empty lines, if they have been recognized.

Example
How to retrieve the resulting text after processing the OCR.
Dim caption As String = "Example: GetOCRResultText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
    'Set up your prefered parameters for OCR.
    gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
    If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
        'Load the image you want to process.
        Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
        'The standard open file dialog displays to allow you to select the file.
        Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
        If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
           gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
            'Setting up the image is mandatory.
            'Run the OCR process.
            Dim resultID As String = gdpictureOCR.RunOCR()
            If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
                'Check the result.
                Dim text As String = gdpictureOCR.GetOCRResultText(resultID)
                If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
                    MessageBox.Show("The OCR result is: " + vbCrLf + text, caption)
                Else
                    MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
            End If
            'Release the used image.
            gdpictureImaging.ReleaseGdPictureImage(image)
        Else
            MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
        End If
        gdpictureImaging.Dispose()
    Else
        MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
    End If
    gdpictureOCR.ReleaseOCRResults()
End Using
See Also