How can I transfer the text to a specific field?

Hello everyone,

This is my first time seeking assistance for this issue, and I'm hopeful for a solution.

I've been using the Windows OCR file from the mbsplugins website to help me capture images and convert them into text. My question is, how can I transfer this text into specific fields, as shown in my screenshot?

Windows OCR.fmp12 (9.4 MB)

You could use RegEx functions to look for specific texts.

Link the card number should be easily queryable with RegEx.Extract and a matching pattern.

You could also look for text btween "Name:" and "Nationality:" as well as for the words after it.

2 Likes

Hello Saeed,

What I would do is to studie the text looking for patterns that can tag your data. The problem with OCR is that the result depends on the quality of the picture being used, but when I look at the text I can identify:

Card ID Number (or just Number)
ame: (Guess this is an OCR error).
Nationality
000

I would the use Substitute (...)

Substitute ( Text ; [ "number" ; "¶XXX1:" ] ; [ "ame:" ; "¶XXX2:" ] ; [ "Nationality" ; "¶XXX3:" ] ) & ¶

XXX can be anything that is unlikely to be in your text, and note the ¶ which gives you a tagged list:

United...
XX1:784-..
XX2:Hammad ...
XX3:United ... 000

Look for patterns so that you get a start and a end for each data, and note that I don't substitute 000 at the end since that can also be part of the Card ID Number.

