Now tyres are being tested
@@ -15,6 +15,7 @@ namespace TrackTrends
|
|||||||
{
|
{
|
||||||
public class DriverTyresWindow:Window
|
public class DriverTyresWindow:Window
|
||||||
{
|
{
|
||||||
|
private static Random rnd = new Random();
|
||||||
//Those are the colors I found but you can change them if they change in the future like in 2019
|
//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 SOFT_TYRE_COLOR = Color.FromArgb(0xff, 0x00, 0x00);
|
||||||
public static Color MEDIUM_TYRE_COLOR = Color.FromArgb(0xf5, 0xbf, 0x00);
|
public static Color MEDIUM_TYRE_COLOR = Color.FromArgb(0xf5, 0xbf, 0x00);
|
||||||
@@ -41,6 +42,9 @@ namespace TrackTrends
|
|||||||
/// <returns>A tyre object containing tyre infos</returns>
|
/// <returns>A tyre object containing tyre infos</returns>
|
||||||
private Tyre GetTyreInfos()
|
private Tyre GetTyreInfos()
|
||||||
{
|
{
|
||||||
|
//DEBUG
|
||||||
|
//WindowImage.Save("./Tyre/raw_"+rnd.Next(0,99999)+".png");
|
||||||
|
|
||||||
Bitmap tyreZone = GetSmallBitmapFromBigOne(WindowImage, FindTyreZone());
|
Bitmap tyreZone = GetSmallBitmapFromBigOne(WindowImage, FindTyreZone());
|
||||||
Tyre.Type type = Tyre.Type.Undefined;
|
Tyre.Type type = Tyre.Type.Undefined;
|
||||||
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(tyreZone));
|
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(tyreZone));
|
||||||
|
|||||||
@@ -59,6 +59,45 @@ namespace TrackTrends.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[TestMethod()]
|
[TestMethod()]
|
||||||
|
public void TyresOCR_Test()
|
||||||
|
{
|
||||||
|
string directory = @"./../../TestImages/Tyres/";
|
||||||
|
foreach (string file in Directory.GetFiles(directory))
|
||||||
|
{
|
||||||
|
Bitmap image = (Bitmap)Image.FromFile(file);
|
||||||
|
DriverTyresWindow tyreWindow = new DriverTyresWindow(image, new Rectangle(0, 0, image.Width, image.Height), true);
|
||||||
|
string[] paths = file.Split('/');
|
||||||
|
string fileName = paths[paths.Length - 1];
|
||||||
|
fileName = fileName.Replace(".png", "");
|
||||||
|
|
||||||
|
string[] fileInfos = fileName.Split('_');
|
||||||
|
string expectedType = fileInfos[0];
|
||||||
|
int expectedLap = Convert.ToInt32(fileInfos[1]);
|
||||||
|
|
||||||
|
Tyre foundTyre = (Tyre)tyreWindow.DecodePng();
|
||||||
|
|
||||||
|
switch (foundTyre.Coumpound)
|
||||||
|
{
|
||||||
|
case Tyre.Type.Soft:
|
||||||
|
Assert.AreEqual("SOFT",expectedType.ToUpper());
|
||||||
|
break;
|
||||||
|
case Tyre.Type.Inter:
|
||||||
|
Assert.AreEqual("INTER", expectedType.ToUpper());
|
||||||
|
break;
|
||||||
|
case Tyre.Type.Hard:
|
||||||
|
Assert.AreEqual("HARD", expectedType.ToUpper());
|
||||||
|
break;
|
||||||
|
case Tyre.Type.Wet:
|
||||||
|
Assert.AreEqual("WET", expectedType.ToUpper());
|
||||||
|
break;
|
||||||
|
case Tyre.Type.Medium:
|
||||||
|
Assert.AreEqual("MEDIUM", expectedType.ToUpper());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Assert.AreEqual(expectedLap,foundTyre.NumberOfLaps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[TestMethod()]
|
||||||
public void GapToLeaderOCR_Test()
|
public void GapToLeaderOCR_Test()
|
||||||
{
|
{
|
||||||
string directory = @"./../../TestImages/Gaps/";
|
string directory = @"./../../TestImages/Gaps/";
|
||||||
|
|||||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |