diff --git a/OCR_Decode/OcrImage.cs b/OCR_Decode/OcrImage.cs index 44b85d9..709402b 100644 --- a/OCR_Decode/OcrImage.cs +++ b/OCR_Decode/OcrImage.cs @@ -1,4 +1,10 @@ -using System; +/// Author : Maxime Rohmer +/// Date : 25/04/2023 +/// File : OcrImage.cs +/// Brief : Class that contains all the post processing methods that can help with OCR +/// Version : 0.1 + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -16,7 +22,7 @@ namespace OCR_Decode { //this is a hardcoded value based on the colors of the F1TV data channel background you can change it if sometime in the future the color changes //Any color that has any of its R,G or B channel higher than the treshold will be considered as being usefull information - public static Color F1TV_BACKGROUND_TRESHOLD = Color.FromArgb(0x50,0x50,0x50); + public static Color F1TV_BACKGROUND_TRESHOLD = Color.FromArgb(0x50, 0x50, 0x50); Bitmap InputBitmap; public enum WindowType { diff --git a/OCR_Decode/Reader.cs b/OCR_Decode/Reader.cs index 63d6d29..f286819 100644 --- a/OCR_Decode/Reader.cs +++ b/OCR_Decode/Reader.cs @@ -1,4 +1,10 @@ -using System; +/// Author : Maxime Rohmer +/// Date : 25/04/2023 +/// File : Reader.cs +/// Brief : Model that contains all the classes and methods to manage the OCR +/// Version : 0.1 + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,7 +29,9 @@ namespace OCR_Decode public List Drivers { get => _drivers; private set => _drivers = value; } public List MainZones { get => _mainZones; set => _mainZones = value; } + //All the image infos will be deleted in not too much time when the merge with the program that recovers the images const string DEFAULT_IMAGE_NAME = "screen_"; + // You will defenitely have to change this if you want to be able to see debug images public const string DEBUG_DUMP_FOLDER = @"C:\Users\Moi\Desktop\imgDump\Decode\"; const int NUMBER_OF_DRIVERS = 20; @@ -33,6 +41,10 @@ namespace OCR_Decode ImagesFolder = imageFolder; Load(82); } + /// + /// Method that reads the JSON config file and create all the Zones and Windows + /// + /// The image #id on wich you want to create the zones on private void Load(int imageNumber) { MainZones = new List(); @@ -159,6 +171,10 @@ namespace OCR_Decode MessageBox.Show("Invalid JSON format: " + ex.Message); } } + /// + /// Changes the zones and windows to the new image + /// + /// The #id of the new image on wich to do OCR public void ChangeImage(int imageNumber) { Bitmap img = null; @@ -180,6 +196,11 @@ namespace OCR_Decode } } } + /// + /// Method that calls all the zones and windows to get the content they can find on the image to display them + /// + /// The id of the image we are working with + /// public async Task Decode(int idImage) { string result = ""; @@ -198,9 +219,8 @@ namespace OCR_Decode mainResults.Add(await z.Decode(Drivers)); } break; - //Next there will be the title and laps added + //Next there could be a Title Zone and TrackInfoZone } - } //Display @@ -212,6 +232,11 @@ namespace OCR_Decode return result; } + /// + /// Method that can be used to convert an amount of miliseconds into a more readable human form + /// + /// The given amount of miliseconds ton convert + /// public static string ConvertMsToTime(int amountOfMs) { //Convert.ToInt32 would round upand I dont want that @@ -221,6 +246,11 @@ namespace OCR_Decode return minuts + ":" + seconds.ToString("00") + ":" + ms.ToString("000"); } + /// + /// Old method that can draw on an image where the windows and zones are created. mostly used for debugging + /// + /// the #id of the image we are working with + /// public Bitmap Draw(int idImage) { Bitmap result; @@ -241,12 +271,6 @@ namespace OCR_Decode int count = 0; foreach (Zone zz in z.Zones) { - //string driverFolder = DEBUG_DUMP_FOLDER + "driver" + count + "\\"; - //if (!Directory.Exists(driverFolder)) - //Directory.CreateDirectory(driverFolder); - - //zz.ZoneImage.Save(driverFolder + "FullImage.png"); - g.DrawRectangle(Pens.Red, z.Bounds); foreach (Window w in zz.Windows) {