我是googlevision的新手,我想创建代码来接收异步响应。例如,创建一个JSON文件来响应,然后加载JSON文件并继续使用反识别器
我正在尝试使用Google的一些代码,但是当我尝试读取JSON文件时,它不像在同步模式下那样工作
这就是我如何将响应保存到JSON文件的方法:
with open(path_source_image, 'rb') as image_file:
tmp_image_opened = image_file.read()
tpm_image_opened_to_vision = vision.types.Image(content=tmp_image_opened)
tpm_vision_client = vision.ImageAnnotatorClient()
tpm_response_from_vision = tpm_vision_client.document_text_detection(image=tpm_image_opened_to_vision)
以下是我尝试读取和使用JSON文件的方式:
with open('proyecto/2_MILE.json') as fp:
document = json.load(fp)
for page in document.pages:
for block in page.blocks:
for paragraph in block.paragraphs:
for word in paragraph.words:
assembled_word = assemble_word(word)
if (assembled_word == 'LEIDY'):
return word.bounding_box.vertices[0]
但它不起作用,它说
in find_word_location for page in document.pages: AttributeError: 'dict' object has no attribute 'pages'
目前没有回答
相关问题 更多 >
编程相关推荐