DocSDK  2.4.1
c_api.h File Reference
#include <stdint.h>
#include <stddef.h>
#include "config.h"

Go to the source code of this file.

Data Structures

struct  DocSdkLivenessPipelineResult
 Liveness pipeline result. More...
 
struct  DocSdkLivenessCheckOptions
 Configurable options used for document liveness check. More...
 
struct  DocSdkFeature
 DocSDK feature information. More...
 
struct  DocSdkLicenseInfo
 Information about DocSDK features available with the installed license. More...
 

Typedefs

typedef struct DocSdkImage DocSdkImage
 Image representation. More...
 
typedef struct DocSdkLivenessPipeline DocSdkLivenessPipeline
 Document liveness checking pipeline. More...
 
typedef enum DocSdkErrorCode DocSdkErrorCode
 DocSDK error codes enumeration. More...
 
typedef enum DocSdkColorEncoding DocSdkColorEncoding
 Image color encoding. More...
 
typedef enum DocSdkValidationStatusCode DocSdkValidationStatusCode
 Image validation status code (image validation is performed beforehand each liveness check) More...
 
typedef enum DocSdkImageQualityWarning DocSdkImageQualityWarning
 Image quality warning (image quality check is performed along with liveness check) More...
 
typedef struct DocSdkLivenessPipelineResult DocSdkLivenessPipelineResult
 Liveness pipeline result. More...
 
typedef enum DocSdkLivenessCheckCalibration DocSdkLivenessCheckCalibration
 Score/threshold calibration to be used for document liveness check. More...
 
typedef struct DocSdkLivenessCheckOptions DocSdkLivenessCheckOptions
 Configurable options used for document liveness check. More...
 
typedef enum DocSdkAttackType DocSdkAttackType
 Document spoofing attack type. More...
 
typedef struct DocSdkFeature DocSdkFeature
 DocSDK feature information. More...
 
typedef struct DocSdkLicenseInfo DocSdkLicenseInfo
 Information about DocSDK features available with the installed license. More...
 

Enumerations

enum  DocSdkErrorCode { kDocSdkErrorCodeOk, kDocSdkErrorCodeNullptr, kDocSdkErrorCodeNativeException, kDocSdkErrorCodeLicenseException }
 DocSDK error codes enumeration. More...
 
enum  DocSdkColorEncoding { kDocSdkColorEncodingRGB888, kDocSdkColorEncodingBGR888 }
 Image color encoding. More...
 
enum  DocSdkValidationStatusCode {
  kDocSdkValidationStatusCodeOk, kDocSdkValidationStatusCodeDocumentTooCloseToCamera, kDocSdkValidationStatusCodeDocumentTooCloseToBorder, kDocSdkValidationStatusCodeDocumentCropped,
  kDocSdkValidationStatusCodeDocumentNotFound, kDocSdkValidationStatusCodeDocumentTooSmall, kDocSdkValidationStatusCodeTooManyDocuments, kDocSdkValidationStatusCodeDocumentIsColorless,
  kDocSdkValidationStatusCodeDocumentPhotoNotFound
}
 Image validation status code (image validation is performed beforehand each liveness check) More...
 
enum  DocSdkImageQualityWarning {
  kDocSdkImageQualityWarningRelativeDocumentSizeLowerThan10Percent, kDocSdkImageQualityWarningDocumentBordersOutsideOfFrame, kDocSdkImageQualityWarningMultipleDocumentsInFrame, kDocSdkImageQualityWarningDocumentTooCloseToBorder,
  kDocSdkImageQualityWarningImageTooBlurry, kDocSdkImageQualityWarningImageTooCompressed, kDocSdkImageQualityWarningPoorImageExposure, kDocSdkImageQualityWarningGlareOnImage
}
 Image quality warning (image quality check is performed along with liveness check) More...
 
enum  DocSdkLivenessCheckCalibration { kDocSdkLivenessCheckCalibrationRegular, kDocSdkLivenessCheckCalibrationSoft, kDocSdkLivenessCheckCalibrationHard }
 Score/threshold calibration to be used for document liveness check. More...
 
enum  DocSdkAttackType {
  kDocSdkAttackTypeScreenReplay, kDocSdkAttackTypePrintedCopy, kDocSdkAttackTypePortraitSubstitution, kDocSdkAttackTypeDigitalManipulation,
  kDocSdkAttackTypeOther
}
 Document spoofing attack type. More...
 

Functions

