Updated on 2023-10-26 GMT+08:00

Preparing Data

Data Requirements

Multiple factors such as technology and cost impose the following constraints on your use of OCR services.

Take Passport OCR API as an example. For details about constraints on calling other OCR APIs, see Constraints.

  • Passports issued by different countries can be recognized by detecting and extracting the machine-readable code at the bottom of the first page.
  • Only images in PNG, JPG, JPEG, BMP, or TIFF format can be recognized.
  • No side of the image can be smaller than 15 or larger than 4,096 pixels.
  • The information page of the passport to be recognized must occupy more than 25% of the image. When scanning a passport, ensure that the entire page is displayed in the image.
  • A passport can be rotated to any angle.
  • The passport in the image can be moderately distorted, but the aspect ratio cannot be distorted by more than 10%.
  • Illuminated or dark images can be recognized, but the accuracy may be compromised.

Data Import Methods

When OCR APIs or SDKs are used, data is imported in either of the following methods:

  • image

    Import the Base64 code of an image.

    You can use an online transcoding tool or the base64.b64encode function in Python to obtain the Base64 code of an image.

  • url
    Import the URL of an image.
    • Use an HTTP/HTTPS URL, for example, https://support.huaweicloud.com/intl/en-us/api-ocr/en-us_image_0000001425779334.png.
    • Upload the image to Huawei Cloud OBS and use the URL provided by OBS. To use OBS data, authorize OCR to access OBS, including service authorization, temporary authorization, and anonymous public authorization. For details, see Configuring the Access Permission of OBS.