Added detection of driver positions

This commit is contained in:
2023-04-05 15:53:50 +02:00
parent 41f7913b80
commit 3271580a1e
2 changed files with 24 additions and 2 deletions
+13 -1
View File
@@ -15,7 +15,19 @@ namespace OCR_Decode
} }
public override object DecodePng() public override object DecodePng()
{ {
return 0; string result = GetStringFromPng(true);
int position;
try
{
position = Convert.ToInt32(result);
}
catch
{
position = -1;
WindowImage.Save(Reader.DEBUG_DUMP_FOLDER + "FailedPosition"+".png");
}
return position;
} }
} }
} }
+11 -1
View File
@@ -137,10 +137,20 @@ namespace OCR_Decode
page.Dispose(); page.Dispose();
return result; return result;
} }
protected string GetStringFromPng() protected string GetStringFromPng(bool onlyDigit = false)
{ {
string result = ""; string result = "";
if (onlyDigit)
{
Engine.SetVariable("tessedit_char_whitelist", "0123456789");
}
else
{
Engine.SetVariable("tessedit_char_whitelist", "");
}
Bitmap rawData = WindowImage; Bitmap rawData = WindowImage;
Bitmap enhancedImage = new OcrImage(rawData).Enhance(); Bitmap enhancedImage = new OcrImage(rawData).Enhance();