深度学习系列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')
相关推荐
软件聚导航7 分钟前
马年、我用AI写了个“打工了马” 小程序
人工智能·ui·微信小程序
陈天伟教授1 小时前
人工智能应用-机器听觉:7. 统计合成法
人工智能·语音识别
笨蛋不要掉眼泪1 小时前
Spring Boot集成LangChain4j:与大模型对话的极速入门
java·人工智能·后端·spring·langchain
昨夜见军贴06161 小时前
IACheck AI审核技术赋能消费认证:为智能宠物喂食器TELEC报告构筑智能合规防线
人工智能·宠物
DisonTangor2 小时前
阿里开源语音识别模型——Qwen3-ASR
人工智能·开源·语音识别
万事ONES2 小时前
ONES 签约北京高级别自动驾驶示范区专设国有运营平台——北京车网
人工智能·机器学习·自动驾驶
qyr67892 小时前
深度解析:3D细胞培养透明化试剂供应链与主要制造商分布
大数据·人工智能·3d·市场分析·市场报告·3d细胞培养·细胞培养
软件开发技术深度爱好者2 小时前
浅谈人工智能(AI)对个人发展的影响
人工智能
一路向北he2 小时前
esp32 arduino环境的搭建
人工智能
SmartBrain2 小时前
Qwen3-VL 模型架构及原理详解
人工智能·语言模型·架构·aigc