C# C语言中基于IronOCR的光学字符识别#
我正在学习OCR,并试图从背景变化的图像中读取一些文本 我正在使用位图拍摄屏幕截图,然后将其提供给IronOCR以识别图像中的字符C# C语言中基于IronOCR的光学字符识别#,c#,image,bitmap,ocr,screen-capture,C#,Image,Bitmap,Ocr,Screen Capture,我正在学习OCR,并试图从背景变化的图像中读取一些文本 我正在使用位图拍摄屏幕截图,然后将其提供给IronOCR以识别图像中的字符 // Selecting the area where I capture the image Rectangle rectangle = new Rectangle(); rectangle.X = 830; rectangle.Y = 980; rectangle.Width = 270; rectangle.Height = 100; Rectangle bo
// Selecting the area where I capture the image
Rectangle rectangle = new Rectangle();
rectangle.X = 830;
rectangle.Y = 980;
rectangle.Width = 270;
rectangle.Height = 100;
Rectangle bounds = rectangle;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
bitmap.SetResolution(500, 500);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
}
// Save the image
bitmap.Save(@"testimages\1.tiff", ImageFormat.Tiff);
}
// Reading the characters
var Ocr = new IronTesseract();
using (var Input = new OcrInput(@"testimages\1.tiff"))
{
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
这是图像的外观:
图像的背景稍有变化,但文本保持不变。可以将文本修改为更可读的字符(例如,代替“--此处的一些文本--”我可以将其更改为“X”)。关于如何提高我的OCR有什么想法吗
我的问题是如何在代码中改进这一点以使OCR更加可靠,在拍摄图像的过程中是否有任何东西可以改进我的结果
最终,我的目标是以至少95%的准确率唯一地确定这是出现的文本
如果我运行这5次,这些是输出:
尝试1:
)3-“§0ME”文本;}特瑞——
p LW hl
尝试2:
:SRR TS
奥阿\
尝试3:
五十、 ;。,Q{SOMEYEXT(]3]
泰
尝试4:
“天哪
尝试5:
N TR
- 2PV N f
using (var Input = new OcrInput(@"testimages\image1.tiff"))
{
Input.EnhanceResolution();
Input.Contrast();
Input.Invert();
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}