如何在 Google Cloud Vision API 中对属于较大句子的块进行分组?
How to group blocks that are part of a bigger sentences in Google Cloud Vision API?
我在 Python
上使用 Google Cloud Vision API
来检测通常在 shop/store 上方发现的囤积板中的文本值。到目前为止,我已经能够检测到单个单词及其边界多边形的坐标。有没有办法根据检测到的词的相对位置和大小对它们进行分组?
比如店名一般都是用同样大小写的,字对齐。 API 是否提供了一些功能来将那些可能是较大句子的一部分的单词(商店名称或地址等)分组?
如果API没有提供这样的功能,有什么好的方法来对它们进行分组?以下是我到目前为止所做的图像示例:
视觉 API 输出摘录:
description: "SHOP"
bounding_poly {
vertices {
x: 4713
y: 737
}
vertices {
x: 5538
y: 737
}
vertices {
x: 5538
y: 1086
}
vertices {
x: 4713
y: 1086
}
}
, description: "OVOns"
bounding_poly {
vertices {
x: 6662
y: 1385
}
vertices {
x: 6745
y: 1385
}
vertices {
x: 6745
y: 1402
}
vertices {
x: 6662
y: 1402
}
}
我建议您看一下使用DOCUMENT_TEXT_DETECTION
进行OCR 识别请求时应用的TextAnnotation 响应格式。此响应包含有关图像元数据和文本内容值的详细信息,可用于按块、段落、单词等对文本进行分组,如 public 文档中所述:
TextAnnotation contains a structured representation of OCR extracted text. The hierarchy of an OCR extracted text structure is like this: TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol
此外,您可以按照这个有用的 example 进行操作,其中显示了如何通过处理 fullTextAnnotation
响应内容来组织从收据图像中提取的文本。
我在 Python
上使用 Google Cloud Vision API
来检测通常在 shop/store 上方发现的囤积板中的文本值。到目前为止,我已经能够检测到单个单词及其边界多边形的坐标。有没有办法根据检测到的词的相对位置和大小对它们进行分组?
比如店名一般都是用同样大小写的,字对齐。 API 是否提供了一些功能来将那些可能是较大句子的一部分的单词(商店名称或地址等)分组?
如果API没有提供这样的功能,有什么好的方法来对它们进行分组?以下是我到目前为止所做的图像示例:
description: "SHOP"
bounding_poly {
vertices {
x: 4713
y: 737
}
vertices {
x: 5538
y: 737
}
vertices {
x: 5538
y: 1086
}
vertices {
x: 4713
y: 1086
}
}
, description: "OVOns"
bounding_poly {
vertices {
x: 6662
y: 1385
}
vertices {
x: 6745
y: 1385
}
vertices {
x: 6745
y: 1402
}
vertices {
x: 6662
y: 1402
}
}
我建议您看一下使用DOCUMENT_TEXT_DETECTION
进行OCR 识别请求时应用的TextAnnotation 响应格式。此响应包含有关图像元数据和文本内容值的详细信息,可用于按块、段落、单词等对文本进行分组,如 public 文档中所述:
TextAnnotation contains a structured representation of OCR extracted text. The hierarchy of an OCR extracted text structure is like this: TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol
此外,您可以按照这个有用的 example 进行操作,其中显示了如何通过处理 fullTextAnnotation
响应内容来组织从收据图像中提取的文本。