mindee 3.1.0 → 3.2.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 +21 -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_vitale_v1.md +123 -0
- data/docs/code_samples/barcode_reader_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 +101 -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 +369 -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 +14 -6
- data/lib/mindee/http/error.rb +104 -0
- data/lib/mindee/http.rb +1 -0
- data/lib/mindee/input/sources.rb +84 -15
- data/lib/mindee/parsing/common/api_response.rb +11 -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/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 +24 -24
- 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_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 +1 -0
- data/lib/mindee/product/invoice/invoice_v4_document.rb +24 -24
- 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 +5 -0
- data/lib/mindee/version.rb +5 -1
- data/lib/mindee.rb +47 -0
- metadata +43 -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 API 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: 0f54c154-5030-41ac-939e-046b7f6aca71
|
|
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)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: FR Carte Vitale OCR Ruby
|
|
3
|
+
---
|
|
4
|
+
The Ruby OCR SDK supports the [Carte Vitale API](https://platform.mindee.com/mindee/carte_vitale).
|
|
5
|
+
|
|
6
|
+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/carte_vitale/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::FR::CarteVitale::CarteVitaleV1
|
|
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: 8c25cc63-212b-4537-9c9b-3fbd3bd0ee20
|
|
38
|
+
:Filename: default_sample.jpg
|
|
39
|
+
|
|
40
|
+
Inference
|
|
41
|
+
#########
|
|
42
|
+
:Product: mindee/carte_vitale v1.0
|
|
43
|
+
:Rotation applied: Yes
|
|
44
|
+
|
|
45
|
+
Prediction
|
|
46
|
+
==========
|
|
47
|
+
:Given Name(s): NATHALIE
|
|
48
|
+
:Surname: DURAND
|
|
49
|
+
:Social Security Number: 269054958815780
|
|
50
|
+
:Issuance Date: 2007-01-01
|
|
51
|
+
|
|
52
|
+
Page Predictions
|
|
53
|
+
================
|
|
54
|
+
|
|
55
|
+
Page 0
|
|
56
|
+
------
|
|
57
|
+
:Given Name(s): NATHALIE
|
|
58
|
+
:Surname: DURAND
|
|
59
|
+
:Social Security Number: 269054958815780
|
|
60
|
+
:Issuance Date: 2007-01-01
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
# Field Types
|
|
64
|
+
## Standard Fields
|
|
65
|
+
These fields are generic and used in several products.
|
|
66
|
+
|
|
67
|
+
### Basic Field
|
|
68
|
+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
69
|
+
A typical `Field` object will have the following attributes:
|
|
70
|
+
|
|
71
|
+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
72
|
+
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
73
|
+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
74
|
+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
75
|
+
* **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
|
|
76
|
+
* **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
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.
|
|
80
|
+
|
|
81
|
+
### Date Field
|
|
82
|
+
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
|
83
|
+
|
|
84
|
+
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
|
85
|
+
|
|
86
|
+
### String Field
|
|
87
|
+
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
88
|
+
|
|
89
|
+
# Attributes
|
|
90
|
+
The following fields are extracted for Carte Vitale V1:
|
|
91
|
+
|
|
92
|
+
## Given Name(s)
|
|
93
|
+
**given_names** (Array<[StringField](#string-field)>): The given name(s) of the card holder.
|
|
94
|
+
|
|
95
|
+
```rb
|
|
96
|
+
for given_names_elem in result.document.inference.prediction.given_names do
|
|
97
|
+
puts given_names_elem.value
|
|
98
|
+
end
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Issuance Date
|
|
102
|
+
**issuance_date** ([DateField](#date-field)): The date the card was issued.
|
|
103
|
+
|
|
104
|
+
```rb
|
|
105
|
+
puts result.document.inference.prediction.issuance_date.value
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Social Security Number
|
|
109
|
+
**social_security** ([StringField](#string-field)): The Social Security Number (Numéro de Sécurité Sociale) of the card holder
|
|
110
|
+
|
|
111
|
+
```rb
|
|
112
|
+
puts result.document.inference.prediction.social_security.value
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Surname
|
|
116
|
+
**surname** ([StringField](#string-field)): The surname of the card holder.
|
|
117
|
+
|
|
118
|
+
```rb
|
|
119
|
+
puts result.document.inference.prediction.surname.value
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
# Questions?
|
|
123
|
+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
|
|
@@ -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::BarcodeReader::BarcodeReaderV1
|
|
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
|
|
@@ -0,0 +1,16 @@
|
|
|
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::Cropper::CropperV1
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Print a full summary of the parsed data in RST format
|
|
16
|
+
puts result.document
|
|
@@ -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::FR::IdCard::IdCardV2
|
|
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
|
|
@@ -6,61 +6,13 @@ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
|
|
6
6
|
# Load a file from disk
|
|
7
7
|
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
doc_class = Mindee::Product::InvoiceSplitter::InvoiceSplitterV1
|
|
11
|
-
|
|
12
|
-
# Limit the amount of API calls to retrieve your document
|
|
13
|
-
MAX_RETRIES = 10
|
|
14
|
-
|
|
15
|
-
# How many seconds to wait in-between tries
|
|
16
|
-
INTERVAL_SECS = 6
|
|
17
|
-
|
|
18
|
-
# Counter to keep track of how many times we try to retrieve the document
|
|
19
|
-
times_tried = 1
|
|
20
|
-
|
|
21
|
-
queue_result = mindee_client.enqueue(
|
|
9
|
+
result = mindee_client.enqueue_and_parse(
|
|
22
10
|
input_source,
|
|
23
|
-
|
|
11
|
+
Mindee::Product::InvoiceSplitter::InvoiceSplitterV1
|
|
24
12
|
)
|
|
25
13
|
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# Recursive function that tries to retrieve the completed document.
|
|
30
|
-
# If the document is not "complete", try again
|
|
31
|
-
def get_doc_from_async_queue(
|
|
32
|
-
queue_id,
|
|
33
|
-
mindee_client,
|
|
34
|
-
doc_class,
|
|
35
|
-
times_tried=0,
|
|
36
|
-
interval_secs=INTERVAL_SECS,
|
|
37
|
-
max_retries=MAX_RETRIES
|
|
38
|
-
)
|
|
39
|
-
# Have we exceeded our retry count?
|
|
40
|
-
if times_tried >= max_retries
|
|
41
|
-
raise "Maximum retries reached #{times_tried}"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Wait for a few seconds before fetching
|
|
45
|
-
sleep interval_secs
|
|
46
|
-
|
|
47
|
-
# Fetch and parse the result, using the same type
|
|
48
|
-
parsed_result = mindee_client.parse_queued(queue_id, doc_class)
|
|
49
|
-
|
|
50
|
-
# Check whether the result is ready
|
|
51
|
-
if parsed_result.job.status == Mindee::Parsing::Common::JobStatus::COMPLETED
|
|
52
|
-
# Print a brief summary of the parsed data
|
|
53
|
-
puts parsed_result.document
|
|
54
|
-
return
|
|
55
|
-
# Otherwise, try again...
|
|
56
|
-
else
|
|
57
|
-
get_doc_from_async_queue(
|
|
58
|
-
queue_id, mindee_client,
|
|
59
|
-
doc_class,
|
|
60
|
-
times_tried+1
|
|
61
|
-
)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
14
|
+
# Print a full summary of the parsed data in RST format
|
|
15
|
+
puts result.document
|
|
64
16
|
|
|
65
|
-
#
|
|
66
|
-
|
|
17
|
+
# Print the document-level parsed data
|
|
18
|
+
# puts result.document.inference.prediction
|
|
@@ -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::MultiReceiptsDetector::MultiReceiptsDetectorV1
|
|
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
|
|
@@ -0,0 +1,16 @@
|
|
|
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::US::W9::W9V1
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Print a full summary of the parsed data in RST format
|
|
16
|
+
puts result.document
|
data/docs/cropper_v1.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cropper API Ruby
|
|
3
|
+
---
|
|
4
|
+
The Ruby OCR SDK supports the [Cropper API](https://platform.mindee.com/mindee/cropper).
|
|
5
|
+
|
|
6
|
+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/cropper/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::Cropper::CropperV1
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Print a full summary of the parsed data in RST format
|
|
26
|
+
puts result.document
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Output (RST):**
|
|
30
|
+
```rst
|
|
31
|
+
########
|
|
32
|
+
Document
|
|
33
|
+
########
|
|
34
|
+
:Mindee ID: 149ce775-8302-4798-8649-7eda9fb84a1a
|
|
35
|
+
:Filename: default_sample.jpg
|
|
36
|
+
|
|
37
|
+
Inference
|
|
38
|
+
#########
|
|
39
|
+
:Product: mindee/cropper v1.0
|
|
40
|
+
:Rotation applied: No
|
|
41
|
+
|
|
42
|
+
Prediction
|
|
43
|
+
==========
|
|
44
|
+
|
|
45
|
+
Page Predictions
|
|
46
|
+
================
|
|
47
|
+
|
|
48
|
+
Page 0
|
|
49
|
+
------
|
|
50
|
+
:Document Cropper: Polygon with 26 points.
|
|
51
|
+
Polygon with 25 points.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
# Field Types
|
|
55
|
+
## Standard Fields
|
|
56
|
+
These fields are generic and used in several products.
|
|
57
|
+
|
|
58
|
+
### Basic Field
|
|
59
|
+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
60
|
+
A typical `Field` object will have the following attributes:
|
|
61
|
+
|
|
62
|
+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
63
|
+
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
64
|
+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
65
|
+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
66
|
+
* **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
|
|
67
|
+
* **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Position Field
|
|
74
|
+
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:
|
|
75
|
+
|
|
76
|
+
* **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
|
|
77
|
+
* **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
|
|
78
|
+
|
|
79
|
+
## Page-Level Fields
|
|
80
|
+
Some fields are constrained to the page level, and so will not be retrievable to through the document.
|
|
81
|
+
|
|
82
|
+
# Attributes
|
|
83
|
+
The following fields are extracted for Cropper V1:
|
|
84
|
+
|
|
85
|
+
## Document Cropper
|
|
86
|
+
[📄](#page-level-fields "This field is only present on individual pages.")**cropping** (Array<[PositionField](#position-field)>): List of documents found in the image.
|
|
87
|
+
|
|
88
|
+
```rb
|
|
89
|
+
for page in result.document.inference.pages do
|
|
90
|
+
for cropping_elem in page.prediction.cropping do
|
|
91
|
+
puts cropping_elem.polygon
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
# Questions?
|
|
97
|
+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
|