Skip to main content
Version: 3.8.0

Connecting Face SDK to Your Project

Adding Library to the Project#

Required dependencies#

To use Face SDK, you have to install the following dependencies:

  • Windows: sense4.dll. This library is located in the bin folder in Face SDK and should be located next to facerec.dll if you change the default location
  • Windows 64-bit: tensorflow.dll. This library is located in the bin folder of the Face SDK distribution package. It must be located in the directory from which the application is launched or you must add the path to the directory with this library to the PATH system variable
  • Windows 64-bit: Microsoft Visual C++ Redistributable for Visual Studio 2019
  • Linux:
  • Linux 64-bit: This library is located in the lib folder in Face SDK


The libfacerec library is loaded dynamically in runtime mode when the static method pbio::FacerecService::createService is called. Therefore, do not link your program with (Linux) or facerec.dll (Windows). You only need to add the include directory to include directories, or, for Linux projects, to link the libdl library with the -export-dynamic flag.

Warning: You can call pbio::FacerecService::createService only once, otherwise, you may encounter a crash.

All libfacerec declarations are divided in two headers:

The libfacerec library does not have any actual third-party dependencies*, since all used third-party libraries (see Open Source Licenses) are linked statically. Therefore, any version of these libraries should work for examples, in which OpenCV or boost is used.

* โ€“ except for the linux x86_64 and windows_x86_64 distribution packages. At the moment, they have a dependency on and tensorflow.dll, respectively.

Library Version#

You can get the current library version by calling the get_version method from the created FacerecService object. This will return a string in the format of x.yy.zz, where x is the major version, yy is the minor version, and zz is the patch version.

In C++, the version can be additionally obtained from the preprocessor constants:

  • LIBFACEREC_VERSION โ€“ string representation, similar to FacerecService.get_version()
  • LIBFACEREC_VERSION_HEX โ€“ 3-byte HEX representation that is useful in numeric comparisons, e.g. 0x010234


To use facerec.jar in a project, specify the path to this file in classpath. The facerec.jar Java library is a wrapper for the C++ library, so and for Linux and Android or facerec_jni.dll and facerec.dll for Windows are required in runtime. Path to the directory containing or facerec_jni.dll should be specified in java.library.path.


To use facerec in a project, add reference to FacerecCSharpWrapper.dll in a project. Add (for Linux) or facerec.dll (for Windows) and FacerecCSharpWrapper.dll to the folder with executable file.

Using the libfacerec library#

To use the libfacerec library, call the FacerecService.createService method, which dynamically loads the library.

The FacerecService.createService method has an overloading signature and can be called:

  • by passing the path to the directory with the license (from which the 3divi_face_sdk.lic license is loaded)
  • by passing the license in the form of a special structure: FacerecService.License

Warning: You can call FacerecService.createService only once, otherwise, you may encounter a crash.


#include <iostream>
#include <exception>
#include <facerec/import.h>
#include <facerec/libfacerec.h>
int main (int argc, char** argv)
pbio::FacerecService::Ptr service;
#ifdef _WIN32
service = pbio::FacerecService::createService("../bin/facerec.dll", "../conf/facerec/");
service = pbio::FacerecService::createService("../lib/", "../conf/facerec/");
const pbio::Recognizer::Ptr recognizer = service->createRecognizer("method7v7_recognizer.xml");
pbio::FacerecService::Config capturer_config("common_capturer4_fda.xml");
capturer_config.overrideParameter("min_size", 200);
pbio::Capturer::Ptr capturer = service->createCapturer(capturer_config);
// ...
catch(const pbio::Error &e)
std::cerr << "facerec exception catched: '" << e.what() << "' code: " << std::hex << e.code() << std::endl;
catch(const std::exception &e)
std::cerr << "exception catched: '" << e.what() << "'" << std::endl;

Examples of calling the createService method with a preloaded (stored in a string variable) license#

std::string license_body = "<?xml version="1.0" encoding="utf-8"?><License>........"; // contents of your license
auto license = pbio::FacerecService::License(license_body);
const pbio::FacerecService::Ptr service = pbio::FacerecService::createService("../bin/facerec.dll", "../conf/facerec/", license);
Last updated on