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, True)
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, true);
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();
}