3DiVi Face SDK  3.24.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
pbio::FacerecService Class Reference

Interface object for creating other interface objects. More...

#include <FacerecService.h>

Classes

struct  License
 Storing the license as a string variable. More...
 
struct  LicenseState
 License status. More...
 

Public Types

typedef LightSmartPtr
< FacerecService >::tPtr 
Ptr
 Alias for the type of a smart pointer to FacerecService.
 

Public Member Functions

std::string getVersion () const
 Get version of face recognition library. Thread-safe. More...
 
void forceOnlineLicenseUpdate () const
 Force online license update.
 
Capturer::Ptr createCapturer (const pbio::FacerecService::Config config) const
 Creates a Capturer object. Type and features depend on the content of the configuration file. Thread-safe. More...
 
AgeGenderEstimator::Ptr createAgeGenderEstimator (const std::string ini_file) const
 Creates a AgeGenderEstimator object. Thread-safe. More...
 
QualityEstimator::Ptr createQualityEstimator (const std::string ini_file) const
 Creates a QualityEstimator object. Thread-safe. More...
 
FaceQualityEstimator::Ptr createFaceQualityEstimator (const std::string ini_file) const
 Creates a FaceQualityEstimator object. Thread-safe. More...
 
LivenessEstimator::Ptr createLivenessEstimator () const
 Creates a LivenessEstimator object. Thread-safe. More...
 
EmotionsEstimator::Ptr createEmotionsEstimator (const std::string ini_file) const
 Creates a EmotionsEstimator object. Thread-safe. More...
 
Recognizer::Ptr createRecognizer (const char *ini_file, const bool processing=true, const bool matching=true, const bool processing_less_memory_consumption=false) const
 Creates a Recognizer object. Thread-safe. More...
 
Recognizer::Ptr createRecognizer (const pbio::FacerecService::Config recognizer_config, const bool processing=true, const bool matching=true, const bool processing_less_memory_consumption=false) const
 Creates a Recognizer object. Thread-safe. More...
 
VideoWorker::Ptr createVideoWorker (const pbio::VideoWorker::Params params) const
 Creates a VideoWorker object. Thread-safe.
When VideoWorker is created with matching_thread=0 and processing_thread=0, then the standard Capturer license is used.
Depending on the settings, VideoWorker uses either the VideoClient license (face tracking on video streams) or the VideoClientExt license (face tracking, template creation and matching with the database). More...
 
VideoWorker::Ptr createVideoWorker (const pbio::FacerecService::Config video_worker_config, const char *recognizer_ini_file, const int streams_count, const int processing_threads_count, const int matching_threads_count) const
 
VideoWorker::Ptr createVideoWorker (const pbio::FacerecService::Config video_worker_config, const pbio::FacerecService::Config recognizer_config, const int streams_count, const int processing_threads_count, const int matching_threads_count) const
 
RawSample::Ptr loadRawSample (std::istream &binary_stream) const
 Loads a RawSample object that was saved with the RawSample::save member function. The format is platform-independent. Thread-safe. More...
 
RawSample::Ptr loadRawSample (pbio::stl_wraps::WrapIStream &binary_stream) const
 Loads a RawSample object that was saved with the RawSample::save member function. The format is platform-independent. Thread-safe. More...
 
RawSample::Ptr loadRawSampleWithoutImage (pbio::stl_wraps::WrapIStream &binary_stream, const RawImage image, const double space_translation_x=0, const double space_translation_y=0, const double space_scale=1) const
 Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function. If you transformed the image in some way, you can set the parameters of coordinate space transformation: (x, y) -> ( (x + space_translation_x) * space_scale, (y + space_translation_y) * space_scale ) that will be applied to the information abour face position. Note that you must set the same transformation only once - either during serialization or during deserialization, otherwise transformation will be applied twice, which is wrong. The format is platform-independent. Thread-safe. More...
 
RawSample::Ptr loadRawSampleWithoutImage (std::istream &binary_stream, const RawImage image, const double space_translation_x=0, const double space_translation_y=0, const double space_scale=1) const
 Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function. If you transformed the image in some way, you can set the parameters of coordinate space transformation: (x, y) -> ( (x + space_translation_x) * space_scale, (y + space_translation_y) * space_scale ) that will be applied to the information abour face position. Note that you must set the same transformation only once - either during serialization or during deserialization, otherwise transformation will be applied twice, which is wrong. The format is platform-independent. Thread-safe. More...
 
