Paddle ocr基本识别

卸载当前版本

pip uninstall paddlepaddle paddleocr paddlex -y

安装稳定版本

pip install paddlepaddle==3.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install paddleocr==2.7.3 -i https://pypi.tuna.tsinghua.edu.cn/simple

例子:

python 复制代码
import sys
import os

os.environ['FLAGS_use_onednn'] = '0'
os.environ['PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK'] = 'True'

import paddle
print(f"PaddlePaddle version: {paddle.__version__}")

from paddleocr import PaddleOCR
import cv2
import numpy as np

# 初始化 PaddleOCR (PaddleOCR 3.x API)
ocr = PaddleOCR(
    lang='ch',
    use_textline_orientation=True
)

# 方法1: 识别图片文件
img_path = 'd:/123.png'

try:

    result = ocr.ocr(img_path)

    # 只打印识别的文本
    texts = []
    if result is not None:
        for res in result:
            if res is not None and len(res) > 0:
                for word_info in res:
                    if isinstance(word_info, dict):
                        text = word_info.get('text', '')
                        texts.append(text)
                    elif isinstance(word_info, (list, tuple)) and len(word_info) >= 2:
                        text = word_info[1][0] if isinstance(word_info[1], (list, tuple)) else word_info[1]
                        texts.append(text)
    
    if texts:
        print('\n'.join(texts))
    else:
        print("未识别到任何文本")
        
except Exception as e:
    print(f"错误: {e}")
    import traceback
    traceback.print_exc()
相关推荐
楚识科技4 小时前
手写表格OCR接口接入全指南:实战调用与结构化字段解析
ocr
VidDown7 小时前
从视频画面里提取文字:OCR、文字检测与结构化输出
python·网络协议·ocr·音视频·视频编解码·视频
一马平川的大草原11 小时前
pdf转md的三种方式
pdf·ocr·md
zhoupenghui16813 小时前
复杂PDF与扫描件解析存储实战:文本、图片OCR、表格识别及RAG向量入库全流程
pdf·ocr·复杂pdf解析
楚识科技8 天前
电力电网 OCR 落地实践:轻量级模型 CPU 推理与鲲鹏 + 昇腾信创适配
ocr
巡山小钻风来也9 天前
【保姆级教程】自定义数据集微调PP-OCRv6文本检测模型
python·ocr·paddlepaddle
山顶夕景10 天前
【文档解析】2026年技术发展和趋势
ocr·文档解析·agentic
楚识科技10 天前
云端 API 与私有化 OCR 的架构取舍:数据边界、并发模型与成本测算
ocr
AI人工智能+10 天前
基于深度学习的车辆合格证识别技术,通过图像预处理、文字检测、文字识别到结构化提取、后处理校验,实现车辆合格证信息的结构化提取
深度学习·自然语言处理·ocr·车辆合格证识别
楚识科技12 天前
卡证OCR识别实战:证件识别SDK、端侧设备与私有化部署清单
ocr