如何用Python3结合腾讯云OCR技术从图片中提取文字内容?
- 内容介绍
- 文章标签
- 相关推荐
本文共计525个文字,预计阅读时间需要3分钟。
百度OCR体验地址:[https://ai.baidu.com/tech/imagerecognition/general](https://ai.baidu.com/tech/imagerecognition/general)腾讯OCR体验地址:[https://cloud.tencent.com/act/event/ocrdemo](https://cloud.tencent.com/act/event/ocrdemo)测试结果是:腾讯的效果要好一些,云服务的前瞻度是:每个接口1元。
百度OCR体验地址:
ai.baidu.com/tech/imagerecognition/general
腾讯OCR体验地址:
cloud.tencent.com/act/event/ocrdemo
测试结果是:腾讯的效果要比百度的好
腾讯云目前额度是:
每个接口 1,000次/月免费,有6个文字识别的接口,一共是6,000次/月
百度接口调用之前写过文章
python实现百度OCR图片识别过程解析
使用步骤
1、注册账号: cloud.tencent.com/
2、开通服务:console.cloud.tencent.com/ocr/general
3、申请访问秘钥:console.cloud.tencent.com/cam/capi
4、通过 API 或 SDK 或命令行来使用服务
具体参考《操作指南》:cloud.tencent.com/document/product/866/17622
接口使用
1、安装SDK
github.com/TencentCloud/tencentcloud-sdk-python
pip3 install tencentcloud-sdk-python
2、代码实例
# -*- coding: utf-8 -*- import json from tencentcloud.common import credential from tencentcloud.common.profile.client_profile import ClientProfile from tencentcloud.common.profile.cloud.tencent.com/document/product/866/17619 """ SECRET_ID = "你的秘钥 SECRET_ID" SECRET_KEY = "你的秘钥 SECRET_KEY" # 地域列表 # cloud.tencent.com/document/api/866/33518#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 Region = "ap-beijing" endpoint = "ocr.tencentcloudapi.com" # 通用文字识别相关接口 # cloud.tencent.com/document/api/866/37173 mapping = { # 通用印刷体识别(高精度版) ok "GeneralAccurateOCR": GeneralAccurateOCRRequest, # 英文识别 ok "EnglishOCR": EnglishOCRRequest, # 通用印刷体识别 一般 "GeneralBasicOCR": GeneralBasicOCRRequest, # 通用印刷体识别(精简版)(免费公测版)no "GeneralEfficientOCR": GeneralEfficientOCRRequest, # 通用印刷体识别(高速版)一般 "GeneralFastOCR": GeneralFastOCRRequest, # 通用手写体识别 ok "GeneralHandwritingOCR": GeneralHandwritingOCRRequest, } def __init__(self): cred = credential.Credential(self.SECRET_ID, self.SECRET_KEY) img.558idc.com/uploadfile/allimg/python/GeneralBasicOCR3.jpg" print(tencentOcr.get_image_text(url, ocr="GeneralHandwritingOCR")) if __name__ == '__main__': main()
更多关于Python3使用腾讯云文字识别(腾讯OCR)提取图片中的文字内容实例请查看下面的相关链接
本文共计525个文字,预计阅读时间需要3分钟。
百度OCR体验地址:[https://ai.baidu.com/tech/imagerecognition/general](https://ai.baidu.com/tech/imagerecognition/general)腾讯OCR体验地址:[https://cloud.tencent.com/act/event/ocrdemo](https://cloud.tencent.com/act/event/ocrdemo)测试结果是:腾讯的效果要好一些,云服务的前瞻度是:每个接口1元。
百度OCR体验地址:
ai.baidu.com/tech/imagerecognition/general
腾讯OCR体验地址:
cloud.tencent.com/act/event/ocrdemo
测试结果是:腾讯的效果要比百度的好
腾讯云目前额度是:
每个接口 1,000次/月免费,有6个文字识别的接口,一共是6,000次/月
百度接口调用之前写过文章
python实现百度OCR图片识别过程解析
使用步骤
1、注册账号: cloud.tencent.com/
2、开通服务:console.cloud.tencent.com/ocr/general
3、申请访问秘钥:console.cloud.tencent.com/cam/capi
4、通过 API 或 SDK 或命令行来使用服务
具体参考《操作指南》:cloud.tencent.com/document/product/866/17622
接口使用
1、安装SDK
github.com/TencentCloud/tencentcloud-sdk-python
pip3 install tencentcloud-sdk-python
2、代码实例
# -*- coding: utf-8 -*- import json from tencentcloud.common import credential from tencentcloud.common.profile.client_profile import ClientProfile from tencentcloud.common.profile.cloud.tencent.com/document/product/866/17619 """ SECRET_ID = "你的秘钥 SECRET_ID" SECRET_KEY = "你的秘钥 SECRET_KEY" # 地域列表 # cloud.tencent.com/document/api/866/33518#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 Region = "ap-beijing" endpoint = "ocr.tencentcloudapi.com" # 通用文字识别相关接口 # cloud.tencent.com/document/api/866/37173 mapping = { # 通用印刷体识别(高精度版) ok "GeneralAccurateOCR": GeneralAccurateOCRRequest, # 英文识别 ok "EnglishOCR": EnglishOCRRequest, # 通用印刷体识别 一般 "GeneralBasicOCR": GeneralBasicOCRRequest, # 通用印刷体识别(精简版)(免费公测版)no "GeneralEfficientOCR": GeneralEfficientOCRRequest, # 通用印刷体识别(高速版)一般 "GeneralFastOCR": GeneralFastOCRRequest, # 通用手写体识别 ok "GeneralHandwritingOCR": GeneralHandwritingOCRRequest, } def __init__(self): cred = credential.Credential(self.SECRET_ID, self.SECRET_KEY) img.558idc.com/uploadfile/allimg/python/GeneralBasicOCR3.jpg" print(tencentOcr.get_image_text(url, ocr="GeneralHandwritingOCR")) if __name__ == '__main__': main()
更多关于Python3使用腾讯云文字识别(腾讯OCR)提取图片中的文字内容实例请查看下面的相关链接

