深度学习系列59:文字识别

1. 简单文本:

使用google加的tesseract,效果不错。

首先安装tesseract,在mac直接brew install即可。

python调用代码:

复制代码
import pytesseract
from PIL import Image
img = Image.open('1.png')
pytesseract.image_to_string(img, lang='chi_sim+eng')

2. 结构化文本

使用百度家的paddleocr可以达成如下效果:

安装方法:pip install "paddleocr>=2.2",调用代码。

其中画图的部分如果要用的话,需要下载字体库:!git clone https://gh.api.99988866.xyz/https://github.com/PaddlePaddle/PaddleOCR;不需要画图的话,注释掉即可。

复制代码
import os
import cv2
from paddleocr import PPStructure, draw_structure_result, save_structure_res
from PIL import Image


def Structure_analysis(img_path):
    table_engine = PPStructure(show_log=True)
    save_folder = './output/table'
    img = cv2.imread(img_path)
    result = table_engine(img)1
    save_structure_res(result, save_folder,os.path.basename(img_path).split('.')[0])

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

    font_path = '../PaddleOCR/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('result.jpg')
    pass

Structure_analysis('1.png')
相关推荐
Gigavision2 小时前
基于BUAA-MIHR数据集的噪声解耦对比学习算法
人工智能·python·深度学习·算法
红海云2 小时前
Kimi 双端接入 CloudBase 的工程价值
人工智能·语言模型
计算机编程-吉哥3 小时前
YOLO26 vs YOLO11 vs YOLOv8:深度学习咖啡果实成熟度分割系统【计算机毕业设计选题推荐】
人工智能·python·深度学习·yolo·django·毕业设计
冬奇Lab3 小时前
一年前没启动 AI 提效的团队,今年在付什么钱?
人工智能
NeoGressAI外贸数字化4 小时前
IOR新规9月18日生效:Form 5106六项资料自查清单
人工智能
根目录下的猫4 小时前
RK3588适配的轻量级AI模型推荐
人工智能·后端·python·目标检测
weixin_6684 小时前
Cursor 插件使用说明:Linear 与 Figma
人工智能·cursor
wshzd5 小时前
LLM之Agent(六十八)|PI(七)构建测试与开发流程
人工智能
H0311169855 小时前
App竞品数据平台功能梳理:月狐数据、七麦数据、点点数据
人工智能
YOLO数据集集合5 小时前
高铁轨道紧固件损坏检测数据集 | 高铁巡检 紧固件缺陷 轨道安全9093期
人工智能·目标检测·计算机视觉·目标跟踪·轨道·铁轨紧固件·铁轨