diff --git a/Test_Merge/Form1.cs b/Test_Merge/Form1.cs index 9852314..e4aea63 100644 --- a/Test_Merge/Form1.cs +++ b/Test_Merge/Form1.cs @@ -25,7 +25,7 @@ namespace Test_Merge Bitmap screen = Emulator.Screenshot(); screen.Save("SCREEEEEEEEN.png"); Reader.ChangeImage(screen); - tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers,screen); + tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers); } } private void btnSettings_Click(object sender, EventArgs e) diff --git a/Test_Merge/Reader.cs b/Test_Merge/Reader.cs index 13f49b2..e1f045c 100644 --- a/Test_Merge/Reader.cs +++ b/Test_Merge/Reader.cs @@ -154,7 +154,7 @@ namespace Test_Merge /// /// The id of the image we are working with /// a string representation of all the returns - public async Task Decode(List mainZones,List drivers, Bitmap imageToDecode) + public async Task Decode(List mainZones,List drivers) { string result = ""; List mainResults = new List(); @@ -192,9 +192,9 @@ namespace Test_Merge public void ChangeImage(Bitmap Image) { - foreach (Zone BigZone in MainZones) + foreach (Zone z in MainZones) { - BigZone.Image = Image; + z.Image = Image; } } /// diff --git a/Test_Merge/Window.cs b/Test_Merge/Window.cs index 8210cde..6a679f9 100644 --- a/Test_Merge/Window.cs +++ b/Test_Merge/Window.cs @@ -87,7 +87,7 @@ namespace Test_Merge /// The type of window it is /// The Tesseract Engine /// The time in milliseconds - public static async Task GetTimeFromPng(Bitmap windowImage, OcrImage.WindowType windowType, TesseractEngine Engine) + public static async Task GetTimeFromPng(Bitmap image, OcrImage.WindowType windowType, TesseractEngine Engine) { //Kind of a big method but it has a lot of error handling and has to work with three special cases string rawResult = ""; @@ -113,7 +113,7 @@ namespace Test_Merge } - Bitmap enhancedImage = new OcrImage(windowImage).Enhance(windowType); + Bitmap enhancedImage = new OcrImage(image).Enhance(windowType); var tessImage = Pix.LoadFromMemory(ImageToByte(enhancedImage)); @@ -227,13 +227,13 @@ namespace Test_Merge /// The list of allowed chars /// The type of window the text is on. Depending on the context the OCR will behave differently /// the string it found - public static async Task GetStringFromPng(Bitmap WindowImage, TesseractEngine Engine, string allowedChars = "", OcrImage.WindowType windowType = OcrImage.WindowType.Text) + public static async Task GetStringFromPng(Bitmap image, TesseractEngine Engine, string allowedChars = "", OcrImage.WindowType windowType = OcrImage.WindowType.Text) { string result = ""; Engine.SetVariable("tessedit_char_whitelist", allowedChars); - Bitmap rawData = WindowImage; + Bitmap rawData = image; Bitmap enhancedImage = new OcrImage(rawData).Enhance(windowType); Page page = Engine.Process(enhancedImage); diff --git a/Test_Merge/Zone.cs b/Test_Merge/Zone.cs index 3d3d1fe..9af124b 100644 --- a/Test_Merge/Zone.cs +++ b/Test_Merge/Zone.cs @@ -38,7 +38,7 @@ namespace Test_Merge set { //It automatically sets the image for the contained windows and zones - _image = Image; + _image = value; foreach (Window w in Windows) { w.Image = ZoneImage; @@ -88,36 +88,6 @@ namespace Test_Merge /// A driver data object that contains all the infos about a driver public virtual async Task Decode(List driverList) { - /* - int sectorCount = 0; - DriverData result = new DriverData(); - Parallel.ForEach(Windows, async w => - { - // A switch would be prettier but I dont think its supported in this C# version - if (w is DriverNameWindow) - result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList); - if (w is DriverDrsWindow) - result.DRS = (bool)await (w as DriverDrsWindow).DecodePng(); - if (w is DriverGapToLeaderWindow) - result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng(); - if (w is DriverLapTimeWindow) - result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng(); - if (w is DriverPositionWindow) - result.Position = (int)await (w as DriverPositionWindow).DecodePng(); - if (w is DriverSectorWindow) - { - sectorCount++; - if (sectorCount == 1) - result.Sector1 = (int)await (w as DriverSectorWindow).DecodePng(); - if (sectorCount == 2) - result.Sector2 = (int)await (w as DriverSectorWindow).DecodePng(); - if (sectorCount == 3) - result.Sector3 = (int)await (w as DriverSectorWindow).DecodePng(); - } - if (w is DriverTyresWindow) - result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng(); - }); - */ int sectorCount = 0; DriverData result = new DriverData(); foreach(Window w in Windows)