mindee 3.16.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/bin/mindee.rb +20 -2
- data/docs/code_samples/{international_id_v1_async.txt → driver_license_v1_async.txt} +1 -1
- data/docs/code_samples/french_healthcard_v1_async.txt +19 -0
- data/docs/code_samples/payslip_fra_v3_async.txt +19 -0
- data/docs/code_samples/workflow_execution.txt +29 -0
- data/docs/driver_license_v1.md +156 -0
- data/docs/{carte_vitale_v1.md → french_healthcard_v1.md} +14 -24
- data/docs/payslip_fra_v3.md +319 -0
- data/lib/mindee/client.rb +40 -0
- data/lib/mindee/http/workflow_endpoint.rb +90 -0
- data/lib/mindee/http.rb +1 -0
- data/lib/mindee/parsing/common/api_response.rb +22 -1
- data/lib/mindee/parsing/common/execution.rb +73 -0
- data/lib/mindee/parsing/common/execution_file.rb +24 -0
- data/lib/mindee/parsing/common/execution_priority.rb +30 -0
- data/lib/mindee/parsing/common.rb +3 -0
- data/lib/mindee/product/{international_id/international_id_v1.rb → driver_license/driver_license_v1.rb} +9 -9
- data/lib/mindee/product/driver_license/driver_license_v1_document.rb +91 -0
- data/lib/mindee/product/{international_id/international_id_v1_page.rb → driver_license/driver_license_v1_page.rb} +7 -7
- data/lib/mindee/product/fr/health_card/health_card_v1.rb +41 -0
- data/lib/mindee/product/fr/health_card/health_card_v1_document.rb +52 -0
- data/lib/mindee/product/fr/health_card/health_card_v1_page.rb +34 -0
- data/lib/mindee/product/fr/payslip/payslip_v3.rb +41 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_bank_account_detail.rb +54 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_document.rb +166 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_employee.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_employer.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_employment.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_page.rb +34 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_paid_time_off.rb +89 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_pay_detail.rb +100 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_pay_period.rb +66 -0
- data/lib/mindee/product/fr/payslip/payslip_v3_salary_detail.rb +89 -0
- data/lib/mindee/product/resume/resume_v1_document.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_page.rb +1 -1
- data/lib/mindee/product.rb +3 -1
- data/lib/mindee/version.rb +1 -1
- metadata +30 -10
- data/docs/eu_driver_license_v1.md +0 -227
- data/docs/proof_of_address_v1.md +0 -211
- data/docs/us_driver_license_v1.md +0 -272
- data/lib/mindee/product/international_id/international_id_v1_document.rb +0 -109
@@ -1,227 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: EU Driver License OCR Ruby
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
4
|
-
slug: ruby-eu-driver-license-ocr
|
5
|
-
parentDoc: 6294d97ee723f1008d2ab28e
|
6
|
-
---
|
7
|
-
The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/eu_driver_license).
|
8
|
-
|
9
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/eu_driver_license/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
10
|
-

