Myanmar ID Card OCR
Function
Myanmar ID Card OCR recognizes information on Myanmar-issued national registration cards. For details about the constraints on using this API, see Constraints. For details about how to use this API, see Introduction to OCR.

Prerequisites
Before using Myanmar ID Card OCR, you need to apply for the service and complete authentication. For details, see Subscribing to OCR and Authentication.

Before using the service for the first time, you need to enable the service by clicking Subscribe. 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/myanmar-id-card
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 a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token During API authentication using a token, the token is added to requests to obtain permissions for calling the API. The value of X-Subject-Token in the response header is the obtained token. |
Content-Type |
Yes |
String |
MIME type of the request body. The value is application/json. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
image |
No. Set either this parameter or url. |
String |
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 8,000 pixels. Only images in JPEG, JPG, PNG, BMP, or TIFF format can be recognized. |
url |
No. Set either this parameter or image. |
String |
Image URL. Currently, the following URLs are supported:
NOTE:
|
convert_unicode |
No |
Boolean |
If this parameter is not specified or does not exist, the output will be in the zawgyi format by default. |
return_confidence |
No |
Boolean |
Whether to return the confidence. Value options are as follows: true: The confidence will be returned. false: The confidence will not be returned. If this parameter is not specified, the system does not return the confidence by default. If a non-Boolean value is entered, an error message will be displayed, indicating that the parameter is invalid. |
return_portrait_image |
No |
Boolean |
Whether to return the portrait. Value options are as follows:
If this parameter is not specified, false is used by default. In this case, the Base64 code of the portrait on the ID card will not be returned. |
return_portrait_location |
No |
Boolean |
Whether to return the location of the portrait on the ID card. Value options are as follows:
|
return_idcard_type |
No |
Boolean |
Whether to return the ID card type. Value options are as follows:
|
Response Parameters
Response parameters and status codes vary in different recognition results. They are described as below.
Status code: 200
Parameter |
Type |
Description |
---|---|---|
result |
Object |
Calling result of a successful API call This parameter is not included when the API fails to be called. |
Parameter |
Type |
Description |
---|---|---|
side |
String |
Front or back of a national registration card. Value options are front and back. |
class |
String |
|
nrc_id |
String |
ID number |
issue_date |
String |
Date of issue |
name |
String |
Name |
father_name |
String |
Father's name |
birth |
String |
Date of birth |
bloodlines_religion |
String |
Ethnic group or religion |
height |
String |
Height |
blood_group |
String |
Blood type |
card_id |
String |
National registration card number on the back |
nrc_id_back |
String |
National registration card ID on the back |
profession |
String |
Occupation |
address |
String |
Address |
confidence |
Object |
Confidence information of a related field. The value ranges from 0 to 1. A higher confidence indicates a higher reliability of the corresponding field identified this time. In the statistical sense, a higher confidence indicates a higher accuracy. The confidence is calculated using algorithms and is not equal to the accuracy. |
portrait_image |
String |
Base64 code of the portrait This parameter is available only when return_portrait_image is set to true. |
portrait_location |
Array of objects |
Location of the portrait on the original image This parameter is available only when return_portrait_location is set to true. The image is displayed in a list. The list contains the two-dimensional coordinates (x,y) of the four vertices in the portrait area. The origin of the coordinates is the upper left corner of the image. The x axis is horizontal, and the y axis is vertical. |
idcard_type |
String |
ID card type. Value options are as follows:
This parameter is available only when return_idcard_type is set to true. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code of a failed API call. For details, see Error Codes. If error code ModelArts.4204 is displayed, refer to Why Is a Message Stating "ModelArts.4204" Displayed When the OCR API Is Called? This parameter is not included when the API is successfully called. |
error_msg |
String |
Error message returned when the API fails to be called This parameter is not included when the API is successfully called. |
Request Example

- The endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.
For example, Myanmar ID Card OCR is deployed in the CN-Hong Kong region. The endpoint is ocr.ap-southeast-1.myhuaweicloud.com. The request URL is https://ocr.ap-southeast-1.myhuaweicloud.com/v2/{project_id}/ocr/myanmar-id-card. project_id is the project ID. For details about how to obtain the project ID, see Obtaining a Project ID.
- For details about how to obtain a token, see Making an API Request.
- Request example (Method 1: Use the image Base64 string.)
POST https://{endpoint}/v2/{project_id}/ocr/myanmar-id-card Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAd...", "convert_unicode": true, "return_confidence": true, "return_portrait_image": true, "return_portrait_location": true, "return_idcard_type": true }
- Request example (Method 2: Use the image URL.)
POST https://{endpoint}/v2/{project_id}/ocr/myanmar-id-card Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "url":"https://BucketName.obs.xxxx.com/ObjectName", "convert_unicode": true, "return_confidence": true, "return_portrait_image": true, "return_portrait_location": true, "return_idcard_type": true }
- Sample code for a Python 3 request (For codes in other languages, refer to the following sample or use OCR SDK.)
# encoding:utf-8 import requests import base64 url = "https://{endpoint}/v2/{project_id}/ocr/myanmar-id-card" token = "Actual token value obtained by the user" headers = {'Content-Type': 'application/json', 'X-Auth-Token': token} imagepath = r'./data/myanmar-id-card-demo.png' with open(imagepath, "rb") as bin_data: image_data = bin_data.read() image_base64 = base64.b64encode(image_data).decode("utf-8") # Base64 encoding of images. payload = {"image": image_base64} # url or image. response = requests.post(url, headers=headers, json=payload) print(response.text)
Example Response
Status code: 200
Successful response example (the front)
{ "result":{ "side": "front", "nrc_id": "XXXXXXXX", "issue_date": "၂၀.၉.၂၀၁၁", "name": "XXXX", "father_name": "XXX", "birth": "၁၄.၁၀.၁၉၉၁", "bloodlines_religion": "ဗမာ၊ဗုဒ္ဓ", "height": "၅'၅\"", "blood_group": "ဘီ", "class": "new_version", "confidence": { "nrc_id": 0.7514, "issue_date": 0.5385, "name": 0.6641, "birth": 0.5216, "bloodlines_religion": 0.9774, "height": 0.7526, "blood_group": 0.7541 }, "idcard_type": "normal", "portrait_image": "/9j/4AAQSkZJRgABAgEASABIABRHFGD...", "portrait_location": [ [106, 178], [369, 181], [366, 448], [108, 445] ] } }
Successful response example (the back)
{ "result":{ "side": "back", "card_id": "XXXXXXX", "nrc_id_back": "", "profession": "ကျောင်းသား", "address": "XXXXXXXX", "class": "new_version", "confidence": { "card_id": 0.9878, "nrc_id_back": 0.9595, "profession": 0.9995, "address": 0.9299 }, "idcard_type": "normal" } }
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.
