|
@@ -87,45 +87,45 @@ def image_process(image_np, image_path, is_from_pdf=False, is_from_docx=False, u
|
|
|
|
|
|
log("into image_preprocess")
|
|
log("into image_preprocess")
|
|
try:
|
|
try:
|
|
- # # 图片倾斜校正,写入原来的图片路径
|
|
|
|
- # # print("image_process", image_path)
|
|
|
|
- # g_r_i = get_rotated_image(image_np, image_path)
|
|
|
|
- # if judge_error_code(g_r_i):
|
|
|
|
- # if is_from_docx:
|
|
|
|
- # return []
|
|
|
|
- # else:
|
|
|
|
- # return g_r_i
|
|
|
|
- # image_np = cv2.imread(image_path)
|
|
|
|
- # if image_np is None:
|
|
|
|
- # return []
|
|
|
|
-
|
|
|
|
- if image_np is None:
|
|
|
|
- return []
|
|
|
|
-
|
|
|
|
- with open(image_path, "rb") as f:
|
|
|
|
- image_bytes = f.read()
|
|
|
|
-
|
|
|
|
- # idc模型实现图片倾斜校正
|
|
|
|
- image_np = from_idc_interface(image_bytes)
|
|
|
|
- if judge_error_code(image_np):
|
|
|
|
|
|
+ # 图片倾斜校正,写入原来的图片路径
|
|
|
|
+ # print("image_process", image_path)
|
|
|
|
+ g_r_i = get_rotated_image(image_np, image_path)
|
|
|
|
+ if judge_error_code(g_r_i):
|
|
if is_from_docx:
|
|
if is_from_docx:
|
|
return []
|
|
return []
|
|
else:
|
|
else:
|
|
- return image_np
|
|
|
|
- idc_path = image_path.split(".")[0] + "_idc." + image_path.split(".")[-1]
|
|
|
|
- cv2.imwrite(idc_path, image_np)
|
|
|
|
- with open(idc_path, "rb") as f:
|
|
|
|
- image_bytes = f.read()
|
|
|
|
|
|
+ return g_r_i
|
|
|
|
+ image_np = cv2.imread(image_path)
|
|
|
|
+ if image_np is None:
|
|
|
|
+ return []
|
|
|
|
|
|
- # isr模型去除印章
|
|
|
|
- image_np = from_isr_interface(image_bytes)
|
|
|
|
- if judge_error_code(image_np):
|
|
|
|
- if is_from_docx:
|
|
|
|
- return []
|
|
|
|
- else:
|
|
|
|
- return image_np
|
|
|
|
- isr_path = image_path.split(".")[0] + "_isr." + image_path.split(".")[-1]
|
|
|
|
- cv2.imwrite(isr_path, image_np)
|
|
|
|
|
|
+ # if image_np is None:
|
|
|
|
+ # return []
|
|
|
|
+ #
|
|
|
|
+ # with open(image_path, "rb") as f:
|
|
|
|
+ # image_bytes = f.read()
|
|
|
|
+ #
|
|
|
|
+ # # idc模型实现图片倾斜校正
|
|
|
|
+ # image_np = from_idc_interface(image_bytes)
|
|
|
|
+ # if judge_error_code(image_np):
|
|
|
|
+ # if is_from_docx:
|
|
|
|
+ # return []
|
|
|
|
+ # else:
|
|
|
|
+ # return image_np
|
|
|
|
+ # idc_path = image_path.split(".")[0] + "_idc." + image_path.split(".")[-1]
|
|
|
|
+ # cv2.imwrite(idc_path, image_np)
|
|
|
|
+ # with open(idc_path, "rb") as f:
|
|
|
|
+ # image_bytes = f.read()
|
|
|
|
+ #
|
|
|
|
+ # # isr模型去除印章
|
|
|
|
+ # image_np = from_isr_interface(image_bytes)
|
|
|
|
+ # if judge_error_code(image_np):
|
|
|
|
+ # if is_from_docx:
|
|
|
|
+ # return []
|
|
|
|
+ # else:
|
|
|
|
+ # return image_np
|
|
|
|
+ # isr_path = image_path.split(".")[0] + "_isr." + image_path.split(".")[-1]
|
|
|
|
+ # cv2.imwrite(isr_path, image_np)
|
|
|
|
|
|
# otr模型识别表格,需要图片resize成模型所需大小, 写入另一个路径
|
|
# otr模型识别表格,需要图片resize成模型所需大小, 写入另一个路径
|
|
best_h, best_w = get_best_predict_size(image_np)
|
|
best_h, best_w = get_best_predict_size(image_np)
|