cleaned the rest of the files
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
/// Author : Maxime Rohmer
|
||||
/// Date : 25/04/2023
|
||||
/// File : DriverData.cs
|
||||
/// Brief : File that contains strcutures to store the found data
|
||||
/// Version : 0.1
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -42,6 +48,10 @@ namespace OCR_Decode
|
||||
Sector3 = -1;
|
||||
CurrentTyre = new Tyre(Tyre.Type.Undefined,-1);
|
||||
}
|
||||
/// <summary>
|
||||
/// Method that displays all the data found in a string
|
||||
/// </summary>
|
||||
/// <returns>string containing all the driver datas</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
string result = "";
|
||||
@@ -68,8 +78,10 @@ namespace OCR_Decode
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//Structure to store tyres infos
|
||||
public struct Tyre
|
||||
{
|
||||
//If new tyres were to be added you will have to need to change this enum
|
||||
public enum Type
|
||||
{
|
||||
Soft,
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
/// Author : Maxime Rohmer
|
||||
/// Date : 25/04/2023
|
||||
/// File : DriverGapToLeaderWindow.cs
|
||||
/// Brief : Window that contains infos about the driver Gap to leader
|
||||
/// Version : 0.1
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
@@ -14,6 +20,10 @@ namespace OCR_Decode
|
||||
{
|
||||
Name = "Gap to leader";
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodes the gap to leader using Tesseract OCR
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override async Task<object> DecodePng()
|
||||
{
|
||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Gap, Engine);
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
/// Author : Maxime Rohmer
|
||||
/// Date : 25/04/2023
|
||||
/// File : DriverLapTimeWindow.cs
|
||||
/// Brief : Window that contains infos about a laptime of the driver
|
||||
/// Version : 0.1
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
@@ -14,6 +20,10 @@ namespace OCR_Decode
|
||||
{
|
||||
Name = "Lap time";
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodes the lap time contained in the image using OCR Tesseract
|
||||
/// </summary>
|
||||
/// <returns>The laptime in int (ms)</returns>
|
||||
public override async Task<object> DecodePng()
|
||||
{
|
||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.LapTime,Engine);
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
/// Author : Maxime Rohmer
|
||||
/// Date : 25/04/2023
|
||||
/// File : DriverNameWindow.cs
|
||||
/// Brief : Window that contains infos about the driver name in it
|
||||
/// Version : 0.1
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
@@ -15,6 +21,11 @@ namespace OCR_Decode
|
||||
{
|
||||
Name = "Name";
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodes using OCR wich driver name is in the image
|
||||
/// </summary>
|
||||
/// <param name="DriverList"></param>
|
||||
/// <returns>The driver name in string</returns>
|
||||
public override async Task<object> DecodePng(List<string> DriverList)
|
||||
{
|
||||
string result = "";
|
||||
@@ -27,11 +38,17 @@ namespace OCR_Decode
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static bool IsADriver(List<string> drivers, string potentialDriver)
|
||||
/// <summary>
|
||||
/// Verifies that the name found in the OCR is a valid name
|
||||
/// </summary>
|
||||
/// <param name="driverList"></param>
|
||||
/// <param name="potentialDriver"></param>
|
||||
/// <returns>If ye or no the driver exists</returns>
|
||||
private static bool IsADriver(List<string> driverList, string potentialDriver)
|
||||
{
|
||||
bool result = false;
|
||||
//I cant use drivers.Contains because it has missmatched cases and all
|
||||
foreach (string name in drivers)
|
||||
foreach (string name in driverList)
|
||||
{
|
||||
if (name.ToUpper() == potentialDriver.ToUpper())
|
||||
result = true;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
/// Author : Maxime Rohmer
|
||||
/// Date : 25/04/2023
|
||||
/// File : DriverPositionWindow.cs
|
||||
/// Brief : Window that contains infos about a driver position
|
||||
/// Version : 0.1
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
@@ -14,19 +20,22 @@ namespace OCR_Decode
|
||||
{
|
||||
Name = "Position";
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodes the position number using Tesseract OCR
|
||||
/// </summary>
|
||||
/// <returns>The position of the pilot in int</returns>
|
||||
public override async Task<object> DecodePng()
|
||||
{
|
||||
string result = await GetStringFromPng(WindowImage,Engine, "0123456789");
|
||||
string ocrResult = await GetStringFromPng(WindowImage,Engine, "0123456789");
|
||||
|
||||
int position;
|
||||
try
|
||||
{
|
||||
position = Convert.ToInt32(result);
|
||||
position = Convert.ToInt32(ocrResult);
|
||||
}
|
||||
catch
|
||||
{
|
||||
position = -1;
|
||||
//WindowImage.Save(Reader.DEBUG_DUMP_FOLDER + "FailedPosition" + ".png");
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace OCR_Decode
|
||||
/// <returns>the sector time in int (ms)</returns>
|
||||
public override async Task<object> DecodePng()
|
||||
{
|
||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector, Engine);
|
||||
return result;
|
||||
int ocrResult = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector, Engine);
|
||||
return ocrResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace OCR_Decode
|
||||
/// <returns>the sector time in int (ms)</returns>
|
||||
public override async Task<object> DecodePng()
|
||||
{
|
||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
||||
return result;
|
||||
int ocrResult = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
||||
return ocrResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace OCR_Decode
|
||||
/// <returns>the sector time in int (ms)</returns>
|
||||
public override async Task<object> DecodePng()
|
||||
{
|
||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
||||
return result;
|
||||
int ocrResult = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
||||
return ocrResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user