docs/global_products/driver_license_v1
title: Driver License
category: 622b805aaec68102ea7fcbc2
slug: ruby-driver-license-ocr
parentDoc: 67b49df15b843f3fa9cd622b
The Ruby Client Library supports the Driver License API.
> 📝 Product Specs
>
> | Specification | Details |
> | —————————— | ————————————————– |
> | Endpoint Name | driver_license
|
> | Recommended Version | v1.0
|
> | Supports Polling/Webhooks | ✔️ Yes |
> | Support Synchronous HTTP Calls | ❌ No |
> | Geography | 🌐 Global |
> 🔐 Polling Limitations
>
> | Setting | Parameter name | Default Value |
> | ——————————- | ———————– | ————- |
> | Initial Delay Before Polling | initial_delay_seconds
| 2 seconds |
> | Default Delay Between Calls | delay_sec
| 1.5 seconds |
> | Polling Attempts Before Timeout | max_retries
| 80 retries |
Using the sample below,
we are going to illustrate how to extract the data that we want using the Ruby Client Library.
Quick-Start
# # Install the Ruby client library by running: # gem install mindee # require 'mindee' # Init a new client mindee_client = Mindee::Client.new(api_key: 'my-api-key') # Load a file from disk input_source = mindee_client.source_from_path('/path/to/the/file.ext') # Parse the file result = mindee_client.parse( input_source, Mindee::Product::DriverLicense::DriverLicenseV1 ) # Print a full summary of the parsed data in RST format puts result.document # Print the document-level parsed data # puts result.document.inference.prediction
Output (RST):
######## Document ######## :Mindee ID: fbdeae38-ada3-43ac-aa58-e01a3d47e474 :Filename: default_sample.jpg Inference ######### :Product: mindee/driver_license v1.0 :Rotation applied: Yes Prediction ========== :Country Code: USA :State: AZ :ID: D12345678 :Category: D :Last Name: Sample :First Name: Jelani :Date of Birth: 1957-02-01 :Place of Birth: :Expiry Date: 2018-02-01 :Issued Date: 2013-01-10 :Issuing Authority: :MRZ: :DD Number: DD1234567890123456
Field Types
Standard Fields
These fields are generic and used in several products.
Basic Field
Each prediction object contains a set of fields that inherit from the generic Field
class.
A typical Field
object will have the following attributes:
- value (
String
,Float
,Integer
,bool
): corresponds to the field value. Can benil
if no value was extracted. - confidence (Float, nil): the confidence score of the field prediction.
- bounding_box (
Mindee::Geometry::Quadrilateral
,nil
): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. - polygon (
Mindee::Geometry::Polygon
,nil
): contains the relative vertices coordinates (Point
) of a polygon containing the field in the image. - page_id (
Integer
,nil
): the ID of the page, alwaysnil
when at document-level. - reconstructed (
bool
): indicates whether an object was reconstructed (not extracted as the API gave it).
Aside from the previous attributes, all basic fields have access to a to_s
method that can be used to print their value as a string.
Date Field
Aside from the basic Field
attributes, the date field DateField
also implements the following:
- date_object (
Date
): an accessible representation of the value as a JavaScript object.
String Field
The text field StringField
only has one constraint: it’s value is a String
(or nil
).
Attributes
The following fields are extracted for Driver License V1:
Category
category (StringField): The category or class of the driver license.
puts result.document.inference.prediction.category.value
Country Code
country_code (StringField): The alpha-3 ISO 3166 code of the country where the driver license was issued.
puts result.document.inference.prediction.country_code.value
Date of Birth
date_of_birth (DateField): The date of birth of the driver license holder.
puts result.document.inference.prediction.date_of_birth.value
DD Number
dd_number (StringField): The DD number of the driver license.
puts result.document.inference.prediction.dd_number.value
Expiry Date
expiry_date (DateField): The expiry date of the driver license.
puts result.document.inference.prediction.expiry_date.value
First Name
first_name (StringField): The first name of the driver license holder.
puts result.document.inference.prediction.first_name.value
ID
id (StringField): The unique identifier of the driver license.
puts result.document.inference.prediction.id.value
Issued Date
issued_date (DateField): The date when the driver license was issued.
puts result.document.inference.prediction.issued_date.value
Issuing Authority
issuing_authority (StringField): The authority that issued the driver license.
puts result.document.inference.prediction.issuing_authority.value
Last Name
last_name (StringField): The last name of the driver license holder.
puts result.document.inference.prediction.last_name.value
MRZ
mrz (StringField): The Machine Readable Zone (MRZ) of the driver license.
puts result.document.inference.prediction.mrz.value
Place of Birth
place_of_birth (StringField): The place of birth of the driver license holder.
puts result.document.inference.prediction.place_of_birth.value
State
state (StringField): Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
puts result.document.inference.prediction.state.value