« MBS Xojo Plugins, ver… | Home | MBS Plugin Advent cal… »

MBS Plugin Advent calendar: 2 - Vision

Door 2 - Vision

Fact of the day
The MBS FileMaker Plugin not only offers you the Apple Vision as a framework, using MapKit you can also integrate Apple maps into your application or take pictures with your iPhone via Continuty Camera and store them directly in FileMaker.

The second door provides something for Mac users. Apple provides a framework called Vision. With this framework you can recognize barcodes, recognize texts from images or classify images into categories with the help of machine learning, e.g. so that you can search for them in your image database. This framework makes MBS usable with the plugin for FileMaker.

Barcode recognition

Let's first look at the possibility of recognizing multiple barcodes on an image. You simply pass the image to the Vision.DetectBarcode function as a parameter and Vision then searches for the barcodes on the image and returns a JSON in which the barcodes are listed. If you only want to search for QR codes on the image, for example, you can restrict the barcode types in the search by specifying the desired types as parameters. You can find out which barcode types can be recognized with Vision on your computer using the Vision.SupportedSymbologies function.

Result from Vision.DetectBarcode

Text recognition

We now have two possible returns for text recognition. If we use the Vision.RecognizeText function, we get plain text as a return, which we can then output in a field, for example. The other return option is a JSON. This JSON not only contains the plain text, but also the position of the individual lines. This has the advantage that you can, for example, make a page out of the image with DynaPDF and place the text behind it so that the text can be marked.

In the example, we have created both options as buttons. Otherwise, the parameters that we have to pass to the two text recognition functions are identical. First we pass the image from which the text should be recognized. This is sufficient for now, the other parameters are optional. Here we can specify the type of recognition to be performed. We can choose between Fast and Accurate. Accurate uses neurological networks for word recognition. Fast recognizes the individual characters. Fast also works well if the desired language is not available. Next, we can specify the language of the text to be recognized. The Vision.SupportedRecognitionLanguages function tells you which languages can be recognized. Then you can specify a list of words that may occur in the text but are not in the dictionary so that they can be recognized more easily. The last parameter PageLimit is interesting for PDF documents, because with Vision you can use text recognition not only in images, but also in PDF documents. With the last parameter, we decide how many pages the text recognition should run over. If we do not specify anything, only the text recognition for the first page is performed automatically.

Here you can see the code from our example for the JSON function. We did not need the last two parameters in our example:

Set Variable [ $JSON ; Value: MBS("Vision.RecognizeTextJSON"; DoorTwo::Input_Image;"Accurate"; "en_US") ] 
Set Field [ DoorTwo::Output ; MBS("JSON.Colorize"; MBS("JSON.Format"; $JSON)) ] 
Result from Vision.RecognizeText
Result from Vision.RecognizeTextJSON

Classification of images

Vision also offers the option of automatically classifying images, which can help you, for example, if you have a photo library and you want to search for images from a specific category. You can then enter and use this classification in a field. Vision.ClassifyImage provides us with a result for this.

Set Variable [ $Content ; Value: 
   MBS( "Vision.ClassifyImage";DoorTwo::Input_Image; 0 ) ] 

Here again, we first pass the image. As an optional parameter, we can now specify whether we only want to get back the most suitable category (the default) or whether we want to receive a JSON with all suitable categories. The JSON also contains the probability with which the image fits into this category.

Now you can get more out of your images. We hope you enjoy using these functions.


Monkeybread Software Logo with Monkey with Santa hat
1 👈 2 of 24 👉 3
02 12 23 - 11:37