You can now also add windows and it all gets dump into a nice directory for each driver.

This commit is contained in:
2023-03-31 15:24:03 +02:00
parent d60de1a0c0
commit 5ec9656b03
5 changed files with 86 additions and 20 deletions
+21 -9
View File
@@ -10,10 +10,12 @@ namespace OCR_tester
public class Zone
{
protected Bitmap FullImage;
protected List<Zone> Zones;
protected List<Window> Windows;
private List<Zone> _zones;
private List<Window> _windows;
protected Rectangle _bounds;
public List<Zone> Zones { get => _zones; protected set => _zones = value; }
public List<Window> Windows { get => _windows; protected set => _windows = value; }
public Rectangle Bounds { get => _bounds; private set => _bounds = value; }
public Bitmap ZoneImage
@@ -43,15 +45,15 @@ namespace OCR_tester
Zones = new List<Zone>();
Windows = new List<Window>();
}
private void AddZone(Rectangle bounds)
{
if(Fits(bounds))
Zones.Add(new Zone(ZoneImage,bounds));
}
private void AddWindow(Rectangle bounds)
public void AddZone(Rectangle bounds)
{
if (Fits(bounds))
Windows.Add(new Window(ZoneImage,bounds));
Zones.Add(new Zone(ZoneImage, bounds));
}
public void AddWindow(Rectangle bounds)
{
if (Fits(bounds))
Windows.Add(new Window(ZoneImage, bounds));
}
/// <summary>
/// Checks if the given Rectangle fits in the current zone
@@ -69,5 +71,15 @@ namespace OCR_tester
return true;
}
}
public virtual Bitmap Draw()
{
Image img = ZoneImage;
Graphics g = Graphics.FromImage(img);
foreach (Window w in Windows)
{
g.DrawRectangle(Pens.Blue, w.Bounds);
}
return (Bitmap)img;
}
}
}