简体   繁体   English

如何从图库中的图像中获取(提取)文本并搜索该文本 - Android?

[英]How to fetch (extract) text from image which is in gallery and search that text - Android?

I want to do that I have thousands of images on my phone and I want to fetch text from an image like below image: for example, i have above image on my phone and I want to fetch text "Sample Source Code" which is written in image.我想这样做我的手机上有数千张图片,我想从如下图所示的图像中获取文本:例如,我的手机上有上面的图像,我想获取编写的文本“示例源代码”在图像中。 so how can we do that in android I have to try Google Vision API also gives sometimes correct text but sometimes not accurate.那么我们如何在 android 中做到这一点我必须尝试 Google Vision API 有时也提供正确的文本但有时不准确。 so is there any other option for this?那么还有其他选择吗?

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();
}

First you need to create a Demo for首先你需要创建一个Demo

Optical Character Recognition on Android – OCR Android 上的光学字符识别 – OCR

to fetch text from images.从图像中获取文本。

Here posted some helpful links:-这里发布了一些有用的链接:-

1.Android OCR Library 1.安卓OCR库

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

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

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

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

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

Many Examples you get from internet just Google it.你从互联网上得到的许多例子只是谷歌。 hope this helps you.希望这对你有帮助。

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

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