diff --git a/OCR_Decode/DriverDrsWindow.cs b/OCR_Decode/DriverDrsWindow.cs index 7b38382..f7572a2 100644 --- a/OCR_Decode/DriverDrsWindow.cs +++ b/OCR_Decode/DriverDrsWindow.cs @@ -13,5 +13,10 @@ namespace OCR_Decode { Name = "DRS"; } + public override object DecodePng() + { + //TODO + return false; + } } } diff --git a/OCR_Decode/DriverGapToLeaderWindow.cs b/OCR_Decode/DriverGapToLeaderWindow.cs index c100ef0..ed41f03 100644 --- a/OCR_Decode/DriverGapToLeaderWindow.cs +++ b/OCR_Decode/DriverGapToLeaderWindow.cs @@ -13,5 +13,9 @@ namespace OCR_Decode { Name = "Gap to leader"; } + public override object DecodePng() + { + return 0; + } } } diff --git a/OCR_Decode/DriverLapTimeWindow.cs b/OCR_Decode/DriverLapTimeWindow.cs index 3d00a3a..01e6e68 100644 --- a/OCR_Decode/DriverLapTimeWindow.cs +++ b/OCR_Decode/DriverLapTimeWindow.cs @@ -13,5 +13,9 @@ namespace OCR_Decode { Name = "Lap time"; } + public override object DecodePng() + { + return 0; + } } } diff --git a/OCR_Decode/DriverNameWindow.cs b/OCR_Decode/DriverNameWindow.cs index 2e213ee..81c5aa9 100644 --- a/OCR_Decode/DriverNameWindow.cs +++ b/OCR_Decode/DriverNameWindow.cs @@ -10,6 +10,7 @@ namespace OCR_Decode { internal class DriverNameWindow : Window { + public static Random rnd = new Random(); public DriverNameWindow(Bitmap image, Rectangle bounds) : base(image, bounds) { Name = "Name"; @@ -18,7 +19,8 @@ namespace OCR_Decode { string result = ""; - Image rawData = WindowImage; + Image rawData = Image; + rawData.Save(Reader.DEBUG_DUMP_FOLDER + Name + "_Before" + ".png"); TesseractEngine engine = new TesseractEngine(TESS_DATA_FOLDER.FullName, "eng", EngineMode.Default); var tessImage = Pix.LoadFromMemory(ImageToByte(WindowImage)); @@ -35,7 +37,8 @@ namespace OCR_Decode result += iter.GetText(PageIteratorLevel.Word); } while (iter.Next(PageIteratorLevel.Word)); } - + //REMOVE !!! + //result += rnd.Next(0,100); return result; } } diff --git a/OCR_Decode/DriverPositionWindow.cs b/OCR_Decode/DriverPositionWindow.cs index bd5e902..84971e5 100644 --- a/OCR_Decode/DriverPositionWindow.cs +++ b/OCR_Decode/DriverPositionWindow.cs @@ -13,5 +13,9 @@ namespace OCR_Decode { Name = "Position"; } + public override object DecodePng() + { + return 0; + } } } diff --git a/OCR_Decode/DriverSector1Window.cs b/OCR_Decode/DriverSector1Window.cs index 38ae80a..8358089 100644 --- a/OCR_Decode/DriverSector1Window.cs +++ b/OCR_Decode/DriverSector1Window.cs @@ -13,5 +13,9 @@ namespace OCR_Decode { Name = "Sector 1"; } + public override object DecodePng() + { + return 0; + } } } diff --git a/OCR_Decode/DriverSector2Window.cs b/OCR_Decode/DriverSector2Window.cs index 414060e..193c98a 100644 --- a/OCR_Decode/DriverSector2Window.cs +++ b/OCR_Decode/DriverSector2Window.cs @@ -13,5 +13,9 @@ namespace OCR_Decode { Name = "Sector 2"; } + public override object DecodePng() + { + return 0; + } } } diff --git a/OCR_Decode/DriverSector3Window.cs b/OCR_Decode/DriverSector3Window.cs index d7d0221..20a5bdf 100644 --- a/OCR_Decode/DriverSector3Window.cs +++ b/OCR_Decode/DriverSector3Window.cs @@ -13,5 +13,9 @@ namespace OCR_Decode { Name = "Sector 3"; } + public override object DecodePng() + { + return 0; + } } } diff --git a/OCR_Decode/DriverTyresWindow.cs b/OCR_Decode/DriverTyresWindow.cs index 293a0a7..44c12ac 100644 --- a/OCR_Decode/DriverTyresWindow.cs +++ b/OCR_Decode/DriverTyresWindow.cs @@ -13,6 +13,10 @@ namespace OCR_Decode { Name = "Tyres"; } + public override object DecodePng() + { + return new Tyre(Tyre.Type.Undefined, 0); + } } struct Tyre { @@ -22,9 +26,15 @@ namespace OCR_Decode Medium, Hard, Inter, - Wet + Wet, + Undefined + } + public Type Coumpound; + public int NumberOfLaps; + public Tyre(Type type, int laps) + { + Coumpound = type; + NumberOfLaps = laps; } - public int numberOfLaps; - public Type type; } } diff --git a/OCR_Decode/Form1.Designer.cs b/OCR_Decode/Form1.Designer.cs index 2bb026f..c21f65f 100644 --- a/OCR_Decode/Form1.Designer.cs +++ b/OCR_Decode/Form1.Designer.cs @@ -50,6 +50,7 @@ this.tbxResult.Location = new System.Drawing.Point(441, 618); this.tbxResult.Multiline = true; this.tbxResult.Name = "tbxResult"; + this.tbxResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.tbxResult.Size = new System.Drawing.Size(571, 192); this.tbxResult.TabIndex = 1; // diff --git a/OCR_Decode/Form1.cs b/OCR_Decode/Form1.cs index 0fc4f5a..01af7ab 100644 --- a/OCR_Decode/Form1.cs +++ b/OCR_Decode/Form1.cs @@ -25,6 +25,8 @@ namespace OCR_Decode { Reader = new Reader(CONFIG_FILE,TEMPORARY_IMAGE_FOLDER); pbxImage.Image = Reader.Draw(9); + + tbxResult.Text = Reader.Decode(9); } } } diff --git a/OCR_Decode/Reader.cs b/OCR_Decode/Reader.cs index ed81b66..adfdac8 100644 --- a/OCR_Decode/Reader.cs +++ b/OCR_Decode/Reader.cs @@ -23,6 +23,7 @@ namespace OCR_Decode public List MainZones { get => _mainZones; set => _mainZones = value; } const string DEFAULT_IMAGE_NAME = "screen_"; + public const string DEBUG_DUMP_FOLDER = @"C:\Users\Moi\Desktop\imgDump\Decode\"; const int NUMBER_OF_DRIVERS = 20; public Reader(string configFile, string imageFolder) @@ -174,55 +175,63 @@ namespace OCR_Decode List> mainResults = new List>(); //Decode - foreach (Zone z in MainZones) + for (int mainZoneId = 0; mainZoneId < MainZones.Count;mainZoneId ++) { - foreach (Zone zz in z.Zones) + switch (mainZoneId) { - mainResults.Add(zz.Decode()); + case 0: + //Main Zone + foreach (Zone z in MainZones[mainZoneId].Zones) + { + mainResults.Add(z.Decode()); + } + break; + //Next there will be the title and laps added } + } //Display foreach (List objects in mainResults) { - for (int objId = 1; objId <= objects.Count; objId++) + for (int objId = 0; objId < objects.Count; objId++) { switch (objId) { - case 1: + case 0: //Position result += "Position : " + (int)objects[objId] + " "; break; - case 2: + case 1: //Gap result += "Gap to leader : " + ConvertMsToTime((int)objects[objId]) + " "; break; - case 3: + case 2: //LapTime result += "Lap time : " + ConvertMsToTime((int)objects[objId]) + " "; break; - case 4: + case 3: //DRS result += "DRS : " + (bool)objects[objId] + ""; break; - case 5: + case 4: //Tyres Tyre tyre = (Tyre)objects[objId]; - result += "Tyre : " + tyre.type + " laps with the tyre : " + tyre.numberOfLaps + " "; + result += "Tyre : " + tyre.Coumpound + " laps with the tyre : " + tyre.NumberOfLaps + " "; break; - case 6: + case 5: //Name result += "Driver name : " + (string)objects[objId] + " "; break; - case 7: + case 6: //Sector 1 result += "Sector 1 : " + ConvertMsToTime((int)objects[objId]) + " "; break; - case 8: + case 7: //Sector 1 result += "Sector 2 : " + ConvertMsToTime((int)objects[objId]) + " "; break; - case 9: + case 8: //Sector 1 result += "Sector 3 : " + ConvertMsToTime((int)objects[objId]) + " "; break; @@ -246,7 +255,6 @@ namespace OCR_Decode } public Bitmap Draw(int idImage) { - string debugDumpFolder = @"C:\Users\Moi\Desktop\imgDump\Decode\"; Bitmap result; try { @@ -265,7 +273,7 @@ namespace OCR_Decode int count = 0; foreach (Zone zz in z.Zones) { - string driverFolder = debugDumpFolder + "driver" + count + "\\"; + string driverFolder = DEBUG_DUMP_FOLDER + "driver" + count + "\\"; if (!Directory.Exists(driverFolder)) Directory.CreateDirectory(driverFolder); @@ -274,7 +282,6 @@ namespace OCR_Decode g.DrawRectangle(Pens.Red, z.Bounds); foreach (Window w in zz.Windows) { - w.WindowImage.Save(driverFolder + w.Name + ".png"); g.DrawRectangle(Pens.Blue, new Rectangle(z.Bounds.X + zz.Bounds.X, z.Bounds.Y + zz.Bounds.Y, zz.Bounds.Width, zz.Bounds.Height)); } diff --git a/OCR_Decode/Zone.cs b/OCR_Decode/Zone.cs index ac2ca09..761f0d1 100644 --- a/OCR_Decode/Zone.cs +++ b/OCR_Decode/Zone.cs @@ -32,7 +32,7 @@ namespace OCR_Decode _image = Image; foreach (Window w in Windows) { - w.Image = Image; + w.Image = ZoneImage; } foreach (Zone z in Zones) { @@ -47,11 +47,12 @@ namespace OCR_Decode public Zone(Bitmap image, Rectangle bounds) { - Image = image; - Bounds = bounds; - Windows = new List(); Zones = new List(); + + //You cant set the image in the CTOR because the processing is impossible at first initiation + _image = image; + Bounds = bounds; } public virtual void AddZone(Zone zone) {