【问题标题】:Force Google Vision API to detect dates / numbers强制 Google Vision API 检测日期/数字
【发布时间】:2019-07-27 22:15:45
【问题描述】:

我正在尝试使用 Google Vision API 检测手写日期。你知道是否可以强制它检测日期(DD/MM/YYYY),或者至少只是为了增加可靠性而检测数字?

我使用的函数,将 Image 作为 np.array 作为输入:

def detect_handwritten_text(img):
"""Recognizes characters using the Google Cloud Vision API.
Args:
    img(np.array) = The Image on which to apply the OCR.

Returns:
    The recognized content of img as string.
"""

from google.cloud import vision_v1p3beta1 as vision
client = vision.ImageAnnotatorClient()

# Transform np.array image format into vision api readable byte format
sucess, encoded_image = cv.imencode('.png', img)
content = encoded_image.tobytes()

# Configure client to detect handwriting and load picture
image = vision.types.Image(content=content)
image_context = vision.types.ImageContext(language_hints=['en-t-i0-handwrit'])

response = client.document_text_detection(image=image, image_context=image_context)
return response.full_text_annotation.text

【问题讨论】:

    标签: computer-vision google-vision handwriting-recognition


    【解决方案1】:

    在 ImageAnnotatorClient.DetectDocumentText(your image) 之后,您可以遍历每个块内的块和单词,并尝试在每个单词上匹配正则表达式以查找日期和数字。

    【讨论】:

    • 问题是关于强制谷歌视觉寻找数字。例如,如果正常的google vision OCR结果为1b/O8/201B,强制google vision后,必须找到16/08/2018
    猜你喜欢
    • 2016-10-01
    • 1970-01-01
    • 2018-11-18
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2019-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多