Reworked the GapToLeader metrics
This commit is contained in:
+17
-2
@@ -46,6 +46,18 @@ namespace Test_Merge
|
||||
Bitmap outputBitmap = (Bitmap)InputBitmap.Clone();
|
||||
switch (type)
|
||||
{
|
||||
case WindowType.Gap:
|
||||
outputBitmap.Save(Window.GAPTOLEADER_DEBUG_FOLDER + @"\raw_" + id + ".png");
|
||||
|
||||
outputBitmap = Tresholding(outputBitmap, 165);
|
||||
outputBitmap.Save(Window.GAPTOLEADER_DEBUG_FOLDER + @"\treshold_" + id + ".png");
|
||||
|
||||
outputBitmap = Resize(outputBitmap, 2);
|
||||
outputBitmap.Save(Window.GAPTOLEADER_DEBUG_FOLDER + @"\resize_" + id + ".png");
|
||||
|
||||
outputBitmap = Dilatation(outputBitmap, 1);
|
||||
outputBitmap.Save(Window.GAPTOLEADER_DEBUG_FOLDER + @"\Final_dilatation_" + id + ".png");
|
||||
break;
|
||||
case WindowType.Sector:
|
||||
outputBitmap.Save(Window.SECTOR1_DEBUG_FOLDER + @"\raw_" + id + ".png");
|
||||
|
||||
@@ -71,13 +83,16 @@ namespace Test_Merge
|
||||
outputBitmap.Save(Window.STRING_DEBUG_FOLDER + @"\Final_treshold_" + id + ".png");
|
||||
break;
|
||||
case WindowType.Tyre:
|
||||
outputBitmap.Save(Window.TYRE_DEBUG_FOLDER + @"\raw_" + id + ".png");
|
||||
|
||||
outputBitmap = RemoveUseless(outputBitmap);
|
||||
outputBitmap = Resize(outputBitmap, 4);
|
||||
outputBitmap.Save(Window.TYRE_DEBUG_FOLDER + @"\uselessRemoved_" + id + ".png");
|
||||
|
||||
outputBitmap = Dilatation(outputBitmap, 1);
|
||||
outputBitmap.Save(Window.TYRE_DEBUG_FOLDER + @"\Final_dilatation_" + id + ".png");
|
||||
break;
|
||||
default:
|
||||
outputBitmap = Tresholding(outputBitmap, 165);
|
||||
//outputBitmap = Resize(outputBitmap, 4);
|
||||
outputBitmap = Resize(outputBitmap, 2);
|
||||
outputBitmap = Erode(outputBitmap, 1);
|
||||
break;
|
||||
|
||||
+122
-12
@@ -194,8 +194,8 @@ namespace Test_Merge
|
||||
//The perect case
|
||||
try
|
||||
{
|
||||
seconds = Convert.ToInt32(rawNumbers[0]);
|
||||
miliseconds = Convert.ToInt32(rawNumbers[1]);
|
||||
seconds = Convert.ToInt32(rawNumbers[0].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[1].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -260,9 +260,9 @@ namespace Test_Merge
|
||||
//The normal way
|
||||
try
|
||||
{
|
||||
minuts = Convert.ToInt32(rawNumbers[0]);
|
||||
seconds = Convert.ToInt32(rawNumbers[1]);
|
||||
miliseconds = Convert.ToInt32(rawNumbers[2]);
|
||||
minuts = Convert.ToInt32(rawNumbers[0].ToString());
|
||||
seconds = Convert.ToInt32(rawNumbers[1].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[2].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -321,7 +321,7 @@ namespace Test_Merge
|
||||
if (rawNumbers[1].Length == 5)
|
||||
{
|
||||
//It has been forgotten
|
||||
minuts = Convert.ToInt32(rawNumbers[0]);
|
||||
minuts = Convert.ToInt32(rawNumbers[0].ToString());
|
||||
seconds = Convert.ToInt32(rawNumbers[1][0].ToString() + rawNumbers[1][1].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[1][2].ToString() + rawNumbers[1][3].ToString() + rawNumbers[1][4].ToString());
|
||||
}
|
||||
@@ -408,23 +408,133 @@ namespace Test_Merge
|
||||
}
|
||||
}
|
||||
|
||||
if(minuts > 9)
|
||||
{
|
||||
Console.Write("Euuuuuh chelou la non?");
|
||||
}
|
||||
|
||||
result = 0;
|
||||
result += minuts * 60 * 1000;
|
||||
result += seconds * 1000;
|
||||
result += miliseconds;
|
||||
break;
|
||||
case OcrImage.WindowType.Gap:
|
||||
if (rawNumbers.Count == 2)
|
||||
{
|
||||
// This should be the x.xxx or a missed x:xx.xxx
|
||||
if (rawNumbers[0].Length > 2)
|
||||
{
|
||||
//Its a missed x:xx.xxx
|
||||
if (rawNumbers[0].Length == 3)
|
||||
{
|
||||
//It forgot the ":"
|
||||
try
|
||||
{
|
||||
minuts = Convert.ToInt32(rawNumbers[0][0].ToString());
|
||||
seconds = Convert.ToInt32(rawNumbers[0][1].ToString() + rawNumbers[0][2].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[1]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//The ":" has been mistaken as a number
|
||||
if (rawNumbers[0].Length == 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
minuts = Convert.ToInt32(rawNumbers[0][0].ToString());
|
||||
seconds = Convert.ToInt32(rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[1]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//It should be a normal x.xxx or xx.xxx
|
||||
try
|
||||
{
|
||||
seconds = Convert.ToInt32(rawNumbers[0].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[1].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rawNumbers.Count == 1)
|
||||
{
|
||||
//can be anything depending on the size of the string
|
||||
if (rawNumbers[0].Length == 4)
|
||||
{
|
||||
//We just missed the '.'
|
||||
try
|
||||
{
|
||||
seconds = Convert.ToInt32(rawNumbers[0][0].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[0][1].ToString() + rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rawNumbers[0].Length == 5)
|
||||
{
|
||||
//We just missed the '.'
|
||||
try
|
||||
{
|
||||
seconds = Convert.ToInt32(rawNumbers[0][0].ToString() + rawNumbers[0][1].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString() + rawNumbers[0][4].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
//There is just too much possibilities that it would be stupid to try and tell them appart so for now im leaving that as just an error
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rawNumbers.Count == 3)
|
||||
{
|
||||
// This should be the x:xx.xxx
|
||||
try
|
||||
{
|
||||
minuts = Convert.ToInt32(rawNumbers[0].ToString());
|
||||
seconds = Convert.ToInt32(rawNumbers[1].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[2].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Gap to leader convertion failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
result += minuts * 60 * 1000;
|
||||
result += seconds * 1000;
|
||||
result += miliseconds;
|
||||
break;
|
||||
default:
|
||||
try
|
||||
{
|
||||
result = Convert.ToInt32(rawNumbers[0]);
|
||||
result = Convert.ToInt32(rawNumbers[0].ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
+2
-8
@@ -94,16 +94,13 @@ namespace Test_Merge
|
||||
{
|
||||
// A switch would be prettier but I dont think its supported in this C# version
|
||||
if (w is DriverNameWindow)
|
||||
//result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList);
|
||||
result.Name = "Unknown";
|
||||
result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList);
|
||||
if (w is DriverDrsWindow)
|
||||
result.DRS = (bool)await (w as DriverDrsWindow).DecodePng();
|
||||
if (w is DriverGapToLeaderWindow)
|
||||
//result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng();
|
||||
result.GapToLeader = 0;
|
||||
result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng();
|
||||
if (w is DriverLapTimeWindow)
|
||||
result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng();
|
||||
//result.LapTime = 0;
|
||||
if (w is DriverPositionWindow)
|
||||
result.Position = (int)await (w as DriverPositionWindow).DecodePng();
|
||||
if (w is DriverSectorWindow)
|
||||
@@ -111,13 +108,10 @@ namespace Test_Merge
|
||||
sectorCount++;
|
||||
if (sectorCount == 1)
|
||||
result.Sector1 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
//result.Sector1 = 0;
|
||||
if (sectorCount == 2)
|
||||
result.Sector2 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
//result.Sector2 = 0;
|
||||
if (sectorCount == 3)
|
||||
result.Sector3 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
//result.Sector3 = 0;
|
||||
}
|
||||
if (w is DriverTyresWindow)
|
||||
//result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng();
|
||||
|
||||
Reference in New Issue
Block a user