Image processing 来自Google Vision API的OCR信心分数

Image processing 来自Google Vision API的OCR信心分数,image-processing,computer-vision,ocr,google-cloud-vision,google-vision,Image Processing,Computer Vision,Ocr,Google Cloud Vision,Google Vision,我正在使用Google Vision OCR从python中的图像中提取文本。 使用以下代码段。 但是,置信度得分始终显示0.0,这显然是不正确的 如何从Google响应中提取单个字符或单词的OCR置信度分数 content = cv2.imencode('.jpg', cv2.imread(file_name))[1].tostring() img = types.Image(content=content) response1 = client.text_detection(image

我正在使用Google Vision OCR从python中的图像中提取文本。
使用以下代码段。
但是,置信度得分始终显示
0.0
,这显然是不正确的

如何从Google响应中提取单个字符或单词的OCR置信度分数

 content = cv2.imencode('.jpg', cv2.imread(file_name))[1].tostring()
 img = types.Image(content=content)
 response1 = client.text_detection(image=img, image_context={"language_hints": ["en"]})
 response_annotations = response1.text_annotations
 for x in response1.text_annotations:
      print(x)
      print(f'confidence:{x.confidence}')
例如:迭代的输出

description: "Date:"
bounding_poly {
  vertices {
    x: 127
    y: 11
  }
  vertices {
    x: 181
    y: 10
  }
  vertices {
    x: 181
    y: 29
  }
  vertices {
    x: 127
    y: 30
  }
}

confidence:0.0

我设法复制了你的问题。我使用了以下函数,所有项目的置信度均为0.0

来自google.cloud导入vision
def检测文本uri(uri):
client=vision.ImageAnnotatorClient()
image=vision.types.image()
image.source.image_uri=uri
响应=客户端.text\u检测(图像=图像)
text=response.text\u注释
打印('文本:')
对于文本中的文本:
打印(“\n”{}”格式(text.description))
顶点=(['({},{}').format(vertex.x,vertex.y)
用于文本中的顶点。边界(多边形顶点])
打印('bounds:{}'。格式(','.join(顶点)))
打印(“信心:{}”。格式(text.confidence))
如果响应.error.message:
引发异常(
“{}\n有关错误消息的详细信息,请检查:”
'https://cloud.google.com/apis/design/errors“.格式(
响应。错误。消息)
但是,当使用相同的图像和中的“trytheapi”选项时,我得到了一个信任度为非0的结果。从局部图像检测文本时也会发生这种情况


使用这两种方法时,人们应该期望信任具有相同的价值。我已经打开了一个问题跟踪器,检查它。

正在运行的代码检索GOCR响应的正确置信值

def detect_document(path):
    """Detects document features in an image."""
    from google.cloud import vision
    import io
    client = vision.ImageAnnotatorClient()

    # [START vision_python_migration_document_text_detection]
    with io.open(path, 'rb') as image_file:
        content = image_file.read()

    image = vision.types.Image(content=content)

    response = client.document_text_detection(image=image)

    for page in response.full_text_annotation.pages:
        for block in page.blocks:
            print('\nBlock confidence: {}\n'.format(block.confidence))

            for paragraph in block.paragraphs:
                print('Paragraph confidence: {}'.format(
                    paragraph.confidence))

                for word in paragraph.words:
                    word_text = ''.join([
                        symbol.text for symbol in word.symbols
                    ])
                    print('Word text: {} (confidence: {})'.format(
                        word_text, word.confidence))

                    for symbol in word.symbols:
                        print('\tSymbol: {} (confidence: {})'.format(
                            symbol.text, symbol.confidence))

    if response.error.message:
        raise Exception(
            '{}\nFor more info on error messages, check: '
            'https://cloud.google.com/apis/design/errors'.format(
                response.error.message))
    # [END vision_python_migration_document_text_detection]
# [END vision_fulltext_detection]

# add your own path
path = "gocr_vision.png"
detect_document(path)

是否尝试在演示api中发布图像?不同的结果?也可能删除语言提示会对演示api产生一些影响?我们可以进一步阐述。它的OCR非常完美,甚至每个字符的大小写都能正确地找到空格数。这是因为它的置信度为零,这不会在这里加上->,同样的置信度?通过
googlecloudvision==1.0.0
@letsBeePolite获得关于这个问题的任何消息?改变方法不是解决方案。文档文本检测没有文本检测的目标