-
Notifications
You must be signed in to change notification settings - Fork 62
/
index.ts
36 lines (31 loc) · 917 Bytes
/
index.ts
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, Platform } from 'react-native';
export interface Label {
text: string;
confidence: number;
index: number;
}
interface IImageLabeling {
/**
* Label an image
*
* @param imageURL The URL/Path of the image to label
* @returns Array of expected labels for the image
*/
label: (imageURL: string) => Promise<Label[]>;
}
const LINKING_ERROR =
`The package '@react-native-ml-kit/image-labeling' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo managed workflow\n';
const ImageLabeling: IImageLabeling = NativeModules.ImageLabeling
? NativeModules.ImageLabeling
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
export default ImageLabeling;