DOCSDK_API void DocSdkSetErrorLogCallback (void(*callback)(DocSdkErrorCode, const char *))
 
DOCSDK_API void DocSdkSetNumThreads (unsigned int num_threads)
 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). More...
 
DOCSDK_API DocSdkLicenseInfoDocSdkGetLicenseInfo (DocSdkErrorCode *error_code)
 Returns information (e.g. supported features and expiration dates) about the installed license if available. More...
 
DOCSDK_API void DocSdkDestroyLicenseInfo (DocSdkLicenseInfo *license_info)
 
DOCSDK_API void DocSdkSetRuntimeLicense (const char *license_str, DocSdkErrorCode *error_code)
 Sets the runtime license. Only takes effect in "Lambda" SDK distribution and should be called before any other SDK invocation. More...
 
DOCSDK_API DocSdkImageDocSdkCreateImageFromBuffer (const uint8_t *bytes, size_t size, DocSdkErrorCode *error_code)
 
DOCSDK_API DocSdkImageDocSdkCreateImageFromFile (const char *file_path, DocSdkErrorCode *error_code)
 
DOCSDK_API DocSdkImageDocSdkCreateImageFromRawData (const uint8_t *data, size_t num_rows, size_t num_cols, DocSdkColorEncoding encoding, DocSdkErrorCode *error_code)
 
DOCSDK_API void DocSdkDestroyImage (DocSdkImage *image)
 
DOCSDK_API DocSdkLivenessPipelineDocSdkCreateLivenessPipeline (const char *config_path, DocSdkErrorCode *error_code)
 
DOCSDK_API void DocSdkDestroyLivenessPipeline (DocSdkLivenessPipeline *liveness_pipeline)
 
DOCSDK_API DocSdkLivenessCheckOptions DocSdkLivenessCheckOptionsDefault ()
 
DOCSDK_API DocSdkLivenessPipelineResult DocSdkLivenessPipelineCheckLiveness (DocSdkLivenessPipeline *liveness_pipeline, DocSdkImage *image, DocSdkLivenessCheckOptions *options, DocSdkErrorCode *error_code)
 
DOCSDK_API DocSdkLivenessPipelineResult DocSdkLivenessPipelineCheckLivenessSequence (DocSdkLivenessPipeline *liveness_pipeline, DocSdkImage **images, size_t num_images, DocSdkLivenessCheckOptions *options, DocSdkErrorCode *error_code)
 

Detailed Description

IDLive Doc SDK C API

Typedef Documentation

◆ DocSdkAttackType

Document spoofing attack type.

◆ DocSdkColorEncoding

Image color encoding.

◆ DocSdkErrorCode

DocSDK error codes enumeration.

◆ DocSdkFeature

typedef struct DocSdkFeature DocSdkFeature

DocSDK feature information.

◆ DocSdkImage

typedef struct DocSdkImage DocSdkImage

Image representation.

◆ DocSdkImageQualityWarning

Image quality warning (image quality check is performed along with liveness check)

◆ DocSdkLicenseInfo

Information about DocSDK features available with the installed license.

◆ DocSdkLivenessCheckCalibration

Score/threshold calibration to be used for document liveness check.

◆ DocSdkLivenessCheckOptions

Configurable options used for document liveness check.

◆ DocSdkLivenessPipeline

Document liveness checking pipeline.

◆ DocSdkLivenessPipelineResult

Liveness pipeline result.

◆ DocSdkValidationStatusCode

Image validation status code (image validation is performed beforehand each liveness check)

Enumeration Type Documentation

◆ DocSdkAttackType

Document spoofing attack type.

Enumerator
kDocSdkAttackTypeScreenReplay 

Screen replay attack

kDocSdkAttackTypePrintedCopy 

Printed copy attack

kDocSdkAttackTypePortraitSubstitution 

Portrait substitution attack

kDocSdkAttackTypeDigitalManipulation 

Digital manipulation attack

kDocSdkAttackTypeOther 

Other attack

◆ DocSdkColorEncoding

Image color encoding.

Enumerator
kDocSdkColorEncodingRGB888 

RGB encoding, each channel value is represented as 8 bits

kDocSdkColorEncodingBGR888 

BGR encoding, each channel value is represented as 8 bits

◆ DocSdkErrorCode

DocSDK error codes enumeration.

Enumerator
kDocSdkErrorCodeOk 

No error

kDocSdkErrorCodeNullptr 

Null pointer was passed as a parameter

