Handle no text detected for Google Vision and Azure
This commit is contained in:
@@ -167,7 +167,8 @@ class GoogleVision:
|
|||||||
except:
|
except:
|
||||||
return (False, 'Unknown error!')
|
return (False, 'Unknown error!')
|
||||||
texts = response.text_annotations
|
texts = response.text_annotations
|
||||||
x = (True, texts[0].description)
|
res = texts[0].description if len(texts) > 0 else ''
|
||||||
|
x = (True, res)
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def _preprocess(self, img):
|
def _preprocess(self, img):
|
||||||
@@ -379,7 +380,8 @@ class AzureImageAnalysis:
|
|||||||
|
|
||||||
res = ''
|
res = ''
|
||||||
if read_result.read:
|
if read_result.read:
|
||||||
for line in read_result.read.blocks[0].lines:
|
for block in read_result.read.blocks:
|
||||||
|
for line in block.lines:
|
||||||
res += line.text + ' '
|
res += line.text + ' '
|
||||||
else:
|
else:
|
||||||
return (False, 'Unknown error!')
|
return (False, 'Unknown error!')
|
||||||
|
|||||||
Reference in New Issue
Block a user