|
11
|
-
|
12
|
-
# Quick-Start
|
13
|
-
```rb
|
14
|
-
require 'mindee'
|
15
|
-
|
16
|
-
# Init a new client
|
17
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
18
|
-
|
19
|
-
# Load a file from disk
|
20
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
21
|
-
|
22
|
-
# Parse the file
|
23
|
-
result = mindee_client.parse(
|
24
|
-
input_source,
|
25
|
-
Mindee::Product::EU::DriverLicense::DriverLicenseV1
|
26
|
-
)
|
27
|
-
|
28
|
-
# Print a full summary of the parsed data in RST format
|
29
|
-
puts result.document
|
30
|
-
|
31
|
-
# Print the document-level parsed data
|
32
|
-
# puts result.document.inference.prediction
|
33
|
-
|
34
|
-
```
|
35
|
-
|
36
|
-
**Output (RST):**
|
37
|
-
```rst
|
38
|
-
########
|
39
|
-
Document
|
40
|
-
########
|
41
|
-
:Mindee ID: b19cc32e-b3e6-4ff9-bdc7-619199355d54
|
42
|
-
:Filename: default_sample.jpg
|
43
|
-
|
44
|
-
Inference
|
45
|
-
#########
|
46
|
-
:Product: mindee/eu_driver_license v1.0
|
47
|
-
:Rotation applied: Yes
|
48
|
-
|
49
|
-
Prediction
|
50
|
-
==========
|
51
|
-
:Country Code: FR
|
52
|
-
:Document ID: 13AA00002
|
53
|
-
:Driver License Category: AM A1 B1 B D BE DE
|
54
|
-
:Last Name: MARTIN
|
55
|
-
:First Name: PAUL
|
56
|
-
:Date Of Birth: 1981-07-14
|
57
|
-
:Place Of Birth: Utopiacity
|
58
|
-
:Expiry Date: 2018-12-31
|
59
|
-
:Issue Date: 2013-01-01
|
60
|
-
:Issue Authority: 99999UpiaCity
|
61
|
-
:MRZ: D1FRA13AA000026181231MARTIN<<9
|
62
|
-
:Address:
|
63
|
-
|
64
|
-
Page Predictions
|
65
|
-
================
|
66
|
-
|
67
|
-
Page 0
|
68
|
-
------
|
69
|
-
:Photo: Polygon with 4 points.
|
70
|
-
:Signature: Polygon with 4 points.
|
71
|
-
:Country Code: FR
|
72
|
-
:Document ID: 13AA00002
|
73
|
-
:Driver License Category: AM A1 B1 B D BE DE
|
74
|
-
:Last Name: MARTIN
|
75
|
-
:First Name: PAUL
|
76
|
-
:Date Of Birth: 1981-07-14
|
77
|
-
:Place Of Birth: Utopiacity
|
78
|
-
:Expiry Date: 2018-12-31
|
79
|
-
:Issue Date: 2013-01-01
|
80
|
-
:Issue Authority: 99999UpiaCity
|
81
|
-
:MRZ: D1FRA13AA000026181231MARTIN<<9
|
82
|
-
:Address:
|
83
|
-
```
|
84
|
-
|
85
|
-
# Field Types
|
86
|
-
## Standard Fields
|
87
|
-
These fields are generic and used in several products.
|
88
|
-
|
89
|
-
### Basic Field
|
90
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
91
|
-
A typical `Field` object will have the following attributes:
|
92
|
-
|
93
|
-
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
94
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
95
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
96
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
97
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
98
|
-
* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
99
|
-
|
100
|
-
|
101
|
-
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.
|
102
|
-
|
103
|
-
### Date Field
|
104
|
-
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
105
|
-
|
106
|
-
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
107
|
-
|
108
|
-
|
109
|
-
### Position Field
|
110
|
-
The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**, **polygon** and **page_id**. On top of these, it has access to:
|
111
|
-
|
112
|
-
* **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
|
113
|
-
* **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
|
114
|
-
|
115
|
-
### String Field
|
116
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
117
|
-
|
118
|
-
## Page-Level Fields
|
119
|
-
Some fields are constrained to the page level, and so will not be retrievable at document level.
|
120
|
-
|
121
|
-
# Attributes
|
122
|
-
The following fields are extracted for Driver License V1:
|
123
|
-
|
124
|
-
## Address
|
125
|
-
**address** ([StringField](#string-field)): EU driver license holders address
|
126
|
-
|
127
|
-
```rb
|
128
|
-
puts result.document.inference.prediction.address.value
|
129
|
-
```
|
130
|
-
|
131
|
-
## Driver License Category
|
132
|
-
**category** ([StringField](#string-field)): EU driver license holders categories
|
133
|
-
|
134
|
-
```rb
|
135
|
-
puts result.document.inference.prediction.category.value
|
136
|
-
```
|
137
|
-
|
138
|
-
## Country Code
|
139
|
-
**country_code** ([StringField](#string-field)): Country code extracted as a string.
|
140
|
-
|
141
|
-
```rb
|
142
|
-
puts result.document.inference.prediction.country_code.value
|
143
|
-
```
|
144
|
-
|
145
|
-
## Date Of Birth
|
146
|
-
**date_of_birth** ([DateField](#date-field)): The date of birth of the document holder
|
147
|
-
|
148
|
-
```rb
|
149
|
-
puts result.document.inference.prediction.date_of_birth.value
|
150
|
-
```
|
151
|
-
|
152
|
-
## Document ID
|
153
|
-
**document_id** ([StringField](#string-field)): ID number of the Document.
|
154
|
-
|
155
|
-
```rb
|
156
|
-
puts result.document.inference.prediction.document_id.value
|
157
|
-
```
|
158
|
-
|
159
|
-
## Expiry Date
|
160
|
-
**expiry_date** ([DateField](#date-field)): Date the document expires
|
161
|
-
|
162
|
-
```rb
|
163
|
-
puts result.document.inference.prediction.expiry_date.value
|
164
|
-
```
|
165
|
-
|
166
|
-
## First Name
|
167
|
-
**first_name** ([StringField](#string-field)): First name(s) of the driver license holder
|
168
|
-
|
169
|
-
```rb
|
170
|
-
puts result.document.inference.prediction.first_name.value
|
171
|
-
```
|
172
|
-
|
173
|
-
## Issue Authority
|
174
|
-
**issue_authority** ([StringField](#string-field)): Authority that issued the document
|
175
|
-
|
176
|
-
```rb
|
177
|
-
puts result.document.inference.prediction.issue_authority.value
|
178
|
-
```
|
179
|
-
|
180
|
-
## Issue Date
|
181
|
-
**issue_date** ([DateField](#date-field)): Date the document was issued
|
182
|
-
|
183
|
-
```rb
|
184
|
-
puts result.document.inference.prediction.issue_date.value
|
185
|
-
```
|
186
|
-
|
187
|
-
## Last Name
|
188
|
-
**last_name** ([StringField](#string-field)): Last name of the driver license holder.
|
189
|
-
|
190
|
-
```rb
|
191
|
-
puts result.document.inference.prediction.last_name.value
|
192
|
-
```
|
193
|
-
|
194
|
-
## MRZ
|
195
|
-
**mrz** ([StringField](#string-field)): Machine-readable license number
|
196
|
-
|
197
|
-
```rb
|
198
|
-
puts result.document.inference.prediction.mrz.value
|
199
|
-
```
|
200
|
-
|
201
|
-
## Photo
|
202
|
-
[📄](#page-level-fields "This field is only present on individual pages.")**photo** ([PositionField](#position-field)): Has a photo of the EU driver license holder
|
203
|
-
|
204
|
-
```rb
|
205
|
-
for photo_elem in result.document.photo do
|
206
|
-
puts photo_elem.polygon
|
207
|
-
end
|
208
|
-
```
|
209
|
-
|
210
|
-
## Place Of Birth
|
211
|
-
**place_of_birth** ([StringField](#string-field)): Place where the driver license holder was born
|
212
|
-
|
213
|
-
```rb
|
214
|
-
puts result.document.inference.prediction.place_of_birth.value
|
215
|
-
```
|
216
|
-
|
217
|
-
## Signature
|
218
|
-
[📄](#page-level-fields "This field is only present on individual pages.")**signature** ([PositionField](#position-field)): Has a signature of the EU driver license holder
|
219
|
-
|
220
|
-
```rb
|
221
|
-
for signature_elem in result.document.signature do
|
222
|
-
puts signature_elem.polygon
|
223
|
-
end
|
224
|
-
```
|
225
|
-
|
226
|
-
# Questions?
|
227
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
data/docs/proof_of_address_v1.md
DELETED
@@ -1,211 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Proof of Address OCR Ruby
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
4
|
-
slug: ruby-proof-of-address-ocr
|
5
|
-
parentDoc: 6294d97ee723f1008d2ab28e
|
6
|
-
---
|
7
|
-
The Ruby OCR SDK supports the [Proof of Address API](https://platform.mindee.com/mindee/proof_of_address).
|
8
|
-
|
9
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
10
|
-

|
11
|
-
|
12
|
-
# Quick-Start
|
13
|
-
```rb
|
14
|
-
require 'mindee'
|
15
|
-
|
16
|
-
# Init a new client
|
17
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
18
|
-
|
19
|
-
# Load a file from disk
|
20
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
21
|
-
|
22
|
-
# Parse the file
|
23
|
-
result = mindee_client.parse(
|
24
|
-
input_source,
|
25
|
-
Mindee::Product::ProofOfAddress::ProofOfAddressV1
|
26
|
-
)
|
27
|
-
|
28
|
-
# Print a full summary of the parsed data in RST format
|
29
|
-
puts result.document
|
30
|
-
|
31
|
-
# Print the document-level parsed data
|
32
|
-
# puts result.document.inference.prediction
|
33
|
-
|
34
|
-
```
|
35
|
-
|
36
|
-
**Output (RST):**
|
37
|
-
```rst
|
38
|
-
########
|
39
|
-
Document
|
40
|
-
########
|
41
|
-
:Mindee ID: 5d2361e9-405e-4fc1-8531-f92a3aef0c38
|
42
|
-
:Filename: default_sample.jpg
|
43
|
-
|
44
|
-
Inference
|
45
|
-
#########
|
46
|
-
:Product: mindee/proof_of_address v1.1
|
47
|
-
:Rotation applied: Yes
|
48
|
-
|
49
|
-
Prediction
|
50
|
-
==========
|
51
|
-
:Locale: en; en; USD;
|
52
|
-
:Issuer Name: PPL ELECTRIC UTILITIES
|
53
|
-
:Issuer Company Registrations:
|
54
|
-
:Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN.PA 18101-1175
|
55
|
-
:Recipient Name:
|
56
|
-
:Recipient Company Registrations:
|
57
|
-
:Recipient Address: 123 MAIN ST ANYTOWN,PA 18062
|
58
|
-
:Dates: 2011-07-27
|
59
|
-
2011-07-06
|
60
|
-
2011-08-03
|
61
|
-
2011-07-27
|
62
|
-
2011-06-01
|
63
|
-
2011-07-01
|
64
|
-
2010-07-01
|
65
|
-
2010-08-01
|
66
|
-
2011-07-01
|
67
|
-
2009-08-01
|
68
|
-
2010-07-01
|
69
|
-
2011-07-27
|
70
|
-
:Date of Issue: 2011-07-27
|
71
|
-
|
72
|
-
Page Predictions
|
73
|
-
================
|
74
|
-
|
75
|
-
Page 0
|
76
|
-
------
|
77
|
-
:Locale: en; en; USD;
|
78
|
-
:Issuer Name: PPL ELECTRIC UTILITIES
|
79
|
-
:Issuer Company Registrations:
|
80
|
-
:Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN.PA 18101-1175
|
81
|
-
:Recipient Name:
|
82
|
-
:Recipient Company Registrations:
|
83
|
-
:Recipient Address: 123 MAIN ST ANYTOWN,PA 18062
|
84
|
-
:Dates: 2011-07-27
|
85
|
-
2011-07-06
|
86
|
-
2011-08-03
|
87
|
-
2011-07-27
|
88
|
-
2011-06-01
|
89
|
-
2011-07-01
|
90
|
-
2010-07-01
|
91
|
-
2010-08-01
|
92
|
-
2011-07-01
|
93
|
-
2009-08-01
|
94
|
-
2010-07-01
|
95
|
-
2011-07-27
|
96
|
-
:Date of Issue: 2011-07-27
|
97
|
-
```
|
98
|
-
|
99
|
-
# Field Types
|
100
|
-
## Standard Fields
|
101
|
-
These fields are generic and used in several products.
|
102
|
-
|
103
|
-
### Basic Field
|
104
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
105
|
-
A typical `Field` object will have the following attributes:
|
106
|
-
|
107
|
-
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
108
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
109
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
110
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
111
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
112
|
-
* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
113
|
-
|
114
|
-
|
115
|
-
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.
|
116
|
-
|
117
|
-
|
118
|
-
### Company Registration Field
|
119
|
-
Aside from the basic `Field` attributes, the company registration field `CompanyRegistrationField` also implements the following:
|
120
|
-
|
121
|
-
* **type** (`String`): the type of company.
|
122
|
-
|
123
|
-
### Date Field
|
124
|
-
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
125
|
-
|
126
|
-
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
127
|
-
|
128
|
-
### Locale Field
|
129
|
-
The locale field `LocaleField` only implements the **value**, **confidence** and **page_id** base `Field` attributes, but it comes with its own:
|
130
|
-
|
131
|
-
* **language** (`String`): ISO 639-1 language code (e.g.: `en` for English). Can be `nil`.
|
132
|
-
* **country** (`String`): ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code for countries (e.g.: `GRB` or `GB` for "Great Britain"). Can be `nil`.
|
133
|
-
* **currency** (`String`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `nil`.
|
134
|
-
|
135
|
-
### String Field
|
136
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
137
|
-
|
138
|
-
# Attributes
|
139
|
-
The following fields are extracted for Proof of Address V1:
|
140
|
-
|
141
|
-
## Date of Issue
|
142
|
-
**date** ([DateField](#date-field)): The date the document was issued.
|
143
|
-
|
144
|
-
```rb
|
145
|
-
puts result.document.inference.prediction.date.value
|
146
|
-
```
|
147
|
-
|
148
|
-
## Dates
|
149
|
-
**dates** (Array<[DateField](#date-field)>): List of dates found on the document.
|
150
|
-
|
151
|
-
```rb
|
152
|
-
for dates_elem in result.document.inference.prediction.dates do
|
153
|
-
puts dates_elem.value
|
154
|
-
end
|
155
|
-
```
|
156
|
-
|
157
|
-
## Issuer Address
|
158
|
-
**issuer_address** ([StringField](#string-field)): The address of the document's issuer.
|
159
|
-
|
160
|
-
```rb
|
161
|
-
puts result.document.inference.prediction.issuer_address.value
|
162
|
-
```
|
163
|
-
|
164
|
-
## Issuer Company Registrations
|
165
|
-
**issuer_company_registration** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations found for the issuer.
|
166
|
-
|
167
|
-
```rb
|
168
|
-
for issuer_company_registration_elem in result.document.inference.prediction.issuer_company_registration do
|
169
|
-
puts issuer_company_registration_elem.value
|
170
|
-
end
|
171
|
-
```
|
172
|
-
|
173
|
-
## Issuer Name
|
174
|
-
**issuer_name** ([StringField](#string-field)): The name of the person or company issuing the document.
|
175
|
-
|
176
|
-
```rb
|
177
|
-
puts result.document.inference.prediction.issuer_name.value
|
178
|
-
```
|
179
|
-
|
180
|
-
## Locale
|
181
|
-
**locale** ([LocaleField](#locale-field)): The locale detected on the document.
|
182
|
-
|
183
|
-
```rb
|
184
|
-
puts result.document.inference.prediction.locale.value
|
185
|
-
```
|
186
|
-
|
187
|
-
## Recipient Address
|
188
|
-
**recipient_address** ([StringField](#string-field)): The address of the recipient.
|
189
|
-
|
190
|
-
```rb
|
191
|
-
puts result.document.inference.prediction.recipient_address.value
|
192
|
-
```
|
193
|
-
|
194
|
-
## Recipient Company Registrations
|
195
|
-
**recipient_company_registration** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations found for the recipient.
|
196
|
-
|
197
|
-
```rb
|
198
|
-
for recipient_company_registration_elem in result.document.inference.prediction.recipient_company_registration do
|
199
|
-
puts recipient_company_registration_elem.value
|
200
|
-
end
|
201
|
-
```
|
202
|
-
|
203
|
-
## Recipient Name
|
204
|
-
**recipient_name** ([StringField](#string-field)): The name of the person or company receiving the document.
|
205
|
-
|
206
|
-
```rb
|
207
|
-
puts result.document.inference.prediction.recipient_name.value
|
208
|
-
```
|
209
|
-
|
210
|
-
# Questions?
|
211
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
@@ -1,272 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: US Driver License OCR Ruby
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
4
|
-
slug: ruby-us-driver-license-ocr
|
5
|
-
parentDoc: 6294d97ee723f1008d2ab28e
|
6
|
-
---
|
7
|
-
The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/us_driver_license).
|
8
|
-
|
9
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_driver_license/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
10
|
-

|
11
|
-
|
12
|
-
# Quick-Start
|
13
|
-
```rb
|
14
|
-
require 'mindee'
|
15
|
-
|
16
|
-
# Init a new client
|
17
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
18
|
-
|
19
|
-
# Load a file from disk
|
20
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
21
|
-
|
22
|
-
# Parse the file
|
23
|
-
result = mindee_client.parse(
|
24
|
-
input_source,
|
25
|
-
Mindee::Product::US::DriverLicense::DriverLicenseV1
|
26
|
-
)
|
27
|
-
|
28
|
-
# Print a full summary of the parsed data in RST format
|
29
|
-
puts result.document
|
30
|
-
|
31
|
-
# Print the document-level parsed data
|
32
|
-
# puts result.document.inference.prediction
|
33
|
-
|
34
|
-
```
|
35
|
-
|
36
|
-
**Output (RST):**
|
37
|
-
```rst
|
38
|
-
########
|
39
|
-
Document
|
40
|
-
########
|
41
|
-
:Mindee ID: bf70068d-d3d6-49dc-b93a-b4b7d156fc3d
|
42
|
-
:Filename: default_sample.jpg
|
43
|
-
|
44
|
-
Inference
|
45
|
-
#########
|
46
|
-
:Product: mindee/us_driver_license v1.0
|
47
|
-
:Rotation applied: Yes
|
48
|
-
|
49
|
-
Prediction
|
50
|
-
==========
|
51
|
-
:State: AZ
|
52
|
-
:Driver License ID: D12345678
|
53
|
-
:Expiry Date: 2018-02-01
|
54
|
-
:Date Of Issue: 2013-01-10
|
55
|
-
:Last Name: SAMPLE
|
56
|
-
:First Name: JELANI
|
57
|
-
:Address: 123 MAIN STREET PHOENIX AZ 85007
|
58
|
-
:Date Of Birth: 1957-02-01
|
59
|
-
:Restrictions: NONE
|
60
|
-
:Endorsements: NONE
|
61
|
-
:Driver License Class: D
|
62
|
-
:Sex: M
|
63
|
-
:Height: 5-08
|
64
|
-
:Weight: 185
|
65
|
-
:Hair Color: BRO
|
66
|
-
:Eye Color: BRO
|
67
|
-
:Document Discriminator: 1234567890123456
|
68
|
-
|
69
|
-
Page Predictions
|
70
|
-
================
|
71
|
-
|
72
|
-
Page 0
|
73
|
-
------
|
74
|
-
:Photo: Polygon with 4 points.
|
75
|
-
:Signature: Polygon with 4 points.
|
76
|
-
:State: AZ
|
77
|
-
:Driver License ID: D12345678
|
78
|
-
:Expiry Date: 2018-02-01
|
79
|
-
:Date Of Issue: 2013-01-10
|
80
|
-
:Last Name: SAMPLE
|
81
|
-
:First Name: JELANI
|
82
|
-
:Address: 123 MAIN STREET PHOENIX AZ 85007
|
83
|
-
:Date Of Birth: 1957-02-01
|
84
|
-
:Restrictions: NONE
|
85
|
-
:Endorsements: NONE
|
86
|
-
:Driver License Class: D
|
87
|
-
:Sex: M
|
88
|
-
:Height: 5-08
|
89
|
-
:Weight: 185
|
90
|
-
:Hair Color: BRO
|
91
|
-
:Eye Color: BRO
|
92
|
-
:Document Discriminator: 1234567890123456
|
93
|
-
```
|
94
|
-
|
95
|
-
# Field Types
|
96
|
-
## Standard Fields
|
97
|
-
These fields are generic and used in several products.
|
98
|
-
|
99
|
-
### Basic Field
|
100
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
101
|
-
A typical `Field` object will have the following attributes:
|
102
|
-
|
103
|
-
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
104
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
105
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
106
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
107
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
108
|
-
* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
109
|
-
|
110
|
-
|
111
|
-
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.
|
112
|
-
|
113
|
-
### Date Field
|
114
|
-
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
115
|
-
|
116
|
-
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
117
|
-
|
118
|
-
|
119
|
-
### Position Field
|
120
|
-
The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**, **polygon** and **page_id**. On top of these, it has access to:
|
121
|
-
|
122
|
-
* **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
|
123
|
-
* **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
|
124
|
-
|
125
|
-
### String Field
|
126
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
127
|
-
|
128
|
-
## Page-Level Fields
|
129
|
-
Some fields are constrained to the page level, and so will not be retrievable at document level.
|
130
|
-
|
131
|
-
# Attributes
|
132
|
-
The following fields are extracted for Driver License V1:
|
133
|
-
|
134
|
-
## Address
|
135
|
-
**address** ([StringField](#string-field)): US driver license holders address
|
136
|
-
|
137
|
-
```rb
|
138
|
-
puts result.document.inference.prediction.address.value
|
139
|
-
```
|
140
|
-
|
141
|
-
## Date Of Birth
|
142
|
-
**date_of_birth** ([DateField](#date-field)): US driver license holders date of birth
|
143
|
-
|
144
|
-
```rb
|
145
|
-
puts result.document.inference.prediction.date_of_birth.value
|
146
|
-
```
|
147
|
-
|
148
|
-
## Document Discriminator
|
149
|
-
**dd_number** ([StringField](#string-field)): Document Discriminator Number of the US Driver License
|
150
|
-
|
151
|
-
```rb
|
152
|
-
puts result.document.inference.prediction.dd_number.value
|
153
|
-
```
|
154
|
-
|
155
|
-
## Driver License Class
|
156
|
-
**dl_class** ([StringField](#string-field)): US driver license holders class
|
157
|
-
|
158
|
-
```rb
|
159
|
-
puts result.document.inference.prediction.dl_class.value
|
160
|
-
```
|
161
|
-
|
162
|
-
## Driver License ID
|
163
|
-
**driver_license_id** ([StringField](#string-field)): ID number of the US Driver License.
|
164
|
-
|
165
|
-
```rb
|
166
|
-
puts result.document.inference.prediction.driver_license_id.value
|
167
|
-
```
|
168
|
-
|
169
|
-
## Endorsements
|
170
|
-
**endorsements** ([StringField](#string-field)): US driver license holders endorsements
|
171
|
-
|
172
|
-
```rb
|
173
|
-
puts result.document.inference.prediction.endorsements.value
|
174
|
-
```
|
175
|
-
|
176
|
-
## Expiry Date
|
177
|
-
**expiry_date** ([DateField](#date-field)): Date on which the documents expires.
|
178
|
-
|
179
|
-
```rb
|
180
|
-
puts result.document.inference.prediction.expiry_date.value
|
181
|
-
```
|
182
|
-
|
183
|
-
## Eye Color
|
184
|
-
**eye_color** ([StringField](#string-field)): US driver license holders eye colour
|
185
|
-
|
186
|
-
```rb
|
187
|
-
puts result.document.inference.prediction.eye_color.value
|
188
|
-
```
|
189
|
-
|
190
|
-
## First Name
|
191
|
-
**first_name** ([StringField](#string-field)): US driver license holders first name(s)
|
192
|
-
|
193
|
-
```rb
|
194
|
-
puts result.document.inference.prediction.first_name.value
|
195
|
-
```
|
196
|
-
|
197
|
-
## Hair Color
|
198
|
-
**hair_color** ([StringField](#string-field)): US driver license holders hair colour
|
199
|
-
|
200
|
-
```rb
|
201
|
-
puts result.document.inference.prediction.hair_color.value
|
202
|
-
```
|
203
|
-
|
204
|
-
## Height
|
205
|
-
**height** ([StringField](#string-field)): US driver license holders hight
|
206
|
-
|
207
|
-
```rb
|
208
|
-
puts result.document.inference.prediction.height.value
|
209
|
-
```
|
210
|
-
|
211
|
-
## Date Of Issue
|
212
|
-
**issued_date** ([DateField](#date-field)): Date on which the documents was issued.
|
213
|
-
|
214
|
-
```rb
|
215
|
-
puts result.document.inference.prediction.issued_date.value
|
216
|
-
```
|
217
|
-
|
218
|
-
## Last Name
|
219
|
-
**last_name** ([StringField](#string-field)): US driver license holders last name
|
220
|
-
|
221
|
-
```rb
|
222
|
-
puts result.document.inference.prediction.last_name.value
|
223
|
-
```
|
224
|
-
|
225
|
-
## Photo
|
226
|
-
[📄](#page-level-fields "This field is only present on individual pages.")**photo** ([PositionField](#position-field)): Has a photo of the US driver license holder
|
227
|
-
|
228
|
-
```rb
|
229
|
-
for photo_elem in result.document.photo do
|
230
|
-
puts photo_elem.polygon
|
231
|
-
end
|
232
|
-
```
|
233
|
-
|
234
|
-
## Restrictions
|
235
|
-
**restrictions** ([StringField](#string-field)): US driver license holders restrictions
|
236
|
-
|
237
|
-
```rb
|
238
|
-
puts result.document.inference.prediction.restrictions.value
|
239
|
-
```
|
240
|
-
|
241
|
-
## Sex
|
242
|
-
**sex** ([StringField](#string-field)): US driver license holders gender
|
243
|
-
|
244
|
-
```rb
|
245
|
-
puts result.document.inference.prediction.sex.value
|
246
|
-
```
|
247
|
-
|
248
|
-
## Signature
|
249
|
-
[📄](#page-level-fields "This field is only present on individual pages.")**signature** ([PositionField](#position-field)): Has a signature of the US driver license holder
|
250
|
-
|
251
|
-
```rb
|
252
|
-
for signature_elem in result.document.signature do
|
253
|
-
puts signature_elem.polygon
|
254
|
-
end
|
255
|
-
```
|
256
|
-
|
257
|
-
## State
|
258
|
-
**state** ([StringField](#string-field)): US State
|
259
|
-
|
260
|
-
```rb
|
261
|
-
puts result.document.inference.prediction.state.value
|
262
|
-
```
|
263
|
-
|
264
|
-
## Weight
|
265
|
-
**weight** ([StringField](#string-field)): US driver license holders weight
|
266
|
-
|
267
|
-
```rb
|
268
|
-
puts result.document.inference.prediction.weight.value
|
269
|
-
```
|
270
|
-
|
271
|
-
# Questions?
|
272
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|