From 1dcb4aadd2adefe812c1c9da20038262ee56389b Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Fri, 26 Jul 2024 14:12:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=82=E6=8A=B9=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E8=AF=8D=E8=87=AA=E5=AE=9A=E4=B9=89=E5=81=8F=E7=A7=BB?= =?UTF-8?q?=E9=87=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_mask/__init__.py | 6 +++++- photo_mask/photo_mask.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/photo_mask/__init__.py b/photo_mask/__init__.py index 977695e..22b7d13 100644 --- a/photo_mask/__init__.py +++ b/photo_mask/__init__.py @@ -14,12 +14,16 @@ SEND_ERROR_EMAIL = True 关键词配置 """ # 使用正则匹配 +# key: 正则表达式 +# length: 涂抹的长度 +# offset: 涂抹的偏移量,基于正则匹配的开头偏移。如果不写,默认偏移量为匹配到的字符串长度,即从匹配到的字符串结尾开始涂抹 NAME_KEYS = [ - {"key": "^名[:|:]$", "length": 3}, # 可能误涂 + {"key": "^名[:|:]$", "length": 3}, {"key": "[姓|娃|生]名", "length": 4}, {"key": "款人", "length": 4}, {"key": "[交|文][^病]?人", "length": 4}, {"key": "购买方名称", "length": 4}, + {"key": "[(|(]个人[)|)]", "length": 3, "offset": -3}, ] ID_CARD_NUM_KEYS = [ {"key": "[身]?份证号", "length": 19}, diff --git a/photo_mask/photo_mask.py b/photo_mask/photo_mask.py index 59967fc..def856d 100644 --- a/photo_mask/photo_mask.py +++ b/photo_mask/photo_mask.py @@ -150,7 +150,7 @@ def get_mask_layout(image, name, id_card_num): match_list = re.findall(key["key"], layout[1]) for m in match_list: if m in layout[1]: - boxes += find_boxes(m, layout, offset=len(m), length=key["length"]) + boxes += find_boxes(m, layout, offset=key.get("offset", len(m)), length=key["length"]) if match_list: break return boxes