优化关键词涂抹的判断
This commit is contained in:
@@ -137,16 +137,22 @@ def get_mask_layout(image, name, id_card_num):
|
||||
result += find_boxes(id_card_num, layout, improve=True, image_path=temp_file.name)
|
||||
find_id_card_num_by_key = False
|
||||
|
||||
keys = []
|
||||
if find_name_by_key:
|
||||
keys += NAME_KEYS
|
||||
if find_id_card_num_by_key:
|
||||
keys += ID_CARD_NUM_KEYS
|
||||
def _find_boxes_by_keys(keys):
|
||||
boxes = []
|
||||
for key in keys:
|
||||
matches = re.findall(key["key"], layout[1])
|
||||
for match in matches:
|
||||
if match in layout[1]:
|
||||
result += find_boxes(match, layout, offset=len(match), length=key["length"])
|
||||
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"])
|
||||
if matches:
|
||||
break
|
||||
return boxes
|
||||
|
||||
if find_name_by_key:
|
||||
result += _find_boxes_by_keys(NAME_KEYS)
|
||||
if find_id_card_num_by_key:
|
||||
result += _find_boxes_by_keys(ID_CARD_NUM_KEYS)
|
||||
|
||||
return result
|
||||
except Exception as e:
|
||||
logging.error("涂抹时出错!", exc_info=e)
|
||||
|
||||
Reference in New Issue
Block a user