优化关键词涂抹的判断
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)
|
result += find_boxes(id_card_num, layout, improve=True, image_path=temp_file.name)
|
||||||
find_id_card_num_by_key = False
|
find_id_card_num_by_key = False
|
||||||
|
|
||||||
keys = []
|
def _find_boxes_by_keys(keys):
|
||||||
|
boxes = []
|
||||||
|
for key in keys:
|
||||||
|
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:
|
if find_name_by_key:
|
||||||
keys += NAME_KEYS
|
result += _find_boxes_by_keys(NAME_KEYS)
|
||||||
if find_id_card_num_by_key:
|
if find_id_card_num_by_key:
|
||||||
keys += ID_CARD_NUM_KEYS
|
result += _find_boxes_by_keys(ID_CARD_NUM_KEYS)
|
||||||
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"])
|
|
||||||
return result
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("涂抹时出错!", exc_info=e)
|
logging.error("涂抹时出错!", exc_info=e)
|
||||||
|
|||||||
Reference in New Issue
Block a user