OCR Qualities Detector
Qualities detector service for OCR.
Supported qualities:
Blur
This quality check if the image is blur or not.
Key | Description | Type |
---|---|---|
value | Determine whether the image is blur or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "blur" or "not blur" | Float |
confidence_blur | This confidence indicates the certainty of the model when it predicts "blur" | Float |
Example output
1
2
3
4
5
6
7
{
"blur": {
"confidence": 1.0,
"confidence_blur": 1.0,
"value": true
}
}
Dark
This quality check if the image is dark or not. The image is considered dark by the average pixel value of the image.
Key | Description | Type |
---|---|---|
value | Determine whether the image is dark or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "dark" or "not dark" | Float |
confidence_dark | This confidence indicates the certainty of the model when it predicts "dark" | Float |
Example output
1
2
3
4
5
6
7
{
"dark": {
"confidence": 0.9993858337402344,
"confidence_dark": 0.9993858337402344,
"value": true
}
}
Bright
This quality check if the image is bright or not. The bright is determined by the average of the image pixel value.
Key | Description | Type |
---|---|---|
value | Determine whether the image is bright or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "bright" or "not bright" | Float |
confidence_bright | This confidence indicates the certainty of the model when it predicts "bright" | Float |
Example output
1
2
3
4
5
6
7
{
"bright": {
"confidence": 0.9999924898147583,
"confidence_bright": 0.9999924898147583,
"value": true
}
}
Flash
This quality check if the image is taken with flash or not. The flash is determined by flash spot on the image.
Key | Description | Type |
---|---|---|
value | Determine whether the image is flash or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "flash" or "not flash" | Float |
confidence_flash | This confidence indicates the certainty of the model when it predicts "flash" | Float |
Example output
1
2
3
4
5
6
7
{
"flash": {
"confidence": 0.9999924898147583,
"confidence_flash": 0.9999924898147583,
"value": true
}
}
Crop
This quality check if the document is cropped or not. The crop is determined by the content of the document.
Key | Description | Type |
---|---|---|
value | Determine whether the document is cropped or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "crop" or "not crop" | Float |
confidence_crop | This confidence indicates the certainty of the model when it predicts "crop" | Float |
1
2
3
4
5
6
7
{
"crop": {
"confidence": 0.9999924898147583,
"confidence_crop": 0.9999924898147583,
"value": true
}
}
Rotated
This quality check if the document is rotated or not. The rotation is determined by the content of the document.
Key | Description | Type |
---|---|---|
value | Document rotation value. Available value 0_degree , 90_degree , 180_degree , and 270_degree | String |
confidence | Confidence score for the given results | Float |
fixed_image | The fixed image if the image is rotated in base64 | String |
Example output
1
2
3
4
5
6
7
{
"rotated": {
"confidence": 1.0,
"fixed_image": "iVBORw0KGgoAAAA...",
"value": "90_degree"
}
}
Photocopy
This quality check if the document is photocopy or not. The photocopy is determined by the document color, whether it's colored or black and white.
Key | Description | Type |
---|---|---|
value | Determine whether the document is photocopy or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "photocopy" or "not photocopy" | Float |
confidence_photocopy | This confidence indicates the certainty of the model when it predicts "photocopy" | Float |
1
2
3
4
5
6
7
{
"photocopy": {
"confidence": 0.9999924898147583,
"confidence_photocopy": 0.9999924898147583,
"value": true
}
}
Screen / Spoofing
This quality check if the document is taken from screen or not.
Key | Description | Type |
---|---|---|
value | Determine whether the document is spoofing or not | Boolean |
confidence | Confidence score for the given results, whether it predicts "screen" or "not screen" | Float |
confidence_screen | This confidence indicates the certainty of the model when it predicts "screen" | Float |
Example output
1
2
3
4
5
6
7
{
"screen": {
"confidence": 0.9999924898147583,
"confidence_screen": 0.9999924898147583,
"value": true
}
}
Document Classifier
This module classify the document type.
Key | Description | Type |
---|---|---|
value | Document type | String |
confidence | Confidence score for the given results | Float |
Available document type:
Document | Description |
---|---|
ktp | Kartu Tanda Penduduk (Indonesian identity card) |
npwp | Nomor Pendaftaran Wajib Pajak |
stnk | Surat Tanda Nomor Kendaraan |
bpkb-1 | Buku Pemilik Kendaraan Bermotor page 1 (Identitas Pemilik) |
bpkb-2 | Buku Pemilik Kendaraan Bermotor page 2 (Identitas Kendaraan) |
bpkb-3 | Buku Pemilik Kendaraan Bermotor page 3 (Dokumen Registrasi Pertama) |
bpkb-4 | Buku Pemilik Kendaraan Bermotor page 4 (Halaman Terakhir) |
passport | Passport |
kk | Kartu Keluarga |
singapore-nric | Singapore National Registration Identity Card |
singapore-work-permit | Singapore S PASS, Work Permit, and Employment Pass |
singapore-family-pass | Singapore Dependant Pass and Long-Term Visit Pass |
Example output
1
2
3
4
5
6
{
"document": {
"confidence": 0.9999924898147583,
"value": "ktp"
}
}
Detect Qualities
Detects the supported qualities from uploaded image.
Required form parameter
- Name
image
- Type
- file (.png, .jpg, .jpeg)
- Description
The image file of the document.
Sample Request
1
2
3
4
curl -v -L -X POST 'https://api.vision.glair.ai/ocr/v1/qualities' \
-H "Authorization: Basic $(printf "%s" "USERNAME:PASSWORD" | base64)" \
-H 'x-api-key: API_KEY' \
-F 'image=@"/path/to/image.jpg"'
Sample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
"qualities": {
"blur": {
"confidence": 1.0,
"confidence_blur": 1.0,
"value": false
},
"bright": {
"confidence": 0.9999924898147583,
"confidence_bright": 0.9999924898147583,
"value": false
},
"crop": {
"confidence": 0.9999818801879883,
"confidence_crop": 0.9999818801879883,
"value": false
},
"dark": {
"confidence": 0.9993858337402344,
"confidence_dark": 0.9993858337402344,
"value": false
},
"document": {
"confidence": 1.0,
"value": "ktp"
},
"flash": {
"confidence": 0.9991378784179688,
"confidence_flash": 0.9991378784179688,
"value": false
},
"photocopy": {
"confidence": 0.9999991655349731,
"confidence_photocopy": 0.9999991655349731,
"value": false
},
"rotated": {
"confidence": 1.0,
"fixed_image": "iVBORw0KGgoAAAA...",
"value": "0_degree"
},
"screen": {
"confidence": 0.9889932153746486,
"confidence_screen": 0.9889932153746486,
"value": false
}
},
"reason": "File successfully read.",
"status": "SUCCESS"
}
Optional query parameter
- Name
qualities
- Type
- string (supported qualities above)
- Description
The quality only you want to detect
Sample Request
1
2
3
4
curl -v -L -X POST 'https://api.vision.glair.ai/ocr/v1/qualities?qualities=dark,flash,blur' \
-H "Authorization: Basic $(printf "%s" "USERNAME:PASSWORD" | base64)" \
-H 'x-api-key: API_KEY' \
-F 'image=@"/path/to/image.jpg"'
Sample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"qualities": {
"blur": {
"confidence": 1.0,
"value": false
},
"dark": {
"confidence": 0.9993858337402344,
"value": false
},
"flash": {
"confidence": 0.9991378784179688,
"value": false
}
},
"reason": "File successfully read.",
"status": "SUCCESS"
}
Request ID
An associated request identifier is generated for every request made to this endpoint.
This value can be found in the response headers under Request-Id
Responses
Various responses for this endpoint, in addition to general responses specified in Errors.
200 - OK
Request with readable image
Response
1
2
3
4
5
{
"status": "SUCCESS",
"reason": "File successfully read.",
//...,
}
200 - Unrecognized Document Type
Request with unrecognized document type
Response
1
2
3
4
5
{
"status": "UNRECOGNIZED_DOCUMENT_TYPE",
"reason": "Unrecognized document type detected.",
//...,
}
200 - Multiple Documents
Request with multiple documents
Response
1
2
3
4
5
{
"status": "MULTIPLE_DOCUMENTS_DETECTED",
"reason": "Multiple documents detected.",
//...,
}
400 - Bad Request
Request without form-data image
Response
1
2
3
4
5
{
"status": "FAILED",
"reason": "Input should be an instance of FileStorage",
//...,
}
400 - Bad Request
Request with non supported file format
Response
1
2
3
4
5
{
"status": "FAILED",
"reason": "mimetype: application/zip is not supported",
//...,
}