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

时间:2017-11-03 05:37:43

标签: java android android-image google-vision

我想这样做我手机上有数以千计的图像,我想从图像下面的图像中获取文字:例如,我手机上面有图像,我想获取文字“示例源代码”这是写在图像中。那么我们怎么能在Android中做到这一点我必须尝试谷歌Vision API也有时提供正确的文本,但有时不准确。那还有其他选择吗?

2 个答案:

答案 0 :(得分:0)

First you need to create a Demo for

Optical Character Recognition on Android – OCR

to fetch text from images.

Here posted some helpful links:-

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

Many Examples you get from internet just Google it. hope this helps you.

答案 1 :(得分:0)

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