Hello,
Thank you for contacting us.
To use Recognizer you can refer to this page of the documentation: https://developer.myscript.com/docs/interactive-ink/4.1/windows/advanced/recognizers/
We recommand you to implement the IRecognizerListener that will help you getting Error notification and being notified of recognition result.
An example of such an implementation can be:
public class RecognizerListener : IRecognizerListener { private MainWindow _mainWindow; public RecognizerListener(MainWindow mainWindow) { _mainWindow = mainWindow; } public void OnError(Recognizer recognizer, RecognizerError error, string message) { MessageBox.Show(error.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } public void ResultChanged(Recognizer recognizer, string result) { // you can get your current recognition result // recognizer - the recognizer on which the result has changed. // result - the new result. } }
Here is below a WPF code snippet illustrating how to create and use a Text Recognizer:
string[] confDirs = new string[1]; confDirs[0] = "conf"; _engine.Configuration.SetStringArray("recognizer.configuration-manager.search-path", confDirs); _engine.Configuration.SetString("recognizer.lang", "en_US"); _engine.Configuration.SetString("recognizer.result.default-format", "text/plain"); var scaleX = 1.0f; var scaleY = 1.0f; Recognizer recognizer = _engine.CreateRecognizer(scaleX, scaleY, "Text"); RecognizerListener recolisterner = new RecognizerListener(this); recognizer.AddListener(recolisterner); recognizer.PointerEvents(pointerEvents); recognizer.WaitForIdle(); var recognitionResult = recognizer.GetResult(MimeType.TEXT).ToString();
For a more advanced code example, you can refer to our Android write to type example, that you can then adapt to WPF.
The write to type example gives you a hint how to implement scribble like feature relying on the Recognizer API of iink SDK. It is available on the MyScript Git repository containing the additional examples for the Android platform. This sample comes with a description that helps you understand its principle.
It is based on a contextless gesture recognition combined with a text recognition. To run both recognitions simultaneously, two instances of Recognizer are created - one for Gesture recognition and the other one for Text recognition.
Best regards,
Gwenaëlle
294186898
How to use text Recognizer in wpf ,can give me an example code ,thanks