【问题标题】:Use Google's mobile vision api to detect numbers only?仅使用 Google 的移动视觉 api 检测数字?
【发布时间】:2017-03-20 05:35:41
【问题描述】:

我想知道如何过滤以仅检测数字(整数)?例如 1,2,....,10。目前该api检测“文本”的所有格式。

【问题讨论】:

    标签: android-vision


    【解决方案1】:

    您应该在您身边进行该处理。使用 Regex 从 Vision API 接收的字符串中过滤掉数字:

    str="Text received 123,0";
    number = str.replace(/\D/g,'');
    
    result: 123
    

    【讨论】:

    • 我不认为这是他要求的。
    【解决方案2】:

    Google vision API 会检测所有字符,google vision 不会 有单独的 API(只能检测到 扫描)到现​​在为止只有数字,但是在扫描图像之后 使用 google vision api,我们将获得响应示例中的文本 “23XA3783”,所以现在我们可以替换我们不想要的字符了。

    将 google api 响应存储在临时变量中

    source_str = "23XA3783"

    在我的情况下,我使用 google api 响应获取所需的字符串 js

    source_str= temp["responses"][0].textAnnotations[0].description

      final_output = source_str.replace(/\D/g,'');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 1970-01-01
      • 2017-02-04
      • 2017-09-09
      • 2018-02-09
      相关资源
      最近更新 更多