Trying to implement tyres but not working for now
This commit is contained in:
+12
-14
@@ -153,22 +153,14 @@ namespace OCR_Decode
|
||||
page.Dispose();
|
||||
return result;
|
||||
}
|
||||
protected string GetStringFromPng(bool onlyDigit = false)
|
||||
public static string GetStringFromPng(Bitmap image,string allowedChars = "",OcrImage.WindowType windowType = OcrImage.WindowType.Text)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
if (onlyDigit)
|
||||
{
|
||||
Engine.SetVariable("tessedit_char_whitelist", "0123456789");
|
||||
}
|
||||
else
|
||||
{
|
||||
Engine.SetVariable("tessedit_char_whitelist", "");
|
||||
}
|
||||
|
||||
Engine.SetVariable("tessedit_char_whitelist", allowedChars);
|
||||
|
||||
Bitmap rawData = WindowImage;
|
||||
Bitmap enhancedImage = new OcrImage(rawData).Enhance();
|
||||
Bitmap rawData = image;
|
||||
Bitmap enhancedImage = new OcrImage(rawData).Enhance(windowType);
|
||||
|
||||
Page page = Engine.Process(enhancedImage);
|
||||
using (var iter = page.GetIterator())
|
||||
@@ -185,7 +177,13 @@ namespace OCR_Decode
|
||||
page.Dispose();
|
||||
return result;
|
||||
}
|
||||
//This method has been gnerated using ChatGPT
|
||||
protected Bitmap GetSmallBitmapFromBigOne(Bitmap bmp, Rectangle rectangle)
|
||||
{
|
||||
Bitmap sample = new Bitmap(rectangle.Width, rectangle.Height);
|
||||
Graphics g = Graphics.FromImage(sample);
|
||||
g.DrawImage(bmp, new Rectangle(0, 0, sample.Width, sample.Height), rectangle, GraphicsUnit.Pixel);
|
||||
return sample;
|
||||
}
|
||||
protected static string FindClosestMatch(List<string> array, string target)
|
||||
{
|
||||
var closestMatch = "";
|
||||
@@ -202,7 +200,7 @@ namespace OCR_Decode
|
||||
}
|
||||
return closestMatch;
|
||||
}
|
||||
//This is a tool to be able to compare strings
|
||||
//This method has been generated with the help of ChatGPT
|
||||
protected static int LevenshteinDistance(string s1, string s2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s1))
|
||||
|
||||
Reference in New Issue
Block a user