admin 管理员组文章数量: 1103785
# 网上代码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")
本文标签: 路径 例程 PP PaddleOCR Structure
版权声明:本文标题:PaddleOCR中PP-Structure使用例程img_show.save保存路径问题 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.520sys.cn/xp/1755048211a1463274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论