kDocSdkErrorCodeNativeException 

Native exception was thrown by underlying C++ code

kDocSdkErrorCodeLicenseException 

License exception was thrown by underlying C++ code

◆ DocSdkImageQualityWarning

Image quality warning (image quality check is performed along with liveness check)

Enumerator
kDocSdkImageQualityWarningRelativeDocumentSizeLowerThan10Percent 

Document size (area) is lower than 10% of the frame size

kDocSdkImageQualityWarningDocumentBordersOutsideOfFrame 

Document border(s) are outside of the frame, corresponds to kDocSdkValidationStatusCodeDocumentCropped

kDocSdkImageQualityWarningMultipleDocumentsInFrame 

More than one document are present in the frame, corresponds to kDocSdkValidationStatusCodeTooManyDocuments

kDocSdkImageQualityWarningDocumentTooCloseToBorder 

Document is too close to the frame border

kDocSdkImageQualityWarningImageTooBlurry 

Image is too blurry

kDocSdkImageQualityWarningImageTooCompressed 

Image is too compressed

kDocSdkImageQualityWarningPoorImageExposure 

Image is either too bright or too dark

kDocSdkImageQualityWarningGlareOnImage 

Image has glare

◆ DocSdkLivenessCheckCalibration

Score/threshold calibration to be used for document liveness check.

Enumerator
kDocSdkLivenessCheckCalibrationRegular 

Regular calibration, targets low APCER

kDocSdkLivenessCheckCalibrationSoft 

Soft calibration, achieves lower BPCER while still having acceptable APCER

kDocSdkLivenessCheckCalibrationHard 

Hard calibration, achieves lower APCER while still having acceptable BPCER

◆ DocSdkValidationStatusCode

Image validation status code (image validation is performed beforehand each liveness check)

Enumerator
kDocSdkValidationStatusCodeOk 

Validation successful

kDocSdkValidationStatusCodeDocumentTooCloseToCamera 

Document is too close to the camera

kDocSdkValidationStatusCodeDocumentTooCloseToBorder 

Document is too close to the image border

kDocSdkValidationStatusCodeDocumentCropped 

Document is cropped (part of the document is not present in the image), corresponds to kDocSdkImageQualityWarningDocumentBordersOutsideOfFrame

kDocSdkValidationStatusCodeDocumentNotFound 

Document is not detected in the image

kDocSdkValidationStatusCodeDocumentTooSmall 

Document size in the image is too small

kDocSdkValidationStatusCodeTooManyDocuments 

Too many documents were detected in the image, corresponds to kDocSdkImageQualityWarningMultipleDocumentsInFrame

kDocSdkValidationStatusCodeDocumentIsColorless 

Document is colorless (black and white)

kDocSdkValidationStatusCodeDocumentPhotoNotFound 

Document photo is not detected in the image

Function Documentation

◆ DocSdkCreateImageFromBuffer()

DOCSDK_API DocSdkImage* DocSdkCreateImageFromBuffer ( const uint8_t *  bytes,
size_t  size,
DocSdkErrorCode error_code 
)

Image factory method, creates Image from a buffer containing image file contents.

Parameters
bytes[in] Pointer to a buffer containing image file contents
size[in] Buffer size
error_code[out] Error code
Returns
Pointer to created DocSdkImage instance

◆ DocSdkCreateImageFromFile()

DOCSDK_API DocSdkImage* DocSdkCreateImageFromFile ( const char *  file_path,
DocSdkErrorCode error_code 
)

Image factory method, creates Image from an image file using given file path.

Parameters
file_path[in] Null-terminated string containing path to the image file
error_code[out] Error code
Returns
Pointer to created DocSdkImage instance

◆ DocSdkCreateImageFromRawData()

DOCSDK_API DocSdkImage* DocSdkCreateImageFromRawData ( const uint8_t *  data,
size_t  num_rows,
size_t  num_cols,
DocSdkColorEncoding  encoding,
DocSdkErrorCode error_code 
)

Image factory method, creates Image from raw color data.

Parameters
data[in] Raw color data (three-dimensional array containing color channel values for each image pixel)
num_rows[in] Number of image rows
num_cols[in] Number of image columns
encodingImage color encoding
error_code[out] Error code
Returns
Pointer to created DocSdkImage instance

◆ DocSdkCreateLivenessPipeline()

DOCSDK_API DocSdkLivenessPipeline* DocSdkCreateLivenessPipeline ( const char *  config_path,
DocSdkErrorCode error_code 
)

Liveness pipeline factory method.

Parameters
config_path[in] Null-terminated string containing path to liveness pipeline configuration file
error_code[out] Error code
Returns
Pointer to created DocSdkLivenessPipeline instance

◆ DocSdkDestroyImage()

DOCSDK_API void DocSdkDestroyImage ( DocSdkImage image)

Destroys DocSdkImage instance.

Parameters
image[in] Pointer to DocSdkImage instance

◆ DocSdkDestroyLicenseInfo()

DOCSDK_API void DocSdkDestroyLicenseInfo ( DocSdkLicenseInfo license_info)

Destroys DocSdkLicenseInfo instance.

Parameters
license_info[in] Pointer to DocSdkLicenseInfo instance

◆ DocSdkDestroyLivenessPipeline()

DOCSDK_API void DocSdkDestroyLivenessPipeline ( DocSdkLivenessPipeline liveness_pipeline)

Destroys DocSdkLivenessPipeline instance.

Parameters
liveness_pipeline[in] Pointer to DocSdkLivenessPipeline instance

◆ DocSdkGetLicenseInfo()

DOCSDK_API DocSdkLicenseInfo* DocSdkGetLicenseInfo ( DocSdkErrorCode error_code)

Returns information (e.g. supported features and expiration dates) about the installed license if available.

Parameters
error_code[out] Error code
Returns
Pointer to the DocSdkLicense info instance describing DocSDK features available with the installed license. The DocSdkLicenseInfo should be destroy with .

◆ DocSdkLivenessCheckOptionsDefault()

DOCSDK_API DocSdkLivenessCheckOptions DocSdkLivenessCheckOptionsDefault ( )

Default-initializes DocSdkLivenessCheckOptions instance.

Returns
DocSdkLivenessCheckOptions instance

◆ DocSdkLivenessPipelineCheckLiveness()

DOCSDK_API DocSdkLivenessPipelineResult DocSdkLivenessPipelineCheckLiveness ( DocSdkLivenessPipeline liveness_pipeline,
DocSdkImage image,
DocSdkLivenessCheckOptions options,
DocSdkErrorCode error_code 
)

Checks liveness using the provided document photo.

Parameters
liveness_pipeline[in] Pointer to DocSdkLivenessPipeline instance
image[in] Image containing the photo of document
options[in] Liveness check options, can be NULL
error_code[out] Error code
Returns
Liveness checking result

◆ DocSdkLivenessPipelineCheckLivenessSequence()

DOCSDK_API DocSdkLivenessPipelineResult DocSdkLivenessPipelineCheckLivenessSequence ( DocSdkLivenessPipeline liveness_pipeline,
DocSdkImage **  images,
size_t  num_images,
DocSdkLivenessCheckOptions options,
DocSdkErrorCode error_code 
)

Performs liveness check using a sequence of photos (e.g. taken from video) producing a single aggregated liveness checking result.

Parameters
liveness_pipeline[in] Pointer to DocSdkLivenessPipeline instance
images[in] Images array (photo sequence)
num_images[in] Images array size
options[in] Liveness check options, can be NULL
error_code[out] Error code
Returns
Liveness checking result

◆ DocSdkSetErrorLogCallback()

DOCSDK_API void DocSdkSetErrorLogCallback ( void(*)(DocSdkErrorCode, const char *)  callback)

Sets error logging callback. By default, all error messages are printed to stderr. Callback accepts two parameters: an error code and a null-terminated string containing error description.

Parameters
callback[in] Pointer to a function for handling error messages

◆ DocSdkSetNumThreads()

DOCSDK_API void DocSdkSetNumThreads ( unsigned int  num_threads)

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_threadsMaximum number of CPU threads available for DocSDK
Note
Function call is equivalent to setting DOCSDK_NUM_THREADS_PIPELINE, DOCSDK_NUM_THREADS_ENGINE and DOCSDK_NUM_THREADS_OPERATOR environment variables to the same value before loading the DocSDK library.
Function call takes precedence over environment variables.

◆ DocSdkSetRuntimeLicense()

DOCSDK_API void DocSdkSetRuntimeLicense ( const char *  license_str,
DocSdkErrorCode error_code 
)

Sets the runtime license. Only takes effect in "Lambda" SDK distribution and should be called before any other SDK invocation.

Parameters
license_str[in] String holding the license content
error_code[out] Error code