请查找下面的代码
def获取文档边界(图像、功能): #[START vision\u document\u text\u tutorial\u detect\u bounds] “”“返回给定图像的文档边界。”“” os.environ['GOOGLE\u APPLICATION\u CREDENTIALS']=r'C:\DSpython\bounds.json' client=vision.ImageAnnotatorClient()
bounds = []
with io.open(image, 'rb') as image_file:
content = image_file.read()
image= types.Image(content=content)
response = client.document_text_detection(image=image)
document = response.full_text_annotation
# Collect specified feature bounds by enumerating all document features
for page in document.pages:
for block in page.blocks:
for paragraph in block.paragraphs:
for word in paragraph.words:
for symbol in word.symbols:
if (feature == FeatureType.SYMBOL):
bounds.append(symbol.bounding_box)
if (feature == FeatureType.WORD):
bounds.append(word.bounding_box)
if (feature == FeatureType.PARA):
bounds.append(paragraph.bounding_box)
if (feature == FeatureType.BLOCK):
bounds.append(block.bounding_box)
# The list `bounds` contains the coordinates of the bounding boxes.
# [END vision_document_text_tutorial_detect_bounds]
return bounds
***我的目标是需要从图像中提取文本。作为其中的一部分,我在函数“GetDocument\u bounds”中创建边界
使用io.open(image,'rb')作为image_文件:“当使用io.open函数打开映像时,我得到了上面的代码
你的意思是说
以前
?
相关问题 更多 >
编程相关推荐