For MBS Xojo Plugins 23.1 we add new classes to use the built-in OCR in Windows 10. Similar to the Vision framework on macOS, these classes provide an easy way to use the text recognition in Windows. We got these classes:
- WindowsOCREngineMBS is the central class to recognize text.
- WindowsOCRExceptionMBS is the exception class to report errors.
- WindowsOCRLanguageMBS defines which language to use.
- WindowsOCRResultMBS provides the result of the recognition process.
- WindowsOCRLineMBS represents a line of text within the result.
- WindowsOCRWordMBS represents a word within the line.
You can query the available languages on your computer with the AvailableRecognizerLanguages method. This usually only includes the installed language packs for Windows like in Germany the German one. But you can go to system settings and install another language if you need it.
Here is a sample method to query languages, put the display name and language tag in an array of string and shows it with a MessageBox:
In our sample project, it looks like this when you recognize some text:
If you like to recognize a file (or picture), you can use either the synchronous or the asynchronous recognize methods in our WindowsOCREngineMBS class. You can initialize such an object with a specific language or just use the one for the current user. The recognizeSync functions return the result right away or raise an exception. Here is a bit of sample code:
Please try the new classes in 23.1pr2 and let us know if you have questions or find an issue.