Vehicle documents
Image input standards: The system achieves the best results in both quality and processing speed with images in HD resolution (1280x720)
1. Extract information of vehicle documents with image URL or pdf URL input
API:
| Method | URL |
|---|---|
| GET | https://demo.computervision.com.vn/api/v2/ocr/vehicle |
Params:
| Key | Value | Description |
|---|---|---|
img | https://example.com/image.png | URL of photo or pdf |
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?img=%s&format_type=url&get_thumb=false"% image_url,auth=(api_key, api_secret))print(response.json())
2. Extract information of vehicle documents with image file or pdf file input
API:
| Method | URL | content-type |
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/vehicle | 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 | Image file or pdf file |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"image_path = '/path/to/your/image.jpg'response = requests.post("https://demo.computervision.com.vn/api/v2/ocr/vehicle?format_type=file&get_thumb=false",auth=(api_key, api_secret),files={'img': open(image_path, 'rb')})print(response.json())
3. Extract information of vehicle documents with JSON input
API:
| Method | URL | content-type |
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/vehicle | 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 or pdf to extract}
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?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": array,"errorCode": string,"errorMessage": string}
The data field is an array, each element in the array corresponds to the information a page in a pdf file or an extracted document image.
Each element in the array will be a JSON with the following format:
{"type": string,"info": object}
type: Type of document in the Vehicle documents to which information is extracted.
vehicle_registration_frontvehicle_registration_backpicertificatedriving_license
info : Including extracted information, for each type of document, there will be different information returned.
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
Vehicle registry - picertificate
chassis_numberchassis_number_confidencecommercial_usecommercial_use_confidencedesign_pay_loaddesign_pay_load_confidencedesign_towed_massdesign_towed_mass_confidenceengine_numberengine_number_confidenceinside_cargo_container_dimensioninside_cargo_container_dimension_confidenceissued_onissued_on_confidenceissued_on_codelife_time_limitlife_time_limit_confidencemanufactured_countrymanufactured_country_confidencemanufactured_yearmanufactured_year_confidencemarkmark_confidencemodel_codemodel_code_confidencemodificationmodification_confidencepermissible_nopermissible_no_confidenceregis_dateregis_date_confidenceregistration_numberregistration_number_confidenceseriseri_confidencetire_sizetire_size_confidencetypetype_confidencevalid_untilvalid_until_confidencewheel_formwheel_form_confidencecapacitycapacity_confidencereport_numberreport_number_confidenceauthorized_pay_loadauthorized_pay_load_confidencelying_placelying_place_confidenceseat_placeseat_place_confidencestand_placestand_place_confidenceimage
Driving license - driving_license
idnamedobclassnationalityissue_datedue_dateaddressaddress_townaddress_districtaddress_wardaddress_town_codeaddress_district_codeaddress_ward_codeid_confidencename_confidencedob_confidenceclass_confidencenationality_confidenceissue_date_confidencedue_date_confidenceaddress_confidenceid_boxname_boxdob_boxclass_boxnationality_boxissue_date_boxdue_date_boxaddress_boximage
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 |