Cleaned up a little bit to make room for the windows
This commit is contained in:
+63
-23
@@ -17,28 +17,69 @@ namespace OCR_tester
|
||||
const string DEFAULT_IMAGE_NAME = "screen_"; //You will need to add a number and extension after it ex: screen_2.png
|
||||
const string ENGLISH_TESSDATA_FILENAME = "eng.traineddata";
|
||||
const string DEFAULT_CREATEZONE_BUTTON_TEXT = "Create Zone";
|
||||
const string DEFAULT_CREATEWINDOW_BUTTON_TEXT = "Create Window";
|
||||
|
||||
Point[] zonePoints;
|
||||
Point[] windowPoints;
|
||||
|
||||
Point[] zonePoints = new Point[2] { new Point(-1, -1), new Point(-1, -1) };
|
||||
bool selectingZonePoints = false;
|
||||
bool selectingWindowPoints = false;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
reload();
|
||||
}
|
||||
private void reload()
|
||||
{
|
||||
pbxInput.Image = Image.FromFile(Path.Combine(imagesFolder.FullName, DEFAULT_IMAGE_NAME + "30.png"));
|
||||
}
|
||||
|
||||
private void btnCreateZone_Click(object sender, EventArgs e)
|
||||
private void SwitchCreateZoneButton()
|
||||
{
|
||||
if (selectingZonePoints)
|
||||
if (!selectingWindowPoints)
|
||||
{
|
||||
btnCreateZone.Text = DEFAULT_CREATEZONE_BUTTON_TEXT;
|
||||
selectingZonePoints = false;
|
||||
if (selectingWindowPoints)
|
||||
SwitchCreateWindowButton();
|
||||
selectingZonePoints = true;
|
||||
zonePoints = new Point[] { new Point(-1, -1), new Point(-1, -1) };
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingZonePoints = true;
|
||||
zonePoints = new Point[2] { new Point(-1, -1), new Point(-1, -1) };
|
||||
btnCreateZone.Text = "Points remaining : " + ZonePointsRemaining();
|
||||
selectingZonePoints = false;
|
||||
}
|
||||
|
||||
UpdateCreateZoneButton();
|
||||
}
|
||||
private void SwitchCreateWindowButton()
|
||||
{
|
||||
if (!selectingWindowPoints)
|
||||
{
|
||||
if (selectingZonePoints)
|
||||
SwitchCreateZoneButton();
|
||||
selectingWindowPoints = true;
|
||||
windowPoints = new Point[] { new Point(-1, -1), new Point(-1, -1) };
|
||||
}
|
||||
else
|
||||
{
|
||||
selectingWindowPoints = false;
|
||||
}
|
||||
|
||||
UpdateCreateWindowButton();
|
||||
}
|
||||
private void UpdateCreateWindowButton()
|
||||
{
|
||||
btnCreateWindow.Text = "Points remaining : " + ZonePointsRemaining();
|
||||
}
|
||||
private void UpdateCreateZoneButton()
|
||||
{
|
||||
btnCreateZone.Text = "Points remaining : " + ZonePointsRemaining();
|
||||
}
|
||||
private void btnCreateZone_Click(object sender, EventArgs e)
|
||||
{
|
||||
SwitchCreateZoneButton();
|
||||
}
|
||||
private void btnCreateWindow_Click(object sender, EventArgs e)
|
||||
{
|
||||
SwitchCreateWindowButton();
|
||||
}
|
||||
private int ZonePointsRemaining()
|
||||
{
|
||||
@@ -53,11 +94,7 @@ namespace OCR_tester
|
||||
|
||||
private void pbxInput_Click(object sender, EventArgs e)
|
||||
{
|
||||
MouseEventArgs me = (MouseEventArgs)e;
|
||||
//Point coordinates = new Point(Cursor.Location.X - pbxInput.Location.X,Cursor.Location.Y-pbxInput.Location.Y);
|
||||
//Point coordinates = new Point(me.X,me.Y);
|
||||
Point coordinates = pbxInput.PointToClient(new Point(MousePosition.X, MousePosition.Y));
|
||||
//MessageBox.Show("Coordinates "+coordinates.X+":"+coordinates.Y);
|
||||
Point coordinates = pbxInput.PointToClient(new Point(MousePosition.X, MousePosition.Y));
|
||||
|
||||
float xOffset = (float)pbxInput.Image.Width / (float)pbxInput.Width;
|
||||
float yOffset = (float)pbxInput.Image.Height / (float)pbxInput.Height;
|
||||
@@ -65,25 +102,28 @@ namespace OCR_tester
|
||||
{
|
||||
int remaining = ZonePointsRemaining();
|
||||
int index = (zonePoints.Length) - remaining;
|
||||
zonePoints[index] = new Point(Convert.ToInt32((float)coordinates.X * xOffset),Convert.ToInt32((float)coordinates.Y * yOffset));
|
||||
zonePoints[index] = new Point(Convert.ToInt32((float)coordinates.X * xOffset), Convert.ToInt32((float)coordinates.Y * yOffset));
|
||||
remaining -= 1;
|
||||
btnCreateZone.Text = "Points remaining : " + remaining;
|
||||
|
||||
if (remaining == 0)
|
||||
{
|
||||
selectingZonePoints = false;
|
||||
btnCreateZone.Text = DEFAULT_CREATEZONE_BUTTON_TEXT;
|
||||
|
||||
//CREATE MAIN ZONE
|
||||
Image fullImage = pbxInput.Image;
|
||||
//13 186
|
||||
//1920 960 HARD CODED
|
||||
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));
|
||||
pbxInput.Image = mainZone.Draw();
|
||||
}
|
||||
|
||||
SwitchCreateZoneButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateCreateZoneButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDeleteZone_Click(object sender, EventArgs e)
|
||||
{
|
||||
reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user