实际上,我在我的项目中使用ocr.space作为OCR任务的OCR (这是一个python项目)。
我想使用Azure OCR并检查哪个API比其他API更好。
如您所见,computervision_client.read(.)函数需要图像URL才能正确工作。但是,我想在我的计算机中的本地图像上应用这个API。
你有什么建议朋友吗?
谢谢
发布于 2022-03-09 22:18:45
我也有同样的问题,他们在github 这里上讨论过。有人列举了很多例子用于使用带有本地图像的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)https://stackoverflow.com/questions/68070488
复制相似问题