我尝试使用 C# 通过 Tesseract 从位图(捕获屏幕)读取文本,但结果是错误的单词语言。我的代码:
Class TesseractApi{
public static auto_login.text_rect get_all_text(Bitmap bitmp = null)
{
Bitmap bmp;
if (bitmp != null)
bmp = bitmp;
else bmp = ScreenShot.Capture();
auto_login.text_rect results = new auto_login.text_rect();
Tesseract.PageIteratorLevel myLevel = PageIteratorLevel.TextLine;
using (var img = PixConverter.ToPix(bmp))
{
using (var page = engine.Process(img))
{
using (var iter = page.GetIterator())
{
iter.Begin();
do
{
if (iter.TryGetBoundingBox(myLevel, out var rect))
{
var curText = iter.GetText(myLevel).ToLower();
results.Add(new auto_login.text_rect()
{
text = curText,
x = rect.X1,
y = rect.Y1
});
}
} while (iter.Next(myLevel));
//iter.Dispose();
//page.Dispose();
img.Dispose();
bmp.Dispose();
}
}
}
return results;
}
}
打电话...
Bitmap bmp = new Bitmap("test/screen.png");
text_rect text_arg = TesseractApi.get_all_text(bmp);
结果:
安然
1.
1.
l ' ' 1”: ,_ c.
wm63mm,""mm, , y
almweunnswwnedw!.
(puddellhzslo-ne?aunnel 7
. [傀儡] ns wowed om ' ; ,
quppaqhasmmudchinnnl a 0 / v: ' \ 1mm -
如果 f / - 'j 1' ' ., aurlnoiennovshndwnmum v
. \i 4"毫米'</p>
' ' 我 ',/ \ \ dwnoc-lermwunnmn 我
'他们妈妈我
我想得到单词“ WAVE ”,并得到位置绑定
见图片字“ WAVE ”
我的代码有什么问题