-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtypes.ts
More file actions
182 lines (167 loc) · 3.48 KB
/
Copy pathtypes.ts
File metadata and controls
182 lines (167 loc) · 3.48 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
export type {
Frame,
CameraProps,
CameraDevice,
} from 'react-native-vision-camera';
export type { ForwardedRef } from 'react';
import type { CameraProps, Frame } from 'react-native-vision-camera';
export type ReadonlyFrameProcessor = (frame: Frame) => void;
export type Languages =
| 'af'
| 'sq'
| 'ar'
| 'be'
| 'bn'
| 'bg'
| 'ca'
| 'zh'
| 'cs'
| 'da'
| 'nl'
| 'en'
| 'eo'
| 'et'
| 'fi'
| 'fr'
| 'gl'
| 'ka'
| 'de'
| 'el'
| 'gu'
| 'ht'
| 'he'
| 'hi'
| 'hu'
| 'is'
| 'id'
| 'ga'
| 'it'
| 'ja'
| 'kn'
| 'ko'
| 'lv'
| 'lt'
| 'mk'
| 'ms'
| 'mt'
| 'mr'
| 'no'
| 'fa'
| 'pl'
| 'pt'
| 'ro'
| 'ru'
| 'sk'
| 'sl'
| 'es'
| 'sw'
| 'tl'
| 'ta'
| 'te'
| 'th'
| 'tr'
| 'uk'
| 'ur'
| 'vi'
| 'cy';
/**
* Percentage string type (e.g., "0%", "50%", "100%")
*/
export type Percentage = `${number}%`;
export type ScanRegion = {
left: Percentage;
top: Percentage;
width: Percentage;
height: Percentage;
};
export type TextRecognitionOptions = {
/**
* Language to recognize
* @default 'latin'
*/
language?: 'latin' | 'chinese' | 'devanagari' | 'japanese' | 'korean';
/**
* Scan region within the frame to focus text recognition on
* @default undefined
*/
scanRegion?: ScanRegion;
/**
* Performance optimization: Skip frames to reduce processing load
* Higher values = better performance, lower accuracy
* @default 10
*/
frameSkipThreshold?: number;
/**
* Use lightweight processing for better performance (Android only)
* Skips corner points, languages, and element processing for better performance
* Has no effect on iOS - iOS always returns full data structure
* @default false
*/
useLightweightMode?: boolean;
};
export type TranslatorOptions = {
from: Languages;
to: Languages;
/**
* Scan region within the frame to focus text recognition on
* @default undefined
*/
scanRegion?: ScanRegion;
};
export type CameraTypes = {
callback: (data: string | Text) => void;
mode: 'translate' | 'recognize';
} & CameraProps &
(
| { mode: 'recognize'; options: TextRecognitionOptions }
| { mode: 'translate'; options: TranslatorOptions }
);
export type ScanTextConfig = { scanRegion: ScanRegion };
export type TextRecognitionPlugin = {
scanText: (frame: Frame, config?: ScanTextConfig) => Text;
};
export type TranslatorPlugin = {
/** Worklet-safe synchronous call that returns the last completed OCR result while OCR runs asynchronously. */
scanText: (frame: Frame) => Text;
/** Async translation of a text string — runs on the JS thread. */
translate: (text: string) => Promise<string>;
};
export type Text = {
blocks: BlockData[];
resultText: string;
};
export type BlockData = {
blockText: string;
blockCornerPoints?: CornerPointsType;
blockFrame: FrameType;
lines: LineData[];
};
export type CornerPointsType = { x: number; y: number }[];
export type FrameType = {
boundingCenterX: number;
boundingCenterY: number;
height: number;
width: number;
x: number;
y: number;
};
export type LineData = {
lineText: string;
lineCornerPoints?: CornerPointsType;
lineFrame: FrameType;
lineLanguages?: string[];
elements: ElementData[];
};
export type ElementData = {
elementText: string;
elementCornerPoints?: CornerPointsType;
elementFrame: FrameType;
};
export type PhotoOptions = {
uri: string;
orientation?:
| 'landscapeRight'
| 'portrait'
| 'portraitUpsideDown'
| 'landscapeLeft';
};