Birth certificate

1. Extract birth certificate information with image URL input

API:

MethodURL
GEThttps://cloud.computervision.com.vn/api/v2/ocr/birth_certificate

Params:

KeyValueDescription
imghttps://example.com/blx.pngURL of photo
format_typeurlType of data to pass in, receive value: url, file, base64
get_thumbtrue/falseReturns a aligned image

Demo Python:

import requests
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
image_url = 'https://example.com/image.png'
response = requests.get(
"https://cloud.computervision.com.vn/api/v2/ocr/birth_certificate?img=%s&format_type=url&get_thumb=false"
% image_url,
auth=(api_key, api_secret))
print(response.json())

2. Extract birth certificate information with image file input

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/ocr/birth_certificatemultipart/form-data

Params:

KeyValueDescription
format_typefileType of data to pass in, receive value: url, file, base64
get_thumbtrue/falseReturns a aligned image

Body:

KeyTypeValueDescription
imgfileexample.jpgImage file

Demo Python:

import requests
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
image_path = '/path/to/your/image.jpg'
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/ocr/birth_certificate?format_type=file&get_thumb=false",
auth=(api_key, api_secret),
files={'img': open(image_path, 'rb')})
print(response.json())

3. Extract birth certificate information with JSON input

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/ocr/birth_certificateapplication/json

Params:

KeyValueDescription
format_typebase64Type of data to pass in, receive value: url, file, base64
get_thumbtrue/falseReturns a aligned image

Body:

{
"img": "iVBORw0KGgoAAAANSU..." // string base64 of the image or pdf to extract
}

Demo Python:

import base64
import io
import requests
from PIL import Image
def get_byte_img(img):
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format='PNG')
encoded_img = base64.encodebytes(img_byte_arr.getvalue()).decode('ascii')
return encoded_img
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
img_name = "path_img"
encode_cmt = get_byte_img(Image.open(img_name))
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/ocr/birth_certificate?format_type=base64&get_thumb=false",
auth=(api_key, api_secret),
json={'img' : encode_cmt})
print(response.json())

4. Response

The response will be a JSON with the following format:

{
"data": [xxxx],
"errorCode": string,
"errorMessage": string
}

Where data is a list, each element in the list corresponds to a birth certificate (a birth certificate can be one or more pages). Each of these elements is a JSON formatted as follows:

{
"type": "birth_certificate",
"info": [xxxx]
}

The info field will contain the following information:

  • dob
  • dob_confidence
  • father_dob
  • father_dob_confidence
  • father_name
  • father_name_confidence
  • gender
  • gender_confidence
  • mother_dob
  • mother_dob_confidence
  • mother_name
  • mother_name_confidence
  • name
  • name_confidence
  • number
  • number_confidence
  • number_book
  • number_book_confidence
  • regis_date
  • regis_date_confidence
  • id
  • id_confidence
  • regis_place
  • regis_place_confidence
  • regis_place_district
  • regis_place_district_code
  • regis_place_town
  • regis_place_town_code
  • regis_place_ward
  • regis_place_ward_code
  • image

Error code table:

CodeMessage
0Success
1The photo does not contain content
2Url is unavailable
3Incorrect image format
4Out of requests
5Incorrect api_key or api_secret
6Incorrect format type