【问题标题】:Return string using Keras OCR使用 Keras OCR 返回字符串
【发布时间】:2021-07-08 08:20:16
【问题描述】:

我正在使用 Keras OCR 的示例从图像中检测文本。使用官方文档中提供的示例代码,我使用预训练的权重获得了很好的准确性。 我打算使用 OCR 字符串来比较文本中检测到的一些模式。为了能够创建应用程序,我正在使用 Flask。

我想打印从 OCR 行接收到的字符串。目前,输出返回带有文本(单个单词)的图像。我希望只能打印从 OCR 行接收到的字符串。我怎样才能做到这一点?

代码:

import matplotlib.pyplot as plt

import keras_ocr

# keras-ocr will automatically download pretrained
# weights for the detector and recognizer.
pipeline = keras_ocr.pipeline.Pipeline()

# Get a set of three example images
images = [
    keras_ocr.tools.read(url) for url in [
        'https://upload.wikimedia.org/wikipedia/commons/b/b4/EUBanana-500x112.jpg',
         'abc.jpg'
    ]
]

# Each list of predictions in prediction_groups is a list of
# (word, box) tuples.
prediction_groups = pipeline.recognize(images)

# Plot the predictions
fig, axs = plt.subplots(nrows=len(images), figsize=(90, 90))
for ax, image, predictions in zip(axs, images, prediction_groups):
    keras_ocr.tools.drawAnnotations(image=image, predictions=predictions, ax=ax)

【问题讨论】:

    标签: python keras ocr


    【解决方案1】:

    我不知道你解决了没有。但是经过几个小时的努力,我想出了以下解决方案。我在搜索相同问题的答案时遇到了您的问题。

    for i in prediction_groups:
        for y in i:
            print(y[0])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-24
      • 2015-07-01
      • 2012-05-14
      相关资源
      最近更新 更多