Now tyres are being tested

This commit is contained in:
2023-06-01 13:36:22 +02:00
parent eb98466a98
commit da23c40ac2
21 changed files with 43 additions and 0 deletions
+4
View File
@@ -15,6 +15,7 @@ namespace TrackTrends
{
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
public static Color SOFT_TYRE_COLOR = Color.FromArgb(0xff, 0x00, 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>
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));
+39
View File
@@ -59,6 +59,45 @@ namespace TrackTrends.Tests
}
}
[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()
{
string directory = @"./../../TestImages/Gaps/";
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB