【问题标题】:I want to read text from Google OCR API and store in database我想从 Google OCR API 读取文本并存储在数据库中
【发布时间】:2019-03-28 07:48:56
【问题描述】:

我使用 Google OCR API 开发了一个可以从扫描图像中读取文本的应用程序。我想将文本存储在数据库中。我想要完整的代码从图像中读取文本并将其存储在数据库中。

【问题讨论】:

  • 到目前为止,您是否尝试过任何方法来存储这些值? Stackoverflow 不是免费的编码服务。

标签: android database ocr


【解决方案1】:

以下代码有助于从图像中提取文本

`implementation 'com.google.android.gms:play-services-vision:17.0.2'

    TextRecognizer textRecognizer = new TextRecognizer.Builder(getApplicationContext()).build();

Frame imageFrame = new Frame.Builder()

        .setBitmap(bitmap)                
        .build();

String imageText = "";


SparseArray<TextBlock> textBlocks = textRecognizer.detect(imageFrame);

for (int i = 0; i < textBlocks.size(); i++) {
    TextBlock textBlock = textBlocks.get(textBlocks.keyAt(i));
    imageText = textBlock.getValue();                   

}`

$imageText 返回可以转储到数据库的文本

【讨论】:

  • 嗨,谢谢。我是 android 的新手...我需要整个代码/项目 ..它将从图像中读取文本并同时存储在数据库中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-27
  • 1970-01-01
  • 2023-01-27
  • 1970-01-01
  • 1970-01-01
  • 2021-01-18
相关资源
最近更新 更多