From 5a91d2e27a1d45d998ebeb75dca4bda97b52e9e5 Mon Sep 17 00:00:00 2001 From: maxluli Date: Wed, 2 Nov 2022 13:39:01 +0100 Subject: [PATCH] Characters are now outlined correctly in the preview --- TestVideo/Form1.cs | 6 ------ TestVideo/Zone.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/TestVideo/Form1.cs b/TestVideo/Form1.cs index 6d63c45..f88c778 100644 --- a/TestVideo/Form1.cs +++ b/TestVideo/Form1.cs @@ -100,14 +100,10 @@ namespace TestVideo if (creatingZone) { //Convert coordinates to image coordinates - - //Rectangle screenSize = extraction.CurrentScreen.Bounds; float xRatio = (float)pbxInput.Image.Width / (float)pbxInput.Width; float yRatio = (float)pbxInput.Image.Height / (float)pbxInput.Height; Point tmpPoint = pbxInput.PointToClient(MousePosition); Point testPoint = MousePosition; - //MouseEventArgs me = (MouseEventArgs)e; - //Point tmpPoint = me.Location; Point newPoint = new Point(Convert.ToInt32((float)tmpPoint.X * xRatio),Convert.ToInt32((float)tmpPoint.Y * yRatio)); if (newZonePoints[0] == new Point(-1,-1)) @@ -197,8 +193,6 @@ namespace TestVideo float yRatio = (float)pbxInput.Image.Height / (float)pbxInput.Height; Point tmpPoint = pbxInput.PointToClient(new Point(MousePosition.X,MousePosition.Y)); Point testPoint = MousePosition; - //MouseEventArgs me = (MouseEventArgs)e; - //Point tmpPoint = me.Location; Point newPoint = new Point(Convert.ToInt32((float)tmpPoint.X * xRatio), Convert.ToInt32((float)tmpPoint.Y * yRatio)); debugLBL.Text = "Absolute : " + testPoint.ToString() + Environment.NewLine + "Relative : " + tmpPoint.ToString(); diff --git a/TestVideo/Zone.cs b/TestVideo/Zone.cs index 936f882..077fc8a 100644 --- a/TestVideo/Zone.cs +++ b/TestVideo/Zone.cs @@ -57,15 +57,19 @@ namespace TestVideo break; string letter = data[0]; + //Point position = new Point(Convert.ToInt32(data[1]), Convert.ToInt32(data[2])); + //Size size = new Size(Convert.ToInt32(data[3]), Convert.ToInt32(data[4])); Point position = new Point(Convert.ToInt32(data[1]), Convert.ToInt32(data[2])); - Size size = new Size(Convert.ToInt32(data[3]), Convert.ToInt32(data[4])); + Size size = new Size(Convert.ToInt32(data[3]) - Convert.ToInt32(data[1]), Convert.ToInt32(data[4]) - Convert.ToInt32(data[2])); + Point correctedPosition = new Point(position.X, inputBmp.Height - position.Y - size.Height); int unknownData = Convert.ToInt32(data[5]); //A neat post processing Idea would be to separate letters that have a unusually big difference in X or Y axis to try and recognise words //Use the data result += letter; - g.DrawRectangle(new Pen(Brushes.Red, 5), new Rectangle(position, size)); + //g.DrawRectangle(new Pen(Brushes.Red, 5), new Rectangle(position, size)); + g.DrawRectangle(new Pen(Brushes.Red, 3), new Rectangle(correctedPosition, size)); } }