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





In This Topic
GetOCRResultText(String) Method
In This Topic
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
public string GetOCRResultText( 
   string OCRResultID
)
public function GetOCRResultText( 
    OCRResultID: String
): String; 
public function GetOCRResultText( 
   OCRResultID : String
) : String;
public: string* GetOCRResultText( 
   string* OCRResultID
) 
public:
String^ GetOCRResultText( 
   String^ OCRResultID
) 

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
string caption = "Example: GetOCRResultText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
    //Set up your prefered parameters for OCR.
    gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
    if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
    {
        //Load the image you want to process.
        GdPictureImaging gdpictureImaging = new GdPictureImaging();
        //The standard open file dialog displays to allow you to select the file.
        int image = gdpictureImaging.CreateGdPictureImageFromFile("");
        if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
            (gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
        {
            //Run the OCR process.
            string resultID = gdpictureOCR.RunOCR();
            if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
            {
                //Check the result.
                string text = gdpictureOCR.GetOCRResultText(resultID);
                if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
                    MessageBox.Show("The OCR result is: \n" + text, caption);
                else
                    MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
            }
            else
            {
                MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
            }
            //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);
        gdpictureImaging.Dispose();
    }
    else
        MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
    gdpictureOCR.ReleaseOCRResults();
}
See Also