Added all the files needed for calibration and detection but it now needs to be wired up

This commit is contained in:
2023-04-26 15:55:00 +02:00
parent e0d5f82467
commit 0080104072
17 changed files with 1819 additions and 12 deletions
+52
View File
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Test_Merge
{
public class DriverNameWindow : Window
{
public static Random rnd = new Random();
public DriverNameWindow(Bitmap image, Rectangle bounds) : base(image, bounds)
{
Name = "Name";
}
/// <summary>
/// Decodes using OCR wich driver name is in the image
/// </summary>
/// <param name="DriverList"></param>
/// <returns>The driver name in string</returns>
public override async Task<object> DecodePng(List<string> DriverList)
{
string result = "";
result = await GetStringFromPng(WindowImage, Engine);
if (!IsADriver(DriverList, result))
{
//I put everything in uppercase to try to lower the chances of bad answers
result = FindClosestMatch(DriverList.ConvertAll(d => d.ToUpper()), result.ToUpper());
}
return result;
}
/// <summary>
/// Verifies that the name found in the OCR is a valid name
/// </summary>
/// <param name="driverList"></param>
/// <param name="potentialDriver"></param>
/// <returns>If ye or no the driver exists</returns>
private static bool IsADriver(List<string> driverList, string potentialDriver)
{
bool result = false;
//I cant use drivers.Contains because it has missmatched cases and all
foreach (string name in driverList)
{
if (name.ToUpper() == potentialDriver.ToUpper())
result = true;
}
return result;
}
}
}