Vehicle registration
Image input standards: The system achieves the best results in both quality and processing speed with images in HD resolution (1280x720)
1. Extract two-sided vehicle registration information with image URL input
API:
| Method | URL |
|---|---|
| GET | https://demo.computervision.com.vn/api/v2/ocr/vehicle_registrations |
Params:
| Key | Value | Description |
|---|---|---|
img1 | https://example.com/front.png | Front side photo URL |
img2 | https://example.com/back.png | Back side photo URL |
format_type | url | Type of data to pass in, receive value: url, file, base64 |
get_thumb | true/false | Returns a aligned image |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"front_url = 'sample front url'back_url = 'sample back url'response = requests.get("https://demo.computervision.com.vn/api/v2/ocr/vehicle_registrations?img1=%s&img2=%s&format_type=%s&get_thumb=%s"% (front_url, back_url, 'url', 'false'),auth=(api_key, api_secret))print(response.json())
2. Extract two-sided vehicle registration information with image file input
API:
| Method | URL | content-type |
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/vehicle_registrations | multipart/form-data |
Params:
| Key | Value | Description |
|---|---|---|
format_type | file | Type of data to pass in, receive value: url, file, base64 |
get_thumb | true/false | Returns a aligned image |
Body:
| Key | Type | Value | Description |
|---|---|---|---|
img1 | file | example_front.jpg | Image file of the front side |
img2 | file | example_back.jpg | Image file of the back side |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"front_path = '/path/to/your/example_front.jpg'back_path = '/path/to/your/example_back.jpg'response = requests.post("https://demo.computervision.com.vn/api/v2/ocr/vehicle_registrations?format_type=file&get_thumb=false",auth=(api_key, api_secret),files={'img1': open(front_path, 'rb'), 'img2' : open(back_path, 'rb')})print(response.json())
3. Extract two-sided vehicle registration information with JSON input
API:
| Method | URL | content-type |
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/vehicle_registrations | application/json |
Params:
| Key | Value | Description |
|---|---|---|
format_type | base64 | Type of data to pass in, receive value: url, file, base64 |
get_thumb | true/false | Returns a aligned image |
Body:
{"img1": "iVBORw0KGgoAAAANSU...", // string base64 of the front image"img2": "iVBORw0KGgoAAAANSU..." // string base64 of the back image}
Demo Python:
import base64import ioimport requestsfrom PIL import Imagedef 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_imgapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"img_front_path = "/path/to/your/img_front.jpg"img_back_path = "/path/to/your/img_back.jpg"encode_front = get_byte_img(Image.open(img_front_path))encode_back = get_byte_img(Image.open(img_back_path))response = requests.post("https://demo.computervision.com.vn/api/v2/ocr/vehicle_registrations?format_type=base64&get_thumb=false",auth=(api_key, api_secret),json={'img1' : encode_front, "img2" : encode_back})print(response.json())
4. Extract information on any one side of vehicle registration with image URL input
API:
| Method | URL |
|---|---|
| GET | https://demo.computervision.com.vn/api/v2/ocr/vehicle_registration |
Params:
| Key | Value | Description |
|---|---|---|
img | https://example.com/image.png | Front or back photo URL of vehicle registration |
format_type | url | Type of data to pass in, receive value: url, file, base64 |
get_thumb | true/false | Returns a aligned image |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"image_url = 'https://example.com/image.png'response = requests.get("https://demo.computervision.com.vn/api/v2/ocr/vehicle_registration?img=%s&format_type=%s&get_thumb=%s"% (image_url, 'url', 'false'),auth=(api_key, api_secret))print(response.json())
5. Extract information on any one side of vehicle registration with image file input
API:
| Method | URL | content-type |
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/vehicle_registration | multipart/form-data |
Params:
| Key | Value | Description |
|---|---|---|
format_type | file | Type of data to pass in, receive value: url, file, base64 |
get_thumb | true/false | Returns a aligned image |
Body:
| Key | Type | Value | Description |
|---|---|---|---|
img | file | example.jpg | Photo file of the front or back of the vehicle registration |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"image_path = '/path/to/your/example.jpg'response = requests.post("https://demo.computervision.com.vn/api/v2/ocr/vehicle_registration?format_type=file&get_thumb=false",auth=(api_key, api_secret),files={'img': open(image_path, 'rb')})print(response.json())
6. Extract information on any one side of vehicle registration with JSON input
API:
| Method | URL | content-type |
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/vehicle_registration | application/json |
Params:
| Key | Value | Description |
|---|---|---|
format_type | base64 | Type of data to pass in, receive value: url, file, base64 |
get_thumb | true/false | Returns a aligned image |
Body:
{"img": "iVBORw0KGgoAAAANSU..." // string base64 of the image to be extracted}
Demo Python:
import base64import ioimport requestsfrom PIL import Imagedef 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_imgapi_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://demo.computervision.com.vn/api/v2/ocr/vehicle_registration?format_type=base64&get_thumb=false",auth=(api_key, api_secret),json={'img' : encode_cmt})print(response.json())
7. Response
The response will be a JSON with the following format:
{"data": [xxxx],"errorCode": string,"errorMessage": string}
Where the data field is a list, each element in the list corresponds to the vehicle registration (a vehicle registration can be one or more pages). Each of these elements is a JSON formatted as follows:
{"type": "vehicle_registrations","info": [xxxx]}
Vehicle registration front - vehicle_registration_front
namename_confidenceaddressaddress_confidenceidid_confidenceplateplate_confidenceissued_atissued_at_confidenceimage
Vehicle registration back - vehicle_registration_back
namename_confidenceaddressaddress_confidenceaddress_town_codeaddress_district_codeaddress_ward_codeaddress_townaddress_districtaddress_wardengineengine_confidencechassischassis_confidencebrandbrand_confidencemodelmodel_confidencecolorcolor_confidencecapacitycapacity_confidenceissued_atissued_at_confidenceissued_at_codelast_issue_datelast_issue_date_confidencefirst_issue_datefirst_issue_date_confidenceplateplate_confidencepay_loadpay_load_confidenceyear_of_manufactureyear_of_manufacture_confidencelielie_confidencesitsit_confidencestandstand_confidenceimage
Error code table:
| Code | Message |
|---|---|
| 0 | Success |
| 1 | The photo does not contain content |
| 2 | Url is unavailable |
| 3 | Incorrect image format |
| 4 | Out of requests |
| 5 | Incorrect api_key or api_secret |
| 6 | Incorrect format type |