Files
fcb_photo_review/photo_mask_error_check.py
2024-07-23 16:59:36 +08:00

45 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import cv2
from sqlalchemy import update
import util.util
from db import MysqlSession
from db.mysql import ZxIeOcrerror
from photo_mask.photo_mask import mask_photo
from ucloud import ufile
from util import image_util
def check_error(error_ocr):
img_url = ufile.get_private_url(error_ocr.cfjaddress, "drg2015")
if not img_url:
# 没有自动涂抹的图片
img_url = ufile.get_private_url(error_ocr.cfjaddress, "drg103")
name = error_ocr.cXm
id_card_num = error_ocr.cSfzh
return mask_photo(img_url, name, id_card_num, (0, 0, 0))[1]
if __name__ == '__main__':
session = MysqlSession()
ocr_error = (session.query(ZxIeOcrerror.pk_phrec, ZxIeOcrerror.cXm, ZxIeOcrerror.cSfzh, ZxIeOcrerror.cfjaddress)
.filter(ZxIeOcrerror.checktime.is_(None)).order_by(ZxIeOcrerror.pk_phrec.desc()).limit(1).one())
session.close()
final_img_url = ufile.get_private_url(ocr_error.cfjaddress, "drg100")
final_image = image_util.read(final_img_url)
cv2.imwrite(f"./mask_error_check/{ocr_error.cfjaddress}_final.jpg", final_image)
image = check_error(ocr_error)
cv2.imwrite(f"./mask_error_check/{ocr_error.cfjaddress}.jpg", image)
check_finish = input("是否完成(是/否)")
if check_finish == "":
remarks = input("备注:")
session = MysqlSession()
update_flag = (update(ZxIeOcrerror).where(ZxIeOcrerror.pk_phrec == ocr_error.pk_phrec).values(
checktime=util.util.get_default_datetime(), cfjaddress2=remarks))
session.execute(update_flag)
session.commit()
session.close()