Skip to content

Commit c967c2d

Browse files
authored
Merge pull request #9461 from Azadehkhojandi/patch-1
update python-hand-text.md
2 parents bb5dc4f + b5528da commit c967c2d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

articles/cognitive-services/Computer-vision/QuickStarts/python-hand-text.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,22 @@ operation_url = response.headers["Operation-Location"]
8686

8787
# The recognized text isn't immediately available, so poll to wait for completion.
8888
analysis = {}
89-
while "recognitionResult" not in analysis:
89+
poll = True
90+
while (poll):
9091
response_final = requests.get(
9192
response.headers["Operation-Location"], headers=headers)
9293
analysis = response_final.json()
9394
time.sleep(1)
95+
if ("recognitionResult" in analysis):
96+
poll= False
97+
if ("status" in analysis and analysis['status'] == 'Failed'):
98+
poll= False
9499

95-
# Extract the recognized text, with bounding boxes.
96-
polygons = [(line["boundingBox"], line["text"])
97-
for line in analysis["recognitionResult"]["lines"]]
100+
polygons=[]
101+
if ("recognitionResult" in analysis):
102+
# Extract the recognized text, with bounding boxes.
103+
polygons = [(line["boundingBox"], line["text"])
104+
for line in analysis["recognitionResult"]["lines"]]
98105

99106
# Display the image and overlay it with the extracted text.
100107
plt.figure(figsize=(15, 15))

0 commit comments

Comments
 (0)