59da79a4 by 周伟奇

slice part 1

1 parent 85d82a3e
......@@ -1542,6 +1542,9 @@ BC_FIELD_ORDER_2 = (('BankName', '发卡行名称'),
IMG_PATH_KEY = 'uniq_img_path_key'
IMG_PATH_KEY_2 = 'uniq_img_path_key_2'
POSITION_KEY = 'uniq_position_key'
SECTION_KEY = 'uniq_section_key'
ANGLE_KEY = 'uniq_angle_key'
INFO_SOURCE = ['POS', 'CMS']
......
......@@ -373,7 +373,7 @@ class Command(BaseCommand, LoggerMixin):
license_summary.setdefault(classify, []).extend(license_data)
res_list.append((pno, ino, part_idx, consts.RES_SUCCESS))
def license2_process(self, ocr_res_2, license_summary, pid, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping):
def license2_process(self, ocr_res_2, license_summary, pid, classify, res_list, pno, ino, part_idx, img_path, do_dda, dda_id_bc_mapping, section_img_path=None):
if ocr_res_2.get('ErrorCode') in consts.SUCCESS_CODE_SET:
res_list.append((pno, ino, part_idx, consts.RES_SUCCESS))
if pid == consts.BC_PID:
......@@ -390,10 +390,17 @@ class Command(BaseCommand, LoggerMixin):
else:
# 营业执照等
for result_dict in ocr_res_2.get('ResultList', []):
position = result_dict.get('position', {})
angle = result_dict.get('angle', 0)
res_dict = {}
position_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
position_dict[field_dict.get('chn_key', '')] = field_dict.get('position', [])
position_dict[consts.SECTION_KEY] = position
position_dict[consts.ANGLE_KEY] = angle
res_dict[consts.IMG_PATH_KEY] = section_img_path if isinstance(section_img_path, str) else img_path
res_dict[consts.POSITION_KEY] = position_dict
license_summary.setdefault(classify, []).append(res_dict)
else:
res_list.append((pno, ino, part_idx, consts.RES_FAILED_2))
......@@ -972,9 +979,23 @@ class Command(BaseCommand, LoggerMixin):
card_name_res.get('data', {}).get('is_exists_name') == 0:
name = '无'
ocr_2_res['Name'] = name
section_img_path = None
try:
if ocr_2_res.get('ErrorCode') in consts.SUCCESS_CODE_SET:
pre, suf = os.path.splitext(img_path)
section_img_path = '{0}_{1}{2}'.format(pre, part_idx, suf)
with open(section_img_path, "wb") as fh:
fh.write(base64.b64decode(file_data.encode()))
except Exception as e:
self.online_log.warn(
'{0} [section img save failed] [img_path={1}]'
' [part_idx={2}]'.format(self.log_base, img_path, part_idx))
self.license2_process(ocr_2_res, license_summary, pid, classify,
res_list, pno, ino, part_idx, img_path,
do_dda, dda_id_bc_mapping)
do_dda, dda_id_bc_mapping,
section_img_path=section_img_path)
break
else:
res_list.append((pno, ino, part_idx, consts.RES_FAILED_2))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!