Skip to content

Commit b1e25c1

Browse files
✨ add support for EU Driver License & International ID v2 (#82)
1 parent 18ba2f6 commit b1e25c1

58 files changed

Lines changed: 1071 additions & 185 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ customize the experience.
137137
* [Custom OCR Ruby](https://developers.mindee.com/docs/api-builder-ocr-ruby)
138138
* [Generated API Ruby](https://developers.mindee.com/docs/generated-api-ruby)
139139
* [Invoice OCR Ruby](https://developers.mindee.com/docs/invoice-ocr-ruby)
140+
* [International Id OCR Ruby](https://developers.mindee.com/docs/international-id-ocr-ruby)
140141
* [Financial Document OCR Ruby](https://developers.mindee.com/docs/financial-document-ocr-ruby)
141142
* [Passport OCR Ruby](https://developers.mindee.com/docs/passport-ocr-ruby)
142143
* [Proof of Address OCR Ruby](https://developers.mindee.com/docs/proof-of-address-ocr-ruby)
143144
* [Receipt OCR Ruby](https://developers.mindee.com/docs/receipt-ocr-ruby)
144145
* [EU License Plate OCR Ruby](https://developers.mindee.com/docs/eu-license-plate-ocr-ruby)
146+
* [EU Driver License OCR Ruby](https://developers.mindee.com/docs/eu-driver-license-ocr-ruby)
145147
* [FR Bank Account Details OCR Ruby](https://developers.mindee.com/docs/fr-bank-account-details-ocr-ruby)
146148
* [FR Bank Statement OCR Ruby](https://developers.mindee.com/docs/fr-bank-statement-ocr-ruby)
147149
* [FR Carte Vitale OCR Ruby](https://developers.mindee.com/docs/fr-carte-vitale-ocr-ruby)

bin/mindee.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
sync: true,
4444
async: false,
4545
},
46+
"international-id" => {
47+
description: 'International Id',
48+
doc_class: Mindee::Product::InternationalId::InternationalIdV2,
49+
sync: false,
50+
async: true,
51+
},
4652
"receipt" => {
4753
description: "Expense Receipt",
4854
doc_class: Mindee::Product::Receipt::ReceiptV5,
@@ -61,6 +67,12 @@
6167
sync: true,
6268
async: false,
6369
},
70+
"eu-driver-license" => {
71+
description: "EU Driver License",
72+
doc_class: Mindee::Product::EU::DriverLicense::DriverLicenseV1,
73+
sync: true,
74+
async: false,
75+
},
6476
"fr-bank-account-details" => {
6577
description: "FR Bank Account Details",
6678
doc_class: Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2,

docs/carte_grise_v1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ puts result.document
3434
########
3535
Document
3636
########
37-
:Mindee ID: f0e0f7a9-0f44-4a3d-92c7-5be262133d33
37+
:Mindee ID: 4443182b-57c1-4426-a288-01b94f226e84
3838
:Filename: default_sample.jpg
3939
4040
Inference
4141
#########
42-
:Product: mindee/carte_grise v1.0
42+
:Product: mindee/carte_grise v1.1
4343
:Rotation applied: Yes
4444
4545
Prediction
@@ -67,14 +67,14 @@ Prediction
6767
:p2: 90
6868
:p3: GO
6969
:p6: 6
70-
:q:
70+
:q: 006
7171
:s1: 5
7272
:s2:
7373
:u1: 77
7474
:u2: 3000
7575
:v7: 155
7676
:x1: 2011-07-06
77-
:y1:
77+
:y1: 17835
7878
:y2:
7979
:y3: 0
8080
:y4: 4
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'mindee'
2+
3+
# Init a new client
4+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5+
6+
# Load a file from disk
7+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8+
9+
# Parse the file
10+
result = mindee_client.parse(
11+
input_source,
12+
Mindee::Product::EU::DriverLicense::DriverLicenseV1
13+
)
14+
15+
# Print a full summary of the parsed data in RST format
16+
puts result.document
17+
18+
# Print the document-level parsed data
19+
# puts result.document.inference.prediction
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'mindee'
2+
3+
# Init a new client
4+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5+
6+
# Load a file from disk
7+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8+
9+
# Parse the file
10+
result = mindee_client.enqueue_and_parse(
11+
input_source,
12+
Mindee::Product::InternationalId::InternationalIdV1
13+
)
14+
15+
# Print a full summary of the parsed data in RST format
16+
puts result.document
17+
18+
# Print the document-level parsed data
19+
# puts result.document.inference.prediction
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'mindee'
2+
3+
# Init a new client
4+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5+
6+
# Load a file from disk
7+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8+
9+
# Parse the file
10+
result = mindee_client.enqueue_and_parse(
11+
input_source,
12+
Mindee::Product::InternationalId::InternationalIdV2
13+
)
14+
15+
# Print a full summary of the parsed data in RST format
16+
puts result.document
17+
18+
# Print the document-level parsed data
19+
# puts result.document.inference.prediction

docs/eu_driver_license_v1.md

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

0 commit comments

Comments
 (0)