diff --git a/OCR_Decode/Form1.Designer.cs b/OCR_Decode/Form1.Designer.cs index 9e24a6d..fffc982 100644 --- a/OCR_Decode/Form1.Designer.cs +++ b/OCR_Decode/Form1.Designer.cs @@ -71,6 +71,7 @@ this.btnNext.TabIndex = 3; this.btnNext.Text = "Next"; this.btnNext.UseVisualStyleBackColor = true; + this.btnNext.Click += new System.EventHandler(this.btnNext_Click); // // lblFileName // diff --git a/OCR_Decode/Form1.cs b/OCR_Decode/Form1.cs index 01af7ab..1d99be3 100644 --- a/OCR_Decode/Form1.cs +++ b/OCR_Decode/Form1.cs @@ -15,6 +15,7 @@ namespace OCR_Decode //This should be configurable const string CONFIG_FILE = @"C:\Users\Moi\Desktop\imgDump\Dump1.json"; const string TEMPORARY_IMAGE_FOLDER = @"C:\Users\Moi\Pictures\SeleniumScreens\DataSetHighRes\"; + int pageNmbr = 9; Reader Reader; public Form1() { @@ -24,9 +25,21 @@ namespace OCR_Decode private void Form1_Load(object sender, EventArgs e) { 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(); } } } diff --git a/OCR_Decode/OcrImage.cs b/OCR_Decode/OcrImage.cs index a6a088a..33b2379 100644 --- a/OCR_Decode/OcrImage.cs +++ b/OCR_Decode/OcrImage.cs @@ -23,8 +23,8 @@ namespace OCR_Decode Bitmap result = (Bitmap)InputImage.Clone(); result = Grayscale(result); result = InvertColors(result); - result = Tresholding(result, 100); - result = Resize(result); + //result = Resize(result); + result = Tresholding(result, 165); result = Dilatation(result, 1); return result; } diff --git a/OCR_Decode/Window.cs b/OCR_Decode/Window.cs index 92a9a34..4c82596 100644 --- a/OCR_Decode/Window.cs +++ b/OCR_Decode/Window.cs @@ -59,10 +59,11 @@ namespace OCR_Decode } public static int GetTimeFromPng(Bitmap wImage) { - //returns milliseconds string rawResult = ""; int result = 0; + Engine.SetVariable("tessedit_char_whitelist", "0123456789:."); + Bitmap enhancedImage = new OcrImage(wImage).Enhance(); var tessImage = Pix.LoadFromMemory(ImageToByte(enhancedImage)); @@ -94,10 +95,10 @@ namespace OCR_Decode //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 - string cleanedResult = Regex.Replace(rawResult, "[^0-9.:]", ""); + //string cleanedResult = Regex.Replace(rawResult, "[^0-9.:]", ""); //Splits into minuts seconds miliseconds - rawNumbers = cleanedResult.Split('.', ':').ToList(); + rawNumbers = rawResult.Split('.', ':').ToList(); //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) == "");