优化接口图片传输方式

This commit is contained in:
2024-09-23 14:45:03 +08:00
parent a2a82df21c
commit c091a82a91
8 changed files with 89 additions and 62 deletions

View File

@@ -23,7 +23,7 @@ from photo_review import PATIENT_NAME, ADMISSION_DATE, DISCHARGE_DATE, MEDICAL_E
ADMISSION_ID, SETTLEMENT_ID, AGE, OCR, SETTLEMENT_IE, DISCHARGE_IE, COST_IE, PHHD_BATCH_SIZE, SLEEP_MINUTES, \
UPPERCASE_MEDICAL_EXPENSES, HOSPITAL_ALIAS, HOSPITAL_FILTER, DEPARTMENT_ALIAS, DEPARTMENT_FILTER
from ucloud import ufile
from util import image_util, common_util, html_util
from util import image_util, common_util, html_util, model_util
from util.data_util import handle_date, handle_decimal, parse_department, handle_name, \
handle_insurance_type, handle_original_data, handle_hospital, handle_department, handle_id, handle_age, parse_money, \
parse_hospital
@@ -148,12 +148,12 @@ def get_better_image_from_qrcode(image, image_id, dpi=150):
def information_extraction(ie, phrecs, identity):
result = {}
for phrec in phrecs:
img_path = ufile.get_private_url(phrec.cfjaddress)
if not img_path:
img_url = ufile.get_private_url(phrec.cfjaddress)
if not img_url:
continue
image = image_util.read(img_path)
img_path = image_util.save_to_local(img_url)
image = cv2.imread(img_path)
# 尝试从二维码中获取高清图片
better_image, text = get_better_image_from_qrcode(image, phrec.cfjaddress)
if phrec.cRectype != '1':
@@ -166,12 +166,11 @@ def information_extraction(ie, phrecs, identity):
info_extract = ie(text)[0]
else:
info_extract = ie_temp_image(ie, OCR, image)
ie_result = {'result': info_extract, 'angle': '0'}
now = common_util.get_default_datetime()
if not ie_result['result']:
if not info_extract:
continue
ie_result = {'result': info_extract, 'angle': img_angle}
now = common_util.get_default_datetime()
result_json = json.dumps(ie_result['result'], ensure_ascii=False)
if len(result_json) > 5000:
result_json = result_json[:5000]
@@ -184,7 +183,7 @@ def information_extraction(ie, phrecs, identity):
result = merge_result(result, ie_result['result'])
else:
target_images = []
# target_images += detector.request_book_areas(image) # 识别文档区域并裁剪
target_images += model_util.request_book_areas(img_path) # 识别文档区域并裁剪
if not target_images:
target_images.append(image) # 识别失败
angle_count = defaultdict(int, {'0': 0}) # 分割后图片的最优角度统计