|
@@ -121,6 +121,8 @@ def image_process(image_np, image_path, is_from_pdf=False, is_from_docx=False, u
|
|
# cv2.imwrite(idc_path, image_np)
|
|
# cv2.imwrite(idc_path, image_np)
|
|
|
|
|
|
# isr模型去除印章
|
|
# isr模型去除印章
|
|
|
|
+ image_np_source = image_np
|
|
|
|
+ _isr_time = time.time()
|
|
if count_red_pixel(image_np):
|
|
if count_red_pixel(image_np):
|
|
# 红色像素达到一定值才过模型
|
|
# 红色像素达到一定值才过模型
|
|
with open(image_path, "rb") as f:
|
|
with open(image_path, "rb") as f:
|
|
@@ -134,9 +136,11 @@ def image_process(image_np, image_path, is_from_pdf=False, is_from_docx=False, u
|
|
# [1]代表检测不到印章,直接返回
|
|
# [1]代表检测不到印章,直接返回
|
|
if isinstance(image_np, list) and image_np == [1]:
|
|
if isinstance(image_np, list) and image_np == [1]:
|
|
log("no seals detected!")
|
|
log("no seals detected!")
|
|
|
|
+ image_np = image_np_source
|
|
else:
|
|
else:
|
|
isr_path = image_path.split(".")[0] + "_isr." + image_path.split(".")[-1]
|
|
isr_path = image_path.split(".")[0] + "_isr." + image_path.split(".")[-1]
|
|
cv2.imwrite(isr_path, image_np)
|
|
cv2.imwrite(isr_path, image_np)
|
|
|
|
+ log("isr total time"+str(time.time()-_isr_time))
|
|
|
|
|
|
# otr模型识别表格,需要图片resize成模型所需大小, 写入另一个路径
|
|
# otr模型识别表格,需要图片resize成模型所需大小, 写入另一个路径
|
|
best_h, best_w = get_best_predict_size(image_np)
|
|
best_h, best_w = get_best_predict_size(image_np)
|