forked from sabrinabutton/ReCoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
113 lines (97 loc) · 2.69 KB
/
App.js
File metadata and controls
113 lines (97 loc) · 2.69 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { Component, useState, useEffect } from "react";
import { Button, SafeAreaView, StyleSheet, Alert, Text } from "react-native";
import test_image from "./test_image.jpg";
//Importing the installed libraries
import * as FS from "expo-file-system";
import * as ImagePicker from "expo-image-picker";
import Main from './WebCamFront/src/App';
import database from "mime-db";
import { identity } from "lodash";
const toServer = async (mediaFile) => {
let type = mediaFile.type;
let schema = "http://";
let host ="192.168.30.183";
let route = "/predict";
let port = "5000";
let url = "";
let content_type = "image/jpeg";
url = schema + host + ":" + port + route;
let response = await FS.uploadAsync(url, mediaFile.uri, {
headers: {
"content-type": content_type,
},
httpMethod: "POST",
uploadType: FS.FileSystemUploadType.BINARY_CONTENT,
});
response.json().then(data => {
console.log(data);
return data.class_name;
});
};
export default function App() {
// const uriToBase64 = async (uri) => {
// let base64 = await FS.readAsStringAsync(uri, {
// encoding: FS.EncodingType.Base64,
// });
// return base64;
// };
// const pickMedia = async () => {
// const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
// setCPR(cameraRollPer);
// setDB(true);
// let result = await ImagePicker.launchImageLibraryAsync({
// mediaTypes: ImagePicker.MediaTypeOptions.All,
// base64: true,
// });
// if (result.cancelled) {
// return;
// }
// if (result.type == "image") {
// await toServer({
// type: result.type,
// base64: result.base64,
// uri: result.uri,
// });
// } else {
// let base64 = await uriToBase64(result.uri);
// await toServer({
// type: result.type,
// base64: base64,
// uri: result.uri,
// });
// }
// };
const [identity, setIdentity] = useState(null);
return (
<SafeAreaView style={styles.container}>
{/* {cameraRollPer ? (
<Button
title="Pick From Gallery"
disabled={disableButton}
onPress={async () => {
await pickMedia();
setCPR(cameraRollPer);
setDB(false);
}}
/>
) : (
<Text>Camera Roll Permission Required ! </Text>
)} */}
<Button
title="Test"
onPress={async () => {
setIdentity(await toServer(test_image));
}}
/>
<Main/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});