Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict output 2 #441

Merged
merged 2 commits into from
Jun 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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