【问题标题】:License plate recognition using GCP's Cloud Vision使用 GCP 的 Cloud Vision 进行车牌识别
【发布时间】:2019-07-30 17:46:26
【问题描述】:

我们正在开发一款移动应用,允许用户上传将存储在 GCP 存储桶中的图片。然而,在保存到存储桶之前,我们希望模糊可能存在的任何面孔和车牌。我们一直在使用对 GCP 的 Cloud Vision 服务的调用来为面部图像添加注释,并且效果很好。然而,车牌注释已被证明更具挑战性。没有专门检测车牌的选项,但我们似乎仅限于捕获车牌的文本检测,以及图像中的所有其他文本。这不是我们想要的。

关于我们如何更好地将文本识别范围缩小到车牌的任何指示?

这是我们目前用于检测和收集面部和文本注释数据的 Python 代码示例:

from google.cloud import vision
...
def __annotate(image_storage_url):
    result = []

    client = vision.ImageAnnotatorClient()

    response = client.annotate_image({
        'image': {'source': {'image_uri': image_storage_url}},
        'features': [
            {'type': vision.enums.Feature.Type.FACE_DETECTION}, #works great
            {'type': vision.enums.Feature.Type.TEXT_DETECTION}, #too broad
        ],
    })

    # record facial annotations
    faces = response.face_annotations
    for face in faces:
        vertices = [(vertex.x, vertex.y)
                    for vertex in face.bounding_poly.vertices]
        result.append(vertices)

    # record plate annotations
    texts = response.text_annotations
    for text in texts:
        vertices = [(vertex.x, vertex.y)
                    for vertex in text.bounding_poly.vertices]
        result.append(vertices)

    return result

谢谢

2020 年 4 月 28 日更新 感谢下面 Obed Macallums 的回答(现在标记为答案),我现在可以使用 Python 代码使用 GCP Cloud Vision 来检测和模糊上传到 GCP 存储的图像上的车牌。以下是相关的 Python 代码:

from google.cloud import vision
...

def __annotate(image_storage_url, img_dimensions):
    result = []

    client = vision.ImageAnnotatorClient()

    response = client.annotate_image({
        'image': {'source': {'image_uri': image_storage_url}},
        'features': [
            {'type': vision.enums.Feature.Type.FACE_DETECTION},
            {'type': vision.enums.Feature.Type.TEXT_DETECTION},
            {'type': vision.enums.Feature.Type.OBJECT_LOCALIZATION},
        ],
    })

    # Blur faces
    faces = response.face_annotations
    for face in faces:
        vertices = [(vertex.x, vertex.y)
                    for vertex in face.bounding_poly.vertices]
        LOGGER.debug('Face detected: %s', vertices)
        result.append(vertices)

    # Blur license plates
    # Note: localized_object_annotations use normalized_vertices which represent the relative-distance
    # (between 0 and 1) and so must be multiplied using the image's height and width
    lo_annotations = response.localized_object_annotations
    for obj in lo_annotations:
        if obj.name == 'License plate':
            vertices = [(int(vertex.x * img_dimensions['width']), int(vertex.y * img_dimensions['height']))
                        for vertex in obj.bounding_poly.normalized_vertices]
            LOGGER.debug('License plate detected: %s', vertices)
            result.append(vertices)

    return result

【问题讨论】:

    标签: python image-processing google-cloud-platform google-cloud-vision


    【解决方案1】:

    您必须创建一个自定义模型,上传您的训练图像集(在本例中为车牌)并对其进行训练以生成模型,然后您可以使用该模型发送图像并取回信息...

    看看Google Object Detection

    【讨论】:

      【解决方案2】:

      尝试在同一张图片中使用 OBJECT_LOCALIZATION、FACE_DETECTION 和 TEXT_DETECTION,并通过 OBJECT_LOCALIZATION 中的“车牌”进行过滤,这样你就可以为所欲为。

      【讨论】:

      • 道歉 Obed_Macallums。我最近才看到你早在 10 月就发表了评论。我试过你的建议,它有效!我没有意识到车牌是localized_object_annotations 之一,很高兴看到答案已经内置。感谢您的回答!
      猜你喜欢
      • 2010-12-30
      • 1970-01-01
      • 1970-01-01
      • 2013-10-16
      • 2016-11-03
      • 1970-01-01
      • 2014-11-04
      • 2014-12-31
      相关资源
      最近更新 更多