From 8a05e7b54baa425c2d26e5998fb388fb89404a30 Mon Sep 17 00:00:00 2001 From: maxluli Date: Sun, 16 Oct 2022 10:40:17 +0200 Subject: [PATCH] Messed around with different screenshots --- TestVideo/Form1.Designer.cs | 1 + TestVideo/Form1.cs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/TestVideo/Form1.Designer.cs b/TestVideo/Form1.Designer.cs index 2104901..3d5310b 100644 --- a/TestVideo/Form1.Designer.cs +++ b/TestVideo/Form1.Designer.cs @@ -87,6 +87,7 @@ this.tbxResult.Location = new System.Drawing.Point(498, 288); this.tbxResult.Multiline = true; this.tbxResult.Name = "tbxResult"; + this.tbxResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.tbxResult.Size = new System.Drawing.Size(147, 270); this.tbxResult.TabIndex = 4; // diff --git a/TestVideo/Form1.cs b/TestVideo/Form1.cs index 509ef4c..9adb5e8 100644 --- a/TestVideo/Form1.cs +++ b/TestVideo/Form1.cs @@ -36,10 +36,14 @@ namespace TestVideo //TESTING TESSERACT - string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\Baneer.png"; + //string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\Baneer.png"; + //string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\Test.png"; + //string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\Standings.png"; + //string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\Gaps.png"; + //string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\SectorTimes.png"; + string path = AppDomain.CurrentDomain.BaseDirectory + "Screens\\Standings2.png"; tbxResult.Text = DecodeTessereactResults(testTesseract((Bitmap)Image.FromFile(path)), Image.FromFile(path), pbxOutput); - //MessageBox.Show(DecodeTessereactResults(testTesseract(path), Image.FromFile(path), pbxOutput)); } private Bitmap PrepareImage(Bitmap inputImage) { @@ -64,6 +68,7 @@ namespace TestVideo } private string DecodeTessereactResults(string tesseractResult, Image inputImage, PictureBox resultPbx) { + MessageBox.Show(tesseractResult); string result = ""; string[] lettersData = tesseractResult.Split('\n'); using (Graphics g = Graphics.FromImage(inputImage)) @@ -80,6 +85,8 @@ namespace TestVideo Size size = new Size(Convert.ToInt32(data[3]), Convert.ToInt32(data[4])); 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)); @@ -146,7 +153,6 @@ namespace TestVideo inputBmp = PrepareImage(inputBmp); Image emguImage = inputBmp.ToImage(); - //using (var image = new Image(inputBmp)) using (var image = emguImage) { using (Tesseract tesseractOcrProvider = new Tesseract(AppDomain.CurrentDomain.BaseDirectory + "\\Data", "eng", OcrEngineMode.Default)) @@ -156,7 +162,7 @@ namespace TestVideo result = tesseractOcrProvider.GetBoxText().TrimEnd(); } } - // File.Delete(filePath); + //File.Delete(filePath); return result; } private void tmrScreenshots_Tick(object sender, EventArgs e)