Lap times are fucked once again

This commit is contained in:
2023-04-05 17:02:11 +02:00
parent 3271580a1e
commit 31074428b3
4 changed files with 22 additions and 7 deletions
+1
View File
@@ -71,6 +71,7 @@
this.btnNext.TabIndex = 3; this.btnNext.TabIndex = 3;
this.btnNext.Text = "Next"; this.btnNext.Text = "Next";
this.btnNext.UseVisualStyleBackColor = true; this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
// //
// lblFileName // lblFileName
// //
+15 -2
View File
@@ -15,6 +15,7 @@ namespace OCR_Decode
//This should be configurable //This should be configurable
const string CONFIG_FILE = @"C:\Users\Moi\Desktop\imgDump\Dump1.json"; const string CONFIG_FILE = @"C:\Users\Moi\Desktop\imgDump\Dump1.json";
const string TEMPORARY_IMAGE_FOLDER = @"C:\Users\Moi\Pictures\SeleniumScreens\DataSetHighRes\"; const string TEMPORARY_IMAGE_FOLDER = @"C:\Users\Moi\Pictures\SeleniumScreens\DataSetHighRes\";
int pageNmbr = 9;
Reader Reader; Reader Reader;
public Form1() public Form1()
{ {
@@ -24,9 +25,21 @@ namespace OCR_Decode
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
Reader = new Reader(CONFIG_FILE,TEMPORARY_IMAGE_FOLDER); Reader = new Reader(CONFIG_FILE,TEMPORARY_IMAGE_FOLDER);
pbxImage.Image = Reader.Draw(9); RefreshUi();
}
private void RefreshUi()
{
tbxResult.Text = "";
tbxResult.Text = Reader.Decode(9); pbxImage.Image = Reader.Draw(pageNmbr);
tbxResult.Text = Reader.Decode(pageNmbr);
}
private void btnNext_Click(object sender, EventArgs e)
{
pageNmbr++;
RefreshUi();
} }
} }
} }
+2 -2
View File
@@ -23,8 +23,8 @@ namespace OCR_Decode
Bitmap result = (Bitmap)InputImage.Clone(); Bitmap result = (Bitmap)InputImage.Clone();
result = Grayscale(result); result = Grayscale(result);
result = InvertColors(result); result = InvertColors(result);
result = Tresholding(result, 100); //result = Resize(result);
result = Resize(result); result = Tresholding(result, 165);
result = Dilatation(result, 1); result = Dilatation(result, 1);
return result; return result;
} }
+4 -3
View File
@@ -59,10 +59,11 @@ namespace OCR_Decode
} }
public static int GetTimeFromPng(Bitmap wImage) public static int GetTimeFromPng(Bitmap wImage)
{ {
//returns milliseconds
string rawResult = ""; string rawResult = "";
int result = 0; int result = 0;
Engine.SetVariable("tessedit_char_whitelist", "0123456789:.");
Bitmap enhancedImage = new OcrImage(wImage).Enhance(); Bitmap enhancedImage = new OcrImage(wImage).Enhance();
var tessImage = Pix.LoadFromMemory(ImageToByte(enhancedImage)); var tessImage = Pix.LoadFromMemory(ImageToByte(enhancedImage));
@@ -94,10 +95,10 @@ namespace OCR_Decode
//Removes all non digit chars except for the important ones //Removes all non digit chars except for the important ones
//We will need to change this when trying to see the Leader and Lap texts //We will need to change this when trying to see the Leader and Lap texts
string cleanedResult = Regex.Replace(rawResult, "[^0-9.:]", ""); //string cleanedResult = Regex.Replace(rawResult, "[^0-9.:]", "");
//Splits into minuts seconds miliseconds //Splits into minuts seconds miliseconds
rawNumbers = cleanedResult.Split('.', ':').ToList<string>(); rawNumbers = rawResult.Split('.', ':').ToList<string>();
//removes any empty cells (tho this usually sign of a really bad OCR implementation tbh will have to be fixed higher in the chian) //removes any empty cells (tho this usually sign of a really bad OCR implementation tbh will have to be fixed higher in the chian)
rawNumbers.RemoveAll(x => ((string)x) == ""); rawNumbers.RemoveAll(x => ((string)x) == "");