Python调用ocrspace进行文字识别

willsonlincake之家 willsonlincake之家 1113 人阅读 | 0 人回复 | 2022-04-05

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import ocrspace
import requests


api = ocrspace.API()
TEST_IMAGE_URL = 'https://images-na.ssl-images-ama ... JN1URL._SL1244_.jpg

print('Testing URL-based OCR:')
print(api.ocr_url(TEST_IMAGE_URL))

print('Testing file-based OCR:')
# Download image for demo purposes
TEST_FILENAME = '/tmp/test_image.jpg'
with open(TEST_FILENAME, 'wb') as f:
    r = requests.get(TEST_IMAGE_URL)
    r.raw.decode_content = True
    f.write(r.content)

# With file path
print(api.ocr_file(TEST_FILENAME))
# With file pointer
print(api.ocr_file(open(TEST_FILENAME, 'rb')))

https://github.com/ErikBoesen/ocrspace/blob/master/example.py
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