diff --git a/detect_merge/merge.py b/detect_merge/merge.py index b70acc6..a490c45 100644 --- a/detect_merge/merge.py +++ b/detect_merge/merge.py @@ -191,7 +191,7 @@ def most_pix_around(pad=6, offset=2): def merge(img_path, compo_path, text_path, merge_root=None, is_paragraph=False, is_remove_bar=True, show=False, wait_key=0): compo_json = json.load(open(compo_path, 'r')) - text_json = json.load(open(text_path, 'r')) + text_json = json.load(open(text_path, 'r',encoding='utf-8')) # load text and non-text compo ele_id = 0 diff --git a/detect_text/text_detection.py b/detect_text/text_detection.py index 30ac52c..197d0c7 100644 --- a/detect_text/text_detection.py +++ b/detect_text/text_detection.py @@ -9,7 +9,7 @@ def save_detection_json(file_path, texts, img_shape): - f_out = open(file_path, 'w') + f_out = open(file_path, 'w',encoding='utf-8') output = {'img_shape': img_shape, 'texts': []} for text in texts: c = {'id': text.id, 'content': text.content} @@ -18,7 +18,7 @@ def save_detection_json(file_path, texts, img_shape): c['width'] = text.width c['height'] = text.height output['texts'].append(c) - json.dump(output, f_out, indent=4) + json.dump(output, f_out, indent=4,ensure_ascii=False) def visualize_texts(org_img, texts, shown_resize_height=None, show=False, write_path=None):