Dim caption As String = "Example: SetROI"
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
'Set up 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
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " & gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Analyze your OCR results using the identifiers "PhoneNumberRegion" And "AddressRegion".
'Continue ...
[error]:
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + 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: SetROI";
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)
{
//Set up 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))
{
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Analyze your OCR results using the identifiers "PhoneNumberRegion" and "AddressRegion".
//Continue ...
error:
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}