forked from jazzystring1/react-native-tensorflow-lite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
28 lines (20 loc) · 707 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
import { NativeModules, Image } from "react-native";
const { RNTFLiteImageRecognition } = NativeModules;
class TFLiteImageRecognition {
constructor(data) {
this.state = RNTFLiteImageRecognition.createImageRecognizer(data).catch(err => console.log(err));
}
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 };