RawSample::Ptr loadRawSampleWithoutImage (pbio::stl_wraps::WrapIStream &binary_stream, const unsigned char *image_data, int image_data_size, const double space_translation_x=0, const double space_translation_y=0, const double space_scale=1) const
 
RawSample::Ptr loadRawSampleWithoutImage (std::istream &binary_stream, const unsigned char *image_data, int image_data_size, const double space_translation_x=0, const double space_translation_y=0, const double space_scale=1) const
 
CameraCalibrator::Ptr createCameraCalibrator () const
 Creates a CameraCalibrator object. Thread-safe. More...
 
DepthLivenessEstimator::Ptr createDepthLivenessEstimator (const std::string ini_file) const
 Creates a DepthLivenessEstimator object. Thread-safe. More...
 
DepthLivenessEstimator::Ptr createDepthLivenessEstimator (const pbio::FacerecService::Config config) const
 Creates a DepthLivenessEstimator object. Thread-safe. More...
 
IRLivenessEstimator::Ptr createIRLivenessEstimator (const std::string ini_file) const
 Creates an IRLivenessEstimator object. Thread-safe. More...
 
IRLivenessEstimator::Ptr createIRLivenessEstimator (const pbio::FacerecService::Config config) const
 Creates an IRLivenessEstimator object. Thread-safe. More...
 
Liveness2DEstimator::Ptr createLiveness2DEstimator (const std::string ini_file) const
 Creates an Liveness2DEstimator object. Thread-safe. More...
 
Liveness2DEstimator::Ptr createLiveness2DEstimator (const pbio::FacerecService::Config config) const
 Creates an Liveness2DEstimator object. Thread-safe. More...
 
FaceAttributesEstimator::Ptr createFaceAttributesEstimator (const std::string ini_file) const
 Creates an FaceAttributesEstimator object. Thread-safe. More...
 
LicenseState getLicenseState () const
 Get the license state. Thread-safe. More...
 
void keepAlgorithmsCache () const
 Enalbe keeping algorithms data in memory even if no owners left. This will speedup repeated algorithms initialization. Thread-safe.
 
void freeAlgorithmsCache () const
 Disable keeping algorithms data in memory. Thread-safe.
 
InternalImageBuffer::Ptr createInternalImageBuffer (const int width, const int height, const RawImage::Format format)
 Create InternalImageBuffer for specified image size and format. Thread-safe. Always create new InternalImageBuffer for every image or video frame. Never change image data of InternalImageBuffer after first use. More...
 
void convertYUV2ARGB (const RawImage image, const bool downscale_x2, void *const result_buffer)
 Convert input image to android.graphics.Bitmap.Config.ARGB_8888 format. Input must be in YUV_NV21 of YUV_NV12 format. Note: actual bytes order is BGRA, it looks like ARGB_8888 name use little-endian 32-bit integer notation. Thread-safe. More...
 

Static Public Member Functions

static FacerecService::Ptr createService (const std::string dll_path, std::string facerec_conf_dir, const std::string license_dir=std::string())
 Initializes the facerec lib (can be called only once). More...
 
static FacerecService::Ptr createService (const std::string dll_path, std::string facerec_conf_dir, const pbio::FacerecService::License license)
 Initializes the facerec lib with license content (can be called only once). More...
 

Detailed Description

Interface object for creating other interface objects.

Member Function Documentation

void FacerecService::convertYUV2ARGB ( const RawImage  image,
const bool  downscale_x2,
void *const  result_buffer 
)
inline

Convert input image to android.graphics.Bitmap.Config.ARGB_8888 format. Input must be in YUV_NV21 of YUV_NV12 format. Note: actual bytes order is BGRA, it looks like ARGB_8888 name use little-endian 32-bit integer notation. Thread-safe.

Parameters
[in]imageImage in YUV_NV21 or YUV_NV12 format.
[in]downscale_x2Downscale image during conversion, so the result image size will be image.width/2 x image.height/2.
[out]result_bufferData buffer to store converted result, with size image.width * image.height bytes if downscale_x2, or 4 * image.width * image.height bytes otherwise.
AgeGenderEstimator::Ptr FacerecService::createAgeGenderEstimator ( const std::string  ini_file) const
inline

Creates a AgeGenderEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the config file.
Returns
Created AgeGenderEstimator object.
CameraCalibrator::Ptr FacerecService::createCameraCalibrator ( ) const
inline

