调整涂抹的ocr模型参数;优化关键词
This commit is contained in:
@@ -60,7 +60,7 @@ def find_boxes(content, layout, offset=0, length=None, improve=False, image_path
|
||||
captured_image, offset_x, offset_y = image_util.expand_to_a4_size(captured_image, True)
|
||||
cv2.imwrite(temp_file.name, captured_image)
|
||||
try:
|
||||
layouts = OCR.parse({"doc": temp_file.name})["layout"]
|
||||
layouts = util.get_ocr_layout(OCR, temp_file.name)
|
||||
except TypeError:
|
||||
# 如果是类型错误,大概率是没识别到文字
|
||||
layouts = []
|
||||
@@ -91,8 +91,8 @@ def get_mask_layout(image, name, id_card_num):
|
||||
result = []
|
||||
try:
|
||||
try:
|
||||
# layouts = util.get_ocr_layout(OCR, temp_file.name)
|
||||
layouts = OCR.parse({"doc": temp_file.name})["layout"]
|
||||
layouts = util.get_ocr_layout(OCR, temp_file.name)
|
||||
# layouts = OCR.parse({"doc": temp_file.name})["layout"]
|
||||
except TypeError:
|
||||
# 如果是类型错误,大概率是没识别到文字
|
||||
layouts = []
|
||||
@@ -118,6 +118,10 @@ def get_mask_layout(image, name, id_card_num):
|
||||
keys = []
|
||||
if find_name_by_key:
|
||||
keys += NAME_KEYS
|
||||
if layout[1].startswith("名:"):
|
||||
result += find_boxes("名:", layout, offset=2, length=3)
|
||||
if layout[1].startswith("名:"):
|
||||
result += find_boxes("名:", layout, offset=2, length=3)
|
||||
if find_id_card_num_by_key:
|
||||
keys += ID_CARD_NUM_KEYS
|
||||
for key in keys:
|
||||
@@ -135,8 +139,7 @@ def handle_image_for_mask(split_result):
|
||||
expand_img, offset_x, offset_y = image_util.expand_to_a4_size(split_result["img"], True)
|
||||
split_result["x_offset"] -= offset_x
|
||||
split_result["y_offset"] -= offset_y
|
||||
gray_image = cv2.cvtColor(expand_img, cv2.COLOR_BGR2GRAY)
|
||||
return gray_image, split_result["x_offset"], split_result["y_offset"]
|
||||
return expand_img, split_result["x_offset"], split_result["y_offset"]
|
||||
|
||||
|
||||
def photo_mask(pk_phhd, name, id_card_num):
|
||||
|
||||
Reference in New Issue
Block a user