DocSDK 2.4.1¶
- class DocSdk.Image¶
Image representation.
- class ColorEncoding¶
Image color encoding.
Members:
RGB888 : RGB encoding, each channel value is represented as 8 bits.
BGR888 : BGR encoding, each channel value is represented as 8 bits.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: DocSdk.DocSdk.Image, data: bytes)
Image constructor, creates Image from a buffer containing image file contents.
- Parameters
data (bytes) – Buffer containing image file contents.
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
TypeError – On invalid argument type.
__init__(self: DocSdk.DocSdk.Image, file_path: str)
Image constructor, creates Image from an image file using given file path.
- Parameters
file_path (str) – Path to image file.
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
TypeError – On invalid argument type.
__init__(self: DocSdk.DocSdk.Image, raw_data: numpy.ndarray[numpy.uint8], num_rows: int, num_cols: int, encoding: docsdk::Image::ColorEncoding)
Image constructor, creates Image from raw color data.
- Parameters
raw_data (numpy.array) – Raw color data (flattened three-dimensional array containing color channel values for each image pixel).
num_rows (int) – Number of image rows.
num_cols (int) – Number of image columns.
encoding (Image.ColorEncoding) – Image color encoding.
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
TypeError – On invalid argument type.
- class DocSdk.LivenessCheckOptions¶
Configurable options used for document liveness check.
- class Calibration¶
Score/threshold calibration to be used.
Members:
Regular : Regular calibration, targets low APCER.
Soft : Soft calibration, achieves lower BPCER while still having acceptable APCER.
Hard : Hard calibration, achieves lower APCER while still having acceptable BPCER.
- property calibration¶
Score/threshold calibration to be used for document liveness check.
- property errors_to_ignore¶
Defines which validation errors should be ignored during the liveness check.
- class DocSdk.LivenessPipeline¶
Document liveness checking pipeline.
- __init__(self: DocSdk.DocSdk.LivenessPipeline, path_to_config: str)¶
Liveness pipeline constructor.
- Parameters
path_to_config (str) – Path to liveness pipeline configuration file.
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
LicenseException – On license errors.
TypeError – On invalid argument type.
- check_liveness(self: DocSdk.DocSdk.LivenessPipeline, image: DocSdk.DocSdk.Image, options: DocSdk.DocSdk.LivenessCheckOptions = <DocSdk.DocSdk.LivenessCheckOptions object at 0x7f4c3d3189f0>) DocSdk.DocSdk.LivenessPipelineResult ¶
Checks liveness using the provided document photo.
- Parameters
image (Image) – Image containing the photo of document.
option (
LivenessCheckOptions
, optional) – Optional liveness check options.
- Returns
Liveness checking result.
- Return type
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
LicenseException – On license errors.
TypeError – On invalid argument type.
- check_liveness_sequence(self: DocSdk.DocSdk.LivenessPipeline, images: List[DocSdk.DocSdk.Image], options: DocSdk.DocSdk.LivenessCheckOptions = <DocSdk.DocSdk.LivenessCheckOptions object at 0x7f4c3d318cb0>) DocSdk.DocSdk.LivenessPipelineResult ¶
Performs liveness check using a sequence of photos (e.g. taken from video) producing a single aggregated liveness checking result.
- Parameters
images (list) – List of images containing photo sequence.
option (
LivenessCheckOptions
, optional) – Optional liveness check options.
- Returns
Liveness checking result.
- Return type
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
LicenseException – On license errors.
TypeError – On invalid argument type.
- class DocSdk.LivenessPipelineResult¶
Liveness pipeline result.
- class ImageQualityWarning¶
Image quality warning (image quality check is performed along with liveness check).
Members:
RelativeDocumentSizeLowerThan10Percent : Document size (area) is lower than 10% of the frame size.
DocumentBordersOutsideOfFrame : Document border(s) are outside of the frame. Corresponds to ValidationStatusCode.DocumentCropped.
MultipleDocumentsInFrame : More than one document are present in the frame. Corresponds to ValidationStatusCode.TooManyDocuments.
DocumentTooCloseToBorder : Document is too close to the frame border.
ImageTooBlurry : Image is too blurry.
ImageTooCompressed : Image is too compressed.
PoorImageExposure : Image is either too bright or too dark.
GlareOnImage : Image has glare.
- class ValidationStatusCode¶
Image validation status code (image validation is performed beforehand each liveness check).
Members:
Ok : Validation successful.
DocumentTooCloseToCamera : Document is too close to the camera.
DocumentTooCloseToBorder : Document is too close to the image border.
DocumentCropped : Document is cropped (part of the document is not present in the image). Corresponds to ImageQualityWarning.DocumentBordersOutsideOfFrame.
DocumentNotFound : Document is not detected in the image.
DocumentTooSmall : Document size in the image is too small.
TooManyDocuments : Too many documents were detected in the image. Corresponds to ImageQualityWarning.MultipleDocumentsInFrame.
DocumentIsColorless : Document is colorless (black and white).
DocumentPhotoNotFound : Document photo is not detected in the image.
- class Value¶
Document liveness check result.
- property image_quality_warnings¶
Image quality warnings.
- Type
list
- property liveness_probability¶
Document liveness probability from 0 to 1.
- Type
float
- property liveness_score¶
Raw liveness checking score, can be used for calibration.
- Type
float
- property quality_score¶
Image quality checking score (deprecated, this value is always zero, use image_quality_warnings instead) .
- Type
float
- get_status_code(self: DocSdk.DocSdk.LivenessPipelineResult) docsdk::LivenessPipelineResult::ValidationStatusCode ¶
Returns validation status code.
- Returns
Validation status code.
- Return type
- get_value(self: DocSdk.DocSdk.LivenessPipelineResult) docsdk::LivenessPipelineResult::Value ¶
Returns document liveness checking result if validation was successful. Otherwise, throws an exception.
- Returns
Liveness checking result.
- Return type
- Raises
RuntimeError – If validation status code is not Ok.
- ok(self: DocSdk.DocSdk.LivenessPipelineResult) bool ¶
Returns a binary value indicated whether the validation was successful.
- Returns
True if validation was successful, False otherwise.
- Return type
bool
- DocSdk.get_license_info() List[DocSdk.DocSdk.DocSdkFeature] ¶
Returns information (e.g. supported features and expiration dates) about the installed license if available.
- Returns
List of document liveness features available with the installed license.
- Return type
list
- DocSdk.set_num_threads(num_threads: int)¶
Sets the maximum number of CPU threads available for DocSDK.If 0 is passed, then the optimal number of CPU threads is detected automatically (the same effect is achieved if the function is not called).
- Parameters
num_threads (int) – Maximum number of CPU threads available for DocSDK.
Note: Function call is equivalent to setting DOCSDK_NUM_THREADS_PIPELINE, DOCSDK_NUM_THREADS_ENGINEand DOCSDK_NUM_THREADS_OPERATOR environment variables to the same value before loading the DocSDK library. Function call takes precedence over environment variables.
- DocSdk.set_runtime_license(license_str: str)¶
Sets the runtime license. Only takes effect in “Lambda” SDK distribution and should be called before any other SDK invocation.
- Parameters
license_str (str) – String holding the license content.
- Raises
RuntimeError – On native exceptions thrown in underlying C++ code.
LicenseException – On invalid license string.
TypeError – On invalid argument type.