FR Carte Vitale OCR Java
The Java OCR SDK supports the Carte Vitale API.
Using the sample below, we are going to illustrate how to extract the data that we want using the OCR SDK.
Quick-Start
import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.common.PredictResponse;
import com.mindee.product.fr.cartevitale.CarteVitaleV1;
import java.io.File;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException {
String apiKey = "my-api-key";
String filePath = "/path/to/the/file.ext";
// Init a new client
MindeeClient mindeeClient = new MindeeClient(apiKey);
// Load a file from disk
LocalInputSource inputSource = new LocalInputSource(filePath);
// Parse the file
PredictResponse<CarteVitaleV1> response = mindeeClient.parse(
CarteVitaleV1.class,
inputSource
);
// Print a summary of the response
System.out.println(response.toString());
// Print a summary of the predictions
// System.out.println(response.getDocument().toString());
// Print the document-level predictions
// System.out.println(response.getDocument().getInference().getPrediction().toString());
// Print the page-level predictions
// response.getDocument().getInference().getPages().forEach(
// page -> System.out.println(page.toString())
// );
}
}
Output (RST):
########
Document
########
:Mindee ID: 8c25cc63-212b-4537-9c9b-3fbd3bd0ee20
:Filename: default_sample.jpg
Inference
#########
:Product: mindee/carte_vitale v1.0
:Rotation applied: Yes
Prediction
==========
:Given Name(s): NATHALIE
:Surname: DURAND
:Social Security Number: 269054958815780
:Issuance Date: 2007-01-01
Page Predictions
================
Page 0
------
:Given Name(s): NATHALIE
:Surname: DURAND
:Social Security Number: 269054958815780
:Issuance Date: 2007-01-01
Field Types
Standard Fields
These fields are generic and used in several products.
BaseField
Each prediction object contains a set of fields that inherit from the generic BaseField
class.
A typical BaseField
object will have the following attributes:
- confidence (
Double
): the confidence score of the field prediction. - boundingBox (
Polygon
): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. - polygon (
Polygon
): contains the relative vertices coordinates (polygon
extendsList<Point>
) of a polygon containing the field in the image. - pageId (
Integer
): the ID of the page, alwaysnull
when at document-level.
Note: A
Point
simply refers to a List ofDouble
.
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.
StringField
The text field StringField
extends BaseField
, but also implements:
- value (
String
): corresponds to the field value. - rawValue (
String
): corresponds to the raw value as it appears on the document.
DateField
The date field DateField
extends BaseField
, but also implements:
- value (
LocalDate
): an accessible representation of the value as a Java object. Can benull
.
Attributes
The following fields are extracted for Carte Vitale V1:
Given Name(s)
givenNames: The given name(s) of the card holder.
for (givenNamesElem : result.getDocument().getInference().getPrediction().getGivenNames())
{
System.out.println(givenNamesElem.value);
}
Issuance Date
issuanceDate: The date the card was issued.
System.out.println(result.getDocument().getInference().getPrediction().getIssuanceDate().value);
Social Security Number
socialSecurity: The Social Security Number (Numéro de Sécurité Sociale) of the card holder
System.out.println(result.getDocument().getInference().getPrediction().getSocialSecurity().value);
Surname
surname: The surname of the card holder.
System.out.println(result.getDocument().getInference().getPrediction().getSurname().value);
Questions?
Updated 4 months ago