Now the color recognition is better
This commit is contained in:
@@ -38,15 +38,16 @@ namespace OCR_Decode
|
|||||||
tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "ZONE" + ".png");
|
tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "ZONE" + ".png");
|
||||||
Tyre.Type type = Tyre.Type.Undefined;
|
Tyre.Type type = Tyre.Type.Undefined;
|
||||||
int laps = -1;
|
int laps = -1;
|
||||||
if (text.All(char.IsDigit))
|
//if (text.All(char.IsDigit))
|
||||||
{
|
//{
|
||||||
//We have a lap count
|
//We have a lap count
|
||||||
if (text != "")
|
//if (text != "")
|
||||||
{
|
//{
|
||||||
laps = Convert.ToInt32(text);
|
//laps = Convert.ToInt32(text);
|
||||||
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(tyreZone));
|
type = GetTyreTypeFromColor(OcrImage.GetAvgColorFromBitmap(OcrImage.Resize(tyreZone)));
|
||||||
}
|
//}
|
||||||
}
|
//}
|
||||||
|
/*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//We have a tire type
|
//We have a tire type
|
||||||
@@ -74,6 +75,7 @@ namespace OCR_Decode
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "Tyre" + type + "Laps" + laps + '#' + rnd.Next(0, 1000) + ".png");
|
tyreZone.Save(Reader.DEBUG_DUMP_FOLDER + "Tyre" + type + "Laps" + laps + '#' + rnd.Next(0, 1000) + ".png");
|
||||||
return new Tyre(type,laps);
|
return new Tyre(type,laps);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,8 @@ namespace OCR_Decode
|
|||||||
int R = pixel[2];
|
int R = pixel[2];
|
||||||
|
|
||||||
//We remove the background pixels
|
//We remove the background pixels
|
||||||
if (R >= limitColor.R && G >= limitColor.G && B >= limitColor.B)
|
|
||||||
|
if (R >= limitColor.R || G >= limitColor.G || B >= limitColor.B)
|
||||||
{
|
{
|
||||||
totPixels++;
|
totPixels++;
|
||||||
totB += pixel[0];
|
totB += pixel[0];
|
||||||
@@ -213,7 +214,7 @@ namespace OCR_Decode
|
|||||||
}
|
}
|
||||||
bmp.UnlockBits(bmpData);
|
bmp.UnlockBits(bmpData);
|
||||||
|
|
||||||
return Color.FromArgb(255,totR / totPixels,totG / totPixels,totB / totPixels);
|
return Color.FromArgb(255,Convert.ToInt32((float)totR / (float)totPixels),Convert.ToInt32((float)totG / (float)totPixels),Convert.ToInt32((float)totB / (float)totPixels));
|
||||||
}
|
}
|
||||||
public static Bitmap InvertColors(Bitmap input)
|
public static Bitmap InvertColors(Bitmap input)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user