Creates a CameraCalibrator object. Thread-safe.

Returns
Created CameraCalibrator object.
Capturer::Ptr FacerecService::createCapturer ( const pbio::FacerecService::Config  config) const
inline

Creates a Capturer object. Type and features depend on the content of the configuration file. Thread-safe.

Parameters
[in]configСonfiguration file with optionally overridden parameters.
Returns
Created Capturer object.
DepthLivenessEstimator::Ptr FacerecService::createDepthLivenessEstimator ( const std::string  ini_file) const
inline

Creates a DepthLivenessEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the configuration file.
Returns
Created DepthLivenessEstimator object.
DepthLivenessEstimator::Ptr FacerecService::createDepthLivenessEstimator ( const pbio::FacerecService::Config  config) const
inline

Creates a DepthLivenessEstimator object. Thread-safe.

Parameters
[in]configСonfiguration file with optionally overridden parameters.
Returns
Created DepthLivenessEstimator object.
EmotionsEstimator::Ptr FacerecService::createEmotionsEstimator ( const std::string  ini_file) const
inline

Creates a EmotionsEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the config file.
Returns
Created EmotionsEstimator object.
FaceAttributesEstimator::Ptr FacerecService::createFaceAttributesEstimator ( const std::string  ini_file) const
inline

Creates an FaceAttributesEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the configuration file.
Returns
Created FaceAttributesEstimator object.
FaceQualityEstimator::Ptr FacerecService::createFaceQualityEstimator ( const std::string  ini_file) const
inline

Creates a FaceQualityEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the config file.
Returns
Created FaceQualityEstimator object.
InternalImageBuffer::Ptr FacerecService::createInternalImageBuffer ( const int  width,
const int  height,
const RawImage::Format  format 
)
inline

Create InternalImageBuffer for specified image size and format. Thread-safe. Always create new InternalImageBuffer for every image or video frame. Never change image data of InternalImageBuffer after first use.

Parameters
[in]widthImage width.
[in]heightImage height.
[in]formatImage format.
Returns
Created InternalImageBuffer.
IRLivenessEstimator::Ptr FacerecService::createIRLivenessEstimator ( const std::string  ini_file) const
inline

Creates an IRLivenessEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the configuration file.
Returns
Created IRLivenessEstimator object.
IRLivenessEstimator::Ptr FacerecService::createIRLivenessEstimator ( const pbio::FacerecService::Config  config) const
inline

Creates an IRLivenessEstimator object. Thread-safe.

Parameters
[in]configСonfiguration file with optionally overridden parameters.
Returns
Created IRLivenessEstimator object.
Liveness2DEstimator::Ptr FacerecService::createLiveness2DEstimator ( const std::string  ini_file) const
inline

Creates an Liveness2DEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the configuration file.
Returns
Created Liveness2DEstimator object.
Liveness2DEstimator::Ptr FacerecService::createLiveness2DEstimator ( const pbio::FacerecService::Config  config) const
inline

Creates an Liveness2DEstimator object. Thread-safe.

Parameters
[in]configСonfiguration file with optionally overridden parameters.
Returns
Created Liveness2DEstimator object.
LivenessEstimator::Ptr FacerecService::createLivenessEstimator ( ) const
inline

Creates a LivenessEstimator object. Thread-safe.

Returns
Created LivenessEstimator object.
QualityEstimator::Ptr FacerecService::createQualityEstimator ( const std::string  ini_file) const
inline

Creates a QualityEstimator object. Thread-safe.

Parameters
[in]ini_fileName of the config file.
Returns
Created QualityEstimator object.
Recognizer::Ptr FacerecService::createRecognizer ( const char *  ini_file,
const bool  processing = true,
const bool  matching = true,
const bool  processing_less_memory_consumption = false 
) const
inline

Creates a Recognizer object. Thread-safe.

Parameters
[in]ini_fileName of the config file.
[in]processingFlag to toggle the Recognizer::processing method in the created recognizer.
[in]matchingFlag to toggle the Recognizer::verifyMatch method in the created recognizer.
[in]processing_less_memory_consumptionFlag to toggle the Recognizer::processing member function optimizations that consume a lot of RAM when creating the recognizer (see the docs).
Returns
Created Recognizer object.
Recognizer::Ptr FacerecService::createRecognizer ( const pbio::FacerecService::Config  recognizer_config,
const bool  processing = true,
const bool  matching = true,
const bool  processing_less_memory_consumption = false 
) const
inline

