Now the images are changing
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ namespace Test_Merge
|
||||
Bitmap screen = Emulator.Screenshot();
|
||||
screen.Save("SCREEEEEEEEN.png");
|
||||
Reader.ChangeImage(screen);
|
||||
tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers,screen);
|
||||
tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers);
|
||||
}
|
||||
}
|
||||
private void btnSettings_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Test_Merge
|
||||
/// </summary>
|
||||
/// <param name="idImage">The id of the image we are working with</param>
|
||||
/// <returns>a string representation of all the returns</returns>
|
||||
public async Task<string> Decode(List<Zone> mainZones,List<string> drivers, Bitmap imageToDecode)
|
||||
public async Task<string> Decode(List<Zone> mainZones,List<string> drivers)
|
||||
{
|
||||
string result = "";
|
||||
List<DriverData> mainResults = new List<DriverData>();
|
||||
@@ -192,9 +192,9 @@ namespace Test_Merge
|
||||
|
||||
public void ChangeImage(Bitmap Image)
|
||||
{
|
||||
foreach (Zone BigZone in MainZones)
|
||||
foreach (Zone z in MainZones)
|
||||
{
|
||||
BigZone.Image = Image;
|
||||
z.Image = Image;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Test_Merge
|
||||
/// <param name="windowType">The type of window it is</param>
|
||||
/// <param name="Engine">The Tesseract Engine</param>
|
||||
/// <returns>The time in milliseconds</returns>
|
||||
public static async Task<int> GetTimeFromPng(Bitmap windowImage, OcrImage.WindowType windowType, TesseractEngine Engine)
|
||||
public static async Task<int> GetTimeFromPng(Bitmap image, OcrImage.WindowType windowType, TesseractEngine Engine)
|
||||
{
|
||||
//Kind of a big method but it has a lot of error handling and has to work with three special cases
|
||||
string rawResult = "";
|
||||
@@ -113,7 +113,7 @@ namespace Test_Merge
|
||||
}
|
||||
|
||||
|
||||
Bitmap enhancedImage = new OcrImage(windowImage).Enhance(windowType);
|
||||
Bitmap enhancedImage = new OcrImage(image).Enhance(windowType);
|
||||
|
||||
var tessImage = Pix.LoadFromMemory(ImageToByte(enhancedImage));
|
||||
|
||||
@@ -227,13 +227,13 @@ namespace Test_Merge
|
||||
/// <param name="allowedChars">The list of allowed chars</param>
|
||||
/// <param name="windowType">The type of window the text is on. Depending on the context the OCR will behave differently</param>
|
||||
/// <returns>the string it found</returns>
|
||||
public static async Task<string> GetStringFromPng(Bitmap WindowImage, TesseractEngine Engine, string allowedChars = "", OcrImage.WindowType windowType = OcrImage.WindowType.Text)
|
||||
public static async Task<string> GetStringFromPng(Bitmap image, TesseractEngine Engine, string allowedChars = "", OcrImage.WindowType windowType = OcrImage.WindowType.Text)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
Engine.SetVariable("tessedit_char_whitelist", allowedChars);
|
||||
|
||||
Bitmap rawData = WindowImage;
|
||||
Bitmap rawData = image;
|
||||
Bitmap enhancedImage = new OcrImage(rawData).Enhance(windowType);
|
||||
|
||||
Page page = Engine.Process(enhancedImage);
|
||||
|
||||
+1
-31
@@ -38,7 +38,7 @@ namespace Test_Merge
|
||||
set
|
||||
{
|
||||
//It automatically sets the image for the contained windows and zones
|
||||
_image = Image;
|
||||
_image = value;
|
||||
foreach (Window w in Windows)
|
||||
{
|
||||
w.Image = ZoneImage;
|
||||
@@ -88,36 +88,6 @@ namespace Test_Merge
|
||||
/// <returns>A driver data object that contains all the infos about a driver</returns>
|
||||
public virtual async Task<DriverData> Decode(List<string> driverList)
|
||||
{
|
||||
/*
|
||||
int sectorCount = 0;
|
||||
DriverData result = new DriverData();
|
||||
Parallel.ForEach(Windows, async w =>
|
||||
{
|
||||
// A switch would be prettier but I dont think its supported in this C# version
|
||||
if (w is DriverNameWindow)
|
||||
result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList);
|
||||
if (w is DriverDrsWindow)
|
||||
result.DRS = (bool)await (w as DriverDrsWindow).DecodePng();
|
||||
if (w is DriverGapToLeaderWindow)
|
||||
result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng();
|
||||
if (w is DriverLapTimeWindow)
|
||||
result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng();
|
||||
if (w is DriverPositionWindow)
|
||||
result.Position = (int)await (w as DriverPositionWindow).DecodePng();
|
||||
if (w is DriverSectorWindow)
|
||||
{
|
||||
sectorCount++;
|
||||
if (sectorCount == 1)
|
||||
result.Sector1 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
if (sectorCount == 2)
|
||||
result.Sector2 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
if (sectorCount == 3)
|
||||
result.Sector3 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
}
|
||||
if (w is DriverTyresWindow)
|
||||
result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng();
|
||||
});
|
||||
*/
|
||||
int sectorCount = 0;
|
||||
DriverData result = new DriverData();
|
||||
foreach(Window w in Windows)
|
||||
|
||||
Reference in New Issue
Block a user