Comments (5)
要看具体接口的说明。或者直接提工单给所使用的产品排查一下。
一般而言,无法读取本地数据可能有:1)本地文件已损坏;2)代码读取时有错误,并非二进制数据;3)传值给sdk时有问题,sdk的参数期望的是字符串或base64后的字符串;4)自己添加了不必要的格式头而不是文件原本的数据。网络上的数据下载失败可能有:1)需要特殊的网络权限或者代理等;2)文件太大下载超时;3)格式不对。
腾讯云上的图像数据至少能排除掉网络方面的故障。
from tencentcloud-sdk-python.
是否可以提供一个是使用图像base64编码数据, 通过params传给SDK?
from tencentcloud-sdk-python.
picFilePath = "../images/print_scan_en.png"
f = open(picFilePath, 'rb') # 二进制方式打开图文件
q = base64.b64encode(f.read()).decode('utf-8') # 读取文件内容,转换为base64编码
f.close()
try:
cred = credential.Credential("", "")
httpProfile = HttpProfile()
httpProfile.endpoint = "ocr.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = ocr_client.OcrClient(cred, "ap-guangzhou", clientProfile)
req = models.GeneralHandwritingOCRRequest()
params = '{"ImageBase64": f}'
req.from_json_string(params)
resp = client.GeneralHandwritingOCR(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
其中: params应该是str类型, 但f本身内容就无法知道了, 如果params是dict的话, 解析报错
from tencentcloud-sdk-python.
你填f显然就错了啊,不是应该填q吗?
编码命名习惯可以改善下,不然容易把自己都绕进去还不容易看出毛病
from tencentcloud-sdk-python.
多谢指出! 确实是应该填写为q, (Linux环境) params那行正确的写法是: params = '{"ImageBase64": "%s"}' % q
from tencentcloud-sdk-python.
Related Issues (20)
- [疑问]关于获取预留的环境变量 HOT 2
- python的示例代码,居然配的是c++的文档。 HOT 1
- requests==2.27.1 causes conflicts with other libraries HOT 1
- README中的举例中 类未实例化
- 问题:测试通过配置文件获取ID和key时报错 KeyError: 'HOME'
- 调用查询实例列表api报错 HOT 1
- 为什么release不更新了,版本太老了... HOT 2
- 访问 sms.tencentclound.com 时报错: SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] HOT 1
- tencentcloud.es.v20180416.models.NodeInfo has no attr ```MemSize``` HOT 1
- cvm 何时能支持按实例名模糊搜索? HOT 1
- 通用印刷体识别 TencentCloudSDKException code:ClientNetworkErroressage HOT 1
- Read time out HOT 1
- Remote end closed connection without response
- code:ClientNetworkError message:HTTPSConnectionPool(host='tts.tencentcloudapi.com', port=443): Max retries exceeded with url: / HOT 1
- sdk是否有提供修改http请求信息的切口 HOT 2
- requests>=2.27.0,<=2.28.0一定要这个吗? HOT 3
- 能否支持异步?
- ModuleNotFoundError: No module named 'tencentcloud.common' HOT 1
- 是否有提供 DNSPOD 的自定義線路相關接口? HOT 1
- COS 对象存储服务支持使用该 SDK 调用吗? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tencentcloud-sdk-python.