-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathsample_feature_hub_persistence.c
More file actions
52 lines (45 loc) · 1.58 KB
/
sample_feature_hub_persistence.c
File metadata and controls
52 lines (45 loc) · 1.58 KB
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
#include <inspireface.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
if (argc != 2) {
HFLogPrint(HF_LOG_ERROR, "Usage: %s <pack_path>", argv[0]);
return -1;
}
const char* packPath = argv[1];
HResult ret;
ret = HFLaunchInspireFace(packPath);
if (ret != HSUCCEED) {
HFLogPrint(HF_LOG_ERROR, "Load Resource error: %d", ret);
return ret;
}
const char* DBFilePath = "feature.db";
// remove old db file
if (access(DBFilePath, F_OK) == 0) {
if (remove(DBFilePath) != 0) {
HFLogPrint(HF_LOG_ERROR, "Failed to remove old db file: %s", DBFilePath);
return -1;
}
HFLogPrint(HF_LOG_INFO, "Remove old db file: %s", DBFilePath);
}
HFFeatureHubConfiguration featureHubConfiguration;
featureHubConfiguration.primaryKeyMode = HF_PK_AUTO_INCREMENT;
featureHubConfiguration.enablePersistence = 1;
featureHubConfiguration.persistenceDbPath = DBFilePath;
featureHubConfiguration.searchMode = HF_SEARCH_MODE_EAGER;
featureHubConfiguration.searchThreshold = 0.48f;
ret = HFFeatureHubDataEnable(featureHubConfiguration);
if (ret != HSUCCEED)
{
HFLogPrint(HF_LOG_ERROR, "Enable FeatureHub failed: %d\n", ret);
return ret;
}
if (access(DBFilePath, F_OK) != 0) {
HFLogPrint(HF_LOG_ERROR, "DB file not found: %s", DBFilePath);
return -1;
}
HFLogPrint(HF_LOG_INFO, "DB file found: %s", DBFilePath);
// ....
HFTerminateInspireFace();
return 0;
}