mindee 4.7.2 → 4.8.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/README.md +6 -6
- data/Rakefile +1 -0
- data/lib/mindee/errors/mindee_http_error_v2.rb +23 -4
- data/lib/mindee/errors/mindee_http_unknown_error_v2.rb +18 -0
- data/lib/mindee/http/endpoint.rb +1 -0
- data/lib/mindee/parsing/v2/error_item.rb +21 -0
- data/lib/mindee/parsing/v2/error_response.rb +18 -3
- data/lib/mindee/parsing/v2/inference_result.rb +4 -0
- data/lib/mindee/parsing/v2/rag_metadata.rb +17 -0
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +1 -0
- data/sig/mindee/errors/mindee_http_error_v2.rbs +4 -1
- data/sig/mindee/errors/mindee_http_unknown_error_v2.rbs +9 -0
- data/sig/mindee/http/endpoint.rbs +1 -0
- data/sig/mindee/parsing/v2/error_item.rbs +13 -0
- data/sig/mindee/parsing/v2/error_response.rbs +3 -0
- data/sig/mindee/parsing/v2/inference_result.rbs +1 -0
- data/sig/mindee/parsing/v2/rag_metadata.rbs +13 -0
- metadata +22 -34
- data/docs/advanced_file_operations.md +0 -109
- data/docs/getting_started.md +0 -257
- data/docs/global_products/barcode_reader_v1.md +0 -125
- data/docs/global_products/bill_of_lading_v1.md +0 -276
- data/docs/global_products/business_card_v1.md +0 -194
- data/docs/global_products/cropper_v1.md +0 -123
- data/docs/global_products/delivery_notes_v1.md +0 -168
- data/docs/global_products/driver_license_v1.md +0 -212
- data/docs/global_products/expense_receipts_v5.md +0 -415
- data/docs/global_products/financial_document_v1.md +0 -615
- data/docs/global_products/international_id_v2.md +0 -264
- data/docs/global_products/invoice_splitter_v1.md +0 -127
- data/docs/global_products/invoices_v4.md +0 -576
- data/docs/global_products/multi_receipts_detector_v1.md +0 -131
- data/docs/global_products/nutrition_facts_v1.md +0 -399
- data/docs/global_products/passport_v1.md +0 -207
- data/docs/global_products/resume_v1.md +0 -384
- data/docs/global_products/universal.md +0 -113
- data/docs/global_products.md +0 -6
- data/docs/loading_a_document.md +0 -330
- data/docs/localized_products/bank_account_details_v2.md +0 -158
- data/docs/localized_products/bank_check_v1.md +0 -205
- data/docs/localized_products/bank_statement_fr_v2.md +0 -269
- data/docs/localized_products/carte_grise_v1.md +0 -475
- data/docs/localized_products/energy_bill_fra_v1.md +0 -342
- data/docs/localized_products/french_healthcard_v1.md +0 -142
- data/docs/localized_products/idcard_fr_v2.md +0 -284
- data/docs/localized_products/ind_passport_v1.md +0 -307
- data/docs/localized_products/payslip_fra_v3.md +0 -344
- data/docs/localized_products/us_healthcare_cards_v1.md +0 -258
- data/docs/localized_products/us_mail_v3.md +0 -152
- data/docs/localized_products.md +0 -6
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Business Card
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-business-card-ocr
|
|
5
|
-
parentDoc: 67b49df15b843f3fa9cd622b
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Business Card API](https://platform.mindee.com/mindee/business_card).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> 📝 Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `business_card` |
|
|
15
|
-
> | Recommended Version | `v1.0` |
|
|
16
|
-
> | Supports Polling/Webhooks | ✔️ Yes |
|
|
17
|
-
> | Support Synchronous HTTP Calls | ❌ No |
|
|
18
|
-
> | Geography | 🌐 Global |
|
|
19
|
-
|
|
20
|
-
> 🔐 Polling Limitations
|
|
21
|
-
>
|
|
22
|
-
> | Setting | Parameter name | Default Value |
|
|
23
|
-
> | ------------------------------- | ----------------------- | ------------- |
|
|
24
|
-
> | Initial Delay Before Polling | `initial_delay_seconds` | 2 seconds |
|
|
25
|
-
> | Default Delay Between Calls | `delay_sec` | 1.5 seconds |
|
|
26
|
-
> | Polling Attempts Before Timeout | `max_retries` | 80 retries |
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg),
|
|
30
|
-
we are going to illustrate how to extract the data that we want using the Ruby Client Library.
|
|
31
|
-

