Calling an OCR API Locally
Use Passport OCR as an example to describe how you can use the OCR Python SDK.
To use the OCR Python SDK, perform the following steps:
Prerequisites
- You have registered a Huawei ID and enabled Huawei Cloud services. Your account cannot be in arrears, frozen, or deregistered.
- You have subscribed to Passport OCR by referring to Subscribing to an OCR Service.
Procedure
- Download and install the OCR Python SDK.
The following uses PyCharm as an example to describe how to install the SDK.
Create a project in PyCharm and click Terminal in the lower left corner. Run the following commands to install the SDK (the SDK supports Python 3 or later):# Install the huaweicloudsdkcore package. pip install huaweicloudsdkcore # Install the huaweicloudsdkocr package. pip install huaweicloudsdkocr
- Check whether the SDK has been installed properly.
Choose File > Settings > Project > Python Interpreter in PyCharm and check whether the SDK has been installed properly.
- Obtain the SDK sample code of Passport OCR.
- Log in to the API Explorer and click Python on the Sample Code tab page.
- Configure request body parameters. Set image or url as input data.
- Copy the sample code to PyCharm.
- Obtain the AK and SK and replace <YOUR AK> and <YOUR SK> in the sample code with the AK and SK, respectively.
Log in to the Access Keys page and create an access key or use an existing access key. The AK and SK are contained in the credentials.csv file.
- Run the sample code to obtain recognition results.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot