cc3a4534 by 周伟奇

add img path

1 parent 03d5853c
......@@ -1448,4 +1448,6 @@ SE_SECOND_ID_FIELD_MAPPING = {
HEAD_LIST = ['Info', 'Index', 'License', 'Field', 'Input', 'OCR', 'Result', 'Position', 'Image', 'errorType']
IMG_PATH_KEY = 'uniq_img_path_key'
......
......@@ -221,10 +221,12 @@ class Command(BaseCommand, LoggerMixin):
dda_ocr_result = {key: value.get('words', '') for key, value in license_data.get('result', {}).items()}
dda_ocr_result[consts.DDA_IMG_PATH] = img_path
dda_ocr_result[consts.DDA_PRO] = pro
dda_ocr_result[consts.IMG_PATH_KEY] = img_path
license_summary.setdefault(classify, []).append(dda_ocr_result)
elif classify == consts.MVC_CLASSIFY: # 车辆登记证 3/4页结果整合
for mvc_dict in license_data:
mvc_dict[consts.IMG_PATH_KEY] = img_path
try:
mvc_page = mvc_dict.pop('page')
except Exception as e:
......@@ -242,6 +244,7 @@ class Command(BaseCommand, LoggerMixin):
elif classify == consts.IC_CLASSIFY: # 身份证真伪
for id_card_dict in license_data:
id_card_dict[consts.IMG_PATH_KEY] = img_path
try:
base64_img = id_card_dict.pop('base64_img')
except Exception as e:
......@@ -294,6 +297,8 @@ class Command(BaseCommand, LoggerMixin):
dda_id_bc_mapping.setdefault(consts.IC_FIELD, []).append((ic_name, ic_id, img_path))
license_summary.setdefault(classify, []).extend(license_data)
else:
for res_dict in license_data:
res_dict[consts.IMG_PATH_KEY] = img_path
license_summary.setdefault(classify, []).extend(license_data)
res_list.append((pno, ino, part_idx, consts.RES_SUCCESS))
......@@ -305,6 +310,7 @@ class Command(BaseCommand, LoggerMixin):
# res_dict = {}
# for en_key, chn_key in consts.BC_FIELD:
# res_dict[chn_key] = ocr_res_2.get(en_key, '')
ocr_res_2[consts.IMG_PATH_KEY] = img_path
license_summary.setdefault(classify, []).append(ocr_res_2)
if do_dda and isinstance(ocr_res_2.get(consts.BC_KEY_FIELD), str):
bc_no = ocr_res_2[consts.BC_KEY_FIELD].strip()
......@@ -316,6 +322,7 @@ class Command(BaseCommand, LoggerMixin):
res_dict = {}
for field_dict in result_dict.get('FieldList', []):
res_dict[field_dict.get('chn_key', '')] = field_dict.get('value', '')
res_dict[consts.IMG_PATH_KEY] = img_path
license_summary.setdefault(classify, []).append(res_dict)
else:
res_list.append((pno, ino, part_idx, consts.RES_FAILED_2))
......@@ -922,8 +929,8 @@ class Command(BaseCommand, LoggerMixin):
# self.bs_log.info('[task={0}] [bs_summary={1}]'.format(task_str, merged_bs_summary))
self.online_log.info('{0} [task={1}] [merged_bs_summary={2}] [license_summary={3}] '
'[res_list={4}]'.format(self.log_base, task_str, merged_bs_summary,
license_summary, res_list))
'[res_list={4}]'.format(self.log_base, task_str, merged_bs_summary,
license_summary, res_list))
except Exception as e:
......@@ -1023,7 +1030,7 @@ class Command(BaseCommand, LoggerMixin):
license_list = license_summary.get(classify)
if not license_list:
continue
if classify == consts.IC_CLASSIFY and ic_merge:
if classify == consts.IC_CLASSIFY and ic_merge: # TODO 正反面合并时的img_path处理
license_list[0].update(license_list[1])
license_list.pop(1)
elif classify == consts.RP_CLASSIFY and rp_merge:
......
......@@ -671,12 +671,13 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
result = expiry_date_res
break
img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str
error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value
result_field_list.append((name, value, result, ocr_str, error_type))
result_field_list.append((name, value, result, ocr_str, img_path, error_type))
if not is_find:
for name, value in field_list:
result_field_list.append((name, value, consts.RESULT_N, empty_str, ErrorType.NF.value))
result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value))
return result_field_list
......@@ -696,6 +697,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
first_res = None
for res_idx in range(length-1, -1, -1):
if consts.TRANSFER_DATE in ocr_res_list[res_idx]:
img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '')
for idx, transfer_date in enumerate(ocr_res_list[res_idx].get(consts.TRANSFER_DATE, [])):
try:
transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx]
......@@ -708,7 +710,8 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
core_info = {
consts.TRANSFER_NAME: transfer_name,
consts.TRANSFER_NUM: transfer_num,
consts.TRANSFER_DATE: transfer_date
consts.TRANSFER_DATE: transfer_date,
consts.IMG_PATH_KEY: img_path,
}
page34_date_dict.setdefault(transfer_date, []).append(core_info)
if first_res is None:
......@@ -734,12 +737,13 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
ocr_str = empty_str
else:
result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2])
img_path = ocr_res.get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str
error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value
result_field_list.append((name, value, result, ocr_str, error_type))
result_field_list.append((name, value, result, ocr_str, img_path, error_type))
if not is_find:
for name, value in field_list:
result_field_list.append((name, value, consts.RESULT_N, empty_str, ErrorType.NF.value))
result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value))
return result_field_list
......@@ -762,7 +766,7 @@ def se_compare_process(compare_info, ocr_res_dict):
for license_en, field_list in license_dict.items():
failure_field = []
result_field_list = se_compare_license(license_en, ocr_res_dict, field_list)
for name, value, result, ocr_str, error_type in result_field_list:
for name, value, result, ocr_str, img_path, error_type in result_field_list:
total_fields += 1
if result == consts.RESULT_N:
failed_count += 1
......@@ -778,7 +782,7 @@ def se_compare_process(compare_info, ocr_res_dict):
'OCR': ocr_str,
'Result': result,
'Position': empty_str,
'Image': empty_str,
'Image': img_path,
'errorType': error_type,
}
)
......@@ -790,7 +794,7 @@ def se_compare_process(compare_info, ocr_res_dict):
result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list)
else:
result_field_list = se_compare_license(license_en, ocr_res_dict, field_list)
for name, value, result, ocr_str, error_type in result_field_list:
for name, value, result, ocr_str, img_path, error_type in result_field_list:
total_fields += 1
if result == consts.RESULT_N:
failed_count += 1
......@@ -806,7 +810,7 @@ def se_compare_process(compare_info, ocr_res_dict):
'OCR': ocr_str,
'Result': result,
'Position': empty_str,
'Image': empty_str,
'Image': img_path,
'errorType': error_type,
}
)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!