【问题标题】:How to fetch (extract) text from image which is in gallery and search that text - Android?如何从图库中的图像中获取(提取)文本并搜索该文本 - Android?
【发布时间】:2018-04-15 19:03:11
【问题描述】:

我想这样做,我的手机上有数千张图片,我想从如下图所示的图片中获取文本:例如,我的手机上有上面的图片,我想获取文本“示例源代码”这是用图像写的。那么我们如何在 android 中做到这一点我必须尝试 Google Vision API 有时也会给出正确的文本,但有时并不准确。那么还有其他选择吗?

【问题讨论】:

  • 就图像处理而言,在这种情况下,准确的 Vision API 永远不会做得很好
  • @AkshayKatariya 我尝试了视觉 api,但如果你的图像充满了不同的设计和颜色,然后还有文字,那么它不会给出正确的结果,它只适用于简单的图像,比如只写在图像中的想法或一些引号或其他只能文本图像的东西。

标签: java android android-image google-vision


【解决方案1】:

首先你需要为

创建一个Demo

Android 上的光学字符识别 - OCR

从图像中获取文本。

这里发布了一些有用的链接:-

1.Android OCR Library

2.https://github.com/abbyysdk/ocrsdk.com

3.http://www.truiton.com/2016/11/optical-character-recognition-android-ocr/

4.https://github.com/renard314/textfairy

5.https://github.com/rmtheis/android-ocr

6.https://github.com/priyankvex/Easy-Ocr-Scanner-Android

您从互联网上获得的许多示例只是谷歌它。希望这对你有帮助。

【讨论】:

    【解决方案2】:
    try {
        TextRecognizer txtRecognizer = new TextRecognizer.Builder(getApplicationContext()).build();
        if (!txtRecognizer.isOperational()) {
        } else {
            Frame frame = new Frame.Builder().setBitmap(bitmap).build();
            SparseArray items = txtRecognizer.detect(frame);
            StringBuilder strBuilder = new StringBuilder();
            for (int i = 0; i < items.size(); i++) {
                TextBlock item = (TextBlock) items.valueAt(i);
                strBuilder.append(item.getValue());
            }
            Log.d("My Text : ", strBuilder.toString() + " okok");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-26
      • 2021-01-21
      • 2014-07-31
      相关资源
      最近更新 更多