You can now also add windows and it all gets dump into a nice directory for each driver.
This commit is contained in:
+46
-7
@@ -24,6 +24,8 @@ namespace OCR_tester
|
||||
|
||||
bool selectingZonePoints = false;
|
||||
bool selectingWindowPoints = false;
|
||||
|
||||
MainZone mainZone;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -41,6 +43,7 @@ namespace OCR_tester
|
||||
SwitchCreateWindowButton();
|
||||
selectingZonePoints = true;
|
||||
zonePoints = new Point[] { new Point(-1, -1), new Point(-1, -1) };
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -67,11 +70,11 @@ namespace OCR_tester
|
||||
}
|
||||
private void UpdateCreateWindowButton()
|
||||
{
|
||||
btnCreateWindow.Text = "Points remaining : " + ZonePointsRemaining();
|
||||
btnCreateWindow.Text = "Points remaining : " + PointsRemaining(windowPoints);
|
||||
}
|
||||
private void UpdateCreateZoneButton()
|
||||
{
|
||||
btnCreateZone.Text = "Points remaining : " + ZonePointsRemaining();
|
||||
btnCreateZone.Text = "Points remaining : " + PointsRemaining(zonePoints);
|
||||
}
|
||||
private void btnCreateZone_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -81,10 +84,10 @@ namespace OCR_tester
|
||||
{
|
||||
SwitchCreateWindowButton();
|
||||
}
|
||||
private int ZonePointsRemaining()
|
||||
private int PointsRemaining(Point[] points)
|
||||
{
|
||||
int remaining = 0;
|
||||
foreach (Point p in zonePoints)
|
||||
foreach (Point p in points)
|
||||
{
|
||||
if (p.X == -1 && p.Y == -1)
|
||||
remaining++;
|
||||
@@ -100,7 +103,7 @@ namespace OCR_tester
|
||||
float yOffset = (float)pbxInput.Image.Height / (float)pbxInput.Height;
|
||||
if (selectingZonePoints)
|
||||
{
|
||||
int remaining = ZonePointsRemaining();
|
||||
int remaining = PointsRemaining(zonePoints);
|
||||
int index = (zonePoints.Length) - remaining;
|
||||
zonePoints[index] = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
|
||||
remaining -= 1;
|
||||
@@ -109,9 +112,9 @@ namespace OCR_tester
|
||||
{
|
||||
Image fullImage = pbxInput.Image;
|
||||
Size newSize = new Size(zonePoints[1].X - zonePoints[0].X, zonePoints[1].Y - zonePoints[0].Y);
|
||||
MainZone mainZone = new MainZone(fullImage, new Rectangle(zonePoints[0], newSize));
|
||||
mainZone = new MainZone(fullImage, new Rectangle(zonePoints[0], newSize));
|
||||
pbxInput.Image = mainZone.Draw();
|
||||
|
||||
pbxWindow.Image = mainZone.Zones[0].ZoneImage;
|
||||
SwitchCreateZoneButton();
|
||||
}
|
||||
else
|
||||
@@ -120,7 +123,43 @@ namespace OCR_tester
|
||||
}
|
||||
}
|
||||
}
|
||||
private void pbxWindow_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (mainZone != null)
|
||||
{
|
||||
Point coordinates = pbxWindow.PointToClient(new Point(MousePosition.X, MousePosition.Y));
|
||||
|
||||
float xOffset = (float)pbxWindow.Image.Width / (float)pbxWindow.Width;
|
||||
float yOffset = (float)pbxWindow.Image.Height / (float)pbxWindow.Height;
|
||||
|
||||
if (selectingWindowPoints)
|
||||
{
|
||||
int remaining = PointsRemaining(windowPoints);
|
||||
int index = (windowPoints.Length) - remaining;
|
||||
windowPoints[index] = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
|
||||
remaining -= 1;
|
||||
|
||||
if (remaining == 0)
|
||||
{
|
||||
Image fullImage = pbxWindow.Image;
|
||||
Point position = windowPoints[0];
|
||||
Size newSize = new Size(windowPoints[1].X - windowPoints[0].X, windowPoints[1].Y - windowPoints[0].Y);
|
||||
|
||||
foreach (Zone z in mainZone.Zones)
|
||||
{
|
||||
z.AddWindow(new Rectangle(position,newSize));
|
||||
}
|
||||
pbxInput.Image = mainZone.Draw();
|
||||
pbxWindow.Image = mainZone.Zones[0].Draw();
|
||||
SwitchCreateWindowButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateCreateWindowButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void btnDeleteZone_Click(object sender, EventArgs e)
|
||||
{
|
||||
reload();
|
||||
|
||||
Reference in New Issue
Block a user