forked from IntelRealSense/RealSenseID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enroll.c
82 lines (70 loc) · 2.54 KB
/
enroll.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020-2021 Intel Corporation. All Rights Reserved.
#include "rsid_c/rsid_client.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*******************************************************************************
Enrollment example
User defined callbacks are called during the enrollment process
*******************************************************************************/
void my_enroll_status_clbk(rsid_enroll_status status, void* ctx)
{
printf("Enroll status: %d (%s)\n", status, rsid_enroll_status_str(status));
if (status == RSID_Enroll_Success)
{
printf("Enroll success\n");
}
}
void my_enroll_hint_clbk(rsid_enroll_status hint, void* ctx)
{
printf("Enroll hint: %d (%s)\n", hint, rsid_enroll_status_str(hint));
}
void my_enroll_progress_clbk(rsid_face_pose pose, void* ctx)
{
printf("Enroll face pose callback: %d (%s)\n", pose, rsid_face_pose_str(pose));
}
void my_face_detected_clbk(const rsid_face_rect faces[], size_t n_faces, unsigned int ts, void* ctx)
{
for (size_t i = 0; i < n_faces; i++)
{
rsid_face_rect face = faces[i];
printf("Detected face #%zu: %u,%u %ux%ux (ts=%u)\n", i + 1, face.x, face.y, face.w, face.h, ts);
}
}
int main()
{
#ifdef _WIN32
rsid_serial_config serial_config = {"COM9"};
#elif LINUX
rsid_serial_config serial_config = {"/dev/ttyACM0"};
#endif
rsid_authenticator* authenticator = rsid_create_authenticator();
if (!authenticator)
{
printf("Failed creating authenticator\n");
exit(1);
}
rsid_status status = rsid_connect(authenticator, &serial_config);
if (status != RSID_Ok)
{
printf("Failed connecting: %s\n", rsid_status_str(status));
exit(1);
}
const char* user_id = "some_user_id";
printf("Enrolling user \"%s\"\n", user_id);
rsid_enroll_args enroll_args;
enroll_args.user_id = user_id; /* user id. null terminated string of ascii chars (max 15 chars + null) */
enroll_args.status_clbk = my_enroll_status_clbk;
enroll_args.hint_clbk = my_enroll_hint_clbk;
enroll_args.progress_clbk = my_enroll_progress_clbk;
enroll_args.face_detected_clbk = my_face_detected_clbk;
enroll_args.ctx = NULL; /* user defined context struct. set to null if not needed. */
status = rsid_enroll(authenticator, &enroll_args);
if (status != RSID_Ok)
{
printf("Error status: %d (%s)\n", status, rsid_status_str(status));
}
rsid_destroy_authenticator(authenticator);
return 0;
}