mindee 3.1.1 → 3.3.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/.gitignore +1 -0
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +26 -0
- data/README.md +57 -7
- data/bin/mindee.rb +160 -83
- data/docs/bank_account_details_v2.md +137 -0
- data/docs/bank_check_v1.md +179 -0
- data/docs/barcode_reader_v1.md +104 -0
- data/docs/carte_grise_v1.md +454 -0
- data/docs/carte_vitale_v1.md +123 -0
- data/docs/code_samples/barcode_reader_v1.txt +19 -0
- data/docs/code_samples/carte_grise_v1.txt +19 -0
- data/docs/code_samples/cropper_v1.txt +16 -0
- data/docs/code_samples/idcard_fr_v2.txt +19 -0
- data/docs/code_samples/invoice_splitter_v1_async.txt +6 -54
- data/docs/code_samples/multi_receipts_detector_v1.txt +19 -0
- data/docs/code_samples/us_w9_v1.txt +16 -0
- data/docs/cropper_v1.md +97 -0
- data/docs/custom_v1.md +109 -0
- data/docs/expense_receipts_v5.md +306 -0
- data/docs/financial_document_v1.md +384 -0
- data/docs/{ruby-getting-started.md → getting_started.md} +22 -6
- data/docs/idcard_fr_v2.md +253 -0
- data/docs/invoice_splitter_v1.md +85 -0
- data/docs/invoices_v4.md +338 -0
- data/docs/license_plates_v1.md +91 -0
- data/docs/multi_receipts_detector_v1.md +105 -0
- data/docs/passport_v1.md +186 -0
- data/docs/proof_of_address_v1.md +207 -0
- data/docs/us_driver_license_v1.md +268 -0
- data/docs/us_w9_v1.md +207 -0
- data/lib/mindee/client.rb +95 -16
- data/lib/mindee/geometry/quadrilateral.rb +5 -0
- data/lib/mindee/http/.rubocop.yml +8 -0
- data/lib/mindee/http/endpoint.rb +19 -7
- data/lib/mindee/http/error.rb +104 -0
- data/lib/mindee/http.rb +1 -0
- data/lib/mindee/input/sources.rb +83 -14
- data/lib/mindee/parsing/common/api_response.rb +12 -1
- data/lib/mindee/parsing/common/document.rb +4 -1
- data/lib/mindee/parsing/common/inference.rb +2 -2
- data/lib/mindee/parsing/common/ocr/ocr.rb +1 -0
- data/lib/mindee/parsing/common.rb +0 -1
- data/lib/mindee/parsing/custom/list_field.rb +7 -5
- data/lib/mindee/parsing/standard/base_field.rb +1 -1
- data/lib/mindee/parsing/standard/company_registration_field.rb +1 -1
- data/lib/mindee/parsing/standard/locale_field.rb +1 -1
- data/lib/mindee/parsing/standard/payment_details_field.rb +1 -1
- data/lib/mindee/parsing/standard/position_field.rb +10 -3
- data/lib/mindee/parsing/standard/{text_field.rb → string_field.rb} +1 -1
- data/lib/mindee/parsing/standard.rb +1 -1
- data/lib/mindee/pdf/pdf_processing.rb +2 -1
- data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +37 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +44 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +32 -0
- data/lib/mindee/product/cropper/cropper_v1.rb +37 -0
- data/lib/mindee/product/cropper/cropper_v1_document.rb +13 -0
- data/lib/mindee/product/cropper/cropper_v1_page.rb +49 -0
- data/lib/mindee/product/custom/custom_v1.rb +1 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +1 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +2 -2
- data/lib/mindee/product/financial_document/financial_document_v1.rb +1 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +26 -26
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +1 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +6 -6
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +1 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +6 -6
- data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +39 -0
- data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +235 -0
- data/lib/mindee/product/fr/carte_grise/carte_grise_v1_page.rb +34 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +1 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +6 -6
- data/lib/mindee/product/fr/id_card/id_card_v1.rb +1 -0
- data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +16 -16
- data/lib/mindee/product/fr/id_card/id_card_v2.rb +39 -0
- data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +107 -0
- data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +53 -0
- data/lib/mindee/product/invoice/invoice_v4.rb +2 -2
- data/lib/mindee/product/invoice/invoice_v4_document.rb +115 -155
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +54 -30
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +1 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +5 -3
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +37 -0
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +35 -0
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +32 -0
- data/lib/mindee/product/passport/passport_v1.rb +1 -0
- data/lib/mindee/product/passport/passport_v1_document.rb +16 -16
- data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +1 -0
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +14 -14
- data/lib/mindee/product/receipt/receipt_v4_document.rb +6 -6
- data/lib/mindee/product/receipt/receipt_v5.rb +1 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +12 -12
- data/lib/mindee/product/us/bank_check/bank_check_v1.rb +1 -0
- data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +8 -8
- data/lib/mindee/product/us/driver_license/driver_license_v1.rb +1 -0
- data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +28 -28
- data/lib/mindee/product/us/w9/w9_v1.rb +39 -0
- data/lib/mindee/product/us/w9/w9_v1_document.rb +15 -0
- data/lib/mindee/product/us/w9/w9_v1_page.rb +102 -0
- data/lib/mindee/product.rb +6 -0
- data/lib/mindee/version.rb +5 -1
- data/lib/mindee.rb +45 -1
- metadata +48 -9
- data/docs/ruby-api-builder.md +0 -123
- data/docs/ruby-invoice-ocr.md +0 -271
- data/docs/ruby-passport-ocr.md +0 -165
- data/docs/ruby-receipt-ocr.md +0 -196
- data/lib/mindee/parsing/common/error.rb +0 -24
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: US Bank Check OCR Ruby
|
|
3
|
+
---
|
|
4
|
+
The Ruby OCR SDK supports the [Bank Check API](https://platform.mindee.com/mindee/bank_check).
|
|
5
|
+
|
|
6
|
+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_check/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
|
7
|
+

|
|
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::US::BankCheck::BankCheckV1
|
|
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: b9809586-57ae-4f84-a35d-a85b2be1f2a2
|
|
38
|
+
:Filename: default_sample.jpg
|
|
39
|
+
|
|
40
|
+
Inference
|
|
41
|
+
#########
|
|
42
|
+
:Product: mindee/bank_check v1.0
|
|
43
|
+
:Rotation applied: Yes
|
|
44
|
+
|
|
45
|
+
Prediction
|
|
46
|
+
==========
|
|
47
|
+
:Check Issue Date: 2022-03-29
|
|
48
|
+
:Amount: 15332.90
|
|
49
|
+
:Payees: JOHN DOE
|
|
50
|
+
JANE DOE
|
|
51
|
+
:Routing Number:
|
|
52
|
+
:Account Number: 7789778136
|
|
53
|
+
:Check Number: 0003401
|
|
54
|
+
|
|
55
|
+
Page Predictions
|
|
56
|
+
================
|
|
57
|
+
|
|
58
|
+
Page 0
|
|
59
|
+
------
|
|
60
|
+
:Check Position: Polygon with 21 points.
|
|
61
|
+
:Signature Positions: Polygon with 6 points.
|
|
62
|
+
:Check Issue Date: 2022-03-29
|
|
63
|
+
:Amount: 15332.90
|
|
64
|
+
:Payees: JOHN DOE
|
|
65
|
+
JANE DOE
|
|
66
|
+
:Routing Number:
|
|
67
|
+
:Account Number: 7789778136
|
|
68
|
+
:Check Number: 0003401
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
# Field Types
|
|
72
|
+
## Standard Fields
|
|
73
|
+
These fields are generic and used in several products.
|
|
74
|
+
|
|
75
|
+
### Basic Field
|
|
76
|
+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
77
|
+
A typical `Field` object will have the following attributes:
|
|
78
|
+
|
|
79
|
+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
80
|
+
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
81
|
+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
82
|
+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
83
|
+
* **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
|
|
84
|
+
* **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
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.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Amount Field
|
|
91
|
+
The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
|
|
92
|
+
|
|
93
|
+
### Date Field
|
|
94
|
+
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
|
95
|
+
|
|
96
|
+
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Position Field
|
|
100
|
+
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:
|
|
101
|
+
|
|
102
|
+
* **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
|
|
103
|
+
* **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
|
|
104
|
+
|
|
105
|
+
### String Field
|
|
106
|
+
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
107
|
+
|
|
108
|
+
## Page-Level Fields
|
|
109
|
+
Some fields are constrained to the page level, and so will not be retrievable to through the document.
|
|
110
|
+
|
|
111
|
+
# Attributes
|
|
112
|
+
The following fields are extracted for Bank Check V1:
|
|
113
|
+
|
|
114
|
+
## Account Number
|
|
115
|
+
**account_number** ([StringField](#string-field)): The check payer's account number.
|
|
116
|
+
|
|
117
|
+
```rb
|
|
118
|
+
puts result.document.inference.prediction.account_number.value
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Amount
|
|
122
|
+
**amount** ([AmountField](#amount-field)): The amount of the check.
|
|
123
|
+
|
|
124
|
+
```rb
|
|
125
|
+
puts result.document.inference.prediction.amount.value
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Check Number
|
|
129
|
+
**check_number** ([StringField](#string-field)): The issuer's check number.
|
|
130
|
+
|
|
131
|
+
```rb
|
|
132
|
+
puts result.document.inference.prediction.check_number.value
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Check Position
|
|
136
|
+
[📄](#page-level-fields "This field is only present on individual pages.")**check_position** ([PositionField](#position-field)): The position of the check on the document.
|
|
137
|
+
|
|
138
|
+
```rb
|
|
139
|
+
for check_position_elem in result.document.check_position do
|
|
140
|
+
puts check_position_elem.polygon
|
|
141
|
+
end
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Check Issue Date
|
|
145
|
+
**date** ([DateField](#date-field)): The date the check was issued.
|
|
146
|
+
|
|
147
|
+
```rb
|
|
148
|
+
puts result.document.inference.prediction.date.value
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Payees
|
|
152
|
+
**payees** (Array<[StringField](#string-field)>): List of the check's payees (recipients).
|
|
153
|
+
|
|
154
|
+
```rb
|
|
155
|
+
for payees_elem in result.document.inference.prediction.payees do
|
|
156
|
+
puts payees_elem.value
|
|
157
|
+
end
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Routing Number
|
|
161
|
+
**routing_number** ([StringField](#string-field)): The check issuer's routing number.
|
|
162
|
+
|
|
163
|
+
```rb
|
|
164
|
+
puts result.document.inference.prediction.routing_number.value
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Signature Positions
|
|
168
|
+
[📄](#page-level-fields "This field is only present on individual pages.")**signatures_positions** (Array<[PositionField](#position-field)>): List of signature positions
|
|
169
|
+
|
|
170
|
+
```rb
|
|
171
|
+
for page in result.document.inference.pages do
|
|
172
|
+
for signatures_positions_elem in page.prediction.signatures_positions do
|
|
173
|
+
puts signatures_positions_elem.polygon
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
# Questions?
|
|
179
|
+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Barcode Reader OCR Ruby
|
|
3
|
+
---
|
|
4
|
+
The Ruby OCR SDK supports the [Barcode Reader API](https://platform.mindee.com/mindee/barcode_reader).
|
|
5
|
+
|
|
6
|
+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/barcode_reader/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
|
|
7
|
+

|
|
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::BarcodeReader::BarcodeReaderV1
|
|
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: f9c48da1-a306-4805-8da8-f7231fda2d88
|
|
38
|
+
:Filename: default_sample.jpg
|
|
39
|
+
|
|
40
|
+
Inference
|
|
41
|
+
#########
|
|
42
|
+
:Product: mindee/barcode_reader v1.0
|
|
43
|
+
:Rotation applied: Yes
|
|
44
|
+
|
|
45
|
+
Prediction
|
|
46
|
+
==========
|
|
47
|
+
:Barcodes 1D: Mindee
|
|
48
|
+
:Barcodes 2D: https://developers.mindee.com/docs/barcode-reader-ocr
|
|
49
|
+
I love paperwork! - Said no one ever
|
|
50
|
+
|
|
51
|
+
Page Predictions
|
|
52
|
+
================
|
|
53
|
+
|
|
54
|
+
Page 0
|
|
55
|
+
------
|
|
56
|
+
:Barcodes 1D: Mindee
|
|
57
|
+
:Barcodes 2D: https://developers.mindee.com/docs/barcode-reader-ocr
|
|
58
|
+
I love paperwork! - Said no one ever
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
# Field Types
|
|
62
|
+
## Standard Fields
|
|
63
|
+
These fields are generic and used in several products.
|
|
64
|
+
|
|
65
|
+
### Basic Field
|
|
66
|
+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
67
|
+
A typical `Field` object will have the following attributes:
|
|
68
|
+
|
|
69
|
+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
70
|
+
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
71
|
+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
72
|
+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
73
|
+
* **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
|
|
74
|
+
* **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
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.
|
|
78
|
+
|
|
79
|
+
### String Field
|
|
80
|
+
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
81
|
+
|
|
82
|
+
# Attributes
|
|
83
|
+
The following fields are extracted for Barcode Reader V1:
|
|
84
|
+
|
|
85
|
+
## Barcodes 1D
|
|
86
|
+
**codes_1d** (Array<[StringField](#string-field)>): List of decoded 1D barcodes.
|
|
87
|
+
|
|
88
|
+
```rb
|
|
89
|
+
for codes_1d_elem in result.document.inference.prediction.codes_1d do
|
|
90
|
+
puts codes_1d_elem.value
|
|
91
|
+
end
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Barcodes 2D
|
|
95
|
+
**codes_2d** (Array<[StringField](#string-field)>): List of decoded 2D barcodes.
|
|
96
|
+
|
|
97
|
+
```rb
|
|
98
|
+
for codes_2d_elem in result.document.inference.prediction.codes_2d do
|
|
99
|
+
puts codes_2d_elem.value
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
# Questions?
|
|
104
|
+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
|