From dcb4f3351a0559f024268ad9dc72bc28b944958e Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Sun, 30 May 2021 18:47:43 +0200 Subject: [PATCH 1/2] Add dict output --- easyocr/easyocr.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/easyocr/easyocr.py b/easyocr/easyocr.py index 9fbd0e4ab..35b04e836 100644 --- a/easyocr/easyocr.py +++ b/easyocr/easyocr.py @@ -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) @@ -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 @@ -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 @@ -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 From e48ed0a22146640c9e8fefea8b32ef5e13aceba9 Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Sun, 30 May 2021 18:49:39 +0200 Subject: [PATCH 2/2] Forgot space --- easyocr/easyocr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easyocr/easyocr.py b/easyocr/easyocr.py index 35b04e836..911bc3002 100644 --- a/easyocr/easyocr.py +++ b/easyocr/easyocr.py @@ -386,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,output_format) + filter_ths, y_ths, x_ths, False, output_format) return result