Links

Enrollment

Example for how to enroll a new user.
The enrollment creates a new user entity within the Keyless Network based on the face features captured by the selected camera device. Succesful enrollment outputs a User Secret which may be later used to verify the user identity during an authentication.
To start an enrollment we must first initialize a Keyless SDK session (see Getting Started).

Synchronous enrollment

We will perform enrollment using a simple blocking call.
/// USER SESSION HAS BEEN INITIALIZED
// Enrollment outputs (User Key used as input to authentications, User Secret to
// verify authentication), let's save both
std::vector<unsigned char> user_key, user_secret;
try
{
// IEnrollment object will hold the enrollment result
keyless::IEnrollment::Ptr enroll;
// Perform enrollment using previously selected and configured camera device
enroll = session->enroll(*device_selector, nullptr);
/// USER HAS BEEN SUCCESFULLY ENROLLED HERE
// Optionally we can double-check enrollment here
if (session->isEnrolled()) {
// Save User Key
user_key.resize(enroll->getUserKey().getDataSize());
enroll->getUserKey().readData(user_key.data(), user_key.size());
// Save User Secret
user_secret.resize(enroll->getUserKey().getDataSize());
enroll->getUserSecret().readData(user_secret.data(), user_secret.size());
}
}
catch (const keyless::IException& e)
{
std::cerr << e.message() << std::endl;
}

Asynchronous enrollment

To perform the enrollment we call the enrollAsync()method with our implementation of IEnrollmentCallbacks interface which will report the execution end.
class KeylessEnrollmentCallbacks : public keyless::IEnrollmentCallbacks
{
private:
void KEYLESS_SDK_CALL onFailure(const keyless::IException& exception) noexcept override
{
// Enrollment has ended with failure here, save details from `exception`
}
void KEYLESS_SDK_CALL onSuccess(keyless::IEnrollment* enrollment) noexcept override
{
// Enrollment has ended with success here, save results from `enrollment`
}
keyless::IStatusCallbacks* KEYLESS_SDK_CALL getStatusCallbacks() noexcept override
{
return nullptr; // see "Status Updates" below
}
};
We will also retrieve the IControl interface allowing us to stop the running execution.
/// USER SESSION HAS BEEN INITIALIZED
try
{
// declare our asynchronous callbacks
KeylessEnrollmentCallbacks callbacks;
// Perform enrollment
keyless::IControl& control = session->enrollAsync(callbacks);
/// ENROLLMENT IN PROGRESS, WAIT FOR RESULT VIA CALLBACKS
// we can optionally interrupt the running execution with this call
control.stop();
}
catch (const keyless::IException& e)
{
std::cerr << e.message() << std::endl;
}

Status updates

We may provide both enroll() and enrollAsync() methods with our implementation of IStatusCallbacks interface which will report enrollment progress.
class KeylessWndStatusCallbacks : public keyless::IStatusCallbacks
{
private:
void KEYLESS_SDK_CALL onFrameCapture(const keyless::IFrame& frame) noexcept override
{
// New frame capture from the camera, save it to be displayed to user
}
void KEYLESS_SDK_CALL onSessionStatus(keyless::SessionStatus status, const keyless::IException& e) noexcept override
{
// Overall execution status has changed
}
void KEYLESS_SDK_CALL onLivenessStatus(keyless::LivenessStatus status) noexcept override
{
// Liveness detection status has changed
}
void KEYLESS_SDK_CALL onRecognitionStatus(keyless::FaceRecognitionStatus status) noexcept override
{
// Face recognition status has changed
}
}