Introduction
This application is for drawing basic shapes like line, rectangle, circle, ellipse, free hand shapes, eraser, and clear screen. It also provides a feature handwriting recognition. It allows to save the recognized text as text file and only ink strokes can be saved as image.
About the application
This app provides the easy to use UI which helps the user to write any memos or letters. Then user can convert the hand written letters to text format using a single button click. The hand writing can be saved as image. The recognized words are converted in to text format and can be shared using share contracts for mail, and other target apps if any installed. the GPS facility can be enabled if the user needs to insert the exact location in the document.
Features of the app:
- hand writing recognition
- Draw images
- Can be saved as text or jpeg
- shared using share contracts
- GPS enabling to insert exact location
- Touchscreen aware.
For handwriting recognition, I have used Windows.UI.Input.Inking namesapce. The basic concept is to useInkManager class. It provides properties and methods to manage the input, manipulation, and processing (including handwriting recognition) of one or more InkStroke objects. When a user write something onto canvas, all the points covered in that path is saved as InkManager objects. InkManager class provide an async method calledRecognizeAsync(). The results of the recognition is a collection of InkRecognitionResult objects. To get the text componets, I have used GetTextCandidates() method of InkRecognitionResult class and it retrieves the collection of strings identified as potential matches for handwriting recognition.
Using the code
The code for changing the stroke thickness of the hand writting
private void cbStrokeThickness_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
StrokeThickness = Convert.ToDouble(cbStrokeThickness.SelectedIndex + 1);
}
private void btnExit_Click(object sender, RoutedEventArgs e)
{
canvas.Children.Clear();
App.Current.Exit();
}
private void cbBorderColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbBorderColor.SelectedIndex != -1)
{
var pi = cbBorderColor.SelectedItem as PropertyInfo;
BorderColor = (Color)pi.GetValue(null);
}
}
private void cbFillColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbFillColor.SelectedIndex != -1)
{
var pi = cbFillColor.SelectedItem as PropertyInfo;
FillColor = (Color)pi.GetValue(null);
}
}
IReadOnlyList<String> RecognizedText;
string FinalRecognizedText = ""; IReadOnlyList<InkRecognitionResult> x;
private async void btnRecognize_Click(object sender, RoutedEventArgs e)
{
try
{
txtRecognizedText.Visibility = Windows.UI.Xaml.Visibility.Visible;
btnSaveRecognizedText.Visibility = Windows.UI.Xaml.Visibility.Visible;
canvas.SetValue(Grid.RowProperty, 3);
canvas.SetValue(Grid.RowSpanProperty, 1);
MyInkManager.Mode = InkManipulationMode.Inking;
x = await MyInkManager.RecognizeAsync(InkRecognitionTarget.Recent);
MyInkManager.UpdateRecognitionResults(x);
foreach (InkRecognitionResult i in x)
{
RecognizedText = i.GetTextCandidates();
FinalRecognizedText += " " + RecognizedText[0];
txtRecognizedText.Text += FinalRecognizedText;
}
FinalRecognizedText = string.Empty;
}
Points of Interest
This application demonstrates how a user can draw shapes and how hand writing recognition is performed in a XAML/C# code.