Slightly improved performances of the tyre recognition and added some debug tools
This commit is contained in:
@@ -12,6 +12,7 @@ namespace OCR_Decode
|
|||||||
internal class DriverTyresWindow : Window
|
internal class DriverTyresWindow : Window
|
||||||
{
|
{
|
||||||
private static Random rnd = new Random();
|
private static Random rnd = new Random();
|
||||||
|
int seed = rnd.Next(0,10000);
|
||||||
|
|
||||||
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);
|
||||||
@@ -32,8 +33,9 @@ namespace OCR_Decode
|
|||||||
private async Task<Tyre> GetTyreInfos()
|
private async Task<Tyre> GetTyreInfos()
|
||||||
{
|
{
|
||||||
Bitmap tyreZone = GetSmallBitmapFromBigOne(WindowImage, FindTyreZone());
|
Bitmap tyreZone = GetSmallBitmapFromBigOne(WindowImage, FindTyreZone());
|
||||||
|
//tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "NewTyreZone_"+seed+".png");
|
||||||
Tyre.Type type = Tyre.Type.Undefined;
|
Tyre.Type type = Tyre.Type.Undefined;
|
||||||
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(OcrImage.Resize(tyreZone, 2)));
|
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(tyreZone));
|
||||||
int laps = -1;
|
int laps = -1;
|
||||||
|
|
||||||
string number = await GetStringFromPng(tyreZone, Engine, "0123456789", OcrImage.WindowType.Tyre);
|
string number = await GetStringFromPng(tyreZone, Engine, "0123456789", OcrImage.WindowType.Tyre);
|
||||||
@@ -52,6 +54,9 @@ namespace OCR_Decode
|
|||||||
private Rectangle FindTyreZone()
|
private Rectangle FindTyreZone()
|
||||||
{
|
{
|
||||||
Bitmap bmp = WindowImage;
|
Bitmap bmp = WindowImage;
|
||||||
|
|
||||||
|
//bmp.Save(Reader.DEBUG_DUMP_FOLDER + "OldTyreZone_" + seed + ".png");
|
||||||
|
|
||||||
int currentPosition = bmp.Width;
|
int currentPosition = bmp.Width;
|
||||||
int height = bmp.Height / 2;
|
int height = bmp.Height / 2;
|
||||||
Color limitColor = Color.FromArgb(0x50, 0x50, 0x50);
|
Color limitColor = Color.FromArgb(0x50, 0x50, 0x50);
|
||||||
@@ -97,6 +102,11 @@ namespace OCR_Decode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Bitmap colorBmp = new Bitmap(200, 100);
|
||||||
|
//Graphics g = Graphics.FromImage(colorBmp);
|
||||||
|
//g.FillRectangle(new SolidBrush(closestColor), new Rectangle(0, 0, colorBmp.Width, colorBmp.Height));
|
||||||
|
//colorBmp.Save(Reader.DEBUG_DUMP_FOLDER+"AVGCOLOR_"+closestColor.ToString()+"_"+seed+".png");
|
||||||
|
|
||||||
//We cant use a switch as the colors cant be constants ...
|
//We cant use a switch as the colors cant be constants ...
|
||||||
if (closestColor == SOFT_TYRE_COLOR)
|
if (closestColor == SOFT_TYRE_COLOR)
|
||||||
type = Tyre.Type.Soft;
|
type = Tyre.Type.Soft;
|
||||||
|
|||||||
Reference in New Issue
Block a user