57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
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()
|
||
# 手动填充
|
||
# ocr_error = ZxIeOcrerror()
|
||
# ocr_error.pk_phrec = 0
|
||
# ocr_error.cXm = ""
|
||
# ocr_error.cSfzh = ""
|
||
# ocr_error.cfjaddress = ""
|
||
# 手动选择pk
|
||
# session = MysqlSession()
|
||
# ocr_error = (session.query(ZxIeOcrerror.pk_phrec, ZxIeOcrerror.cXm, ZxIeOcrerror.cSfzh, ZxIeOcrerror.cfjaddress)
|
||
# .filter(ZxIeOcrerror.pk_phrec == 0).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()
|