-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
87 lines (82 loc) · 2.99 KB
/
Copy pathApp.js
File metadata and controls
87 lines (82 loc) · 2.99 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
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
83
84
85
86
87
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, NativeModules } from 'react-native';
import DefaultPreference from 'react-native-default-preference';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useEffect, useState } from 'react';
import Routes from './components/Routes';
import 'react-native-gesture-handler';
import {
initData,
cameraSetting,
setDefaultGroupName,
checkGroupExist,
createGroup,
} from 'facepass-react-native-module';
import Toast from 'react-native-toast-message';
export default function App() {
const { FacePass } = NativeModules;
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
async function init() {
const setting = await AsyncStorage.getItem('parameters');
const camera = await AsyncStorage.getItem('settings');
let group = 'default';
try {
const success = await initData(JSON.parse(setting));
try {
const temp_group = await AsyncStorage.getItem('group_name');
if (temp_group != null) {
group = temp_group;
}
try {
const check = await checkGroupExist(group);
console.log('CHECK', check);
} catch (e) {
console.log('CHECK', e);
try {
const create = await createGroup(group);
AsyncStorage.setItem('group_name', group);
console.log('CREATE', create);
} catch (e) {
console.log('CREATE', e);
}
}
} catch (e) {}
} catch (e) {
console.log(e);
}
// initData({"rcAttributeAndOcclusionMode":1,"searchThreshold":69,"livenessThreshold":55,"livenessEnabled":false,"rgbIrLivenessEnabled":false,"poseThresholdRoll":35,"poseThresholdPitch":35,"poseThresholdYaw":35,"blurThreshold":0.8,"lowBrightnessThreshold":30,"highBrightnessThreshold":210,"brightnessSTDThreshold":80,"faceMinThreshold":100,"retryCount":2,"smileEnabled":false,"maxFaceEnabled":true,"FacePoseThresholdPitch":35,"FacePoseThresholdRoll":35,"FacePoseThresholdYaw":35,"FaceBlurThreshold":0.7,"FaceLowBrightnessThreshold":70,"FaceHighBrightnessThreshold":220,"FaceBrightnessSTDThreshold":60,"FaceFaceMinThreshold":100,"FaceRcAttributeAndOcclusionMode":2})
cameraSetting(JSON.parse(camera));
setDefaultGroupName(group);
// setDefaultGroupName("testi");
//Then call function to initilize,all parameter need to be in JSON string format.
// cameraSetting({
// "cameraFacingFront": false,
// "faceRotation": 90,
// "isSettingAvailable": true,
// "cameraPreviewRotation": 270,
// "isCross": true,
// });
setIsLoading(false);
}
init();
}, []);
if (!isLoading) {
return (
<>
<Routes />
<Toast />
</>
);
} else {
return '';
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});