Skip to main content

pdocr-rpc

基于 PaddleOCR 封装的 RPC 服务,包含客户端和服务端。

客户端提供了一个简单易用的函数 ocr,通过不同的参数控制返回不同的值。

为什么要分成服务端和客户端?

因为 PaddleOCR 安装太重了,如果你的使用场景是需要经常安装,那绝对是一个痛苦的事情,你要是知道它每次安装要装多少东西你肯定会忍不住摇头;

而在服务端一次性安装部署之后,客户端就可以零成本的使用,非常的方便。


Documentation: https://linuxdeepin.github.io/pdocr-rpc

Source Code: https://github.com/linuxdeepin/pdocr-rpc


1、服务端

服务端安装

pip install pdocr-rpc[server]

服务端启动服务

随意新建一个py文件,名称你可以自定义,比如:ocr_server.py

写入以下内容:

# ocr_server.py
from pdocr_rpc.server import server

server()

默认端口号为 8890 如果你想修改端口:

from pdocr_rpc.server import server
from pdocr_rpc.conf import setting

setting.PORT = 8888
server()

2、客户端

客户端安装

pip install pdocr-rpc

客户端使用

2.1、识别当前屏幕的所有文字内容

from pdocr_rpc import OCR
from pdocr_rpc.conf import setting

# 注意IP和端口要和你的服务端IP对应
setting.SERVER_IP = "192.168.0.1"
setting.PORT = 8888

OCR.ocr()

自动识别当前整个屏幕的所有内容。

2.2、指定某张图片识别的所有文字内容

OCR.ocr(picture_abspath="~/Desktop/test.png")

返回识别图片 test.png 的内容。

2.3、在全屏指定查找某个字符串的坐标

OCR.ocr("天天向上")

返回当前屏幕中,“天天向上”的坐标,如果存在多个,则返回一个字典。

2.4、指定某张图片查找某个字符串的坐标

OCR.ocr("天天向上"picture_abspath="~/Desktop/test.png")

2.5、其他参数

  • 识别语言

    lang: ch, en, fr, german, korean, japan

    默认为ch,中文,如果要修改识别语言;

    OCR.ocr(lang="ch") 
    
  • 匹配度

    similarity: float

    默认为0.6,可以修改为从0到1的数;

    OCR.ocr(similarity=0.1)
    
  • 返回原始数据

    return_default: bool

    默认为False,即默认返回识别到字符串的中心坐标,True表示返回原始数据;

    OCR.ocr(return_default=False)
    
  • 只返回第一个

    return_first: bool

    当传入要查找的字符串时,可能存在当前屏幕中有多个目标;

    默认情况下是会将识别到的多个目标组装成字典返回;

    return_first=True 表示返回识别到的第一个。

    OCR.ocr(return_first=True )
    

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdocr_rpc-2024.5.28.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdocr_rpc-2024.5.28-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file pdocr_rpc-2024.5.28.tar.gz.

File metadata

  • Download URL: pdocr_rpc-2024.5.28.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for pdocr_rpc-2024.5.28.tar.gz
Algorithm Hash digest
SHA256 164bcbdc2ec3de5d57ad870a251699d9ad3bc01838dc98053ba461fc9a795376
MD5 5ef847819117562f2222e198aa62d205
BLAKE2b-256 8e5e6b67c05a417eaef18cf443e7662a0ec8b50d503d67748fee606e4e2e5552

See more details on using hashes here.

File details

Details for the file pdocr_rpc-2024.5.28-py3-none-any.whl.

File metadata

  • Download URL: pdocr_rpc-2024.5.28-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for pdocr_rpc-2024.5.28-py3-none-any.whl
Algorithm Hash digest
SHA256 98d5fd8126b51eda942b531370ee33a4c917076b8408ed99d857b7f978996a0d
MD5 fd408aaf53066d98b65c67b3eadb0904
BLAKE2b-256 9afcb89162032b0032b4d94889685f0dd6df844adcd01d9a023f4c4ba84b1e3b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2024.5.28 This release

2 files

2024.5.24

2 files

2024.5.15

2 files

2024.5.14

2 files

2023.12.28

2 files

2023.11.17

2 files

2023.10.17

2 files

2023.10.10

2 files

2023.8.23

2 files

2023.8.22

2 files

2023.6.29

2 files

2023.6.14

2 files

2.0.1

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page