Creates a Recognizer object. Thread-safe.

Parameters
[in]recognizer_configThe Recognizer configuration file with optionally overridden parameters.
[in]processingFlag to toggle the Recognizer::processing method in the created recognizer.
[in]matchingFlag to toggle the Recognizer::verifyMatch method in the created recognizer.
[in]processing_less_memory_consumptionFlag to toggle the Recognizer::processing member function optimizations that consume a lot of RAM when creating the recognizer (see the docs).
Returns
Created Recognizer object.
FacerecService::Ptr FacerecService::createService ( const std::string  dll_path,
std::string  facerec_conf_dir,
const std::string  license_dir = std::string() 
)
inlinestatic

Initializes the facerec lib (can be called only once).

Parameters
[in]dll_pathAn absolute or a relative path to libfacerec.so on Linux or facerec.dll on Windows.
[in]facerec_conf_dirAn absolute or a relative path to the directory with config files (the 'face_sdk/conf/facerec/' directory).
[in]license_dirIf you need to specify the directory containing the license file, then it's an absolute or a relative path to this directory, otherwise, it's an empty string. In case of an empty string, a license file is searched first in the 'face_sdk/license/' directory. If it's not found, it's searched in the 'face_sdk/conf/facerec/' directory.
Returns
Created FacerecService object.
FacerecService::Ptr FacerecService::createService ( const std::string  dll_path,
std::string  facerec_conf_dir,
const pbio::FacerecService::License  license 
)
inlinestatic

Initializes the facerec lib with license content (can be called only once).

Parameters
[in]dll_pathAn absolute or a relative path to libfacerec.so on Linux or facerec.dll on Windows.
[in]facerec_conf_dirAn absolute or a relative path to the directory with config files (the 'face_sdk/conf/facerec/' directory).
[in]licenseСontent of a license (see pbio::FacerecService::License)
Returns
Created FacerecService object.
VideoWorker::Ptr FacerecService::createVideoWorker ( const pbio::VideoWorker::Params  params) const
inline

Creates a VideoWorker object. Thread-safe.
When VideoWorker is created with matching_thread=0 and processing_thread=0, then the standard Capturer license is used.
Depending on the settings, VideoWorker uses either the VideoClient license (face tracking on video streams) or the VideoClientExt license (face tracking, template creation and matching with the database).

Parameters
[in]paramsParameters of the VideoWorker constructor.
Returns
Created VideoWorker object.
VideoWorker::Ptr FacerecService::createVideoWorker ( const pbio::FacerecService::Config  video_worker_config,
const char *  recognizer_ini_file,
const int  streams_count,
const int  processing_threads_count,
const int  matching_threads_count 
) const
inline
Parameters
[in]video_worker_configThe VideoWorker configuration file with optionally overridden parameters.
[in]recognizer_ini_fileName of the config file for the Recognizer that will be used inside the VideoWorker.
[in]streams_countNumber of video streams.
[in]processing_threads_countNumber of threads for creating templates.
[in]matching_threads_countNumber of threads for matching templates with the database.
Returns
Created VideoWorker object.
VideoWorker::Ptr FacerecService::createVideoWorker ( const pbio::FacerecService::Config  video_worker_config,
const pbio::FacerecService::Config  recognizer_config,
const int  streams_count,
const int  processing_threads_count,
const int  matching_threads_count 
) const
inline
Parameters
[in]video_worker_configThe VideoWorker configuration file with optionally overridden parameters.
[in]recognizer_configThe Recognizer configuration file with optionally overridden parameters.
[in]streams_countNumber of video streams.
[in]processing_threads_countNumber of threads for creating templates.
[in]matching_threads_countNumber of threads for matching templates with the database.
Returns
Created VideoWorker object.
FacerecService::LicenseState FacerecService::getLicenseState ( ) const
inline

Get the license state. Thread-safe.

Returns
License state.
std::string FacerecService::getVersion ( ) const
inline

Get version of face recognition library. Thread-safe.

Returns
The version of face recognition library.
RawSample::Ptr FacerecService::loadRawSample ( std::istream &  binary_stream) const
inline

