Cleaned up a little bit to make room for the windows

This commit is contained in:
2023-03-31 14:36:28 +02:00
parent dc6a6ee74d
commit d60de1a0c0
3 changed files with 93 additions and 42 deletions
+13 -18
View File
@@ -20,7 +20,7 @@ namespace OCR_tester
public void AutoCalibrate()
{
List<Rectangle> detectedText = new List<Rectangle>();
Windows = new List<Window>();
Zones = new List<Zone>();
TesseractEngine engine = new TesseractEngine(Window.tessDataFolder.FullName, "eng", EngineMode.Default);
Image image = ZoneImage;
@@ -61,23 +61,15 @@ namespace OCR_tester
}
}
} while (iter.Next(PageIteratorLevel.Word));
foreach (Rectangle Rectangle in detectedText)
{
Rectangle windowRectangle;
Size windowSize = new Size(image.Width, image.Height / NUMBER_OF_DRIVERS);
Point windowLocation = new Point(0, (Rectangle.Y + Rectangle.Height / 2) - windowSize.Height / 2);
windowRectangle = new Rectangle(windowLocation,windowSize);
Windows.Add(new Window(ZoneImage,windowRectangle));
}
}
//Now that we have all the detected text we can try to split the zone
foreach (Rectangle rect in detectedText)
foreach (Rectangle Rectangle in detectedText)
{
//To do
Rectangle windowRectangle;
Size windowSize = new Size(image.Width, image.Height / NUMBER_OF_DRIVERS);
Point windowLocation = new Point(0, (Rectangle.Y + Rectangle.Height / 2) - windowSize.Height / 2);
windowRectangle = new Rectangle(windowLocation, windowSize);
Zones.Add(new Zone(ZoneImage, windowRectangle));
}
}
public Bitmap Draw()
@@ -85,9 +77,12 @@ namespace OCR_tester
Bitmap image = ZoneImage;
Graphics g = Graphics.FromImage(image);
foreach (Window w in Windows)
int count = 0;
foreach (Zone z in Zones)
{
g.DrawRectangle(Pens.Red,w.Bounds);
g.DrawRectangle(Pens.Red,z.Bounds);
z.ZoneImage.Save(@"C:\Users\Moi\Desktop\imgDump\"+"driver"+count+".png");
count++;
}
image.Save(@"C:\Users\Moi\Desktop\imgDump\test.png");
return image;