teh_raab
teh_raab

Reputation: 394

Firebase ML Vision TextRecogniser modify results for a better search

I keep coming across an issue with Firebase Ml-Vision in my Flutter application where the results are not accurate. Now i understand that there is always going to be some level off accuracy that is lost but i am trying to figure out a way that i can at least try and circumvent some of the more obvious issues.

As i am needing to search signage text to see if it matches against a particular list of predefined strings i am trying to figure out a way that i can take a particular word such as the one metnioned below and create a list of all permutations where the following letters and numbers are factored in:-

The issue is that that some letters or numbers are getting replaced by their opposite looking letter or number. For instance: The word 'slob' could be read by OCR as '5lob', 's1ob', 'sl0b', 'slo6' or even '5106'.

I am not sure if there is some baked in functions in flutter/dart that can help with this. The only thing i had was a bunch of really nasty nested for loops. I feel like there must be some elegant way of achieving this. Is there even a term for this type of algorithm?

Upvotes: 0

Views: 437

Answers (1)

Sukhi
Sukhi

Reputation: 14135

Been there.

Unfortunately, there's no "baked in function in Flutter" since, as you guess, Flutter is a mobile app framework. And this stuff (OCR/ML-Vision) falls in some other area.

What you can do is though a simple REST API. You send the text received from Firebase ML-Vision to the API, and grab the response text. You can use the programming language of your choice. Below is what you can do in the API.

Use Levenshtein distance. This gives a 'distance' between two words. For example :

  1. The distance between the words "slob" and "slob" is 0.
  2. The distance between the words "slob" and "5lob" is 1.
  3. The distance between the words "slob" and "Flutter" is 6.
  4. The distance between the words "slob" and "market" is 6.

You can try out the word pairs here. And you'll probably google the code for Levenshtein distance in the programming language you choose.

An alternative might be is to use FuzzyWuzzy in Python. Fuzzywuzzy is a Python library uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package. Find more details on FuzzyWuzzy here.

Upvotes: 1

Related Questions