Loads a RawSample object that was saved with the RawSample::save member function. The format is platform-independent. Thread-safe.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the set flag std::ios_base::binary.
Returns
Loaded RawSample object.
RawSample::Ptr FacerecService::loadRawSample ( pbio::stl_wraps::WrapIStream &  binary_stream) const
inline

Loads a RawSample object that was saved with the RawSample::save member function. The format is platform-independent. Thread-safe.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the set flag std::ios_base::binary.
Returns
Loaded RawSample object.
RawSample::Ptr FacerecService::loadRawSampleWithoutImage ( pbio::stl_wraps::WrapIStream &  binary_stream,
const RawImage  image,
const double  space_translation_x = 0,
const double  space_translation_y = 0,
const double  space_scale = 1 
) const
inline

Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function. If you transformed the image in some way, you can set the parameters of coordinate space transformation: (x, y) -> ( (x + space_translation_x) * space_scale, (y + space_translation_y) * space_scale ) that will be applied to the information abour face position. Note that you must set the same transformation only once - either during serialization or during deserialization, otherwise transformation will be applied twice, which is wrong. The format is platform-independent. Thread-safe.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the set flag std::ios_base::binary.
[in]imageImage.
[in]space_translation_xCoordinate space transform parameter.
[in]space_translation_yCoordinate space transform parameter.
[in]space_scaleCoordinate space transform parameter.
Returns
Loaded RawSample object.
RawSample::Ptr FacerecService::loadRawSampleWithoutImage ( std::istream &  binary_stream,
const RawImage  image,
const double  space_translation_x = 0,
const double  space_translation_y = 0,
const double  space_scale = 1 
) const
inline

Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function. If you transformed the image in some way, you can set the parameters of coordinate space transformation: (x, y) -> ( (x + space_translation_x) * space_scale, (y + space_translation_y) * space_scale ) that will be applied to the information abour face position. Note that you must set the same transformation only once - either during serialization or during deserialization, otherwise transformation will be applied twice, which is wrong. The format is platform-independent. Thread-safe.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the set flag std::ios_base::binary.
[in]imageImage.
[in]space_translation_xCoordinate space transform parameter.
[in]space_translation_yCoordinate space transform parameter.
[in]space_scaleCoordinate space transform parameter.
Returns
Loaded RawSample object.
RawSample::Ptr FacerecService::loadRawSampleWithoutImage ( pbio::stl_wraps::WrapIStream &  binary_stream,
const unsigned char *  image_data,
int  image_data_size,
const double  space_translation_x = 0,
const double  space_translation_y = 0,
const double  space_scale = 1 
) const
inline

Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function. If you transformed the image in some way, you can set the parameters of coordinate space transformation: (x, y) -> ( (x + space_translation_x) * space_scale, (y + space_translation_y) * space_scale ) that will be applied to the information abour face position. Note that you must set the same transformation only once - either during serialization or during deserialization, otherwise transformation will be applied twice, which is wrong. The format is platform-independent. Thread-safe.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the set flag std::ios_base::binary.
[in]image_dataPointer to the encoded image with 8 or 24 bits per pixel. Supported formats are JPEG, PNG, TIF and BMP.
[in]image_data_sizeImage data buffer size in bytes
[in]space_translation_xCoordinate space transform parameter.
[in]space_translation_yCoordinate space transform parameter.
[in]space_scaleCoordinate space transform parameter.
Returns
Loaded RawSample object.
RawSample::Ptr FacerecService::loadRawSampleWithoutImage ( std::istream &  binary_stream,
const unsigned char *  image_data,
int  image_data_size,
const double  space_translation_x = 0,
const double  space_translation_y = 0,
const double  space_scale = 1 
) const
inline

Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function. If you transformed the image in some way, you can set the parameters of coordinate space transformation: (x, y) -> ( (x + space_translation_x) * space_scale, (y + space_translation_y) * space_scale ) that will be applied to the information abour face position. Note that you must set the same transformation only once - either during serialization or during deserialization, otherwise transformation will be applied twice, which is wrong. The format is platform-independent. Thread-safe.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the set flag std::ios_base::binary.
[in]image_dataPointer to the encoded image with 8 or 24 bits per pixel. Supported formats are JPEG, PNG, TIF and BMP.
[in]image_data_sizeImage data buffer size in bytes
[in]space_translation_xCoordinate space transform parameter.
[in]space_translation_yCoordinate space transform parameter.
[in]space_scaleCoordinate space transform parameter.
Returns
Loaded RawSample object.