El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Calling the Passport OCR API

Updated on 2024-09-06 GMT+08:00

Use Postman to call the Passport OCR API.

To call an OCR API, there are four steps:

Step 1: Subscribe to a Service

Step 2: Configure the Environment

Step 3: Use a Token for Authentication

Step 4: Call the Service

Preparations

You have signed up for a HUAWEI ID and enabled Huawei Cloud services. Your account cannot be in arrears or frozen.

Step 1: Subscribe to a Service

  1. Log in to the Huawei Cloud OCR management console.

    The default region is displayed in the upper left corner. Select a region based on service requirements. For details about the region where the OCR service is available, see Regions and Endpoints.

  2. Select and subscribe to your desired API.

    For this example, subscribe to the Passport OCR API.

    NOTE:
    • The OCR service is released on ModelArts. Error codes starting with "ModelArts" may be reported. For details about error codes, see Error Codes.
    • If the ModelArts.4204 error is reported, the service may not be subscribed to or the region where the service is subscribed to is inconsistent with the region where the service is called. Before calling the service, log in to the console and ensure the region is the same.

Step 2: Configure the Environment

Download and install Postman 7.24.0.

Step 3: Use a Token for Authentication

  1. On the Postman page, choose New > Collection, set the name, and click Create.

  2. Right-click the created collection and select Add Request from the shortcut menu. Set the request name and click Save.

  3. Change the request mode to POST and enter the URL.

    For example, if ap-southeast-1 is used, the URL is https://iam.ap-southeast-1.myhuaweicloud.com/v3/auth/tokens.

  4. In the Headers list, set KEY to Content-Type and VALUE to application/json.

  5. Click Body, select raw, and enter the code in the blank area.
    Figure 1 Token-based authentication

    Replace username, ******** (login password), domainname, and project name (region where the service is deployed) with the actual values. To obtain the values of these parameters, log in to the management console and click My Credentials.

    The region where OCR is deployed must be the same as the region where you call the service. In this example, the region is ap-southeast-1.

    {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
                        "name": "username",
                        "password": "**********",
                        "domain": {
                            "name": "domainname"
                        }
                    }
                }
            },
            "scope": {
                "project": {
                    "name": "ap-southeast-1"
                }
            }
        }
    }
  6. Click Send in the upper right corner to send the request. Obtain the token from the returned result. The token is valid for 24 hours.

Step 4: Call the Service

  1. Create a request, set the request mode to POST, and enter the URL as needed.

    For example, if Passport OCR is deployed in the CN-Hong Kong region, the request URL is https://ocr.ap-southeast-1.myhuaweicloud.com/v2/{project_id}/ocr/passport.

    Click Headers and copy the token to X-Auth-Token.

    Log in to the My Credentials page, query the ID of the project in the CN-Hong Kong region, and replace {project_id} in the URI with the queried project ID.

  2. Click Body and add the Base64 code of an image to the request body. For details about the API description, see Passport OCR.
    {     
         "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAA...",
         "country_code": "GENERAL" 
    }
  3. Click Send in the upper right corner to send the request and view the results.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback