Background supergraphic

OCR Qualities Detector

Qualities detector service for OCR.

Supported qualities:

Blur

This quality check if the image is blur or not.

KeyDescriptionType
valueDetermine whether the image is blur or notBoolean
confidenceConfidence score for the given results, whether it predicts "blur" or "not blur"Float
confidence_blurThis 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.

KeyDescriptionType
valueDetermine whether the image is dark or notBoolean
confidenceConfidence score for the given results, whether it predicts "dark" or "not dark"Float
confidence_darkThis 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.

KeyDescriptionType
valueDetermine whether the image is bright or notBoolean
confidenceConfidence score for the given results, whether it predicts "bright" or "not bright"Float
confidence_brightThis 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.

KeyDescriptionType
valueDetermine whether the image is flash or notBoolean
confidenceConfidence score for the given results, whether it predicts "flash" or "not flash"Float
confidence_flashThis 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.

KeyDescriptionType
valueDetermine whether the document is cropped or notBoolean
confidenceConfidence score for the given results, whether it predicts "crop" or "not crop"Float
confidence_cropThis 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.

KeyDescriptionType
valueDocument rotation value. Available value 0_degree, 90_degree, 180_degree, and 270_degreeString
confidenceConfidence score for the given resultsFloat
fixed_imageThe fixed image if the image is rotated in base64String

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.

KeyDescriptionType
valueDetermine whether the document is photocopy or notBoolean
confidenceConfidence score for the given results, whether it predicts "photocopy" or "not photocopy"Float
confidence_photocopyThis 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.

KeyDescriptionType
valueDetermine whether the document is spoofing or notBoolean
confidenceConfidence score for the given results, whether it predicts "screen" or "not screen"Float
confidence_screenThis 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.

KeyDescriptionType
valueDocument typeString
confidenceConfidence score for the given resultsFloat

Available document type:

DocumentDescription
ktpKartu Tanda Penduduk (Indonesian identity card)
npwpNomor Pendaftaran Wajib Pajak
stnkSurat Tanda Nomor Kendaraan
bpkb-1Buku Pemilik Kendaraan Bermotor page 1 (Identitas Pemilik)
bpkb-2Buku Pemilik Kendaraan Bermotor page 2 (Identitas Kendaraan)
bpkb-3Buku Pemilik Kendaraan Bermotor page 3 (Dokumen Registrasi Pertama)
bpkb-4Buku Pemilik Kendaraan Bermotor page 4 (Halaman Terakhir)
passportPassport
kkKartu Keluarga
singapore-nricSingapore National Registration Identity Card
singapore-work-permitSingapore S PASS, Work Permit, and Employment Pass
singapore-family-passSingapore Dependant Pass and Long-Term Visit Pass

Example output

1
2
3
4
5
6
{ "document": { "confidence": 0.9999924898147583, "value": "ktp" } }

POST/ocr/v1/qualities

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

POST
/ocr/v1/qualities
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

POST
/ocr/v1/qualities
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", //..., }