Hi. I am getting an Out Of Memory Exception. I have downloaded the latest version ocr .net.
How do I solve this exception? Thank you!
Image 2.jpg (703.6 KB)
My Code:
OCR_MEMORY_TEST.zip (12.5 KB)
using Aspose.OCR;
using Aspose.OCR.Filters;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OCR_MEMORY_TEST
{
public partial class Form1 : Form
{
Aspose.OCR.OcrEngine ocrEngine = new Aspose.OCR.OcrEngine();
public Form1()
{
InitializeComponent();
CorrectionFilters filters = new CorrectionFilters();
Filter filter = null;
// Initialize Median filter
filter = new MedianFilter(5);
filters.Add(filter);
// Create Gaussian Blur filter
filter = new GaussBlurFilter();
filters.Add(filter);
ocrEngine.Config.ProcessColoredBackground = false;
ocrEngine.Config.DoSpellingCorrection = false;
ocrEngine.Config.DetectTextRegions = false;
ocrEngine.Config.CorrectionFilters = filters;
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = !timer1.Enabled;
if (timer1.Enabled)
button1.Text = "Stop";
else
button1.Text = "Start";
}
private void ocr()
{
ocrEngine.Image = ImageStream.FromFile("Code.bmp");
if (ocrEngine.Process())
{
label1.Text = DateTime.Now.ToString("HH:mm:ss") + "-" + ocrEngine.Text.ToString();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
ocr();
}
}
}