添加姓名模糊判断

This commit is contained in:
2024-07-25 11:07:46 +08:00
parent 162aea0ebb
commit 8eb9255eef

View File

@@ -121,6 +121,17 @@ def get_mask_layout(image, name, id_card_num):
result += find_boxes(name, layout, improve=True, image_path=temp_file.name)
find_name_by_key = False
break
if find_name_by_key and len(name) > 2:
name_len = len(name)
name_offset = int(name_len / 2)
r = f"{name[:-1]}.|.{name[1:]}" + (
f"|{name[:name_offset]}.{name[-name_offset:]}" if (name_len & 1) == 1 else "")
matches = re.findall(r, layout[1])
for match in matches:
if match in layout[1]:
result += find_boxes(match, layout, improve=True, image_path=temp_file.name)
find_name_by_key = False
break
if id_card_num in layout[1]:
result += find_boxes(id_card_num, layout, improve=True, image_path=temp_file.name)
find_id_card_num_by_key = False