Detect words in the picture using the baidu's api rather than tesseract

本文介绍了一种使用Baidu OCR API进行图片文字识别的方法,对比了Tesseract的不足,详细展示了如何注册获取API密钥、安装必要的库以及使用Python代码实现文字检测的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Sometimes tesseract does not work well on detecting the words in the picture,especially the colorful words or blurry ones. So I try to find a new way to realize it and there has an baidu’s API which works well.

The official document is here:word detection document

After you sign in the website, you can get three values about the api that will be used in later’s register progress:

APP_ID = '10xxxx57'
API_KEY = 'vxxxxxxxxxxxxxxxxxsZyuwz9yKS2EghBs'
SECRET_KEY = 'm7pjnSNCKZxxxxxxxxxxxxxxxswGmIO35zsi'

then install the Lib:

pip install aip

and you can use the api to detect the words,for example:

from aip import AipOcr
APP_ID = '10xxxx57'
API_KEY = 'vxxxxxxxxxxxxxxxxxsZyuwz9yKS2EghBs'
SECRET_KEY = 'm7pjnSNCKZxxxxxxxxxxxxxxxswGmIO35zsi'
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
with open('/Users/zhaoluyang/Desktop/test2.png','rb') as f:
    img = f.read()
    msg = client.basicGeneral(img)
    for i in msg.get('words_result'):
        print(i.get('words'))

It works better than tesseract at my test

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值