Extracting text from an image

Hi,

Could you please help me in extracting text from an image file?
This message was posted using Email2Forum by Babar Raza.

Hi Hunaid,

Thank you for considering Aspose products.

We would request you to please go through the below linked detailed article on this subject.

For a brief introduction, Aspose.OCR for .NET requires a resource file as well as reference of Aspose.OCR.dll in the project. Once the environment is set, you can use the below provided code snippet to extract text from a given image. Please note, you have to change the file path locations according to your file system.

C#

// Resource file
const string resourceFileName = “C:/Users/Babar Raza/Downloads/Aspose.OCR.Resources.zip”;
// Source file: the file on which OCR will be performed
string imageFile = “D:/temp/sample.jpg”;
Console.WriteLine("Performing OCR on " + imageFile + “…”);

// Initialize OcrEngine
OcrEngine ocr = new OcrEngine();
// Set the image
ocr.Image = ImageStream.FromFile(imageFile);

// Add language
ocr.Languages.AddLanguage(Language.Load(“english”));

// Load the resource file
using (ocr.Resource = new FileStream(resourceFileName, FileMode.Open))
{
try
{
// Process the whole image
if (ocr.Process())
{
// Get the complete recognized text found from the image
Console.WriteLine(“Text recognized./n” + ocr.Text);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
}

In case you face any difficulty, please feel free to write back anytime.

Hi,

Please find the rar file along with this as attachment the rar file has image inside it.

For checking purpose,i have given an image file,it does not read the text from it

it gave unexpected results

Does this reads any font?

Thanks & Regards,

S.N.Prasad

Hi Prasad,


Thank you for providing your sample image.

By checking the sample, we have noticed two possible reasons for unexpected recognition results. First, the supplied image has low resolution whereas the current implementation of Aspose.OCR APIs requires images of at least 300 DPI resolution. Secondly, the font used to render the text in the supplied image may not be supported. Please note, the support fonts at the moment are Arial, Times New Roman, Calibri, Verdana, Tahoma & Courier New. We are working to identify the exact font used for rendering the text so we may log appropriate ticket in our database to support the font with future releases of Aspose.OCR APIs. If you have created this image yourself, please provide the details of this font.