Cleaned Reader.cs
This commit is contained in:
@@ -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;
|
||||
|
||||
+33
-9
@@ -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<string> Drivers { get => _drivers; private set => _drivers = value; }
|
||||
public List<Zone> 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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Method that reads the JSON config file and create all the Zones and Windows
|
||||
/// </summary>
|
||||
/// <param name="imageNumber">The image #id on wich you want to create the zones on</param>
|
||||
private void Load(int imageNumber)
|
||||
{
|
||||
MainZones = new List<Zone>();
|
||||
@@ -159,6 +171,10 @@ namespace OCR_Decode
|
||||
MessageBox.Show("Invalid JSON format: " + ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Changes the zones and windows to the new image
|
||||
/// </summary>
|
||||
/// <param name="imageNumber">The #id of the new image on wich to do OCR</param>
|
||||
public void ChangeImage(int imageNumber)
|
||||
{
|
||||
Bitmap img = null;
|
||||
@@ -180,6 +196,11 @@ namespace OCR_Decode
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Method that calls all the zones and windows to get the content they can find on the image to display them
|
||||
/// </summary>
|
||||
/// <param name="idImage">The id of the image we are working with</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> 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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Method that can be used to convert an amount of miliseconds into a more readable human form
|
||||
/// </summary>
|
||||
/// <param name="amountOfMs">The given amount of miliseconds ton convert</param>
|
||||
/// <returns></returns>
|
||||
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");
|
||||
}
|
||||
/// <summary>
|
||||
/// Old method that can draw on an image where the windows and zones are created. mostly used for debugging
|
||||
/// </summary>
|
||||
/// <param name="idImage">the #id of the image we are working with</param>
|
||||
/// <returns></returns>
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user