如何在 python 中使用云视觉 api 仅检测特定语言并忽略其他语言?

How to ONLY detect a particular language using cloud vision api in python and ignore others?

我想从图像中检测韩语,并且只检测韩语。我不想检测英语,即使它出现在图像中。我似乎无法在互联网上找到任何可以为我做这件事的方法。

我试过的:

我知道 image_context 属性,并且已经使用它来仅提及韩文,但并未忽略英文文本。我做了:

response = client.document_text_detection(image=image, image_context={"language_hints": ["ko"]})

我想要什么?

有没有办法不从图像中检测到英语?

或者有没有办法阻止某些符号被检测到?

我相信 image_context 属性未用于限制要在单个图像上提取的语言。它的作用恰恰相反,因为它有助于扩大理解语言的范围并获得更好的结果。 1

Providing a language hint to the service is not required, but can be done if the service is having trouble detecting the language used in your image.

If the language hint is left blank, we will attempt to auto-detect the most appropriate language. The TEXT_DETECTION endpoint will auto-detect only a subset of supported languages, while the DOCUMENT_TEXT_DETECTION endpoint will auto-detect the full set of supported languages.

实现 use-case 的一种方法可能是操纵来自 Vision API 的 return 响应。您可以只提取韩文字符或排除带有英文文本的结果。

"textAnnotations": [
    {
      "locale": "ko",
      "description": "牛牛面馆\n",
      "boundingPoly": {
        "vertices": [
          {
            "x": 159,
            "y": 212
          },
          {
            "x": 947,
            "y": 212
          },
          {
            "x": 947,
            "y": 354
          },
          {
            "x": 159,
            "y": 354
          }
        ]
      }
    },

或者您可以为此提交功能请求。