Improved the old way of manually selecting windows, Added all the windows types and implemented them, You can now export to a bad json file
This commit is contained in:
+60
-1
@@ -12,6 +12,7 @@ namespace OCR_tester
|
||||
protected Bitmap FullImage;
|
||||
private List<Zone> _zones;
|
||||
private List<Window> _windows;
|
||||
private string _name;
|
||||
|
||||
protected Rectangle _bounds;
|
||||
public List<Zone> Zones { get => _zones; protected set => _zones = value; }
|
||||
@@ -29,6 +30,8 @@ namespace OCR_tester
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get => _name; set => _name = value; }
|
||||
|
||||
public Zone(Image fullImage, Rectangle bounds)
|
||||
{
|
||||
FullImage = (Bitmap)fullImage;
|
||||
@@ -50,7 +53,7 @@ namespace OCR_tester
|
||||
if (Fits(bounds))
|
||||
Zones.Add(new Zone(ZoneImage, bounds));
|
||||
}
|
||||
public void AddWindow(Rectangle bounds)
|
||||
public virtual void AddWindow(Rectangle bounds)
|
||||
{
|
||||
if (Fits(bounds))
|
||||
Windows.Add(new Window(ZoneImage, bounds));
|
||||
@@ -81,5 +84,61 @@ namespace OCR_tester
|
||||
}
|
||||
return (Bitmap)img;
|
||||
}
|
||||
public virtual string ToJSON()
|
||||
{
|
||||
string result = "";
|
||||
result += "\"" + Name + "\":{" + Environment.NewLine;
|
||||
result += "\t" + "\"x\":" + Bounds.X + "," + Environment.NewLine;
|
||||
result += "\t" + "\"y\":" + Bounds.Y + "," + Environment.NewLine;
|
||||
result += "\t" + "\"width\":" + Bounds.Width + "," + Environment.NewLine;
|
||||
result += "\t" + "\"height\":" + Bounds.Height;
|
||||
|
||||
if (Windows.Count != 0)
|
||||
{
|
||||
result += "," +Environment.NewLine;
|
||||
|
||||
result += "\t" + "\"Windows\":["+Environment.NewLine;
|
||||
result += "\t\t{" + Environment.NewLine;
|
||||
int Wcount = 0;
|
||||
foreach (Window w in Windows)
|
||||
{
|
||||
result += "\t\t" + w.ToJSON();
|
||||
Wcount++;
|
||||
if (Wcount != Windows.Count)
|
||||
result += ",";
|
||||
}
|
||||
result += "\t\t}"+Environment.NewLine;
|
||||
result += "\t" + "]"+Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += Environment.NewLine;
|
||||
}
|
||||
if (Zones.Count != 0)
|
||||
{
|
||||
result += "," + Environment.NewLine;
|
||||
|
||||
result += "\t" + "\"Zones\":[" + Environment.NewLine;
|
||||
result += "\t\t{" + Environment.NewLine;
|
||||
int Zcount = 0;
|
||||
foreach (Zone z in Zones)
|
||||
{
|
||||
result += "\t\t" + z.ToJSON();
|
||||
Zcount++;
|
||||
if (Zcount != Zones.Count)
|
||||
result += ",";
|
||||
}
|
||||
result += "\t\t}" + Environment.NewLine;
|
||||
result += "\t" + "]" + Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += Environment.NewLine;
|
||||
}
|
||||
|
||||
result += "}";
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user