新增功能,获取案子全部原始图片

This commit is contained in:
2025-11-27 08:44:56 +08:00
parent 670172e79e
commit 97903b2722

View File

@@ -14,7 +14,7 @@ from ucloud import ufile
from util import image_util
def check_ie_result(pk_phhd):
def check_ie_result(pk_phhd, need_to_annotation=True):
os.makedirs(f"./check_result/{pk_phhd}", exist_ok=True)
json_result = {"pk_phhd": pk_phhd}
session = MysqlSession()
@@ -46,10 +46,13 @@ def check_ie_result(pk_phhd):
ZxPhrec.pk_phhd == pk_phhd).all()
for phrec in phrecs:
img_name = phrec.cfjaddress
img_path = ufile.get_private_url(img_name, "drg2015")
if not img_path:
img_path = ufile.get_private_url(img_name)
response = requests.get(img_path)
image = Image.open(BytesIO(response.content)).convert("RGB")
if need_to_annotation:
font_size = image.width * image.height / 200000
font = ImageFont.truetype("./font/simfang.ttf", size=font_size)
@@ -85,6 +88,9 @@ def check_ie_result(pk_phhd):
draw.text((box[0], box[3]), value["text"], fill="blue", font=font) # 在矩形下方绘制文本
os.makedirs(f"./check_result/{pk_phhd}/{ocr_item.id}", exist_ok=True)
image.save(f"./check_result/{pk_phhd}/{ocr_item.id}/{img_name}")
else:
os.makedirs(f"./check_result/{pk_phhd}/0", exist_ok=True)
image.save(f"./check_result/{pk_phhd}/0/{img_name}")
session.close()
# 自定义JSON处理器
@@ -99,4 +105,4 @@ def check_ie_result(pk_phhd):
if __name__ == '__main__':
check_ie_result(0)
check_ie_result(5640504)