-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
36 lines (25 loc) · 879 Bytes
/
index.js
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
import { NativeModules, Image } from 'react-native';
const { RNTFLiteImageRecognition } = NativeModules;
class TFLiteImageRecognition {
constructor(data) {
data['model'] = Image.resolveAssetSource(data['model']) != null
? Image.resolveAssetSource(data['model']).uri
: data['model']
data['labels'] = Image.resolveAssetSource(data['labels']) != null
? Image.resolveAssetSource(data['labels']).uri
: data['labels']
this.state = RNTFLiteImageRecognition.createImageRecognizer(data);
}
async recognize(data) {
await this.state;
data['image'] = Image.resolveAssetSource(data['image']) != null
? Image.resolveAssetSource(data['image']).uri
: data['image']
return RNTFLiteImageRecognition.recognize(data);
}
async close() {
await this.state;
RNTFLiteImageRecognition.close();
}
}
export { TFLiteImageRecognition };