forked from IntelRealSense/RealSenseID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
authenticate.c
79 lines (64 loc) · 2.3 KB
/
authenticate.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
// 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>
/*******************************************************************************
Authentication example.
User defined callbacks are called during the authentication process
Upon success (RSID_Auth_Success) the user_id param points to the user id.
*******************************************************************************/
void my_auth_status_clbk(rsid_auth_status status, const char* user_id, void* ctx)
{
printf("Authentication status: %d (%s)\n", status, rsid_auth_status_str(status));
if (status == RSID_Auth_Success)
{
printf("Authentication Success. User id: %s\n", user_id);
}
}
void my_auth_hint_clbk(rsid_auth_status hint, void* ctx)
{
printf("Authentication hint: %d (%s)\n", hint, rsid_auth_status_str(hint));
}
void my_face_detected_calbk(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);
}
printf("\nAuthenticating user..\n");
rsid_auth_args auth_args;
auth_args.result_clbk = my_auth_status_clbk;
auth_args.hint_clbk = my_auth_hint_clbk;
auth_args.face_detected_clbk = my_face_detected_calbk;
auth_args.ctx = NULL; /* user defined context. set to null if not needed. */
status = rsid_authenticate(authenticator, &auth_args);
if (status != RSID_Ok)
{
printf("Error status: %d (%s)\n", status, rsid_status_str(status));
}
rsid_destroy_authenticator(authenticator);
return 0;
}