Compare commits
1 Commits
f2761db4c9
..
0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b9592c8e1 |
@@ -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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -42,6 +48,10 @@ namespace OCR_Decode
|
|||||||
Sector3 = -1;
|
Sector3 = -1;
|
||||||
CurrentTyre = new Tyre(Tyre.Type.Undefined,-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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
@@ -68,8 +78,10 @@ namespace OCR_Decode
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Structure to store tyres infos
|
||||||
public struct Tyre
|
public struct Tyre
|
||||||
{
|
{
|
||||||
|
//If new tyres were to be added you will have to need to change this enum
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
Soft,
|
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.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -14,6 +20,10 @@ namespace OCR_Decode
|
|||||||
{
|
{
|
||||||
Name = "Gap to leader";
|
Name = "Gap to leader";
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Decodes the gap to leader using Tesseract OCR
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override async Task<object> DecodePng()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Gap, Engine);
|
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.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -14,6 +20,10 @@ namespace OCR_Decode
|
|||||||
{
|
{
|
||||||
Name = "Lap time";
|
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()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.LapTime,Engine);
|
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.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -15,6 +21,11 @@ namespace OCR_Decode
|
|||||||
{
|
{
|
||||||
Name = "Name";
|
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)
|
public override async Task<object> DecodePng(List<string> DriverList)
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
@@ -27,11 +38,17 @@ namespace OCR_Decode
|
|||||||
}
|
}
|
||||||
return result;
|
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;
|
bool result = false;
|
||||||
//I cant use drivers.Contains because it has missmatched cases and all
|
//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())
|
if (name.ToUpper() == potentialDriver.ToUpper())
|
||||||
result = true;
|
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.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -14,19 +20,22 @@ namespace OCR_Decode
|
|||||||
{
|
{
|
||||||
Name = "Position";
|
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()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
string result = await GetStringFromPng(WindowImage,Engine, "0123456789");
|
string ocrResult = await GetStringFromPng(WindowImage,Engine, "0123456789");
|
||||||
|
|
||||||
int position;
|
int position;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
position = Convert.ToInt32(result);
|
position = Convert.ToInt32(ocrResult);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
position = -1;
|
position = -1;
|
||||||
//WindowImage.Save(Reader.DEBUG_DUMP_FOLDER + "FailedPosition" + ".png");
|
|
||||||
}
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ namespace OCR_Decode
|
|||||||
/// <returns>the sector time in int (ms)</returns>
|
/// <returns>the sector time in int (ms)</returns>
|
||||||
public override async Task<object> DecodePng()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector, Engine);
|
int ocrResult = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector, Engine);
|
||||||
return result;
|
return ocrResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace OCR_Decode
|
|||||||
/// <returns>the sector time in int (ms)</returns>
|
/// <returns>the sector time in int (ms)</returns>
|
||||||
public override async Task<object> DecodePng()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
int ocrResult = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
||||||
return result;
|
return ocrResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace OCR_Decode
|
|||||||
/// <returns>the sector time in int (ms)</returns>
|
/// <returns>the sector time in int (ms)</returns>
|
||||||
public override async Task<object> DecodePng()
|
public override async Task<object> DecodePng()
|
||||||
{
|
{
|
||||||
int result = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
int ocrResult = await GetTimeFromPng(WindowImage, OcrImage.WindowType.Sector,Engine);
|
||||||
return result;
|
return ocrResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user