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

Passport

Updated on 2022-10-29 GMT+08:00

Function

This API identifies and extracts text from the first page of images of passports and converts the text into a structured JSON format.

Prerequisites

Before using this API, you need to apply for the service and complete authentication. For details, see Subscribing to an OCR Service and Authentication.

NOTE:

Before using the service for the first time, you need to enable the service by clicking . You only need to subscribe to the service once. If the service is not enabled, an error message with error code "ModelArts.4204" will be displayed when you call the service. Before calling the service, log in to the OCR console and enable the service. Ensure that the region where the service is enabled is the same as that where the service is called.

URI

POST https://{endpoint}/v2/{project_id}/ocr/passport

Table 1 Path parameters

Parameter

Mandatory

Description

endpoint

Yes

Domain name or IP address of the server bearing the REST service endpoint. The endpoint varies depending on services in different regions. For more details, see Endpoints.

project_id

Yes

Project ID, which can be obtained from Obtaining an Account ID and Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token

Used to obtain the permission to operate APIs. The token is the value of X-Subject-Token in the response header in Authentication.

Content-Type

Yes

String

MIME type of the request body. The value is application/json.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

image

No

String

Configure either this parameter or url.

Base64-encoded image file. The image file has a size limit of 10 MB.

No side of the image can be smaller than 15 or larger than 4,096 pixels. Only images in JPEG, JPG, PNG, BMP, or TIFF format can be recognized.

An example is /9j/4AAQSkZJRgABAg.... If the image data contains an unnecessary prefix, the error "The image format is not supported" is reported.

url

No

String

Configure either this parameter or image. Image URL. Currently, the following URLs are supported:

  • URL of an image.
NOTE:
  • The API response time depends on the image download time. If the image download takes a long time, the API call will fail.
  • Ensure that the storage service where the images to be detected reside is stable and reliable. OBS is recommended for storing image data.

Response Parameters

NOTE:

The status code may vary depending on the recognition results. For example, 200 indicates that the API is successfully called, and 400 indicates that the API fails to be called. The following describes the status codes and corresponding response parameters.

Status code: 200

Table 4 Response body parameter

Parameter

Type

Description

result

PassportResult object

Calling result

This parameter is not returned when the API fails to be called.

This parameter consists of the following three parts: 13 key fields, expressed in English; extra_info, expressed in local official language; and confidence of key fields. A higher confidence indicates a more accurate result.

Table 5 PassportResult

Parameter

Type

Description

country_code

String

Country code

passport_number

String

Passport ID

surname

String

Last name

given_name

String

Given game

sex

String

Gender

date_of_birth

String

Date of birth, for example, 1990-12-12

date_of_expiry

String

Passport date of expiry, for example, 2020-07-08

confidence

Object

Confidence of a field. The value ranges from 0 to 1.

A higher confidence indicates a higher accuracy of the field identified.

The confidence is calculated using algorithms and is not equal to the accuracy.

extra_info

Object

By default, this parameter is left blank.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code of a failed API call. For details, see Error Codes.

This parameter is not returned when the API is successfully called.

error_msg

String

Error message when the API call fails

This parameter is not returned when the API is successfully called.

Request Example

  • Request example (Method 1: Use the image Base64 string.)
    POST https://ocr.ae-ad-1.g42cloud.com/v2/{project_id}/ocr/passport
    Request Header:
    Content-Type: application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
    Request Body:
    {
        "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAA...",
    }
  • Request example (Method 2: Use the image URL.)
    POST https://ocr.ae-ad-1.g42cloud.com/v2/{project_id}/ocr/passport
    Request Header:
    Content-Type: application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
    Request Body:
    {
        "url":"https://BucketName.obs.xxxx.com/ObjectName",
    }

Example Response

Status code: 200

{
    "result": {
        "country_code": "ETF", 
        "surname": "HUZHAO", 
        "given_name": "ZHAOMIN DESALEGN ", 
        "passport_number": "EP435XXXX", 
        "date_of_birth": "1985-09-18", 
        "sex": "M", 
        "date_of_expiry": "2022-01-15", 
        "machine_code": "P<ETFHUZHAO<< ZHAOMIN <DESALEGN<<<<<<<<<<<<<<<", 
        "machine_code2": "EP435XXXX7ETF8509185M2201155<<<<<<<<<<<<<<08", 
        "extra_info": {},
        "confidence": {
            "country_code": 0.9727, 
            "surname": 0.9727, 
            "given_name": 0.9727, 
            "passport_number": 0.9558, 
            "date_of_birth": 0.9558, 
            "sex": 0.9558, 
            "date_of_expiry": 0.9558
        }
    }
}

Status code: 400

Failure response example

{
    "error_code": "AIS.0103", 
    "error_msg": "The image size does not meet the requirements." 
}

Status Codes

Status Code

Description

200

Success response

400

Failure response

For details about status codes, see Status Codes.

Error Codes

For details about error codes, see Error Codes.

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