Skip to content

Commit 868eb2b

Browse files
✨ add support for business cards, delivery notes, indian passport & update resume & invoice
1 parent 3673f76 commit 868eb2b

23 files changed

+1422
-17
lines changed

docs/business_card_v1.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: Business Card OCR Java
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: java-business-card-ocr
5+
parentDoc: 631a062c3718850f3519b793
6+
---
7+
The Java OCR SDK supports the [Business Card API](https://platform.mindee.com/mindee/business_card).
8+
9+
The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg) can be used for testing purposes.
10+
![Business Card sample](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg?raw=true)
11+
12+
# Quick-Start
13+
```java
14+
import com.mindee.MindeeClient;
15+
import com.mindee.input.LocalInputSource;
16+
import com.mindee.parsing.common.AsyncPredictResponse;
17+
import com.mindee.product.businesscard.BusinessCardV1;
18+
import java.io.File;
19+
import java.io.IOException;
20+
21+
public class SimpleMindeeClient {
22+
23+
public static void main(String[] args) throws IOException, InterruptedException {
24+
String apiKey = "my-api-key";
25+
String filePath = "/path/to/the/file.ext";
26+
27+
// Init a new client
28+
MindeeClient mindeeClient = new MindeeClient(apiKey);
29+
30+
// Load a file from disk
31+
LocalInputSource inputSource = new LocalInputSource(new File(filePath));
32+
33+
// Parse the file asynchronously
34+
AsyncPredictResponse<BusinessCardV1> response = mindeeClient.enqueueAndParse(
35+
BusinessCardV1.class,
36+
inputSource
37+
);
38+
39+
// Print a summary of the response
40+
System.out.println(response.toString());
41+
42+
// Print a summary of the predictions
43+
// System.out.println(response.getDocumentObj().toString());
44+
45+
// Print the document-level predictions
46+
// System.out.println(response.getDocumentObj().getInference().getPrediction().toString());
47+
48+
// Print the page-level predictions
49+
// response.getDocumentObj().getInference().getPages().forEach(
50+
// page -> System.out.println(page.toString())
51+
// );
52+
}
53+
54+
}
55+
56+
```
57+
# Field Types
58+
## Standard Fields
59+
These fields are generic and used in several products.
60+
61+
### BaseField
62+
Each prediction object contains a set of fields that inherit from the generic `BaseField` class.
63+
A typical `BaseField` object will have the following attributes:
64+
65+
* **confidence** (`Double`): the confidence score of the field prediction.
66+
* **boundingBox** (`Polygon`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
67+
* **polygon** (`Polygon`): contains the relative vertices coordinates (`polygon` extends `List<Point>`) of a polygon containing the field in the image.
68+
* **pageId** (`Integer`): the ID of the page, always `null` when at document-level.
69+
70+
> **Note:** A `Point` simply refers to a List of `Double`.
71+
72+
73+
Aside from the previous attributes, all basic fields have access to a custom `toString` method that can be used to print their value as a string.
74+
75+
### StringField
76+
The text field `StringField` extends `BaseField`, but also implements:
77+
* **value** (`String`): corresponds to the field value.
78+
* **rawValue** (`String`): corresponds to the raw value as it appears on the document.
79+
80+
# Attributes
81+
The following fields are extracted for Business Card V1:
82+
83+
## Address
84+
**address**: The address of the person.
85+
86+
```java
87+
System.out.println(result.getDocument().getInference().getPrediction().getAddress().value);
88+
```
89+
90+
## Company
91+
**company**: The company the person works for.
92+
93+
```java
94+
System.out.println(result.getDocument().getInference().getPrediction().getCompany().value);
95+
```
96+
97+
## Email
98+
**email**: The email address of the person.
99+
100+
```java
101+
System.out.println(result.getDocument().getInference().getPrediction().getEmail().value);
102+
```
103+
104+
## Fax Number
105+
**faxNumber**: The Fax number of the person.
106+
107+
```java
108+
System.out.println(result.getDocument().getInference().getPrediction().getFaxNumber().value);
109+
```
110+
111+
## Firstname
112+
**firstname**: The given name of the person.
113+
114+
```java
115+
System.out.println(result.getDocument().getInference().getPrediction().getFirstname().value);
116+
```
117+
118+
## Job Title
119+
**jobTitle**: The job title of the person.
120+
121+
```java
122+
System.out.println(result.getDocument().getInference().getPrediction().getJobTitle().value);
123+
```
124+
125+
## Lastname
126+
**lastname**: The lastname of the person.
127+
128+
```java
129+
System.out.println(result.getDocument().getInference().getPrediction().getLastname().value);
130+
```
131+
132+
## Mobile Number
133+
**mobileNumber**: The mobile number of the person.
134+
135+
```java
136+
System.out.println(result.getDocument().getInference().getPrediction().getMobileNumber().value);
137+
```
138+
139+
## Phone Number
140+
**phoneNumber**: The phone number of the person.
141+
142+
```java
143+
System.out.println(result.getDocument().getInference().getPrediction().getPhoneNumber().value);
144+
```
145+
146+
## Social Media
147+
**socialMedia**: The social media profiles of the person or company.
148+
149+
```java
150+
for (socialMediaElem : result.getDocument().getInference().getPrediction().getSocialMedia())
151+
{
152+
System.out.println(socialMediaElem.value);
153+
}
154+
```
155+
156+
## Website
157+
**website**: The website of the person or company.
158+
159+
```java
160+
System.out.println(result.getDocument().getInference().getPrediction().getWebsite().value);
161+
```
162+
163+
# Questions?
164+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import com.mindee.MindeeClient;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.parsing.common.AsyncPredictResponse;
4+
import com.mindee.product.businesscard.BusinessCardV1;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class SimpleMindeeClient {
9+
10+
public static void main(String[] args) throws IOException, InterruptedException {
11+
String apiKey = "my-api-key";
12+
String filePath = "/path/to/the/file.ext";
13+
14+
// Init a new client
15+
MindeeClient mindeeClient = new MindeeClient(apiKey);
16+
17+
// Load a file from disk
18+
LocalInputSource inputSource = new LocalInputSource(new File(filePath));
19+
20+
// Parse the file asynchronously
21+
AsyncPredictResponse<BusinessCardV1> response = mindeeClient.enqueueAndParse(
22+
BusinessCardV1.class,
23+
inputSource
24+
);
25+
26+
// Print a summary of the response
27+
System.out.println(response.toString());
28+
29+
// Print a summary of the predictions
30+
// System.out.println(response.getDocumentObj().toString());
31+
32+
// Print the document-level predictions
33+
// System.out.println(response.getDocumentObj().getInference().getPrediction().toString());
34+
35+
// Print the page-level predictions
36+
// response.getDocumentObj().getInference().getPages().forEach(
37+
// page -> System.out.println(page.toString())
38+
// );
39+
}
40+
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import com.mindee.MindeeClient;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.parsing.common.AsyncPredictResponse;
4+
import com.mindee.product.deliverynote.DeliveryNoteV1;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class SimpleMindeeClient {
9+
10+
public static void main(String[] args) throws IOException, InterruptedException {
11+
String apiKey = "my-api-key";
12+
String filePath = "/path/to/the/file.ext";
13+
14+
// Init a new client
15+
MindeeClient mindeeClient = new MindeeClient(apiKey);
16+
17+
// Load a file from disk
18+
LocalInputSource inputSource = new LocalInputSource(new File(filePath));
19+
20+
// Parse the file asynchronously
21+
AsyncPredictResponse<DeliveryNoteV1> response = mindeeClient.enqueueAndParse(
22+
DeliveryNoteV1.class,
23+
inputSource
24+
);
25+
26+
// Print a summary of the response
27+
System.out.println(response.toString());
28+
29+
// Print a summary of the predictions
30+
// System.out.println(response.getDocumentObj().toString());
31+
32+
// Print the document-level predictions
33+
// System.out.println(response.getDocumentObj().getInference().getPrediction().toString());
34+
35+
// Print the page-level predictions
36+
// response.getDocumentObj().getInference().getPages().forEach(
37+
// page -> System.out.println(page.toString())
38+
// );
39+
}
40+
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import com.mindee.MindeeClient;
2+
import com.mindee.input.LocalInputSource;
3+
import com.mindee.parsing.common.AsyncPredictResponse;
4+
import com.mindee.product.ind.passport.PassportV1;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class SimpleMindeeClient {
9+
10+
public static void main(String[] args) throws IOException, InterruptedException {
11+
String apiKey = "my-api-key";
12+
String filePath = "/path/to/the/file.ext";
13+
14+
// Init a new client
15+
MindeeClient mindeeClient = new MindeeClient(apiKey);
16+
17+
// Load a file from disk
18+
LocalInputSource inputSource = new LocalInputSource(new File(filePath));
19+
20+
// Parse the file asynchronously
21+
AsyncPredictResponse<PassportV1> response = mindeeClient.enqueueAndParse(
22+
PassportV1.class,
23+
inputSource
24+
);
25+
26+
// Print a summary of the response
27+
System.out.println(response.toString());
28+
29+
// Print a summary of the predictions
30+
// System.out.println(response.getDocumentObj().toString());
31+
32+
// Print the document-level predictions
33+
// System.out.println(response.getDocumentObj().getInference().getPrediction().toString());
34+
35+
// Print the page-level predictions
36+
// response.getDocumentObj().getInference().getPages().forEach(
37+
// page -> System.out.println(page.toString())
38+
// );
39+
}
40+
41+
}

0 commit comments

Comments
 (0)