|
|
32
|
-
|
|
33
|
-
# Quick-Start
|
|
34
|
-
```rb
|
|
35
|
-
#
|
|
36
|
-
# Install the Ruby client library by running:
|
|
37
|
-
# gem install mindee
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
require 'mindee'
|
|
41
|
-
|
|
42
|
-
# Init a new client
|
|
43
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
|
44
|
-
|
|
45
|
-
# Load a file from disk
|
|
46
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
|
47
|
-
|
|
48
|
-
# Parse the file
|
|
49
|
-
result = mindee_client.parse(
|
|
50
|
-
input_source,
|
|
51
|
-
Mindee::Product::BusinessCard::BusinessCardV1
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
# Print a full summary of the parsed data in RST format
|
|
55
|
-
puts result.document
|
|
56
|
-
|
|
57
|
-
# Print the document-level parsed data
|
|
58
|
-
# puts result.document.inference.prediction
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Output (RST):**
|
|
62
|
-
```rst
|
|
63
|
-
########
|
|
64
|
-
Document
|
|
65
|
-
########
|
|
66
|
-
:Mindee ID: 6f9a261f-7609-4687-9af0-46a45156566e
|
|
67
|
-
:Filename: default_sample.jpg
|
|
68
|
-
|
|
69
|
-
Inference
|
|
70
|
-
#########
|
|
71
|
-
:Product: mindee/business_card v1.0
|
|
72
|
-
:Rotation applied: Yes
|
|
73
|
-
|
|
74
|
-
Prediction
|
|
75
|
-
==========
|
|
76
|
-
:Firstname: Andrew
|
|
77
|
-
:Lastname: Morin
|
|
78
|
-
:Job Title: Founder & CEO
|
|
79
|
-
:Company: RemoteGlobal
|
|
80
|
-
:Email: amorin@remoteglobalconsulting.com
|
|
81
|
-
:Phone Number: +14015555555
|
|
82
|
-
:Mobile Number: +13015555555
|
|
83
|
-
:Fax Number: +14015555556
|
|
84
|
-
:Address: 178 Main Avenue, Providence, RI 02111
|
|
85
|
-
:Website: www.remoteglobalconsulting.com
|
|
86
|
-
:Social Media: https://www.linkedin.com/in/johndoe
|
|
87
|
-
https://twitter.com/johndoe
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
# Field Types
|
|
91
|
-
## Standard Fields
|
|
92
|
-
These fields are generic and used in several products.
|
|
93
|
-
|
|
94
|
-
### Basic Field
|
|
95
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
96
|
-
A typical `Field` object will have the following attributes:
|
|
97
|
-
|
|
98
|
-
* **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
99
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
100
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
101
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
102
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
|
103
|
-
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
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.
|
|
107
|
-
|
|
108
|
-
### String Field
|
|
109
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
110
|
-
|
|
111
|
-
# Attributes
|
|
112
|
-
The following fields are extracted for Business Card V1:
|
|
113
|
-
|
|
114
|
-
## Address
|
|
115
|
-
**address** ([StringField](#string-field)): The address of the person.
|
|
116
|
-
|
|
117
|
-
```rb
|
|
118
|
-
puts result.document.inference.prediction.address.value
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Company
|
|
122
|
-
**company** ([StringField](#string-field)): The company the person works for.
|
|
123
|
-
|
|
124
|
-
```rb
|
|
125
|
-
puts result.document.inference.prediction.company.value
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Email
|
|
129
|
-
**email** ([StringField](#string-field)): The email address of the person.
|
|
130
|
-
|
|
131
|
-
```rb
|
|
132
|
-
puts result.document.inference.prediction.email.value
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Fax Number
|
|
136
|
-
**fax_number** ([StringField](#string-field)): The Fax number of the person.
|
|
137
|
-
|
|
138
|
-
```rb
|
|
139
|
-
puts result.document.inference.prediction.fax_number.value
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Firstname
|
|
143
|
-
**firstname** ([StringField](#string-field)): The given name of the person.
|
|
144
|
-
|
|
145
|
-
```rb
|
|
146
|
-
puts result.document.inference.prediction.firstname.value
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Job Title
|
|
150
|
-
**job_title** ([StringField](#string-field)): The job title of the person.
|
|
151
|
-
|
|
152
|
-
```rb
|
|
153
|
-
puts result.document.inference.prediction.job_title.value
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Lastname
|
|
157
|
-
**lastname** ([StringField](#string-field)): The lastname of the person.
|
|
158
|
-
|
|
159
|
-
```rb
|
|
160
|
-
puts result.document.inference.prediction.lastname.value
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Mobile Number
|
|
164
|
-
**mobile_number** ([StringField](#string-field)): The mobile number of the person.
|
|
165
|
-
|
|
166
|
-
```rb
|
|
167
|
-
puts result.document.inference.prediction.mobile_number.value
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## Phone Number
|
|
171
|
-
**phone_number** ([StringField](#string-field)): The phone number of the person.
|
|
172
|
-
|
|
173
|
-
```rb
|
|
174
|
-
puts result.document.inference.prediction.phone_number.value
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Social Media
|
|
178
|
-
**social_media** (Array<[StringField](#string-field)>): The social media profiles of the person or company.
|
|
179
|
-
|
|
180
|
-
```rb
|
|
181
|
-
result.document.inference.prediction.social_media do |social_media_elem|
|
|
182
|
-
puts social_media_elem.value
|
|
183
|
-
end
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Website
|
|
187
|
-
**website** ([StringField](#string-field)): The website of the person or company.
|
|
188
|
-
|
|
189
|
-
```rb
|
|
190
|
-
puts result.document.inference.prediction.website.value
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
# Questions?
|
|
194
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Cropper
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-cropper-ocr
|
|
5
|
-
parentDoc: 67b49df15b843f3fa9cd622b
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Cropper API](https://platform.mindee.com/mindee/cropper).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> 📝 Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `cropper` |
|
|
15
|
-
> | Recommended Version | `v1.1` |
|
|
16
|
-
> | Supports Polling/Webhooks | ❌ No |
|
|
17
|
-
> | Support Synchronous HTTP Calls | ✔️ Yes |
|
|
18
|
-
> | Geography | 🌐 Global |
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/cropper/default_sample.jpg),
|
|
22
|
-
we are going to illustrate how to extract the data that we want using the Ruby Client Library.
|
|
23
|
-

|
|
24
|
-
|
|
25
|
-
# Quick-Start
|
|
26
|
-
```rb
|
|
27
|
-
#
|
|
28
|
-
# Install the Ruby client library by running:
|
|
29
|
-
# gem install mindee
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
require 'mindee'
|
|
33
|
-
|
|
34
|
-
# Init a new client
|
|
35
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
|
36
|
-
|
|
37
|
-
# Load a file from disk
|
|
38
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
|
39
|
-
|
|
40
|
-
# Parse the file
|
|
41
|
-
result = mindee_client.parse(
|
|
42
|
-
input_source,
|
|
43
|
-
Mindee::Product::Cropper::CropperV1
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
# Print a full summary of the parsed data in RST format
|
|
47
|
-
puts result.document
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Output (RST):**
|
|
51
|
-
```rst
|
|
52
|
-
########
|
|
53
|
-
Document
|
|
54
|
-
########
|
|
55
|
-
:Mindee ID: 149ce775-8302-4798-8649-7eda9fb84a1a
|
|
56
|
-
:Filename: default_sample.jpg
|
|
57
|
-
|
|
58
|
-
Inference
|
|
59
|
-
#########
|
|
60
|
-
:Product: mindee/cropper v1.0
|
|
61
|
-
:Rotation applied: No
|
|
62
|
-
|
|
63
|
-
Prediction
|
|
64
|
-
==========
|
|
65
|
-
|
|
66
|
-
Page Predictions
|
|
67
|
-
================
|
|
68
|
-
|
|
69
|
-
Page 0
|
|
70
|
-
------
|
|
71
|
-
:Document Cropper: Polygon with 26 points.
|
|
72
|
-
Polygon with 25 points.
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
# Field Types
|
|
76
|
-
## Standard Fields
|
|
77
|
-
These fields are generic and used in several products.
|
|
78
|
-
|
|
79
|
-
### Basic Field
|
|
80
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
81
|
-
A typical `Field` object will have the following attributes:
|
|
82
|
-
|
|
83
|
-
* **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
84
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
85
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
86
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
87
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
|
88
|
-
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
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.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
### Position Field
|
|
95
|
-
The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**,
|
|
96
|
-
**polygon** and **page_id**. On top of these, it has access to:
|
|
97
|
-
|
|
98
|
-
* **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond
|
|
99
|
-
canvas).
|
|
100
|
-
* **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
|
|
101
|
-
|
|
102
|
-
## Page-Level Fields
|
|
103
|
-
Some fields are constrained to the page level, and so will not be retrievable at document level.
|
|
104
|
-
|
|
105
|
-
# Attributes
|
|
106
|
-
The following fields are extracted for Cropper V1:
|
|
107
|
-
|
|
108
|
-
## Document Cropper
|
|
109
|
-
[📄](#page-level-fields "This field is only present on individual pages.")**cropping** (Array<[PositionField](#position-field)>): List of documents found in the image.
|
|
110
|
-
|
|
111
|
-
```rb
|
|
112
|
-
result.document.inference.pages do |page|
|
|
113
|
-
page.prediction.cropping do |cropping_elem|
|
|
114
|
-
puts cropping_elem.polygon.to_s
|
|
115
|
-
puts cropping_elem.quadrangle.to_s
|
|
116
|
-
puts cropping_elem.rectangle.to_s
|
|
117
|
-
puts cropping_elem.boundingBox.to_s
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
# Questions?
|
|
123
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Delivery note
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-delivery-note-ocr
|
|
5
|
-
parentDoc: 67b49df15b843f3fa9cd622b
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Delivery note API](https://platform.mindee.com/mindee/delivery_notes).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> 📝 Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `delivery_notes` |
|
|
15
|
-
> | Recommended Version | `v1.2` |
|
|
16
|
-
> | Supports Polling/Webhooks | ✔️ Yes |
|
|
17
|
-
> | Support Synchronous HTTP Calls | ❌ No |
|
|
18
|
-
> | Geography | 🌐 Global |
|
|
19
|
-
|
|
20
|
-
> 🔐 Polling Limitations
|
|
21
|
-
>
|
|
22
|
-
> | Setting | Parameter name | Default Value |
|
|
23
|
-
> | ------------------------------- | ----------------------- | ------------- |
|
|
24
|
-
> | Initial Delay Before Polling | `initial_delay_seconds` | 2 seconds |
|
|
25
|
-
> | Default Delay Between Calls | `delay_sec` | 1.5 seconds |
|
|
26
|
-
> | Polling Attempts Before Timeout | `max_retries` | 80 retries |
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/delivery_notes/default_sample.jpg),
|
|
30
|
-
we are going to illustrate how to extract the data that we want using the Ruby Client Library.
|
|
31
|
-

|
|
32
|
-
|
|
33
|
-
# Quick-Start
|
|
34
|
-
```rb
|
|
35
|
-
#
|
|
36
|
-
# Install the Ruby client library by running:
|
|
37
|
-
# gem install mindee
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
require 'mindee'
|
|
41
|
-
|
|
42
|
-
# Init a new client
|
|
43
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
|
44
|
-
|
|
45
|
-
# Load a file from disk
|
|
46
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
|
47
|
-
|
|
48
|
-
# Parse the file
|
|
49
|
-
result = mindee_client.parse(
|
|
50
|
-
input_source,
|
|
51
|
-
Mindee::Product::DeliveryNote::DeliveryNoteV1
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
# Print a full summary of the parsed data in RST format
|
|
55
|
-
puts result.document
|
|
56
|
-
|
|
57
|
-
# Print the document-level parsed data
|
|
58
|
-
# puts result.document.inference.prediction
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Output (RST):**
|
|
62
|
-
```rst
|
|
63
|
-
########
|
|
64
|
-
Document
|
|
65
|
-
########
|
|
66
|
-
:Mindee ID: d5ead821-edec-4d31-a69a-cf3998d9a506
|
|
67
|
-
:Filename: default_sample.jpg
|
|
68
|
-
|
|
69
|
-
Inference
|
|
70
|
-
#########
|
|
71
|
-
:Product: mindee/delivery_notes v1.0
|
|
72
|
-
:Rotation applied: Yes
|
|
73
|
-
|
|
74
|
-
Prediction
|
|
75
|
-
==========
|
|
76
|
-
:Delivery Date: 2019-10-02
|
|
77
|
-
:Delivery Number: INT-001
|
|
78
|
-
:Supplier Name: John Smith
|
|
79
|
-
:Supplier Address: 4490 Oak Drive, Albany, NY 12210
|
|
80
|
-
:Customer Name: Jessie M Horne
|
|
81
|
-
:Customer Address: 4312 Wood Road, New York, NY 10031
|
|
82
|
-
:Total Amount: 204.75
|
|
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`, `bool`): 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** (`bool`): 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
|
-
|
|
104
|
-
### Amount Field
|
|
105
|
-
The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
|
|
106
|
-
|
|
107
|
-
### Date Field
|
|
108
|
-
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
|
109
|
-
|
|
110
|
-
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
|
111
|
-
|
|
112
|
-
### String Field
|
|
113
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
114
|
-
|
|
115
|
-
# Attributes
|
|
116
|
-
The following fields are extracted for Delivery note V1:
|
|
117
|
-
|
|
118
|
-
## Customer Address
|
|
119
|
-
**customer_address** ([StringField](#string-field)): The address of the customer receiving the goods.
|
|
120
|
-
|
|
121
|
-
```rb
|
|
122
|
-
puts result.document.inference.prediction.customer_address.value
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## Customer Name
|
|
126
|
-
**customer_name** ([StringField](#string-field)): The name of the customer receiving the goods.
|
|
127
|
-
|
|
128
|
-
```rb
|
|
129
|
-
puts result.document.inference.prediction.customer_name.value
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Delivery Date
|
|
133
|
-
**delivery_date** ([DateField](#date-field)): The date on which the delivery is scheduled to arrive.
|
|
134
|
-
|
|
135
|
-
```rb
|
|
136
|
-
puts result.document.inference.prediction.delivery_date.value
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Delivery Number
|
|
140
|
-
**delivery_number** ([StringField](#string-field)): A unique identifier for the delivery note.
|
|
141
|
-
|
|
142
|
-
```rb
|
|
143
|
-
puts result.document.inference.prediction.delivery_number.value
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Supplier Address
|
|
147
|
-
**supplier_address** ([StringField](#string-field)): The address of the supplier providing the goods.
|
|
148
|
-
|
|
149
|
-
```rb
|
|
150
|
-
puts result.document.inference.prediction.supplier_address.value
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Supplier Name
|
|
154
|
-
**supplier_name** ([StringField](#string-field)): The name of the supplier providing the goods.
|
|
155
|
-
|
|
156
|
-
```rb
|
|
157
|
-
puts result.document.inference.prediction.supplier_name.value
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Total Amount
|
|
161
|
-
**total_amount** ([AmountField](#amount-field)): The total monetary value of the goods being delivered.
|
|
162
|
-
|
|
163
|
-
```rb
|
|
164
|
-
puts result.document.inference.prediction.total_amount.value
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
# Questions?
|
|
168
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Driver License
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-driver-license-ocr
|
|
5
|
-
parentDoc: 67b49df15b843f3fa9cd622b
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Driver License API](https://platform.mindee.com/mindee/driver_license).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> 📝 Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `driver_license` |
|
|
15
|
-
> | Recommended Version | `v1.0` |
|
|
16
|
-
> | Supports Polling/Webhooks | ✔️ Yes |
|
|
17
|
-
> | Support Synchronous HTTP Calls | ❌ No |
|
|
18
|
-
> | Geography | 🌐 Global |
|
|
19
|
-
|
|
20
|
-
> 🔐 Polling Limitations
|
|
21
|
-
>
|
|
22
|
-
> | Setting | Parameter name | Default Value |
|
|
23
|
-
> | ------------------------------- | ----------------------- | ------------- |
|
|
24
|
-
> | Initial Delay Before Polling | `initial_delay_seconds` | 2 seconds |
|
|
25
|
-
> | Default Delay Between Calls | `delay_sec` | 1.5 seconds |
|
|
26
|
-
> | Polling Attempts Before Timeout | `max_retries` | 80 retries |
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/driver_license/default_sample.jpg),
|
|
30
|
-
we are going to illustrate how to extract the data that we want using the Ruby Client Library.
|
|
31
|
-

|
|
32
|
-
|
|
33
|
-
# Quick-Start
|
|
34
|
-
```rb
|
|
35
|
-
#
|
|
36
|
-
# Install the Ruby client library by running:
|
|
37
|
-
# gem install mindee
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
require 'mindee'
|
|
41
|
-
|
|
42
|
-
# Init a new client
|
|
43
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
|
44
|
-
|
|
45
|
-
# Load a file from disk
|
|
46
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
|
47
|
-
|
|
48
|
-
# Parse the file
|
|
49
|
-
result = mindee_client.parse(
|
|
50
|
-
input_source,
|
|
51
|
-
Mindee::Product::DriverLicense::DriverLicenseV1
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
# Print a full summary of the parsed data in RST format
|
|
55
|
-
puts result.document
|
|
56
|
-
|
|
57
|
-
# Print the document-level parsed data
|
|
58
|
-
# puts result.document.inference.prediction
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Output (RST):**
|
|
62
|
-
```rst
|
|
63
|
-
########
|
|
64
|
-
Document
|
|
65
|
-
########
|
|
66
|
-
:Mindee ID: fbdeae38-ada3-43ac-aa58-e01a3d47e474
|
|
67
|
-
:Filename: default_sample.jpg
|
|
68
|
-
|
|
69
|
-
Inference
|
|
70
|
-
#########
|
|
71
|
-
:Product: mindee/driver_license v1.0
|
|
72
|
-
:Rotation applied: Yes
|
|
73
|
-
|
|
74
|
-
Prediction
|
|
75
|
-
==========
|
|
76
|
-
:Country Code: USA
|
|
77
|
-
:State: AZ
|
|
78
|
-
:ID: D12345678
|
|
79
|
-
:Category: D
|
|
80
|
-
:Last Name: Sample
|
|
81
|
-
:First Name: Jelani
|
|
82
|
-
:Date of Birth: 1957-02-01
|
|
83
|
-
:Place of Birth:
|
|
84
|
-
:Expiry Date: 2018-02-01
|
|
85
|
-
:Issued Date: 2013-01-10
|
|
86
|
-
:Issuing Authority:
|
|
87
|
-
:MRZ:
|
|
88
|
-
:DD Number: DD1234567890123456
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
# Field Types
|
|
92
|
-
## Standard Fields
|
|
93
|
-
These fields are generic and used in several products.
|
|
94
|
-
|
|
95
|
-
### Basic Field
|
|
96
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
97
|
-
A typical `Field` object will have the following attributes:
|
|
98
|
-
|
|
99
|
-
* **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
100
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
101
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
102
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
103
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
|
104
|
-
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
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.
|
|
108
|
-
|
|
109
|
-
### Date Field
|
|
110
|
-
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
|
111
|
-
|
|
112
|
-
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
|
113
|
-
|
|
114
|
-
### String Field
|
|
115
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
116
|
-
|
|
117
|
-
# Attributes
|
|
118
|
-
The following fields are extracted for Driver License V1:
|
|
119
|
-
|
|
120
|
-
## Category
|
|
121
|
-
**category** ([StringField](#string-field)): The category or class of the driver license.
|
|
122
|
-
|
|
123
|
-
```rb
|
|
124
|
-
puts result.document.inference.prediction.category.value
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Country Code
|
|
128
|
-
**country_code** ([StringField](#string-field)): The alpha-3 ISO 3166 code of the country where the driver license was issued.
|
|
129
|
-
|
|
130
|
-
```rb
|
|
131
|
-
puts result.document.inference.prediction.country_code.value
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Date of Birth
|
|
135
|
-
**date_of_birth** ([DateField](#date-field)): The date of birth of the driver license holder.
|
|
136
|
-
|
|
137
|
-
```rb
|
|
138
|
-
puts result.document.inference.prediction.date_of_birth.value
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## DD Number
|
|
142
|
-
**dd_number** ([StringField](#string-field)): The DD number of the driver license.
|
|
143
|
-
|
|
144
|
-
```rb
|
|
145
|
-
puts result.document.inference.prediction.dd_number.value
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Expiry Date
|
|
149
|
-
**expiry_date** ([DateField](#date-field)): The expiry date of the driver license.
|
|
150
|
-
|
|
151
|
-
```rb
|
|
152
|
-
puts result.document.inference.prediction.expiry_date.value
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## First Name
|
|
156
|
-
**first_name** ([StringField](#string-field)): The first name of the driver license holder.
|
|
157
|
-
|
|
158
|
-
```rb
|
|
159
|
-
puts result.document.inference.prediction.first_name.value
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## ID
|
|
163
|
-
**id** ([StringField](#string-field)): The unique identifier of the driver license.
|
|
164
|
-
|
|
165
|
-
```rb
|
|
166
|
-
puts result.document.inference.prediction.id.value
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Issued Date
|
|
170
|
-
**issued_date** ([DateField](#date-field)): The date when the driver license was issued.
|
|
171
|
-
|
|
172
|
-
```rb
|
|
173
|
-
puts result.document.inference.prediction.issued_date.value
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Issuing Authority
|
|
177
|
-
**issuing_authority** ([StringField](#string-field)): The authority that issued the driver license.
|
|
178
|
-
|
|
179
|
-
```rb
|
|
180
|
-
puts result.document.inference.prediction.issuing_authority.value
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## Last Name
|
|
184
|
-
**last_name** ([StringField](#string-field)): The 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)): The Machine Readable Zone (MRZ) of the driver license.
|
|
192
|
-
|
|
193
|
-
```rb
|
|
194
|
-
puts result.document.inference.prediction.mrz.value
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Place of Birth
|
|
198
|
-
**place_of_birth** ([StringField](#string-field)): The place of birth of the driver license holder.
|
|
199
|
-
|
|
200
|
-
```rb
|
|
201
|
-
puts result.document.inference.prediction.place_of_birth.value
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## State
|
|
205
|
-
**state** ([StringField](#string-field)): Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
|
|
206
|
-
|
|
207
|
-
```rb
|
|
208
|
-
puts result.document.inference.prediction.state.value
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
# Questions?
|
|
212
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|