Im try read text from bitmap(capture screen) by Tesseract using C#, but result wrong word language. My code:
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;
}
}
Calling...
Bitmap bmp = new Bitmap("test/screen.png");
text_rect text_arg = TesseractApi.get_all_text(bmp);
Result:
anench
1.
1 .
l ‘ ' 1”: ,_ c.
wm63mm,”“mm, , y
almweunnswwnedw! .
(puddellhzslo-ne? aunnel 7
. [puppet] n-s wowed om ' ; ,
quppaqhasmmudchinnnl a 0 / v: ‘ \ 1mm -
if f / - ‘ j 1 ' ‘ ., aurlnoiennovshndwnmum v
. \ i 4 "mm ‘
‘ ‘ i ‘,/ \ \ dwnoc-lermwunnmn i
‘ em mum i
i want get word "WAVE", and get position Bound
see pic word "WAVE"
what is wrong with my code