I am using the standard .net code to OCR the png files, yet the text that is returned, have funny characters in.
Can you please help with a why?
Also the ocrEngine.Process() take like almost a minute to return, which I feel is extremely slow??
Link to my receipts:
https://drive.google.com/open?id=0B9xHMdrYcVo8UjloZG5lVGtYMlE
//// Create an initialize an instance of OcrEngine
OcrEngine ocrEngine = new OcrEngine();
Aspose.OCR.License license = new Aspose.OCR.License();
license.SetLicense("Aspose.OCR.lic");
Stream stream = new MemoryStream(rcImage.Image);
var sb = new StringBuilder();
//If file type is tiff
if (new FileInfo(rcImage.Filename).Extension.ToLower() == ".tif")
{
// Set the OcrEngine.Image property by loading a multipage TIFF from disk, memory or URL
ocrEngine.Image = ImageStream.FromStream(stream, ImageStreamFormat.Tiff);
// Set OcrEngine.ProcessAllPages to true in order to process all pages of TIFF in single run
ocrEngine.ProcessAllPages = true;
// Call OcrEngine.Process method to perform OCR operation
if (ocrEngine.Process())
{
// Retrieve the list of Pages
Page[] pages = ocrEngine.Pages;
// Iterate over the list of Pages
foreach (Page page in pages)
{
// Display the recognized text from each Page
sb.Append(page.PageText);
sb.Append(Environment.NewLine);
sb.Append("-----------------------------------------------------------------------------------");
sb.Append(Environment.NewLine);
}
rcImage.ImageText = sb.ToString();
}
}
else if (new FileInfo(rcImage.Filename).Extension.ToLower() == ".jpg")
{
//if file type is jpeg
ocrEngine.Image = ImageStream.FromStream(stream, ImageStreamFormat.Jpg);
if (ocrEngine.Process())
{
sb.Append(ocrEngine.Text);
sb.Append(Environment.NewLine);
}
rcImage.ImageText = sb.ToString();
}
else if (new FileInfo(rcImage.Filename).Extension.ToLower() == ".png")
{
//if file type is jpeg
ocrEngine.Image = ImageStream.FromStream(stream, ImageStreamFormat.Png);
ocrEngine.Config.AdjustRotation = AdjustRotationMode.Automatic;
//ocrEngine.Config.AdjustUpsideDownRotation = AdjustUpsideDownRotationMode.None;
ocrEngine.Config.DetectTextRegions = true;
ocrEngine.Config.ProcessColoredBackground = false;
ocrEngine.Config.DetectReadingOrder = true;
if (ocrEngine.Process())
{
sb.Append(ocrEngine.Text);
sb.Append(Environment.NewLine);
}
rcImage.ImageText = sb.ToString();
}
else
{
rcImage.ImageText = "Build in OCR support for file type " + new FileInfo(rcImage.Filename).Extension.ToLower();
}