Slightly improved performances or the tyre recognition
This commit is contained in:
+11
-7
@@ -16,6 +16,7 @@ namespace OCR_Decode
|
|||||||
{
|
{
|
||||||
Bitmap InputImage;
|
Bitmap InputImage;
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
|
int salt = 0;
|
||||||
public enum WindowType
|
public enum WindowType
|
||||||
{
|
{
|
||||||
LapTime,
|
LapTime,
|
||||||
@@ -27,11 +28,11 @@ namespace OCR_Decode
|
|||||||
public OcrImage(Bitmap inputImage)
|
public OcrImage(Bitmap inputImage)
|
||||||
{
|
{
|
||||||
InputImage = inputImage;
|
InputImage = inputImage;
|
||||||
|
salt = rnd.Next(0, 10000);
|
||||||
}
|
}
|
||||||
public Bitmap Enhance(WindowType type = WindowType.Text)
|
public Bitmap Enhance(WindowType type = WindowType.Text)
|
||||||
{
|
{
|
||||||
Bitmap result = (Bitmap)InputImage.Clone();
|
Bitmap result = (Bitmap)InputImage.Clone();
|
||||||
int salt = rnd.Next(0, 10000);
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case WindowType.LapTime:
|
case WindowType.LapTime:
|
||||||
@@ -57,13 +58,13 @@ namespace OCR_Decode
|
|||||||
//result.Save(Reader.DEBUG_DUMP_FOLDER + "TextAfter_" + salt + ".png");
|
//result.Save(Reader.DEBUG_DUMP_FOLDER + "TextAfter_" + salt + ".png");
|
||||||
break;
|
break;
|
||||||
case WindowType.Tyre:
|
case WindowType.Tyre:
|
||||||
//result.Save(Reader.DEBUG_DUMP_FOLDER + "tyreBefore_" + salt + ".png");
|
result.Save(Reader.DEBUG_DUMP_FOLDER + "tyreBefore_" + salt + ".png");
|
||||||
result = RemoveUseless(result);
|
result = RemoveUseless(result);
|
||||||
//result.Save(Reader.DEBUG_DUMP_FOLDER + "tyre01_" + salt + ".png");
|
result.Save(Reader.DEBUG_DUMP_FOLDER + "tyre01_" + salt + ".png");
|
||||||
result = Resize(result, 4);
|
result = Resize(result, 4);
|
||||||
//result.Save(Reader.DEBUG_DUMP_FOLDER + "tyre02_" + salt + ".png");
|
result.Save(Reader.DEBUG_DUMP_FOLDER + "tyre02_" + salt + ".png");
|
||||||
result = Dilatation(result, 1);
|
result = Dilatation(result, 1);
|
||||||
//result.Save(Reader.DEBUG_DUMP_FOLDER + "tyreAfter_" + salt + ".png");
|
result.Save(Reader.DEBUG_DUMP_FOLDER + "tyreAfter_" + salt + ".png");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = Tresholding(result, 165);
|
result = Tresholding(result, 165);
|
||||||
@@ -173,7 +174,10 @@ namespace OCR_Decode
|
|||||||
}
|
}
|
||||||
public unsafe static Bitmap RemoveUseless(Bitmap bmp)
|
public unsafe static Bitmap RemoveUseless(Bitmap bmp)
|
||||||
{
|
{
|
||||||
bmp = RemoveBG(bmp);
|
Random rnd = new Random();
|
||||||
|
int salt = rnd.Next(0,1000);
|
||||||
|
|
||||||
|
//bmp.Save(Reader.DEBUG_DUMP_FOLDER + "RemovedBG_"+salt+".png");
|
||||||
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
||||||
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat);
|
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat);
|
||||||
int bytesPerPixel = Bitmap.GetPixelFormatSize(bmp.PixelFormat) / 8;
|
int bytesPerPixel = Bitmap.GetPixelFormatSize(bmp.PixelFormat) / 8;
|
||||||
@@ -257,7 +261,7 @@ namespace OCR_Decode
|
|||||||
|
|
||||||
//We remove the background pixels
|
//We remove the background pixels
|
||||||
|
|
||||||
if (R >= limitColor.R + 20 || G >= limitColor.G + 20 || B >= limitColor.B + 20)
|
if (R >= limitColor.R + 15 || G >= limitColor.G + 15 || B >= limitColor.B + 15)
|
||||||
{
|
{
|
||||||
pixel[0] = 0xFF;
|
pixel[0] = 0xFF;
|
||||||
pixel[1] = 0xFF;
|
pixel[1] = 0xFF;
|
||||||
|
|||||||
Reference in New Issue
Block a user