【发布时间】:2021-04-23 10:52:07
【问题描述】:
我正在学习 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 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);
}
图像如下所示: IMAGE
图片的背景略有变化,但文字保持不变。可以将文本修改为更易读的字符(例如,代替“--SOME TEXT HERE --”,我可以将其更改为“X X X X X X X X X X”)。关于如何改进 OCR 的任何想法?
我的问题是如何在代码中改进这一点,以使 OCR 更可靠,在捕获图像过程中是否有任何东西可以改进我的结果?
最终,我的目标是至少以 95% 的准确率唯一确定这是出现的文本。
如果我运行 5 次,这些是输出:
尝试 1:
) 3-'§0ME'TEXT;}TERE --;
P LW hl
尝试 2:
:SRR TS o'一个\
尝试 3:
L;.,Q{SOMEYEXT (]3]
泰
尝试 4:
'GEE UG
尝试 5:
NTR
- 2PV N f
【问题讨论】:
标签: c# image bitmap ocr screen-capture