Now the Sectors detection is tested and passes
This commit is contained in:
@@ -13,7 +13,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace TrackTrends
|
namespace TrackTrends
|
||||||
{
|
{
|
||||||
internal class DriverSectorWindow:Window
|
public class DriverSectorWindow:Window
|
||||||
{
|
{
|
||||||
public DriverSectorWindow(Bitmap image, Rectangle bounds, int sectorId, bool generateEngine = true) : base(image, bounds,generateEngine)
|
public DriverSectorWindow(Bitmap image, Rectangle bounds, int sectorId, bool generateEngine = true) : base(image, bounds,generateEngine)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -126,7 +126,38 @@ namespace TrackTrends.Tests
|
|||||||
[TestMethod()]
|
[TestMethod()]
|
||||||
public void SectorOCR_Test()
|
public void SectorOCR_Test()
|
||||||
{
|
{
|
||||||
Assert.Fail();
|
string directory = @"./../../TestImages/Sectors/";
|
||||||
|
foreach (string file in Directory.GetFiles(directory))
|
||||||
|
{
|
||||||
|
Bitmap image = (Bitmap)Image.FromFile(file);
|
||||||
|
DriverSectorWindow sectorsWindow = new DriverSectorWindow(image, new Rectangle(0, 0, image.Width, image.Height), 1,true);
|
||||||
|
string[] paths = file.Split('/');
|
||||||
|
string fileName = paths[paths.Length - 1];
|
||||||
|
fileName = fileName.Replace(".png", "");
|
||||||
|
|
||||||
|
int timeMS = (int)sectorsWindow.DecodePng();
|
||||||
|
string time = Reader.ConvertMsToTime(timeMS);
|
||||||
|
|
||||||
|
string[] checkDigits = fileName.Split('_');
|
||||||
|
string[] digitsToCheck = time.Split(':');
|
||||||
|
|
||||||
|
if (time == "0:00:000")
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, Convert.ToInt32(checkDigits[0]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//The ConvertMSToTime will always return three chars so we need to make the checkDigits be also three chars
|
||||||
|
while (checkDigits.Length != 3)
|
||||||
|
checkDigits = new[] { "0" }.Concat(checkDigits).ToArray();
|
||||||
|
|
||||||
|
for (int i = 0; i < checkDigits.Length; i++)
|
||||||
|
{
|
||||||
|
//We need to convert to int first because sometimes we have "08" and "8" and in string its not the same but in int it is
|
||||||
|
Assert.AreEqual(Convert.ToInt32(checkDigits[i]), Convert.ToInt32(digitsToCheck[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user