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