diff --git a/OCR_Decode/DriverSector1Window.cs b/OCR_Decode/DriverSector1Window.cs
index b83a44d..82d9249 100644
--- a/OCR_Decode/DriverSector1Window.cs
+++ b/OCR_Decode/DriverSector1Window.cs
@@ -1,4 +1,10 @@
-using System;
+/// Author : Maxime Rohmer
+/// Date : 25/04/2023
+/// File : DriverSector1Window.cs
+/// Brief : Window that contains infos about the first sector of a driver
+/// Version : 0.1
+
+using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -14,6 +20,10 @@ namespace OCR_Decode
{
Name = "Sector 1";
}
+ ///
+ /// Decodes the sector
+ ///
+ /// the sector time in int (ms)
public override async Task DecodePng()
{
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector, Engine);
diff --git a/OCR_Decode/DriverSector2Window.cs b/OCR_Decode/DriverSector2Window.cs
index f01f8ab..d7331f5 100644
--- a/OCR_Decode/DriverSector2Window.cs
+++ b/OCR_Decode/DriverSector2Window.cs
@@ -1,4 +1,11 @@
-using System;
+/// Author : Maxime Rohmer
+/// Date : 25/04/2023
+/// File : DriverSector2Window.cs
+/// Brief : Window that contains infos about the second sector of a driver
+/// Version : 0.1
+
+
+using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -14,6 +21,10 @@ namespace OCR_Decode
{
Name = "Sector 2";
}
+ ///
+ /// Decodes the sector
+ ///
+ /// the sector time in int (ms)
public override async Task DecodePng()
{
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
diff --git a/OCR_Decode/DriverSector3Window.cs b/OCR_Decode/DriverSector3Window.cs
index 250f103..0ebbd3b 100644
--- a/OCR_Decode/DriverSector3Window.cs
+++ b/OCR_Decode/DriverSector3Window.cs
@@ -1,4 +1,10 @@
-using System;
+/// Author : Maxime Rohmer
+/// Date : 25/04/2023
+/// File : DriverSector3Window.cs
+/// Brief : Window that contains infos about the third sector of a driver
+/// Version : 0.1
+
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
@@ -15,6 +21,10 @@ namespace OCR_Decode
{
Name = "Sector 3";
}
+ ///
+ /// Decodes the sector
+ ///
+ /// the sector time in int (ms)
public override async Task DecodePng()
{
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
diff --git a/OCR_Decode/DriverTyresWindow.cs b/OCR_Decode/DriverTyresWindow.cs
index 0edb204..2870abf 100644
--- a/OCR_Decode/DriverTyresWindow.cs
+++ b/OCR_Decode/DriverTyresWindow.cs
@@ -1,4 +1,10 @@
-using System;
+/// Author : Maxime Rohmer
+/// Date : 25/04/2023
+/// File : DriverTyresWindow.cs
+/// Brief : Window that contains infos about tyres and that can decode them
+/// Version : 0.1
+
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
@@ -14,6 +20,7 @@ namespace OCR_Decode
private static Random rnd = new Random();
int seed = rnd.Next(0,10000);
+ //Those are the colors I found but you can change them if they change in the future like in 2019
public static Color SOFT_TYRE_COLOR = Color.FromArgb(0xff, 0x00, 0x00);
public static Color MEDIUM_TYRE_COLOR = Color.FromArgb(0xf5, 0xbf, 0x00);
public static Color HARD_TYRE_COLOR = Color.FromArgb(0xa4, 0xa5, 0xa8);
@@ -25,15 +32,21 @@ namespace OCR_Decode
{
Name = "Tyres";
}
+ ///
+ /// This will decode the content of the image
+ ///
+ /// And object containing what was on the image
public override async Task DecodePng()
{
- //WindowImage.Save(Reader.DEBUG_DUMP_FOLDER + "testTyres" + rnd.Next(0, 1000) + ".png");
return await GetTyreInfos();
}
+ ///
+ /// Method that will decode whats on the image and return the tyre infos it could manage to recover
+ ///
+ /// A tyre object containing tyre infos
private async Task GetTyreInfos()
{
Bitmap tyreZone = GetSmallBitmapFromBigOne(WindowImage, FindTyreZone());
- //tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "NewTyreZone_"+seed+".png");
Tyre.Type type = Tyre.Type.Undefined;
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(tyreZone));
int laps = -1;
@@ -51,12 +64,13 @@ namespace OCR_Decode
//tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "Tyre" + type + "Laps" + laps + '#' + rnd.Next(0, 1000) + ".png");
return new Tyre(type, laps);
}
+ ///
+ /// Finds where the important part of the image is
+ ///
+ /// A rectangle containing position and dimensions of the important part of the image
private Rectangle FindTyreZone()
{
Bitmap bmp = WindowImage;
-
- //bmp.Save(Reader.DEBUG_DUMP_FOLDER + "OldTyreZone_" + seed + ".png");
-
int currentPosition = bmp.Width;
int height = bmp.Height / 2;
Color limitColor = Color.FromArgb(0x50, 0x50, 0x50);
@@ -79,10 +93,17 @@ namespace OCR_Decode
return new Rectangle(CorrectedX, CorrectedY, newWindowSize.Width, newWindowSize.Height);
}
//This method has been created with the help of chatGPT
+ ///
+ /// Methods that compares a list of colors to see wich is the closest from the input color and decide wich tyre type it is
+ ///
+ /// The color that you found
+ /// The tyre type
public Tyre.Type GetTyreTypeFromColor(Color inputColor)
{
Tyre.Type type = Tyre.Type.Undefined;
List colors = new List();
+ //dont forget that if for some reason someday F1 adds a new Tyre type you will need to add it in the constants but also here in the list
+ //You will also need to add it below in the Tyre object's enum and add an if in the end of this method
colors.Add(SOFT_TYRE_COLOR);
colors.Add(MEDIUM_TYRE_COLOR);
colors.Add(HARD_TYRE_COLOR);
@@ -102,11 +123,6 @@ namespace OCR_Decode
}
}
- //Bitmap colorBmp = new Bitmap(200, 100);
- //Graphics g = Graphics.FromImage(colorBmp);
- //g.FillRectangle(new SolidBrush(closestColor), new Rectangle(0, 0, colorBmp.Width, colorBmp.Height));
- //colorBmp.Save(Reader.DEBUG_DUMP_FOLDER+"AVGCOLOR_"+closestColor.ToString()+"_"+seed+".png");
-
//We cant use a switch as the colors cant be constants ...
if (closestColor == SOFT_TYRE_COLOR)
type = Tyre.Type.Soft;
diff --git a/OCR_Decode/Zone.cs b/OCR_Decode/Zone.cs
index 619eded..358f43e 100644
--- a/OCR_Decode/Zone.cs
+++ b/OCR_Decode/Zone.cs
@@ -79,7 +79,7 @@ namespace OCR_Decode
Windows.Add(window);
}
///
- /// Calls all the zones and windows to do OCR and to give back the results so we can send them to the model
+ /// Calls all the windows to do OCR and to give back the results so we can send them to the model
///
/// A list of all the driver in the race to help with text recognition
/// A driver data object that contains all the infos about a driver