Now the images are correctly loaded but the OCR is still Fucked

This commit is contained in:
2023-05-11 15:22:59 +02:00
parent 025c2f8d61
commit 134ac85ad1
3 changed files with 52 additions and 12 deletions
+14 -1
View File
@@ -31,6 +31,8 @@
this.btnSettings = new System.Windows.Forms.Button(); this.btnSettings = new System.Windows.Forms.Button();
this.tbxResult = new System.Windows.Forms.TextBox(); this.tbxResult = new System.Windows.Forms.TextBox();
this.btnUpdate = new System.Windows.Forms.Button(); this.btnUpdate = new System.Windows.Forms.Button();
this.pbxResult = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pbxResult)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnSettings // btnSettings
@@ -61,17 +63,27 @@
this.btnUpdate.UseVisualStyleBackColor = true; this.btnUpdate.UseVisualStyleBackColor = true;
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
// //
// pbxResult
//
this.pbxResult.Location = new System.Drawing.Point(328, 71);
this.pbxResult.Name = "pbxResult";
this.pbxResult.Size = new System.Drawing.Size(460, 249);
this.pbxResult.TabIndex = 3;
this.pbxResult.TabStop = false;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 335);
this.Controls.Add(this.pbxResult);
this.Controls.Add(this.btnUpdate); this.Controls.Add(this.btnUpdate);
this.Controls.Add(this.tbxResult); this.Controls.Add(this.tbxResult);
this.Controls.Add(this.btnSettings); this.Controls.Add(this.btnSettings);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pbxResult)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -82,6 +94,7 @@
private System.Windows.Forms.Button btnSettings; private System.Windows.Forms.Button btnSettings;
private System.Windows.Forms.TextBox tbxResult; private System.Windows.Forms.TextBox tbxResult;
private System.Windows.Forms.Button btnUpdate; private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.PictureBox pbxResult;
} }
} }
+22 -3
View File
@@ -22,22 +22,41 @@ namespace Test_Merge
{ {
if(Emulator != null && Reader != null) if(Emulator != null && Reader != null)
{ {
btnSettings.Enabled = false;
btnUpdate.Enabled = false;
Bitmap screen = Emulator.Screenshot(); Bitmap screen = Emulator.Screenshot();
screen.Save("SCREEEEEEEEN.png"); screen.Save("SCREEEEEEEEN.png");
Reader.ChangeImage(screen); Reader.ChangeImage(screen);
pbxResult.Image = screen;
tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers); tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers);
btnSettings.Enabled = true;
btnUpdate.Enabled = true;
} }
} }
private void btnSettings_Click(object sender, EventArgs e) private async void btnSettings_Click(object sender, EventArgs e)
{ {
Settings settingsForm = new Settings(); Settings settingsForm = new Settings();
settingsForm.ShowDialog(); settingsForm.ShowDialog();
MessageBox.Show(settingsForm.GrandPrixUrl + Environment.NewLine + settingsForm.GrandPrixName + Environment.NewLine + settingsForm.GrandPrixYear); //MessageBox.Show(settingsForm.GrandPrixUrl + Environment.NewLine + settingsForm.GrandPrixName + Environment.NewLine + settingsForm.GrandPrixYear);
Emulator = new F1TVEmulator(settingsForm.GrandPrixUrl);
try
{
await Emulator.Start();
Reader = new Reader(settingsForm.SelectedConfigFile,Emulator.Screenshot(),true);
}
catch
{
//Could not start the driver even with the new config
MessageBox.Show("The config is wrong or incomplete please try again");
}
} }
private async void Form1_Load(object sender, EventArgs e) private async void Form1_Load(object sender, EventArgs e)
{ {
string configFile = "./Presets/Clean_2023.json"; string configFile = "./Presets/Clean_4K_2023.json";
string gpUrl = "https://f1tv.formula1.com/detail/1000006688/2023-azerbaijan-grand-prix?action=play"; string gpUrl = "https://f1tv.formula1.com/detail/1000006688/2023-azerbaijan-grand-prix?action=play";
//Emulator = new F1TVEmulator(gpUrl); //Emulator = new F1TVEmulator(gpUrl);
+16 -8
View File
@@ -166,17 +166,25 @@ namespace Test_Merge
if (windowType == OcrImage.WindowType.LapTime) if (windowType == OcrImage.WindowType.LapTime)
{ {
result = 0; result = 0;
if (rawNumbers[0].Length == 4) try
{ {
result += Convert.ToInt32(rawNumbers[0][0]) * 60000; if (rawNumbers[0].Length == 4)
result += Convert.ToInt32(rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString()) * 1000; {
result += Convert.ToInt32(rawNumbers[1]); result += Convert.ToInt32(rawNumbers[0][0]) * 60000;
result += Convert.ToInt32(rawNumbers[0][2].ToString() + rawNumbers[0][3].ToString()) * 1000;
result += Convert.ToInt32(rawNumbers[1]);
}
else
{
//Fuck it
result = 0;
}
} }
else catch
{ {
//Fuck it //A lap time is fucked
result = 0; Console.Write("Fuck");
} }
} }
if (windowType == OcrImage.WindowType.Sector) if (windowType == OcrImage.WindowType.Sector)
{ {