Skip to content

Commit

Permalink
Merge pull request JaidedAI#441 from A2va/dict-output-2
Browse files Browse the repository at this point in the history
Dict output 2
  • Loading branch information
rkcosmos committed Jun 6, 2021
2 parents be9d3a9 + bb8cdba commit af7114e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions easyocr/easyocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def recognize(self, img_cv_grey, horizontal_list=None, free_list=None,\
workers = 0, allowlist = None, blocklist = None, detail = 1,\
rotation_info = None,paragraph = False,\
contrast_ths = 0.1,adjust_contrast = 0.5, filter_ths = 0.003,\
y_ths = 0.5, x_ths = 1.0, reformat=True):
y_ths = 0.5, x_ths = 1.0, reformat=True, output_format='standard'):

if reformat:
img, img_cv_grey = reformat_input(img_cv_grey)
Expand Down Expand Up @@ -356,6 +356,8 @@ def recognize(self, img_cv_grey, horizontal_list=None, free_list=None,\

if detail == 0:
return [item[1] for item in result]
elif output_format == 'dict':
return [ {'boxes':item[0],'text':item[1],'confident':item[2]} for item in result]
else:
return result

Expand All @@ -366,7 +368,7 @@ def readtext(self, image, decoder = 'greedy', beamWidth= 5, batch_size = 1,\
text_threshold = 0.7, low_text = 0.4, link_threshold = 0.4,\
canvas_size = 2560, mag_ratio = 1.,\
slope_ths = 0.1, ycenter_ths = 0.5, height_ths = 0.5,\
width_ths = 0.5, y_ths = 0.5, x_ths = 1.0, add_margin = 0.1):
width_ths = 0.5, y_ths = 0.5, x_ths = 1.0, add_margin = 0.1, output_format='standard'):
'''
Parameters:
image: file path or numpy-array or a byte stream object
Expand All @@ -384,6 +386,6 @@ def readtext(self, image, decoder = 'greedy', beamWidth= 5, batch_size = 1,\
decoder, beamWidth, batch_size,\
workers, allowlist, blocklist, detail, rotation_info,\
paragraph, contrast_ths, adjust_contrast,\
filter_ths, y_ths, x_ths, False)
filter_ths, y_ths, x_ths, False, output_format)

return result

0 comments on commit af7114e

Please sign in to comment.