PaddleOCR中PP-Structure使用例程img_show.save保存路径问题

# 网上代码im_show.save(MapPath("./myImage")+"\\a.gif", ImageFormat.Gif)
im_show.save(os.path.join(save_folder, os.path.basename(img_path).split('.')[0])+"\\result.jpg")
import os
import cv2
from paddleocr import PPStructure, draw_structure_result, save_structure_res

# 自己添加**********************************
import numpy as np

# import warnings
# warnings.filterwarnings("ignore")

# 自己添加************************************

table_engine = PPStructure(det_algorithm='DB', show_log=False, use_gpu=False, use_angle_cls=False)

save_folder = 'F:\\PaddleOCR-release-2.2\\output\\table'
img_path = 'F:\\PaddleOCR-release-2.2\\doc\\table\\1.png'
img = cv2.imread(img_path)

# 自己添加**********************************
# 放大2倍
img = cv2.resize(img, None, fx=1, fy=1, interpolation=cv2.INTER_CUBIC)
# 图像锐化
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]], np.float32)
img = cv2.filter2D(img, -1, kernel=kernel)
# 转回为灰度图片
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 自己添加************************************


result = table_engine(img)
save_structure_res(result, save_folder, os.path.basename(img_path).split('.')[0])

for line in result:
    line.pop('img')
    print(line)

from PIL import Image
font_path = 'F:\\PaddleOCR-release-2.2\\doc\\fonts\\simfang.ttf'  # PaddleOCR下提供字体包
image = Image.open(img_path).convert('RGB')
im_show = draw_structure_result(image, result, font_path=font_path)
im_show = Image.fromarray(im_show)

# 网上代码im_show.save(MapPath("./myImage")+"\\a.gif", ImageFormat.Gif)
im_show.save(os.path.join(save_folder, os.path.basename(img_path).split('.')[0])+"\\result.jpg")


你可能感兴趣的:(深度学习,OCR,python,ocr,深度学习)