Files
OCR_Decode/OCR_Decode/Form1.cs
T

67 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace OCR_Decode
{
public partial class Form1 : Form
{
//This should be configurable
const string CONFIG_FILE = @"C:\Users\Moi\Desktop\imgDump\Dump1.json";
const string TEMPORARY_IMAGE_FOLDER = @"C:\Users\Moi\Pictures\SeleniumScreens\DataSetHighRes\";
int pageNmbr = 82;
Reader Reader;
Stopwatch stopWatch = new Stopwatch();
int LoadMS = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
stopWatch.Start();
Reader = new Reader(CONFIG_FILE,TEMPORARY_IMAGE_FOLDER);
stopWatch.Stop();
LoadMS = (int)stopWatch.ElapsedMilliseconds;
RefreshUi();
}
private async void RefreshUi()
{
tbxResult.Text = "";
stopWatch.Restart();
pbxImage.Image = Reader.Draw(pageNmbr);
stopWatch.Stop();
int DrawMS = (int)stopWatch.ElapsedMilliseconds;
stopWatch.Restart();
tbxResult.Text = await Reader.Decode(pageNmbr);
stopWatch.Stop();
int OcrMS = (int)stopWatch.ElapsedMilliseconds;
MessageBox.Show(
"Loading took : " + Reader.ConvertMsToTime(LoadMS) +
" Image splitting took : " + Reader.ConvertMsToTime(DrawMS) + Environment.NewLine +
" Reading the infos from the image took : " + Reader.ConvertMsToTime(OcrMS) + Environment.NewLine
);
GC.Collect();
}
private void btnNext_Click(object sender, EventArgs e)
{
pageNmbr++;
RefreshUi();
}
}
}