Now parse your list to get the data, XXX..: ¶
You could skip "XXX.." and use GetValue (..) if you can trust the OCR, but it is more safe to do it this way. (The OCR might insert it's own ¶).

After that trim all data so that there are no white space before or after, and fix the "000" at the end of Nationality now that you have separated them.

To make it simple for you to parse data make a Custom function with for example this one:

Final tip: I you use this model you can create different templates for the substitute for different types of documents, and a menu to select which one to use. And, as always with OCR, you will learn over time to tweak different kinds of documents.

Good luck, and let me now if you have any questions about this solution or it's possibilities :blush:

2 Likes

I agree with Christian and I am myself a long time MBS user, but I wanted to give you a simple solution with the basics.

... I just realised that you are already using the MBS plugin, my mistake, only saw the problem, so using the RegEx-functions is a good way to go if you are familiar with that language.

1 Like

To begin with,I'd like to express my gratitude and appreciation to both of you for providing multiple solutions. I will explore the briandunning function, and if I encounter any challenges, I will keep you updated.

1 Like

Welcome to Thesoup @Saeed !

1 Like

Thank you so much Planteg :slight_smile:

another approach that I am testing is using chatGTP api. In short you provide the text retrieved from OCR asking to give back as json the fields that you want. I am currently testing in various certificates and it works really good.

Hi Mike275,

Certainly, it would be more informative if you could provide a sample file here.

Hi, @Saeed , since you're on Windows, have you considered a smart card reader? The IDs in UAE, Bahrain, Thailand... etc. use the smart chip that is readable with an appropriate scanner and related software. Governments often share the software, if specialized data are required to be extracted. Then the data can be imported to FileMaker. One advantage to this is it can also be used to verify a "visitor" against a stored database.

(I know you requested feedback regarding OCR, but thought I'd offer that idea since it solved a task for me in Bahrain a few years ago.)

Edit to add example pics here.

1 Like

Daleallyn, I want to express my sincere gratitude for sharing this idea. To be honest, I've been pondering this concept since 2019, but unfortunately, I hadn't come across any solutions. If you have any information, please do share it with us here. :slight_smile:

Saeed, a few years ago I was supporting a project in Bahrain (for 2.5 years) and a solution was needed so that clients could open an account for which ID was required AND would be required for each visit when the client requested services.

At first the ID was just copied and the data entered manually. And for subsequent visits, the ID was scanned and stored as a pdf or image in a container (not elegant). I then suggested the card reader. The facility is a mostly Mac operation (~50 Macs, but some Windows boxes for specialize instruments [~15] and this ID task) which is why I said “since you’re on Windows…” because Mac solutions for this are rare.

In this case, I looked at various software options, but then, if I recall, we learned that the government made their smart ID reader software available (Windows only). Again, if I recall, I was able get some data off the card with open source software (or maybe something that came with the reader) and even got part of it on Mac natively. It’s just a USB device.

In the end, I believe they went with government software and the simple smart card readers I purchased (I completed my contract during the time this was evolving). I bought the card readers while I was in the US for a few days (B&H Photo and Video) if I recall, but as you can see from the link I posted they’re widely available. (I had purchased them when traveling only because of their procurement policies and I wanted to start testing ASAP :blush: ).

I’m sorry that my recollection is a bit vague/foggy on the details. I’ve had a lot of projects since then and not much rest. :joy: I don’t know if I have downloads or links from that period for this, but if I find them I’ll post back. In the meantime I suggest you poke around the web to look at the solutions available. Check to see if UAE gov offers card reader software. BUT don’t be shy about just trying a smart card reader and whatever driver comes with it, if any. Macs often don’t require drivers for USB devices, but I think Windows may differ.

The smart card readers are cheap, so it’s pretty painless to explore.

Oh, it’s easy to get distracted by info online about military use (especially US military) because their members often use them for logging-in to their networks. I suggest you not waste too much time in those areas (like I did haha). In that use case it’s basically just an authentication dongle.

[Edit: a couple of typos]

1 Like

Based on the screenshot above, I attempted to extract text from the text field, but I'm still encountering an issue where the table appears to be missing.

ParseData ( Text;"¶EID";"ID Number";1)

Hi Saeed,

Happy to see that you have been so well greeted here :smiley:

When I study your screen shot I can find "ID Number" in the text in field Text, but not "¶EID". Has you converted with ¶ as I suggested, or is doing the Parse directly from the field Text?

To get the ID number directly from the text I would use:

Field EID = Parse ( Text ; "ID Number" ; "Name:" ; 1 )

And then make a Trim ( ... ) to get rid of the white space in front and after.
I don't follow you in the the part where you say "... where the table appears to be missing.". Could you please tell me where the table should be?

If you can send me the text with all sensitive data switched to nonsens but otherwise intact, I could make a small database with the parsing as an example using the Custom function.

I'm delighted to have posted my issue here, and I truly appreciate it. :smile:

please find below screenshot

Hi Saeed,

New day, and after seeing your screenshot I felt it better to create an example database for you... but when I got started I could just not help myself but built a more or less complete solution with notes and tips.

I also included one of my over 450 Custom functions that I wrote back in 2017 as a gift, since you will probably do a lot of filtering with special characters. In Sweden we have 3 letters not present in other languages, "åäö", and you should be able to rewrite str.Filter (...) by removing these and replacing with what you need. (You should also rename the flag "aö" to something else).

I hope this will help, and you will also learn how I build code that might give you some new ideas :blush:

ParseText by HuConn.fmp12.zip (115.8 KB)

5 Likes

You're truly exceptional when it comes to FileMaker! Words alone can't express my gratitude for your invaluable help. This is exactly what I've been searching for, for a long time.

I'll make several attempts with both versions of the Emirates ID (Old and New), and I'll keep you updated on the latest developments. Thank you once again for your outstanding support.

2 Likes

Thank you Saeed for those warming words, just what I needed today, and I wish you luck with your project :blush:

1 Like

You can't imagine how valuable this file has been in assisting me, and I've also learned something new in FileMaker. Additionally, I've encountered some issues and attempted to resolve them on my own. I included multiple new substitutions as previously mentioned because there are two versions of Emirates ID.

If I come across any issues, I will keep you updated.

Very nice to hear Saeed, and learning by doing is a very good way to develop your skills.
If you have more questions and I am slow to answer please send me a direct message, since sometimes I miss the mails from FMSoup.

1 Like