实际上,我在我的项目(这是一个 python 项目)中使用 ocr.space 作为 OCR API 来执行 OCR 任务。
我想使用 Azure OCR API 并检查哪个 API 比另一个更好。
如您所见,computervision_client.read(...) 函数需要图像 URL 才能正常工作。但是,我想将此 API 应用于我计算机中的本地镜像。
friend 们有什么建议吗?
谢谢
最佳答案
我也遇到了同样的问题,他们在 github 上讨论了 here 。 And somebody put up a good list of examples用于将所有 Azure OCR 功能与本地镜像结合使用。尝试使用 read_in_stream()
函数,例如
with open("path_to_image.png", "rb") as image_stream:
job = client.read_in_stream(
image=image_stream,
mode="Printed",
raw=True
)
operation_id = job.headers['Operation-Location'].split('/')[-1]
image_analysis = computervision_client.get_read_result(operation_id)
while image_analysis.status.lower() in ['notstarted', 'running']:
time.sleep(1)
image_analysis = computervision_client.get_read_result(
operation_id=operation_id)
print(image_analysis)
lines = [res.lines for res in image_analysis.analyze_result.read_results]
print(lines)
关于python - 如何在本地镜像上应用 Azure OCR API 和 Request 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68070488/