Skip to content

Commit c6a0c3c

Browse files
restore idcard
1 parent 40021bd commit c6a0c3c

File tree

1 file changed

+263
-0
lines changed

1 file changed

+263
-0
lines changed

docs/extras/guide/idcard_fr_v2.md

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
---
2+
title: FR Carte Nationale d'Identité OCR Python
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: python-fr-carte-nationale-didentite-ocr
5+
parentDoc: 609808f773b0b90051d839de
6+
---
7+
The Python OCR SDK supports the [Carte Nationale d'Identité API](https://platform.mindee.com/mindee/idcard_fr).
8+
9+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/idcard_fr/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
10+
![Carte Nationale d'Identité sample](https://github.com/mindee/client-lib-test-data/blob/main/products/idcard_fr/default_sample.jpg?raw=true)
11+
12+
# Quick-Start
13+
```py
14+
from mindee import Client, PredictResponse, product
15+
16+
# Init a new client
17+
mindee_client = Client(api_key="my-api-key")
18+
19+
# Load a file from disk
20+
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
21+
22+
# Load a file from disk and parse it.
23+
# The endpoint name must be specified since it cannot be determined from the class.
24+
result: PredictResponse = mindee_client.parse(product.fr.IdCardV2, input_doc)
25+
26+
# Print a summary of the API result
27+
print(result.document)
28+
29+
# Print the document-level summary
30+
# print(result.document.inference.prediction)
31+
32+
```
33+
34+
**Output (RST):**
35+
```rst
36+
########
37+
Document
38+
########
39+
:Mindee ID: d33828f1-ef7e-4984-b9df-a2bfaa38a78d
40+
:Filename: default_sample.jpg
41+
42+
Inference
43+
#########
44+
:Product: mindee/idcard_fr v2.0
45+
:Rotation applied: Yes
46+
47+
Prediction
48+
==========
49+
:Nationality:
50+
:Card Access Number: 175775H55790
51+
:Document Number:
52+
:Given Name(s): Victor
53+
Marie
54+
:Surname: DAMBARD
55+
:Alternate Name:
56+
:Date of Birth: 1994-04-24
57+
:Place of Birth: LYON 4E ARRONDISSEM
58+
:Gender: M
59+
:Expiry Date: 2030-04-02
60+
:Mrz Line 1: IDFRADAMBARD<<<<<<<<<<<<<<<<<<075025
61+
:Mrz Line 2: 170775H557903VICTOR<<MARIE<9404246M5
62+
:Mrz Line 3:
63+
:Date of Issue: 2015-04-03
64+
:Issuing Authority: SOUS-PREFECTURE DE BELLE (02)
65+
66+
Page Predictions
67+
================
68+
69+
Page 0
70+
------
71+
:Document Type: OLD
72+
:Document Sides: RECTO & VERSO
73+
:Nationality:
74+
:Card Access Number: 175775H55790
75+
:Document Number:
76+
:Given Name(s): Victor
77+
Marie
78+
:Surname: DAMBARD
79+
:Alternate Name:
80+
:Date of Birth: 1994-04-24
81+
:Place of Birth: LYON 4E ARRONDISSEM
82+
:Gender: M
83+
:Expiry Date: 2030-04-02
84+
:Mrz Line 1: IDFRADAMBARD<<<<<<<<<<<<<<<<<<075025
85+
:Mrz Line 2: 170775H557903VICTOR<<MARIE<9404246M5
86+
:Mrz Line 3:
87+
:Date of Issue: 2015-04-03
88+
:Issuing Authority: SOUS-PREFECTURE DE BELLE (02)
89+
```
90+
91+
# Field Types
92+
## Standard Fields
93+
These fields are generic and used in several products.
94+
95+
### BaseField
96+
Each prediction object contains a set of fields that inherit from the generic `BaseField` class.
97+
A typical `BaseField` object will have the following attributes:
98+
99+
* **value** (`Union[float, str]`): corresponds to the field value. Can be `None` if no value was extracted.
100+
* **confidence** (`float`): the confidence score of the field prediction.
101+
* **bounding_box** (`[Point, Point, Point, Point]`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
102+
* **polygon** (`List[Point]`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
103+
* **page_id** (`int`): the ID of the page, always `None` when at document-level.
104+
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
105+
106+
> **Note:** A `Point` simply refers to a List of two numbers (`[float, float]`).
107+
108+
109+
Aside from the previous attributes, all basic fields have access to a custom `__str__` method that can be used to print their value as a string.
110+
111+
112+
### ClassificationField
113+
The classification field `ClassificationField` does not implement all the basic `BaseField` attributes. It only implements **value**, **confidence** and **page_id**.
114+
115+
> Note: a classification field's `value is always a `str`.
116+
117+
### DateField
118+
Aside from the basic `BaseField` attributes, the date field `DateField` also implements the following:
119+
120+
* **date_object** (`Date`): an accessible representation of the value as a python object. Can be `None`.
121+
122+
### StringField
123+
The text field `StringField` only has one constraint: its **value** is an `Optional[str]`.
124+
125+
## Page-Level Fields
126+
Some fields are constrained to the page level, and so will not be retrievable at document level.
127+
128+
# Attributes
129+
The following fields are extracted for Carte Nationale d'Identité V2:
130+
131+
## Alternate Name
132+
**alternate_name** ([StringField](#stringfield)): The alternate name of the card holder.
133+
134+
```py
135+
print(result.document.inference.prediction.alternate_name.value)
136+
```
137+
138+
## Issuing Authority
139+
**authority** ([StringField](#stringfield)): The name of the issuing authority.
140+
141+
```py
142+
print(result.document.inference.prediction.authority.value)
143+
```
144+
145+
## Date of Birth
146+
**birth_date** ([DateField](#datefield)): The date of birth of the card holder.
147+
148+
```py
149+
print(result.document.inference.prediction.birth_date.value)
150+
```
151+
152+
## Place of Birth
153+
**birth_place** ([StringField](#stringfield)): The place of birth of the card holder.
154+
155+
```py
156+
print(result.document.inference.prediction.birth_place.value)
157+
```
158+
159+
## Card Access Number
160+
**card_access_number** ([StringField](#stringfield)): The card access number (CAN).
161+
162+
```py
163+
print(result.document.inference.prediction.card_access_number.value)
164+
```
165+
166+
## Document Number
167+
**document_number** ([StringField](#stringfield)): The document number.
168+
169+
```py
170+
print(result.document.inference.prediction.document_number.value)
171+
```
172+
173+
## Document Sides
174+
[📄](#page-level-fields "This field is only present on individual pages.")**document_side** ([ClassificationField](#classificationfield)): The sides of the document which are visible.
175+
176+
#### Possible values include:
177+
- RECTO
178+
- VERSO
179+
- RECTO & VERSO
180+
181+
```py
182+
for document_side_elem in result.document.document_side:
183+
print(document_side_elem.value)
184+
```
185+
186+
## Document Type
187+
[📄](#page-level-fields "This field is only present on individual pages.")**document_type** ([ClassificationField](#classificationfield)): The document type or format.
188+
189+
#### Possible values include:
190+
- NEW
191+
- OLD
192+
193+
```py
194+
for document_type_elem in result.document.document_type:
195+
print(document_type_elem.value)
196+
```
197+
198+
## Expiry Date
199+
**expiry_date** ([DateField](#datefield)): The expiry date of the identification card.
200+
201+
```py
202+
print(result.document.inference.prediction.expiry_date.value)
203+
```
204+
205+
## Gender
206+
**gender** ([StringField](#stringfield)): The gender of the card holder.
207+
208+
```py
209+
print(result.document.inference.prediction.gender.value)
210+
```
211+
212+
## Given Name(s)
213+
**given_names** (List[[StringField](#stringfield)]): The given name(s) of the card holder.
214+
215+
```py
216+
for given_names_elem in result.document.inference.prediction.given_names:
217+
print(given_names_elem.value)
218+
```
219+
220+
## Date of Issue
221+
**issue_date** ([DateField](#datefield)): The date of issue of the identification card.
222+
223+
```py
224+
print(result.document.inference.prediction.issue_date.value)
225+
```
226+
227+
## Mrz Line 1
228+
**mrz1** ([StringField](#stringfield)): The Machine Readable Zone, first line.
229+
230+
```py
231+
print(result.document.inference.prediction.mrz1.value)
232+
```
233+
234+
## Mrz Line 2
235+
**mrz2** ([StringField](#stringfield)): The Machine Readable Zone, second line.
236+
237+
```py
238+
print(result.document.inference.prediction.mrz2.value)
239+
```
240+
241+
## Mrz Line 3
242+
**mrz3** ([StringField](#stringfield)): The Machine Readable Zone, third line.
243+
244+
```py
245+
print(result.document.inference.prediction.mrz3.value)
246+
```
247+
248+
## Nationality
249+
**nationality** ([StringField](#stringfield)): The nationality of the card holder.
250+
251+
```py
252+
print(result.document.inference.prediction.nationality.value)
253+
```
254+
255+
## Surname
256+
**surname** ([StringField](#stringfield)): The surname of the card holder.
257+
258+
```py
259+
print(result.document.inference.prediction.surname.value)
260+
```
261+
262+
# Questions?
263+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)

0 commit comments

Comments
 (0)