Reworked cleaning of the LapTimes
This commit is contained in:
@@ -55,7 +55,7 @@ namespace Test_Merge
|
|||||||
case WindowType.LapTime:
|
case WindowType.LapTime:
|
||||||
outputBitmap.Save(Window.LAPTIME_DEBUG_FOLDER + @"\raw_" + id + ".png");
|
outputBitmap.Save(Window.LAPTIME_DEBUG_FOLDER + @"\raw_" + id + ".png");
|
||||||
|
|
||||||
outputBitmap = Tresholding(outputBitmap, 185);
|
outputBitmap = Tresholding(outputBitmap, 165);
|
||||||
outputBitmap.Save(Window.LAPTIME_DEBUG_FOLDER + @"\treshold_" + id + ".png");
|
outputBitmap.Save(Window.LAPTIME_DEBUG_FOLDER + @"\treshold_" + id + ".png");
|
||||||
|
|
||||||
outputBitmap = Dilatation(outputBitmap, 1);
|
outputBitmap = Dilatation(outputBitmap, 1);
|
||||||
|
|||||||
+166
-3
@@ -182,11 +182,12 @@ namespace Test_Merge
|
|||||||
//removes any empty cells (tho this usually sign of a really bad OCR implementation tbh will have to be fixed higher in the chian)
|
//removes any empty cells (tho this usually sign of a really bad OCR implementation tbh will have to be fixed higher in the chian)
|
||||||
rawNumbers.RemoveAll(x => ((string)x) == "");
|
rawNumbers.RemoveAll(x => ((string)x) == "");
|
||||||
|
|
||||||
|
int minuts = 0;
|
||||||
|
int seconds = 0;
|
||||||
|
int miliseconds = 0;
|
||||||
switch (windowType)
|
switch (windowType)
|
||||||
{
|
{
|
||||||
case OcrImage.WindowType.Sector:
|
case OcrImage.WindowType.Sector:
|
||||||
int seconds = 0;
|
|
||||||
int miliseconds = 0;
|
|
||||||
//Usually there is supposed to be only 2 parts.
|
//Usually there is supposed to be only 2 parts.
|
||||||
if (rawNumbers.Count == 2)
|
if (rawNumbers.Count == 2)
|
||||||
{
|
{
|
||||||
@@ -253,7 +254,169 @@ namespace Test_Merge
|
|||||||
result += miliseconds;
|
result += miliseconds;
|
||||||
break;
|
break;
|
||||||
case OcrImage.WindowType.LapTime:
|
case OcrImage.WindowType.LapTime:
|
||||||
|
|
||||||
|
if (rawNumbers.Count == 3)
|
||||||
|
{
|
||||||
|
//The normal way
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minuts = Convert.ToInt32(rawNumbers[0]);
|
||||||
|
seconds = Convert.ToInt32(rawNumbers[1]);
|
||||||
|
miliseconds = Convert.ToInt32(rawNumbers[2]);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rawNumbers.Count == 2)
|
||||||
|
{
|
||||||
|
//Either the ':' or the '.' has been missinterpreted
|
||||||
|
if (rawNumbers[0].Length > rawNumbers[1].Length)
|
||||||
|
{
|
||||||
|
//The ':' has been missinterpreted
|
||||||
|
if (rawNumbers[0].Length == 3)
|
||||||
|
{
|
||||||
|
//It has been forgotten
|
||||||
|
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("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rawNumbers[0].Length == 4)
|
||||||
|
{
|
||||||
|
//I has been translated into an other number
|
||||||
|
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("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//This could happen if the ':' has been missinterpreted with a lap time of over 9 minuts (HIGLY IMPROBABLE)
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//The '.' has been missinterpreted
|
||||||
|
if (rawNumbers[1].Length == 5)
|
||||||
|
{
|
||||||
|
//It has been forgotten
|
||||||
|
minuts = Convert.ToInt32(rawNumbers[0]);
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rawNumbers[1].Length == 6)
|
||||||
|
{
|
||||||
|
//It has been interpreted as a number
|
||||||
|
minuts = Convert.ToInt32(rawNumbers[0].ToString());
|
||||||
|
seconds = Convert.ToInt32(rawNumbers[1][0].ToString() + rawNumbers[1][1].ToString());
|
||||||
|
miliseconds = Convert.ToInt32(rawNumbers[1][3].ToString() + rawNumbers[1][4].ToString() + rawNumbers[1][5].ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(rawNumbers.Count == 1)
|
||||||
|
{
|
||||||
|
//Both the '.' and the ':' have been missinterpreted
|
||||||
|
if (rawNumbers[0].Length == 6)
|
||||||
|
{
|
||||||
|
//The just all have been forgotten
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minuts = Convert.ToInt32(rawNumbers[0][0].ToString());
|
||||||
|
seconds = Convert.ToInt32(rawNumbers[0][1].ToString() + rawNumbers[0][2].ToString());
|
||||||
|
miliseconds = Convert.ToInt32(rawNumbers[0][3].ToString() + rawNumbers[0][4].ToString() + rawNumbers[0][5].ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(rawNumbers[0].Length == 7)
|
||||||
|
{
|
||||||
|
//The '.' or ':' have been interpreted as a number (usually the ':')
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minuts = Convert.ToInt32(rawNumbers[0][0].ToString());
|
||||||
|
seconds = Convert.ToInt32(rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString());
|
||||||
|
miliseconds = Convert.ToInt32(rawNumbers[0][4].ToString() + rawNumbers[0][5].ToString() + rawNumbers[0][6].ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rawNumbers[0].Length == 8)
|
||||||
|
{
|
||||||
|
//Both have been interpreted as a number
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minuts = Convert.ToInt32(rawNumbers[0][0].ToString());
|
||||||
|
seconds = Convert.ToInt32(rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString());
|
||||||
|
miliseconds = Convert.ToInt32(rawNumbers[0][5].ToString() + rawNumbers[0][6].ToString() + rawNumbers[0][7].ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//I dont know what could have happened
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//I dont know what could have happened
|
||||||
|
Console.WriteLine("Lap time convertion failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(minuts > 9)
|
||||||
|
{
|
||||||
|
Console.Write("Euuuuuh chelou la non?");
|
||||||
|
}
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
result += minuts * 60 * 1000;
|
||||||
|
result += seconds * 1000;
|
||||||
|
result += miliseconds;
|
||||||
break;
|
break;
|
||||||
case OcrImage.WindowType.Gap:
|
case OcrImage.WindowType.Gap:
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -97,17 +97,15 @@ namespace Test_Merge
|
|||||||
//result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList);
|
//result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList);
|
||||||
result.Name = "Unknown";
|
result.Name = "Unknown";
|
||||||
if (w is DriverDrsWindow)
|
if (w is DriverDrsWindow)
|
||||||
//result.DRS = (bool)await (w as DriverDrsWindow).DecodePng();
|
result.DRS = (bool)await (w as DriverDrsWindow).DecodePng();
|
||||||
result.DRS = false;
|
|
||||||
if (w is DriverGapToLeaderWindow)
|
if (w is DriverGapToLeaderWindow)
|
||||||
//result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng();
|
//result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng();
|
||||||
result.GapToLeader = 0;
|
result.GapToLeader = 0;
|
||||||
if (w is DriverLapTimeWindow)
|
if (w is DriverLapTimeWindow)
|
||||||
//result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng();
|
result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng();
|
||||||
result.LapTime = 0;
|
//result.LapTime = 0;
|
||||||
if (w is DriverPositionWindow)
|
if (w is DriverPositionWindow)
|
||||||
result.Position = (int)await (w as DriverPositionWindow).DecodePng();
|
result.Position = (int)await (w as DriverPositionWindow).DecodePng();
|
||||||
//result.Position = 0;
|
|
||||||
if (w is DriverSectorWindow)
|
if (w is DriverSectorWindow)
|
||||||
{
|
{
|
||||||
sectorCount++;
|
sectorCount++;
|
||||||
|
|||||||
Reference in New Issue
Block a user