简体   繁体   English

Firebase ML Vision TextRecogniser 修改结果以获得更好的搜索

[英]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.我在我的 Flutter 应用程序中不断遇到 Firebase Ml-Vision 的问题,其中结果不准确。 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:-由于我需要搜索标牌文本以查看它是否与特定的预定义字符串列表匹配,因此我试图找出一种方法,我可以采用特定单词(例如下面提到的单词)并创建所有排列的列表,其中以下字母和数字被考虑在内:-

  • 0=O and O=0 0=O 和 O=0
  • 1=l and l=1 1=l 和 l=1
  • 2=z and z=2 2=z 和 z=2
  • 5=s and s=5 5=s 和 s=5
  • 6=b and b=6 6=b 和 b=6
  • 7=T and T=7 7=T 和 T=7

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'.例如:单词“slob”可以被 OCR 读取为“5lob”、“s1ob”、“sl0b”、“slo6”甚至“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.我唯一拥有的是一堆非常讨厌的嵌套 for 循环。 I feel like there must be some elegant way of achieving this.我觉得必须有一些优雅的方式来实现这一点。 Is there even a term for this type of algorithm?这种算法甚至有一个术语吗?

Been there.到过那里。

Unfortunately, there's no "baked in function in Flutter" since, as you guess, Flutter is a mobile app framework.不幸的是,没有“在 Flutter 中的 function 中烘焙”,因为正如您猜测的那样,Flutter 是一个移动应用程序框架。 And this stuff (OCR/ML-Vision) falls in some other area.而这些东西(OCR/ML-Vision)属于其他领域。

What you can do is though a simple REST API.您可以做的是通过一个简单的 REST API。 You send the text received from Firebase ML-Vision to the API, and grab the response text.您将从 Firebase ML-Vision 收到的文本发送到 API,然后获取响应文本。 You can use the programming language of your choice.您可以使用您选择的编程语言。 Below is what you can do in the API.以下是您可以在 API 中执行的操作。

Use Levenshtein distance .使用Levenshtein 距离 This gives a 'distance' between two words.这给出了两个词之间的“距离”。 For example:例如:

  1. The distance between the words "slob" and "slob" is 0.单词“slob”和“slob”之间的距离为0。
  2. The distance between the words "slob" and "5lob" is 1.单词“slob”和“5lob”之间的距离是 1。
  3. The distance between the words "slob" and "Flutter" is 6. “slob”和“Flutter”这两个词之间的距离是 6。
  4. The distance between the words "slob" and "market" is 6. “slob”和“market”这两个词之间的距离是 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.你可能会用你选择的编程语言搜索 Levenshtein distance 的代码。

An alternative might be is to use FuzzyWuzzy in Python.另一种可能是在 Python 中使用 FuzzyWuzzy。 Fuzzywuzzy is a Python library uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package. Fuzzywuzzy 是一个 Python 库,它使用 Levenshtein 距离来计算简单易用的 package 中的序列之间的差异。 Find more details on FuzzyWuzzy here .此处查找有关 FuzzyWuzzy 的更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM