优化错误涂抹分析
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
from datetime import date
|
||||
|
||||
import cv2
|
||||
from sqlalchemy import update, and_
|
||||
from sqlalchemy import update, and_, select, exists
|
||||
|
||||
from db import MysqlSession
|
||||
from db.mysql import ZxIeOcrerror
|
||||
from db.mysql import ZxIeOcrerror, ZxPhrec
|
||||
from photo_mask.photo_mask import mask_photo
|
||||
from ucloud import ufile
|
||||
from util import image_util, util
|
||||
@@ -16,7 +16,7 @@ def check_error(error_ocr):
|
||||
# 没有自动涂抹的图片
|
||||
img_url = ufile.get_private_url(error_ocr.cfjaddress, "drg103")
|
||||
if not img_url:
|
||||
return None
|
||||
raise Exception("云空间已删除")
|
||||
name = error_ocr.cXm
|
||||
id_card_num = error_ocr.cSfzh
|
||||
|
||||
@@ -26,10 +26,28 @@ def check_error(error_ocr):
|
||||
return image_util.combined(final_image, image)
|
||||
|
||||
|
||||
def auto_check_error(error_ocr):
|
||||
if error_ocr.cfjaddress2:
|
||||
return error_ocr.cfjaddress2
|
||||
|
||||
if error_ocr.cfjaddress[17] == '1':
|
||||
return "图片类型错误"
|
||||
|
||||
session = MysqlSession()
|
||||
query = select(exists().where(ZxPhrec.cfjaddress == error_ocr.cfjaddress))
|
||||
record_exists = session.execute(query).scalar()
|
||||
session.close()
|
||||
if not record_exists:
|
||||
return "未同步"
|
||||
|
||||
return "未知错误"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 默认
|
||||
session = MysqlSession()
|
||||
ocr_error = (session.query(ZxIeOcrerror.pk_phrec, ZxIeOcrerror.cXm, ZxIeOcrerror.cSfzh, ZxIeOcrerror.cfjaddress)
|
||||
ocr_error = (session.query(ZxIeOcrerror.pk_phrec, ZxIeOcrerror.cXm, ZxIeOcrerror.cSfzh, ZxIeOcrerror.cfjaddress,
|
||||
ZxIeOcrerror.cfjaddress2)
|
||||
.filter(and_(ZxIeOcrerror.checktime.is_(None), ZxIeOcrerror.paint_date >= date.today()))
|
||||
.limit(1).one())
|
||||
session.close()
|
||||
@@ -45,15 +63,22 @@ if __name__ == '__main__':
|
||||
# .filter(ZxIeOcrerror.pk_phrec == 0).one())
|
||||
# session.close()
|
||||
|
||||
img = check_error(ocr_error)
|
||||
cv2.imwrite(f"./mask_error_check/{ocr_error.cfjaddress}.jpg", img)
|
||||
error_descript = auto_check_error(ocr_error)
|
||||
try:
|
||||
img = check_error(ocr_error)
|
||||
cv2.imwrite(f"./mask_error_check/{ocr_error.cfjaddress}.jpg", img)
|
||||
except Exception as e:
|
||||
error_descript = str(e)
|
||||
|
||||
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.get_default_datetime(), cfjaddress2=remarks))
|
||||
session.execute(update_flag)
|
||||
session.commit()
|
||||
session.close()
|
||||
if error_descript == "未知错误":
|
||||
check_finish = input("是否完成(是/否):")
|
||||
if check_finish == "是":
|
||||
error_descript = input("错误描述:")
|
||||
|
||||
session = MysqlSession()
|
||||
update_error = (update(ZxIeOcrerror).where(ZxIeOcrerror.pk_phrec == ocr_error.pk_phrec).values(
|
||||
checktime=util.get_default_datetime(), cfjaddress2=error_descript))
|
||||
session.execute(update_error)
|
||||
session.commit()
|
||||
session.close()
|
||||
print(f"【{ocr_error.pk_phrec}】错误分析已完成。错误描述:{error_descript}")
|
||||
|
||||
Reference in New Issue
Block a user