Hi
Hi Kathleen,
Thank you for contacting support, and we are sorry for your inconvenience.
Your source code seems to be correct and it shouldn’t throw an exception if you are using the latest version of Aspose.OCR for .NET 1.8.0 (as your resource file name suggests). Please provide the error details along with the sample image that is triggering the exception so we could analyze it on our end to provide further assistance in this regard.
Looking forward to your response.
Hi Babar
Hi Kathleen,
Thank you for sharing the sample images.
Unfortunately, we are unable to observe any exception while performing OCR operation on your provided sample while using Aspose.OCR for .NET 1.8.0. The sample test1.bmp returned the perfect results, whereas test2.bmp returned garbage data. Most probable reason for incorrect recognized text for test2.bmp is the font size of the text. Please note, current implementation of Aspose.OCR for .NET API has 90% and more reliability rate with font size 30pts, and reliability decreases with small font sizes. We are working hard on new algortithms for OcrEngine, that upon implementation will yield better results in terms of reliability and performance.
By checking the error message in your provided screenshot, we suspect that you are using an older version of the API. Could you please double check this on your end? In case the problem persists please provide a runnable sample project to reproduce the said exception on our end.
Test code is provided below for reference,
C#
// image document on which OCR is to be performed
string imageFile = (MyDir + “test2.bmp”);
// Initialize OcrEngine
OcrEngine ocr = new OcrEngine();
ocr.Config.NeedRotationCorrection = false;
ocr.Config.UseDefaultDictionaries = true;
// Load Image
ocr.Image = ImageStream.FromFile(imageFile);
// Add language
ocr.Languages.AddLanguage(Language.Load(“english”));
// Output file to store results
TextWriter outPut = new StreamWriter(MyDir+“output.txt”);
// Load the resource file
using (ocr.Resource = new FileStream(resourceFileName, FileMode.Open))
{
try
{
// Process the whole image
if (ocr.Process())
{
outPut.WriteLine(ocr.Text);
Console.WriteLine(ocr.Text);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
outPut.Close();
}
Hi Babar
Hi again,
Thank you for the confirmation on this. Please note, each version of Aspose.OCR for .NET API uses a specific resource file. If you try to use the resource file from any other version of the API then you may experience exception or undesired results. Therefore it is suggested that you should always update resource file when upgrading the API.
Please feel free to write back any time.