-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
73 lines (61 loc) · 2.04 KB
/
App.tsx
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
import React, { useEffect, useState } from 'react';
// Components
import { Camera } from 'expo-camera';
import { Text, View } from 'react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
// Tensorflow js
import * as tf from '@tensorflow/tfjs';
// Navigation
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
// Pages
import DetectionCocoSSD from './pages/CocoSSD/DetectionCocoSSD';
import DetectionMobilenet from './pages/Mobilenet/DetectionMobilenet';
// Types
import type { FC } from 'react';
// Inicializo Tensorflow
const initialiseTensorflow = async () => {
await tf.ready();
tf.getBackend();
};
const Stack = createBottomTabNavigator();
const App: FC<{}> = () => {
const [hasPermission, setHasPermission] = useState<null | boolean>(null);
useEffect(() => {
(async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
setHasPermission(status === 'granted');
await initialiseTensorflow();
})();
}, []);
if (hasPermission === null) {
return <View />;
}
if (hasPermission === false) {
return <Text>No access to camera</Text>;
}
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={({ route }) => ({
unmountOnBlur: true,
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'CocoSSD') {
iconName = focused ? 'images' : 'images-outline';
} else if (route.name === 'Mobilenet') {
iconName = focused ? 'image' : 'image-outline';
}
return <Ionicons name={iconName as any} size={size} color={color} />;
},
tabBarActiveTintColor: 'tomato',
tabBarInactiveTintColor: 'gray',
})}
>
<Stack.Screen name='CocoSSD' component={DetectionCocoSSD} />
<Stack.Screen name='Mobilenet' component={DetectionMobilenet} />
</Stack.Navigator>
</NavigationContainer>
);
};
export default App;