From c515e5ff623d7aae6d36cf70047e3559c770657c Mon Sep 17 00:00:00 2001 From: maxluli Date: Fri, 7 Apr 2023 17:05:50 +0200 Subject: [PATCH] Tyre recognition is still fucked but im going to bed rn --- OCR_Decode/DriverTyresWindow.cs | 6 +++--- OCR_Decode/OcrImage.cs | 16 ++++++++++++++-- OCR_Decode/Reader.cs | 2 +- OCR_Decode/Window.cs | 11 +++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/OCR_Decode/DriverTyresWindow.cs b/OCR_Decode/DriverTyresWindow.cs index 39d2c5c..82a1602 100644 --- a/OCR_Decode/DriverTyresWindow.cs +++ b/OCR_Decode/DriverTyresWindow.cs @@ -85,7 +85,7 @@ namespace OCR_Decode Color limitColor = Color.FromArgb(0x50,0x50,0x50); Color currentColor = Color.FromArgb(0,0,0); - Size newWindowSize = new Size(bmp.Height -Convert.ToInt32((float)bmp.Height / 100f * 40f),bmp.Height - Convert.ToInt32((float)bmp.Height / 100f * 40f)); + Size newWindowSize = new Size(bmp.Height -Convert.ToInt32((float)bmp.Height / 100f * 40f),bmp.Height - Convert.ToInt32((float)bmp.Height / 100f * 50f)); while(currentColor.R <= limitColor.R && currentColor.G <= limitColor.G && currentColor.B <= limitColor.B && currentPosition > 0) { @@ -94,8 +94,8 @@ namespace OCR_Decode } //Its here to let the new window include a little bit of the right - int CorrectedX = currentPosition - (newWindowSize.Width); - int CorrectedY = Convert.ToInt32((float)newWindowSize.Height / 100f * 30f); + int CorrectedX = currentPosition - (newWindowSize.Width) - Convert.ToInt32((float)newWindowSize.Width/100f*10f); + int CorrectedY = Convert.ToInt32((float)newWindowSize.Height / 100f * 50f); if (CorrectedX <= 0) return new Rectangle(0,0,newWindowSize.Width,newWindowSize.Height); diff --git a/OCR_Decode/OcrImage.cs b/OCR_Decode/OcrImage.cs index 572322d..b3b9917 100644 --- a/OCR_Decode/OcrImage.cs +++ b/OCR_Decode/OcrImage.cs @@ -48,14 +48,26 @@ namespace OCR_Decode result = Dilatation(result, 1); break; case WindowType.Tyre: - //result = Tresholding(result, 200); result = RemoveBG(result); result = Grayscale(result); result = InvertColors(result); + //result = Tresholding(result,80); result = Resize(result); + result = Dilatation(result, 1); + result = Resize(result); + result = Dilatation(result,1); + //result = Erode(result,1); + + //result = Resize(result); + + //result = Dilatation(result, 1); + + //result = Dilatation(result, 1); + //result = InvertColors(result); + //result = Resize(result); //result = Resize(result); //result = Dilatation(result,1); - break; + break; default: result = Tresholding(result, 165); result = Resize(result); diff --git a/OCR_Decode/Reader.cs b/OCR_Decode/Reader.cs index 6f2aa4c..63d1f3d 100644 --- a/OCR_Decode/Reader.cs +++ b/OCR_Decode/Reader.cs @@ -217,7 +217,7 @@ namespace OCR_Decode case 4: //Tyres Tyre tyre = (Tyre)objects[objId]; - result += "Tyre : " + tyre.Coumpound + " laps with the tyre : " + tyre.NumberOfLaps + " "; + result += "Uses " + tyre.Coumpound + " tyre for " + tyre.NumberOfLaps + " laps"; break; case 5: //Name diff --git a/OCR_Decode/Window.cs b/OCR_Decode/Window.cs index 91bc748..0f55c2e 100644 --- a/OCR_Decode/Window.cs +++ b/OCR_Decode/Window.cs @@ -171,8 +171,15 @@ namespace OCR_Decode result += iter.GetText(PageIteratorLevel.Word); } while (iter.Next(PageIteratorLevel.Word)); } - - enhancedImage.Save(Reader.DEBUG_DUMP_FOLDER + Regex.Replace(result, "[^0-9A-Za-z]", "") + ".png"); + if (allowedChars.Contains("S")) + { + enhancedImage.Save(Reader.DEBUG_DUMP_FOLDER + "Tyre" + result +".png"); + } + else + { + enhancedImage.Save(Reader.DEBUG_DUMP_FOLDER + result +".png"); + } + page.Dispose(); return result;