private void btnRecognize_Click(object sender, EventArgs e) { var ds = new DownSample(_entryImage); _downsampled = ds.PerformDownSample(DownsampleWidth, DownsampleHeight); sample.Invalidate(); int sampleSize = DownsampleHeight * DownsampleWidth; char bestChar = '?'; double bestDistance = double.MaxValue; foreach (char ch in _letterData.Keys) { double[] data = _letterData[ch]; double dist = _distCalc.Calculate(data, _downsampled); if (dist < bestDistance) { bestDistance = dist; bestChar = ch; } } MessageBox.Show(@"That might be " + bestChar, @"Recognize"); ClearEntry(); }
private void btnSample_Click(object sender, EventArgs e) { var ds = new DownSample(_entryImage); _downsampled = ds.PerformDownSample(DownsampleWidth, DownsampleHeight); sample.Invalidate(); }
public void ClearEntry() { Brush whiteBrush = new SolidBrush(Color.White); _entryGraphics.FillRectangle(whiteBrush, 0, 0, entry.Width, entry.Height); entry.Invalidate(); var ds = new DownSample(_entryImage); _downsampled = ds.PerformDownSample(DownsampleWidth, DownsampleHeight); sample.Invalidate(); }
private void btnAdd_Click(object sender, EventArgs e) { var ds = new DownSample(_entryImage); _downsampled = ds.PerformDownSample(DownsampleWidth, DownsampleHeight); sample.Invalidate(); const string prompt = "What letter did you just draw."; const string title = "Input Required"; const string Default = ""; Int32 xPos = ((SystemInformation.WorkingArea.Width / 2) - 200); Int32 yPos = ((SystemInformation.WorkingArea.Height / 2) - 100); bool valid = false; foreach (double t in _downsampled) { if (t > 0.1) { valid = true; } } if (!valid) { MessageBox.Show(@"Please draw a letter before adding it."); return; } String result = Interaction.InputBox(prompt, title, Default, xPos, yPos); if (result != null) { result = result.ToUpper(); if (result.Length == 0) { MessageBox.Show(@"Please enter a character."); } else if (result.Length > 1) { MessageBox.Show(@"Please enter only a single character."); } else if (_letterData.ContainsKey(result[0])) { MessageBox.Show(@"That letter is already defined, please delete first."); } else { letters.Items.Add(result); _letterData.Add(result[0], _downsampled); ClearEntry(); } } }
private void btnAdd_Click(object sender, EventArgs e) { var ds = new DownSample(_entryImage); _downsampled = ds.PerformDownSample(DownsampleWidth, DownsampleHeight); sample.Invalidate(); const string prompt = "What letter did you just draw."; const string title = "Input Required"; const string Default = ""; Int32 xPos = ((SystemInformation.WorkingArea.Width/2) - 200); Int32 yPos = ((SystemInformation.WorkingArea.Height/2) - 100); bool valid = false; foreach (double t in _downsampled) { if (t>0.1) { valid = true; } } if (!valid) { MessageBox.Show(@"Please draw a letter before adding it."); return; } String result = Interaction.InputBox(prompt, title, Default, xPos, yPos); if (result != null) { result = result.ToUpper(); if (result.Length == 0) { MessageBox.Show(@"Please enter a character."); } else if (result.Length > 1) { MessageBox.Show(@"Please enter only a single character."); } else if (_letterData.ContainsKey(result[0])) { MessageBox.Show(@"That letter is already defined, please delete first."); } else { letters.Items.Add(result); _letterData.Add(result[0], _downsampled); ClearEntry(); } } }
private void btnRecognize_Click(object sender, EventArgs e) { var ds = new DownSample(_entryImage); _downsampled = ds.PerformDownSample(DownsampleWidth, DownsampleHeight); sample.Invalidate(); int sampleSize = DownsampleHeight*DownsampleWidth; char bestChar = '?'; double bestDistance = double.MaxValue; foreach (char ch in _letterData.Keys) { double[] data = _letterData[ch]; double dist = _distCalc.Calculate(data, _downsampled); if (dist < bestDistance) { bestDistance = dist; bestChar = ch; } } MessageBox.Show(@"That might be " + bestChar, @"Recognize"); ClearEntry(); }