Added a lot to the doc and modified the pdf generation
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/// Author : Maxime Rohmer
|
||||
/// Date : 08/05/2023
|
||||
/// Date : 30/05/2023
|
||||
/// File : DriverTyresWindow.cs
|
||||
/// Brief : Window containing infos about a driver's tyre
|
||||
/// Version : 0.1
|
||||
/// Version : Alpha 1.0
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -11,13 +11,11 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Test_Merge
|
||||
namespace TrackTrends
|
||||
{
|
||||
public class DriverTyresWindow:Window
|
||||
{
|
||||
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);
|
||||
@@ -34,22 +32,25 @@ namespace Test_Merge
|
||||
/// This will decode the content of the image
|
||||
/// </summary>
|
||||
/// <returns>And object containing what was on the image</returns>
|
||||
public override async Task<object> DecodePng()
|
||||
public override object DecodePng()
|
||||
{
|
||||
return await GetTyreInfos();
|
||||
return GetTyreInfos();
|
||||
}
|
||||
/// <summary>
|
||||
/// Method that will decode whats on the image and return the tyre infos it could manage to recover
|
||||
/// </summary>
|
||||
/// <returns>A tyre object containing tyre infos</returns>
|
||||
private async Task<Tyre> GetTyreInfos()
|
||||
private Tyre GetTyreInfos()
|
||||
{
|
||||
//DEBUG
|
||||
//WindowImage.Save("./Tyre/raw_"+rnd.Next(0,99999)+".png");
|
||||
|
||||
Bitmap tyreZone = GetSmallBitmapFromBigOne(WindowImage, FindTyreZone());
|
||||
Tyre.Type type = Tyre.Type.Undefined;
|
||||
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(tyreZone));
|
||||
int laps = -1;
|
||||
|
||||
string number = await GetStringFromPng(tyreZone, Engine, "0123456789", OcrImage.WindowType.Tyre);
|
||||
string number = GetStringFromPng(tyreZone, Engine, "0123456789", OcrImage.WindowType.Tyre);
|
||||
try
|
||||
{
|
||||
laps = Convert.ToInt32(number);
|
||||
@@ -59,7 +60,11 @@ namespace Test_Merge
|
||||
//We could not convert the number so its a letter so its 0 laps old
|
||||
laps = 0;
|
||||
}
|
||||
//tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "Tyre" + type + "Laps" + laps + '#' + rnd.Next(0, 1000) + ".png");
|
||||
|
||||
//71 is the most laps an f1 race is ever going to have (mexico) so any more would be considered as bad (and remember you cant go trough a full race without making at least one pitstop)
|
||||
if (laps > 75)
|
||||
laps = 0;
|
||||
|
||||
return new Tyre(type, laps);
|
||||
}
|
||||
/// <summary>
|
||||
@@ -73,8 +78,8 @@ namespace Test_Merge
|
||||
int height = bmp.Height / 2;
|
||||
Color limitColor = Color.FromArgb(0x50, 0x50, 0x50);
|
||||
Color currentColor = Color.FromArgb(0, 0, 0);
|
||||
|
||||
Size newWindowSize = new Size(bmp.Height - Convert.ToInt32((float)bmp.Height / 100f * 25f), bmp.Height - Convert.ToInt32((float)bmp.Height / 100f * 35f));
|
||||
//25F
|
||||
Size newWindowSize = new Size(bmp.Height - Convert.ToInt32((float)bmp.Height / 100f * 25f), bmp.Height - Convert.ToInt32((float)bmp.Height / 100f * 35f));
|
||||
|
||||
while (currentColor.R <= limitColor.R && currentColor.G <= limitColor.G && currentColor.B <= limitColor.B && currentPosition > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user