File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
articles/cognitive-services/Computer-vision/QuickStarts Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -86,15 +86,22 @@ operation_url = response.headers["Operation-Location"]
86
86
87
87
# The recognized text isn't immediately available, so poll to wait for completion.
88
88
analysis = {}
89
- while " recognitionResult" not in analysis:
89
+ poll = True
90
+ while (poll):
90
91
response_final = requests.get(
91
92
response.headers[" Operation-Location" ], headers = headers)
92
93
analysis = response_final.json()
93
94
time.sleep(1 )
95
+ if (" recognitionResult" in analysis):
96
+ poll= False
97
+ if (" status" in analysis and analysis[' status' ] == ' Failed' ):
98
+ poll= False
94
99
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" ]]
98
105
99
106
# Display the image and overlay it with the extracted text.
100
107
plt.figure(figsize = (15 , 15 ))
You can’t perform that action at this time.
0 commit comments