@mediapipe/tasks-vision 0.1.0-alpha-14 → 0.1.0-alpha-15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vision.d.ts +2247 -0
package/vision.d.ts ADDED
@@ -0,0 +1,2247 @@
1
+ /**
2
+ * Copyright 2022 The MediaPipe Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /** Options to configure MediaPipe model loading and processing. */
17
+ declare interface BaseOptions_2 {
18
+ /**
19
+ * The model path to the model asset file. Only one of `modelAssetPath` or
20
+ * `modelAssetBuffer` can be set.
21
+ */
22
+ modelAssetPath?: string | undefined;
23
+ /**
24
+ * A buffer containing the model aaset. Only one of `modelAssetPath` or
25
+ * `modelAssetBuffer` can be set.
26
+ */
27
+ modelAssetBuffer?: Uint8Array | undefined;
28
+ /** Overrides the default backend to use for the provided model. */
29
+ delegate?: "CPU" | "GPU" | undefined;
30
+ }
31
+
32
+ /**
33
+ * Copyright 2023 The MediaPipe Authors.
34
+ *
35
+ * Licensed under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License.
37
+ * You may obtain a copy of the License at
38
+ *
39
+ * http://www.apache.org/licenses/LICENSE-2.0
40
+ *
41
+ * Unless required by applicable law or agreed to in writing, software
42
+ * distributed under the License is distributed on an "AS IS" BASIS,
43
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ * See the License for the specific language governing permissions and
45
+ * limitations under the License.
46
+ */
47
+ /** An integer bounding box, axis aligned. */
48
+ export declare interface BoundingBox {
49
+ /** The X coordinate of the top-left corner, in pixels. */
50
+ originX: number;
51
+ /** The Y coordinate of the top-left corner, in pixels. */
52
+ originY: number;
53
+ /** The width of the bounding box, in pixels. */
54
+ width: number;
55
+ /** The height of the bounding box, in pixels. */
56
+ height: number;
57
+ }
58
+
59
+ /**
60
+ * A user-defined callback to take input data and map it to a custom output
61
+ * value.
62
+ */
63
+ export declare type Callback<I, O> = (input: I) => O;
64
+
65
+ /**
66
+ * Copyright 2022 The MediaPipe Authors.
67
+ *
68
+ * Licensed under the Apache License, Version 2.0 (the "License");
69
+ * you may not use this file except in compliance with the License.
70
+ * You may obtain a copy of the License at
71
+ *
72
+ * http://www.apache.org/licenses/LICENSE-2.0
73
+ *
74
+ * Unless required by applicable law or agreed to in writing, software
75
+ * distributed under the License is distributed on an "AS IS" BASIS,
76
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77
+ * See the License for the specific language governing permissions and
78
+ * limitations under the License.
79
+ */
80
+ /** A classification category. */
81
+ export declare interface Category {
82
+ /** The probability score of this label category. */
83
+ score: number;
84
+ /** The index of the category in the corresponding label file. */
85
+ index: number;
86
+ /**
87
+ * The label of this category object. Defaults to an empty string if there is
88
+ * no category.
89
+ */
90
+ categoryName: string;
91
+ /**
92
+ * The display name of the label, which may be translated for different
93
+ * locales. For example, a label, "apple", may be translated into Spanish for
94
+ * display purpose, so that the `display_name` is "manzana". Defaults to an
95
+ * empty string if there is no display name.
96
+ */
97
+ displayName: string;
98
+ }
99
+
100
+ /** Classification results for a given classifier head. */
101
+ export declare interface Classifications {
102
+ /**
103
+ * The array of predicted categories, usually sorted by descending scores,
104
+ * e.g., from high to low probability.
105
+ */
106
+ categories: Category[];
107
+ /**
108
+ * The index of the classifier head these categories refer to. This is
109
+ * useful for multi-head models.
110
+ */
111
+ headIndex: number;
112
+ /**
113
+ * The name of the classifier head, which is the corresponding tensor
114
+ * metadata name. Defaults to an empty string if there is no such metadata.
115
+ */
116
+ headName: string;
117
+ }
118
+
119
+ /**
120
+ * Copyright 2022 The MediaPipe Authors.
121
+ *
122
+ * Licensed under the Apache License, Version 2.0 (the "License");
123
+ * you may not use this file except in compliance with the License.
124
+ * You may obtain a copy of the License at
125
+ *
126
+ * http://www.apache.org/licenses/LICENSE-2.0
127
+ *
128
+ * Unless required by applicable law or agreed to in writing, software
129
+ * distributed under the License is distributed on an "AS IS" BASIS,
130
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131
+ * See the License for the specific language governing permissions and
132
+ * limitations under the License.
133
+ */
134
+ /** Options to configure a MediaPipe Classifier Task. */
135
+ declare interface ClassifierOptions {
136
+ /**
137
+ * The locale to use for display names specified through the TFLite Model
138
+ * Metadata, if any. Defaults to English.
139
+ */
140
+ displayNamesLocale?: string | undefined;
141
+ /** The maximum number of top-scored detection results to return. */
142
+ maxResults?: number | undefined;
143
+ /**
144
+ * Overrides the value provided in the model metadata. Results below this
145
+ * value are rejected.
146
+ */
147
+ scoreThreshold?: number | undefined;
148
+ /**
149
+ * Allowlist of category names. If non-empty, detection results whose category
150
+ * name is not in this set will be filtered out. Duplicate or unknown category
151
+ * names are ignored. Mutually exclusive with `categoryDenylist`.
152
+ */
153
+ categoryAllowlist?: string[] | undefined;
154
+ /**
155
+ * Denylist of category names. If non-empty, detection results whose category
156
+ * name is in this set will be filtered out. Duplicate or unknown category
157
+ * names are ignored. Mutually exclusive with `categoryAllowlist`.
158
+ */
159
+ categoryDenylist?: string[] | undefined;
160
+ }
161
+
162
+ /** A connection between two landmarks. */
163
+ declare interface Connection {
164
+ start: number;
165
+ end: number;
166
+ }
167
+
168
+ /** Represents one detection by a detection task. */
169
+ export declare interface Detection {
170
+ /** A list of `Category` objects. */
171
+ categories: Category[];
172
+ /** The bounding box of the detected objects. */
173
+ boundingBox?: BoundingBox;
174
+ /**
175
+ * Optional list of keypoints associated with the detection. Keypoints
176
+ * represent interesting points related to the detection. For example, the
177
+ * keypoints represent the eye, ear and mouth from face detection model. Or
178
+ * in the template matching detection, e.g. KNIFT, they can represent the
179
+ * feature points for template matching.
180
+ */
181
+ keypoints?: NormalizedKeypoint[];
182
+ }
183
+
184
+ /** Detection results of a model. */
185
+ declare interface DetectionResult {
186
+ /** A list of Detections. */
187
+ detections: Detection[];
188
+ }
189
+ export { DetectionResult as FaceDetectorResult }
190
+ export { DetectionResult as ObjectDetectorResult }
191
+
192
+ /**
193
+ * Options for customizing the drawing routines
194
+ */
195
+ export declare interface DrawingOptions {
196
+ /** The color that is used to draw the shape. Defaults to white. */
197
+ color?: string | CanvasGradient | CanvasPattern | Callback<LandmarkData, string | CanvasGradient | CanvasPattern>;
198
+ /**
199
+ * The color that is used to fill the shape. Defaults to `.color` (or black
200
+ * if color is not set).
201
+ */
202
+ fillColor?: string | CanvasGradient | CanvasPattern | Callback<LandmarkData, string | CanvasGradient | CanvasPattern>;
203
+ /** The width of the line boundary of the shape. Defaults to 4. */
204
+ lineWidth?: number | Callback<LandmarkData, number>;
205
+ /** The radius of location marker. Defaults to 6. */
206
+ radius?: number | Callback<LandmarkData, number>;
207
+ }
208
+
209
+ /** Helper class to visualize the result of a MediaPipe Vision task. */
210
+ export declare class DrawingUtils {
211
+ /**
212
+ * Creates a new DrawingUtils class.
213
+ *
214
+ * @param ctx The canvas to render onto.
215
+ */
216
+ constructor(ctx: CanvasRenderingContext2D);
217
+ /**
218
+ * Restricts a number between two endpoints (order doesn't matter).
219
+ *
220
+ * @param x The number to clamp.
221
+ * @param x0 The first boundary.
222
+ * @param x1 The second boundary.
223
+ * @return The clamped value.
224
+ */
225
+ static clamp(x: number, x0: number, x1: number): number;
226
+ /**
227
+ * Linearly interpolates a value between two points, clamping that value to
228
+ * the endpoints.
229
+ *
230
+ * @param x The number to interpolate.
231
+ * @param x0 The x coordinate of the start value.
232
+ * @param x1 The x coordinate of the end value.
233
+ * @param y0 The y coordinate of the start value.
234
+ * @param y1 The y coordinate of the end value.
235
+ * @return The interpolated value.
236
+ */
237
+ static lerp(x: number, x0: number, x1: number, y0: number, y1: number): number;
238
+ /**
239
+ * Draws circles onto the provided landmarks.
240
+ *
241
+ * @param landmarks The landmarks to draw.
242
+ * @param style The style to visualize the landmarks.
243
+ */
244
+ drawLandmarks(landmarks?: NormalizedLandmark[], style?: DrawingOptions): void;
245
+ /**
246
+ * Draws lines between landmarks (given a connection graph).
247
+ *
248
+ * @param landmarks The landmarks to draw.
249
+ * @param connections The connections array that contains the start and the
250
+ * end indices for the connections to draw.
251
+ * @param style The style to visualize the landmarks.
252
+ */
253
+ drawConnectors(landmarks?: NormalizedLandmark[], connections?: Connection[], style?: DrawingOptions): void;
254
+ /**
255
+ * Draws a bounding box.
256
+ *
257
+ * @param boundingBox The bounding box to draw.
258
+ * @param style The style to visualize the boundin box.
259
+ */
260
+ drawBoundingBox(boundingBox: BoundingBox, style?: DrawingOptions): void;
261
+ }
262
+
263
+ /**
264
+ * Copyright 2022 The MediaPipe Authors.
265
+ *
266
+ * Licensed under the Apache License, Version 2.0 (the "License");
267
+ * you may not use this file except in compliance with the License.
268
+ * You may obtain a copy of the License at
269
+ *
270
+ * http://www.apache.org/licenses/LICENSE-2.0
271
+ *
272
+ * Unless required by applicable law or agreed to in writing, software
273
+ * distributed under the License is distributed on an "AS IS" BASIS,
274
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
275
+ * See the License for the specific language governing permissions and
276
+ * limitations under the License.
277
+ */
278
+ /** Options to configure a MediaPipe Embedder Task */
279
+ declare interface EmbedderOptions {
280
+ /**
281
+ * Whether to normalize the returned feature vector with L2 norm. Use this
282
+ * option only if the model does not already contain a native L2_NORMALIZATION
283
+ * TF Lite Op. In most cases, this is already the case and L2 norm is thus
284
+ * achieved through TF Lite inference.
285
+ */
286
+ l2Normalize?: boolean | undefined;
287
+ /**
288
+ * Whether the returned embedding should be quantized to bytes via scalar
289
+ * quantization. Embeddings are implicitly assumed to be unit-norm and
290
+ * therefore any dimension is guaranteed to have a value in [-1.0, 1.0]. Use
291
+ * the l2_normalize option if this is not the case.
292
+ */
293
+ quantize?: boolean | undefined;
294
+ }
295
+
296
+ /**
297
+ * Copyright 2022 The MediaPipe Authors.
298
+ *
299
+ * Licensed under the Apache License, Version 2.0 (the "License");
300
+ * you may not use this file except in compliance with the License.
301
+ * You may obtain a copy of the License at
302
+ *
303
+ * http://www.apache.org/licenses/LICENSE-2.0
304
+ *
305
+ * Unless required by applicable law or agreed to in writing, software
306
+ * distributed under the License is distributed on an "AS IS" BASIS,
307
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
308
+ * See the License for the specific language governing permissions and
309
+ * limitations under the License.
310
+ */
311
+ /**
312
+ * List of embeddings with an optional timestamp.
313
+ *
314
+ * One and only one of the two 'floatEmbedding' and 'quantizedEmbedding' will
315
+ * contain data, based on whether or not the embedder was configured to perform
316
+ * scalar quantization.
317
+ */
318
+ export declare interface Embedding {
319
+ /**
320
+ * Floating-point embedding. Empty if the embedder was configured to perform
321
+ * scalar-quantization.
322
+ */
323
+ floatEmbedding?: number[];
324
+ /**
325
+ * Scalar-quantized embedding. Empty if the embedder was not configured to
326
+ * perform scalar quantization.
327
+ */
328
+ quantizedEmbedding?: Uint8Array;
329
+ /**
330
+ * The index of the classifier head these categories refer to. This is
331
+ * useful for multi-head models.
332
+ */
333
+ headIndex: number;
334
+ /**
335
+ * The name of the classifier head, which is the corresponding tensor
336
+ * metadata name.
337
+ */
338
+ headName: string;
339
+ }
340
+
341
+ /** Performs face detection on images. */
342
+ export declare class FaceDetector extends VisionTaskRunner {
343
+ /**
344
+ * Initializes the Wasm runtime and creates a new face detector from the
345
+ * provided options.
346
+ * @param wasmFileset A configuration object that provides the location of the
347
+ * Wasm binary and its loader.
348
+ * @param faceDetectorOptions The options for the FaceDetector. Note that
349
+ * either a path to the model asset or a model buffer needs to be
350
+ * provided (via `baseOptions`).
351
+ */
352
+ static createFromOptions(wasmFileset: WasmFileset, faceDetectorOptions: FaceDetectorOptions): Promise<FaceDetector>;
353
+ /**
354
+ * Initializes the Wasm runtime and creates a new face detector based on the
355
+ * provided model asset buffer.
356
+ * @param wasmFileset A configuration object that provides the location of the
357
+ * Wasm binary and its loader.
358
+ * @param modelAssetBuffer A binary representation of the model.
359
+ */
360
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceDetector>;
361
+ /**
362
+ * Initializes the Wasm runtime and creates a new face detector based on the
363
+ * path to the model asset.
364
+ * @param wasmFileset A configuration object that provides the location of the
365
+ * Wasm binary and its loader.
366
+ * @param modelAssetPath The path to the model asset.
367
+ */
368
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceDetector>;
369
+ private constructor();
370
+ /**
371
+ * Sets new options for the FaceDetector.
372
+ *
373
+ * Calling `setOptions()` with a subset of options only affects those options.
374
+ * You can reset an option back to its default value by explicitly setting it
375
+ * to `undefined`.
376
+ *
377
+ * @param options The options for the FaceDetector.
378
+ */
379
+ setOptions(options: FaceDetectorOptions): Promise<void>;
380
+ /**
381
+ * Performs face detection on the provided single image and waits
382
+ * synchronously for the response. Only use this method when the
383
+ * FaceDetector is created with running mode `image`.
384
+ *
385
+ * @param image An image to process.
386
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
387
+ * to process the input image before running inference.
388
+ * @return A result containing the list of detected faces.
389
+ */
390
+ detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
391
+ /**
392
+ * Performs face detection on the provided video frame and waits
393
+ * synchronously for the response. Only use this method when the
394
+ * FaceDetector is created with running mode `video`.
395
+ *
396
+ * @param videoFrame A video frame to process.
397
+ * @param timestamp The timestamp of the current frame, in ms.
398
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
399
+ * to process the input image before running inference.
400
+ * @return A result containing the list of detected faces.
401
+ */
402
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
403
+ }
404
+
405
+ /** Options to configure the MediaPipe Face Detector Task */
406
+ export declare interface FaceDetectorOptions extends VisionTaskOptions {
407
+ /**
408
+ * The minimum confidence score for the face detection to be considered
409
+ * successful. Defaults to 0.5.
410
+ */
411
+ minDetectionConfidence?: number | undefined;
412
+ /**
413
+ * The minimum non-maximum-suppression threshold for face detection to be
414
+ * considered overlapped. Defaults to 0.3.
415
+ */
416
+ minSuppressionThreshold?: number | undefined;
417
+ }
418
+
419
+ /**
420
+ * Performs face landmarks detection on images.
421
+ *
422
+ * This API expects a pre-trained face landmarker model asset bundle.
423
+ */
424
+ export declare class FaceLandmarker extends VisionTaskRunner {
425
+ /**
426
+ * Initializes the Wasm runtime and creates a new `FaceLandmarker` from the
427
+ * provided options.
428
+ * @param wasmFileset A configuration object that provides the location of the
429
+ * Wasm binary and its loader.
430
+ * @param faceLandmarkerOptions The options for the FaceLandmarker.
431
+ * Note that either a path to the model asset or a model buffer needs to
432
+ * be provided (via `baseOptions`).
433
+ */
434
+ static createFromOptions(wasmFileset: WasmFileset, faceLandmarkerOptions: FaceLandmarkerOptions): Promise<FaceLandmarker>;
435
+ /**
436
+ * Initializes the Wasm runtime and creates a new `FaceLandmarker` based on
437
+ * the provided model asset buffer.
438
+ * @param wasmFileset A configuration object that provides the location of the
439
+ * Wasm binary and its loader.
440
+ * @param modelAssetBuffer A binary representation of the model.
441
+ */
442
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceLandmarker>;
443
+ /**
444
+ * Initializes the Wasm runtime and creates a new `FaceLandmarker` based on
445
+ * the path to the model asset.
446
+ * @param wasmFileset A configuration object that provides the location of the
447
+ * Wasm binary and its loader.
448
+ * @param modelAssetPath The path to the model asset.
449
+ */
450
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceLandmarker>;
451
+ /** Landmark connections to draw the connection between a face's lips. */
452
+ static FACE_LANDMARKS_LIPS: Connection[];
453
+ /** Landmark connections to draw the connection between a face's left eye. */
454
+ static FACE_LANDMARKS_LEFT_EYE: Connection[];
455
+ /**
456
+ * Landmark connections to draw the connection between a face's left eyebrow.
457
+ */
458
+ static FACE_LANDMARKS_LEFT_EYEBROW: Connection[];
459
+ /** Landmark connections to draw the connection between a face's left iris. */
460
+ static FACE_LANDMARKS_LEFT_IRIS: Connection[];
461
+ /** Landmark connections to draw the connection between a face's right eye. */
462
+ static FACE_LANDMARKS_RIGHT_EYE: Connection[];
463
+ /**
464
+ * Landmark connections to draw the connection between a face's right
465
+ * eyebrow.
466
+ */
467
+ static FACE_LANDMARKS_RIGHT_EYEBROW: Connection[];
468
+ /**
469
+ * Landmark connections to draw the connection between a face's right iris.
470
+ */
471
+ static FACE_LANDMARKS_RIGHT_IRIS: Connection[];
472
+ /** Landmark connections to draw the face's oval. */
473
+ static FACE_LANDMARKS_FACE_OVAL: Connection[];
474
+ /** Landmark connections to draw the face's contour. */
475
+ static FACE_LANDMARKS_CONTOURS: Connection[];
476
+ /** Landmark connections to draw the face's tesselation. */
477
+ static FACE_LANDMARKS_TESSELATION: Connection[];
478
+ private constructor();
479
+ /**
480
+ * Sets new options for this `FaceLandmarker`.
481
+ *
482
+ * Calling `setOptions()` with a subset of options only affects those options.
483
+ * You can reset an option back to its default value by explicitly setting it
484
+ * to `undefined`.
485
+ *
486
+ * @param options The options for the face landmarker.
487
+ */
488
+ setOptions(options: FaceLandmarkerOptions): Promise<void>;
489
+ /**
490
+ * Performs face landmarks detection on the provided single image and waits
491
+ * synchronously for the response. Only use this method when the
492
+ * FaceLandmarker is created with running mode `image`.
493
+ *
494
+ * @param image An image to process.
495
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
496
+ * to process the input image before running inference.
497
+ * @return The detected face landmarks.
498
+ */
499
+ detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): FaceLandmarkerResult;
500
+ /**
501
+ * Performs face landmarks detection on the provided video frame and waits
502
+ * synchronously for the response. Only use this method when the
503
+ * FaceLandmarker is created with running mode `video`.
504
+ *
505
+ * @param videoFrame A video frame to process.
506
+ * @param timestamp The timestamp of the current frame, in ms.
507
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
508
+ * to process the input image before running inference.
509
+ * @return The detected face landmarks.
510
+ */
511
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): FaceLandmarkerResult;
512
+ }
513
+
514
+ /** Options to configure the MediaPipe FaceLandmarker Task */
515
+ export declare interface FaceLandmarkerOptions extends VisionTaskOptions {
516
+ /**
517
+ * The maximum number of faces can be detected by the FaceLandmarker.
518
+ * Defaults to 1.
519
+ */
520
+ numFaces?: number | undefined;
521
+ /**
522
+ * The minimum confidence score for the face detection to be considered
523
+ * successful. Defaults to 0.5.
524
+ */
525
+ minFaceDetectionConfidence?: number | undefined;
526
+ /**
527
+ * The minimum confidence score of face presence score in the face landmark
528
+ * detection. Defaults to 0.5.
529
+ */
530
+ minFacePresenceConfidence?: number | undefined;
531
+ /**
532
+ * The minimum confidence score for the face tracking to be considered
533
+ * successful. Defaults to 0.5.
534
+ */
535
+ minTrackingConfidence?: number | undefined;
536
+ /**
537
+ * Whether FaceLandmarker outputs face blendshapes classification. Face
538
+ * blendshapes are used for rendering the 3D face model.
539
+ */
540
+ outputFaceBlendshapes?: boolean | undefined;
541
+ /**
542
+ * Whether FaceLandmarker outputs facial transformation_matrix. Facial
543
+ * transformation matrix is used to transform the face landmarks in canonical
544
+ * face to the detected face, so that users can apply face effects on the
545
+ * detected landmarks.
546
+ */
547
+ outputFacialTransformationMatrixes?: boolean | undefined;
548
+ }
549
+
550
+ /**
551
+ * Represents the face landmarks deection results generated by `FaceLandmarker`.
552
+ */
553
+ export declare interface FaceLandmarkerResult {
554
+ /** Detected face landmarks in normalized image coordinates. */
555
+ faceLandmarks: NormalizedLandmark[][];
556
+ /** Optional face blendshapes results. */
557
+ faceBlendshapes?: Classifications[];
558
+ /** Optional facial transformation matrix. */
559
+ facialTransformationMatrixes?: Matrix[];
560
+ }
561
+
562
+ /** Performs face stylization on images. */
563
+ export declare class FaceStylizer extends VisionTaskRunner {
564
+ /**
565
+ * Initializes the Wasm runtime and creates a new Face Stylizer from the
566
+ * provided options.
567
+ * @param wasmFileset A configuration object that provides the location of
568
+ * the Wasm binary and its loader.
569
+ * @param faceStylizerOptions The options for the Face Stylizer. Note
570
+ * that either a path to the model asset or a model buffer needs to be
571
+ * provided (via `baseOptions`).
572
+ */
573
+ static createFromOptions(wasmFileset: WasmFileset, faceStylizerOptions: FaceStylizerOptions): Promise<FaceStylizer>;
574
+ /**
575
+ * Initializes the Wasm runtime and creates a new Face Stylizer based on
576
+ * the provided model asset buffer.
577
+ * @param wasmFileset A configuration object that provides the location of
578
+ * the Wasm binary and its loader.
579
+ * @param modelAssetBuffer A binary representation of the model.
580
+ */
581
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceStylizer>;
582
+ /**
583
+ * Initializes the Wasm runtime and creates a new Face Stylizer based on
584
+ * the path to the model asset.
585
+ * @param wasmFileset A configuration object that provides the location of
586
+ * the Wasm binary and its loader.
587
+ * @param modelAssetPath The path to the model asset.
588
+ */
589
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceStylizer>;
590
+ private constructor();
591
+ /**
592
+ * Sets new options for the Face Stylizer.
593
+ *
594
+ * Calling `setOptions()` with a subset of options only affects those
595
+ * options. You can reset an option back to its default value by
596
+ * explicitly setting it to `undefined`.
597
+ *
598
+ * @param options The options for the Face Stylizer.
599
+ */
600
+ setOptions(options: FaceStylizerOptions): Promise<void>;
601
+ /**
602
+ * Performs face stylization on the provided single image and invokes the
603
+ * callback with result. The method returns synchronously once the callback
604
+ * returns. Only use this method when the FaceStylizer is created with the
605
+ * image running mode.
606
+ *
607
+ * @param image An image to process.
608
+ * @param callback The callback that is invoked with the stylized image or
609
+ * `null` if no face was detected. The lifetime of the returned data is
610
+ * only guaranteed for the duration of the callback.
611
+ */
612
+ stylize(image: ImageSource, callback: FaceStylizerCallback): void;
613
+ /**
614
+ * Performs face stylization on the provided single image and invokes the
615
+ * callback with result. The method returns synchronously once the callback
616
+ * returns. Only use this method when the FaceStylizer is created with the
617
+ * image running mode.
618
+ *
619
+ * The 'imageProcessingOptions' parameter can be used to specify one or all
620
+ * of:
621
+ * - the rotation to apply to the image before performing stylization, by
622
+ * setting its 'rotationDegrees' property.
623
+ * - the region-of-interest on which to perform stylization, by setting its
624
+ * 'regionOfInterest' property. If not specified, the full image is used.
625
+ * If both are specified, the crop around the region-of-interest is extracted
626
+ * first, then the specified rotation is applied to the crop.
627
+ *
628
+ * @param image An image to process.
629
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
630
+ * to process the input image before running inference.
631
+ * @param callback The callback that is invoked with the stylized image or
632
+ * `null` if no face was detected. The lifetime of the returned data is
633
+ * only guaranteed for the duration of the callback.
634
+ */
635
+ stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: FaceStylizerCallback): void;
636
+ /**
637
+ * Performs face stylization on the provided single image and returns the
638
+ * result. This method creates a copy of the resulting image and should not be
639
+ * used in high-throughput applictions. Only use this method when the
640
+ * FaceStylizer is created with the image running mode.
641
+ *
642
+ * @param image An image to process.
643
+ * @return A stylized face or `null` if no face was detected. The result is
644
+ * copied to avoid lifetime issues.
645
+ */
646
+ stylize(image: ImageSource): MPImage | null;
647
+ /**
648
+ * Performs face stylization on the provided single image and returns the
649
+ * result. This method creates a copy of the resulting image and should not be
650
+ * used in high-throughput applictions. Only use this method when the
651
+ * FaceStylizer is created with the image running mode.
652
+ *
653
+ * The 'imageProcessingOptions' parameter can be used to specify one or all
654
+ * of:
655
+ * - the rotation to apply to the image before performing stylization, by
656
+ * setting its 'rotationDegrees' property.
657
+ * - the region-of-interest on which to perform stylization, by setting its
658
+ * 'regionOfInterest' property. If not specified, the full image is used.
659
+ * If both are specified, the crop around the region-of-interest is extracted
660
+ * first, then the specified rotation is applied to the crop.
661
+ *
662
+ * @param image An image to process.
663
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
664
+ * to process the input image before running inference.
665
+ * @return A stylized face or `null` if no face was detected. The result is
666
+ * copied to avoid lifetime issues.
667
+ */
668
+ stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): MPImage | null;
669
+ /**
670
+ * Performs face stylization on the provided video frame and invokes the
671
+ * callback with result. The method returns synchronously once the callback
672
+ * returns. Only use this method when the FaceStylizer is created with the
673
+ * video running mode.
674
+ *
675
+ * The input frame can be of any size. It's required to provide the video
676
+ * frame's timestamp (in milliseconds). The input timestamps must be
677
+ * monotonically increasing.
678
+ *
679
+ * @param videoFrame A video frame to process.
680
+ * @param timestamp The timestamp of the current frame, in ms.
681
+ * @param callback The callback that is invoked with the stylized image or
682
+ * `null` if no face was detected. The lifetime of the returned data is only
683
+ * guaranteed for the duration of the callback.
684
+ */
685
+ stylizeForVideo(videoFrame: ImageSource, timestamp: number, callback: FaceStylizerCallback): void;
686
+ /**
687
+ * Performs face stylization on the provided video frame and invokes the
688
+ * callback with result. The method returns synchronously once the callback
689
+ * returns. Only use this method when the FaceStylizer is created with the
690
+ * video running mode.
691
+ *
692
+ * The 'imageProcessingOptions' parameter can be used to specify one or all
693
+ * of:
694
+ * - the rotation to apply to the image before performing stylization, by
695
+ * setting its 'rotationDegrees' property.
696
+ * - the region-of-interest on which to perform stylization, by setting its
697
+ * 'regionOfInterest' property. If not specified, the full image is used.
698
+ * If both are specified, the crop around the region-of-interest is
699
+ * extracted first, then the specified rotation is applied to the crop.
700
+ *
701
+ * The input frame can be of any size. It's required to provide the video
702
+ * frame's timestamp (in milliseconds). The input timestamps must be
703
+ * monotonically increasing.
704
+ *
705
+ * @param videoFrame A video frame to process.
706
+ * @param timestamp The timestamp of the current frame, in ms.
707
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
708
+ * to process the input image before running inference.
709
+ * @param callback The callback that is invoked with the stylized image or
710
+ * `null` if no face was detected. The lifetime of the returned data is only
711
+ * guaranteed for the duration of the callback.
712
+ */
713
+ stylizeForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: FaceStylizerCallback): void;
714
+ /**
715
+ * Performs face stylization on the provided video frame. This method creates
716
+ * a copy of the resulting image and should not be used in high-throughput
717
+ * applictions. Only use this method when the FaceStylizer is created with the
718
+ * video running mode.
719
+ *
720
+ * The input frame can be of any size. It's required to provide the video
721
+ * frame's timestamp (in milliseconds). The input timestamps must be
722
+ * monotonically increasing.
723
+ *
724
+ * @param videoFrame A video frame to process.
725
+ * @param timestamp The timestamp of the current frame, in ms.
726
+ * @return A stylized face or `null` if no face was detected. The result is
727
+ * copied to avoid lifetime issues.
728
+ */
729
+ stylizeForVideo(videoFrame: ImageSource, timestamp: number): MPImage | null;
730
+ /**
731
+ * Performs face stylization on the provided video frame. This method creates
732
+ * a copy of the resulting image and should not be used in high-throughput
733
+ * applictions. Only use this method when the FaceStylizer is created with the
734
+ * video running mode.
735
+ *
736
+ * The 'imageProcessingOptions' parameter can be used to specify one or all
737
+ * of:
738
+ * - the rotation to apply to the image before performing stylization, by
739
+ * setting its 'rotationDegrees' property.
740
+ * - the region-of-interest on which to perform stylization, by setting its
741
+ * 'regionOfInterest' property. If not specified, the full image is used.
742
+ * If both are specified, the crop around the region-of-interest is
743
+ * extracted first, then the specified rotation is applied to the crop.
744
+ *
745
+ * The input frame can be of any size. It's required to provide the video
746
+ * frame's timestamp (in milliseconds). The input timestamps must be
747
+ * monotonically increasing.
748
+ *
749
+ * @param videoFrame A video frame to process.
750
+ * @param timestamp The timestamp of the current frame, in ms.
751
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
752
+ * to process the input image before running inference.
753
+ * @return A stylized face or `null` if no face was detected. The result is
754
+ * copied to avoid lifetime issues.
755
+ */
756
+ stylizeForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): MPImage | null;
757
+ }
758
+
759
+ /**
760
+ * A callback that receives an `MPImage` object from the face stylizer, or
761
+ * `null` if no face was detected. The lifetime of the underlying data is
762
+ * limited to the duration of the callback. If asynchronous processing is
763
+ * needed, all data needs to be copied before the callback returns (via
764
+ * `image.clone()`).
765
+ */
766
+ export declare type FaceStylizerCallback = (image: MPImage | null) => void;
767
+
768
+ /** Options to configure the MediaPipe Face Stylizer Task */
769
+ export declare interface FaceStylizerOptions extends VisionTaskOptions {
770
+ }
771
+
772
+ /**
773
+ * Resolves the files required for the MediaPipe Task APIs.
774
+ *
775
+ * This class verifies whether SIMD is supported in the current environment and
776
+ * loads the SIMD files only if support is detected. The returned filesets
777
+ * require that the Wasm files are published without renaming. If this is not
778
+ * possible, you can invoke the MediaPipe Tasks APIs using a manually created
779
+ * `WasmFileset`.
780
+ */
781
+ export declare class FilesetResolver {
782
+ /**
783
+ * Returns whether SIMD is supported in the current environment.
784
+ *
785
+ * If your environment requires custom locations for the MediaPipe Wasm files,
786
+ * you can use `isSimdSupported()` to decide whether to load the SIMD-based
787
+ * assets.
788
+ *
789
+ * @return Whether SIMD support was detected in the current environment.
790
+ */
791
+ static isSimdSupported(): Promise<boolean>;
792
+ /**
793
+ * Creates a fileset for the MediaPipe Audio tasks.
794
+ *
795
+ * @param basePath An optional base path to specify the directory the Wasm
796
+ * files should be loaded from. If not specified, the Wasm files are
797
+ * loaded from the host's root directory.
798
+ * @return A `WasmFileset` that can be used to initialize MediaPipe Audio
799
+ * tasks.
800
+ */
801
+ static forAudioTasks(basePath?: string): Promise<WasmFileset>;
802
+ /**
803
+ * Creates a fileset for the MediaPipe Text tasks.
804
+ *
805
+ * @param basePath An optional base path to specify the directory the Wasm
806
+ * files should be loaded from. If not specified, the Wasm files are
807
+ * loaded from the host's root directory.
808
+ * @return A `WasmFileset` that can be used to initialize MediaPipe Text
809
+ * tasks.
810
+ */
811
+ static forTextTasks(basePath?: string): Promise<WasmFileset>;
812
+ /**
813
+ * Creates a fileset for the MediaPipe Vision tasks.
814
+ *
815
+ * @param basePath An optional base path to specify the directory the Wasm
816
+ * files should be loaded from. If not specified, the Wasm files are
817
+ * loaded from the host's root directory.
818
+ * @return A `WasmFileset` that can be used to initialize MediaPipe Vision
819
+ * tasks.
820
+ */
821
+ static forVisionTasks(basePath?: string): Promise<WasmFileset>;
822
+ }
823
+
824
+ /** Performs hand gesture recognition on images. */
825
+ export declare class GestureRecognizer extends VisionTaskRunner {
826
+ /**
827
+ * An array containing the pairs of hand landmark indices to be rendered with
828
+ * connections.
829
+ */
830
+ static HAND_CONNECTIONS: Connection[];
831
+ /**
832
+ * Initializes the Wasm runtime and creates a new gesture recognizer from the
833
+ * provided options.
834
+ * @param wasmFileset A configuration object that provides the location of the
835
+ * Wasm binary and its loader.
836
+ * @param gestureRecognizerOptions The options for the gesture recognizer.
837
+ * Note that either a path to the model asset or a model buffer needs to
838
+ * be provided (via `baseOptions`).
839
+ */
840
+ static createFromOptions(wasmFileset: WasmFileset, gestureRecognizerOptions: GestureRecognizerOptions): Promise<GestureRecognizer>;
841
+ /**
842
+ * Initializes the Wasm runtime and creates a new gesture recognizer based on
843
+ * the provided model asset buffer.
844
+ * @param wasmFileset A configuration object that provides the location of the
845
+ * Wasm binary and its loader.
846
+ * @param modelAssetBuffer A binary representation of the model.
847
+ */
848
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<GestureRecognizer>;
849
+ /**
850
+ * Initializes the Wasm runtime and creates a new gesture recognizer based on
851
+ * the path to the model asset.
852
+ * @param wasmFileset A configuration object that provides the location of the
853
+ * Wasm binary and its loader.
854
+ * @param modelAssetPath The path to the model asset.
855
+ */
856
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<GestureRecognizer>;
857
+ private constructor();
858
+ /**
859
+ * Sets new options for the gesture recognizer.
860
+ *
861
+ * Calling `setOptions()` with a subset of options only affects those options.
862
+ * You can reset an option back to its default value by explicitly setting it
863
+ * to `undefined`.
864
+ *
865
+ * @param options The options for the gesture recognizer.
866
+ */
867
+ setOptions(options: GestureRecognizerOptions): Promise<void>;
868
+ /**
869
+ * Performs gesture recognition on the provided single image and waits
870
+ * synchronously for the response. Only use this method when the
871
+ * GestureRecognizer is created with running mode `image`.
872
+ *
873
+ * @param image A single image to process.
874
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
875
+ * to process the input image before running inference.
876
+ * @return The detected gestures.
877
+ */
878
+ recognize(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): GestureRecognizerResult;
879
+ /**
880
+ * Performs gesture recognition on the provided video frame and waits
881
+ * synchronously for the response. Only use this method when the
882
+ * GestureRecognizer is created with running mode `video`.
883
+ *
884
+ * @param videoFrame A video frame to process.
885
+ * @param timestamp The timestamp of the current frame, in ms.
886
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
887
+ * to process the input image before running inference.
888
+ * @return The detected gestures.
889
+ */
890
+ recognizeForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): GestureRecognizerResult;
891
+ }
892
+
893
+ /** Options to configure the MediaPipe Gesture Recognizer Task */
894
+ export declare interface GestureRecognizerOptions extends VisionTaskOptions {
895
+ /**
896
+ * The maximum number of hands can be detected by the GestureRecognizer.
897
+ * Defaults to 1.
898
+ */
899
+ numHands?: number | undefined;
900
+ /**
901
+ * The minimum confidence score for the hand detection to be considered
902
+ * successful. Defaults to 0.5.
903
+ */
904
+ minHandDetectionConfidence?: number | undefined;
905
+ /**
906
+ * The minimum confidence score of hand presence score in the hand landmark
907
+ * detection. Defaults to 0.5.
908
+ */
909
+ minHandPresenceConfidence?: number | undefined;
910
+ /**
911
+ * The minimum confidence score for the hand tracking to be considered
912
+ * successful. Defaults to 0.5.
913
+ */
914
+ minTrackingConfidence?: number | undefined;
915
+ /**
916
+ * Sets the optional `ClassifierOptions` controlling the canned gestures
917
+ * classifier, such as score threshold, allow list and deny list of gestures.
918
+ * The categories for canned gesture
919
+ * classifiers are: ["None", "Closed_Fist", "Open_Palm", "Pointing_Up",
920
+ * "Thumb_Down", "Thumb_Up", "Victory", "ILoveYou"]
921
+ */
922
+ cannedGesturesClassifierOptions?: ClassifierOptions | undefined;
923
+ /**
924
+ * Options for configuring the custom gestures classifier, such as score
925
+ * threshold, allow list and deny list of gestures.
926
+ */
927
+ customGesturesClassifierOptions?: ClassifierOptions | undefined;
928
+ }
929
+
930
+ /**
931
+ * Represents the gesture recognition results generated by `GestureRecognizer`.
932
+ */
933
+ export declare interface GestureRecognizerResult {
934
+ /** Hand landmarks of detected hands. */
935
+ landmarks: NormalizedLandmark[][];
936
+ /** Hand landmarks in world coordniates of detected hands. */
937
+ worldLandmarks: Landmark[][];
938
+ /** Handedness of detected hands. */
939
+ handednesses: Category[][];
940
+ /**
941
+ * Recognized hand gestures of detected hands. Note that the index of the
942
+ * gesture is always -1, because the raw indices from multiple gesture
943
+ * classifiers cannot consolidate to a meaningful index.
944
+ */
945
+ gestures: Category[][];
946
+ }
947
+
948
+ /** Performs hand landmarks detection on images. */
949
+ export declare class HandLandmarker extends VisionTaskRunner {
950
+ /**
951
+ * An array containing the pairs of hand landmark indices to be rendered with
952
+ * connections.
953
+ */
954
+ static HAND_CONNECTIONS: Connection[];
955
+ /**
956
+ * Initializes the Wasm runtime and creates a new `HandLandmarker` from the
957
+ * provided options.
958
+ * @param wasmFileset A configuration object that provides the location of the
959
+ * Wasm binary and its loader.
960
+ * @param handLandmarkerOptions The options for the HandLandmarker.
961
+ * Note that either a path to the model asset or a model buffer needs to
962
+ * be provided (via `baseOptions`).
963
+ */
964
+ static createFromOptions(wasmFileset: WasmFileset, handLandmarkerOptions: HandLandmarkerOptions): Promise<HandLandmarker>;
965
+ /**
966
+ * Initializes the Wasm runtime and creates a new `HandLandmarker` based on
967
+ * the provided model asset buffer.
968
+ * @param wasmFileset A configuration object that provides the location of the
969
+ * Wasm binary and its loader.
970
+ * @param modelAssetBuffer A binary representation of the model.
971
+ */
972
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<HandLandmarker>;
973
+ /**
974
+ * Initializes the Wasm runtime and creates a new `HandLandmarker` based on
975
+ * the path to the model asset.
976
+ * @param wasmFileset A configuration object that provides the location of the
977
+ * Wasm binary and its loader.
978
+ * @param modelAssetPath The path to the model asset.
979
+ */
980
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<HandLandmarker>;
981
+ private constructor();
982
+ /**
983
+ * Sets new options for this `HandLandmarker`.
984
+ *
985
+ * Calling `setOptions()` with a subset of options only affects those options.
986
+ * You can reset an option back to its default value by explicitly setting it
987
+ * to `undefined`.
988
+ *
989
+ * @param options The options for the hand landmarker.
990
+ */
991
+ setOptions(options: HandLandmarkerOptions): Promise<void>;
992
+ /**
993
+ * Performs hand landmarks detection on the provided single image and waits
994
+ * synchronously for the response. Only use this method when the
995
+ * HandLandmarker is created with running mode `image`.
996
+ *
997
+ * @param image An image to process.
998
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
999
+ * to process the input image before running inference.
1000
+ * @return The detected hand landmarks.
1001
+ */
1002
+ detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): HandLandmarkerResult;
1003
+ /**
1004
+ * Performs hand landmarks detection on the provided video frame and waits
1005
+ * synchronously for the response. Only use this method when the
1006
+ * HandLandmarker is created with running mode `video`.
1007
+ *
1008
+ * @param videoFrame A video frame to process.
1009
+ * @param timestamp The timestamp of the current frame, in ms.
1010
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1011
+ * to process the input image before running inference.
1012
+ * @return The detected hand landmarks.
1013
+ */
1014
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): HandLandmarkerResult;
1015
+ }
1016
+
1017
+ /** Options to configure the MediaPipe HandLandmarker Task */
1018
+ export declare interface HandLandmarkerOptions extends VisionTaskOptions {
1019
+ /**
1020
+ * The maximum number of hands can be detected by the HandLandmarker.
1021
+ * Defaults to 1.
1022
+ */
1023
+ numHands?: number | undefined;
1024
+ /**
1025
+ * The minimum confidence score for the hand detection to be considered
1026
+ * successful. Defaults to 0.5.
1027
+ */
1028
+ minHandDetectionConfidence?: number | undefined;
1029
+ /**
1030
+ * The minimum confidence score of hand presence score in the hand landmark
1031
+ * detection. Defaults to 0.5.
1032
+ */
1033
+ minHandPresenceConfidence?: number | undefined;
1034
+ /**
1035
+ * The minimum confidence score for the hand tracking to be considered
1036
+ * successful. Defaults to 0.5.
1037
+ */
1038
+ minTrackingConfidence?: number | undefined;
1039
+ }
1040
+
1041
+ /**
1042
+ * Represents the hand landmarks deection results generated by `HandLandmarker`.
1043
+ */
1044
+ export declare interface HandLandmarkerResult {
1045
+ /** Hand landmarks of detected hands. */
1046
+ landmarks: NormalizedLandmark[][];
1047
+ /** Hand landmarks in world coordinates of detected hands. */
1048
+ worldLandmarks: Landmark[][];
1049
+ /** Handedness of detected hands. */
1050
+ handednesses: Category[][];
1051
+ }
1052
+
1053
+ /** Performs classification on images. */
1054
+ export declare class ImageClassifier extends VisionTaskRunner {
1055
+ /**
1056
+ * Initializes the Wasm runtime and creates a new image classifier from the
1057
+ * provided options.
1058
+ * @param wasmFileset A configuration object that provides the location
1059
+ * Wasm binary and its loader.
1060
+ * @param imageClassifierOptions The options for the image classifier. Note
1061
+ * that either a path to the model asset or a model buffer needs to be
1062
+ * provided (via `baseOptions`).
1063
+ */
1064
+ static createFromOptions(wasmFileset: WasmFileset, imageClassifierOptions: ImageClassifierOptions): Promise<ImageClassifier>;
1065
+ /**
1066
+ * Initializes the Wasm runtime and creates a new image classifier based on
1067
+ * the provided model asset buffer.
1068
+ * @param wasmFileset A configuration object that provides the location of the
1069
+ * Wasm binary and its loader.
1070
+ * @param modelAssetBuffer A binary representation of the model.
1071
+ */
1072
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ImageClassifier>;
1073
+ /**
1074
+ * Initializes the Wasm runtime and creates a new image classifier based on
1075
+ * the path to the model asset.
1076
+ * @param wasmFileset A configuration object that provides the location of the
1077
+ * Wasm binary and its loader.
1078
+ * @param modelAssetPath The path to the model asset.
1079
+ */
1080
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageClassifier>;
1081
+ private constructor();
1082
+ /**
1083
+ * Sets new options for the image classifier.
1084
+ *
1085
+ * Calling `setOptions()` with a subset of options only affects those options.
1086
+ * You can reset an option back to its default value by explicitly setting it
1087
+ * to `undefined`.
1088
+ *
1089
+ * @param options The options for the image classifier.
1090
+ */
1091
+ setOptions(options: ImageClassifierOptions): Promise<void>;
1092
+ /**
1093
+ * Performs image classification on the provided single image and waits
1094
+ * synchronously for the response. Only use this method when the
1095
+ * ImageClassifier is created with running mode `image`.
1096
+ *
1097
+ * @param image An image to process.
1098
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1099
+ * to process the input image before running inference.
1100
+ * @return The classification result of the image
1101
+ */
1102
+ classify(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): ImageClassifierResult;
1103
+ /**
1104
+ * Performs image classification on the provided video frame and waits
1105
+ * synchronously for the response. Only use this method when the
1106
+ * ImageClassifier is created with running mode `video`.
1107
+ *
1108
+ * @param videoFrame A video frame to process.
1109
+ * @param timestamp The timestamp of the current frame, in ms.
1110
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1111
+ * to process the input image before running inference.
1112
+ * @return The classification result of the image
1113
+ */
1114
+ classifyForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): ImageClassifierResult;
1115
+ }
1116
+
1117
+ /** Options to configure the MediaPipe Image Classifier Task. */
1118
+ export declare interface ImageClassifierOptions extends ClassifierOptions, VisionTaskOptions {
1119
+ }
1120
+
1121
+ /** Classification results of a model. */
1122
+ export declare interface ImageClassifierResult {
1123
+ /** The classification results for each head of the model. */
1124
+ classifications: Classifications[];
1125
+ /**
1126
+ * The optional timestamp (in milliseconds) of the start of the chunk of data
1127
+ * corresponding to these results.
1128
+ *
1129
+ * This is only used for classification on time series (e.g. audio
1130
+ * classification). In these use cases, the amount of data to process might
1131
+ * exceed the maximum size that the model can process: to solve this, the
1132
+ * input data is split into multiple chunks starting at different timestamps.
1133
+ */
1134
+ timestampMs?: number;
1135
+ }
1136
+
1137
+ /** Performs embedding extraction on images. */
1138
+ export declare class ImageEmbedder extends VisionTaskRunner {
1139
+ /**
1140
+ * Initializes the Wasm runtime and creates a new image embedder from the
1141
+ * provided options.
1142
+ * @param wasmFileset A configuration object that provides the location of the
1143
+ * Wasm binary and its loader.
1144
+ * @param imageEmbedderOptions The options for the image embedder. Note that
1145
+ * either a path to the TFLite model or the model itself needs to be
1146
+ * provided (via `baseOptions`).
1147
+ */
1148
+ static createFromOptions(wasmFileset: WasmFileset, imageEmbedderOptions: ImageEmbedderOptions): Promise<ImageEmbedder>;
1149
+ /**
1150
+ * Initializes the Wasm runtime and creates a new image embedder based on the
1151
+ * provided model asset buffer.
1152
+ * @param wasmFileset A configuration object that provides the location of the
1153
+ * Wasm binary and its loader.
1154
+ * @param modelAssetBuffer A binary representation of the TFLite model.
1155
+ */
1156
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ImageEmbedder>;
1157
+ /**
1158
+ * Initializes the Wasm runtime and creates a new image embedder based on the
1159
+ * path to the model asset.
1160
+ * @param wasmFileset A configuration object that provides the location of the
1161
+ * Wasm binary and its loader.
1162
+ * @param modelAssetPath The path to the TFLite model.
1163
+ */
1164
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageEmbedder>;
1165
+ private constructor();
1166
+ /**
1167
+ * Sets new options for the image embedder.
1168
+ *
1169
+ * Calling `setOptions()` with a subset of options only affects those options.
1170
+ * You can reset an option back to its default value by explicitly setting it
1171
+ * to `undefined`.
1172
+ *
1173
+ * @param options The options for the image embedder.
1174
+ */
1175
+ setOptions(options: ImageEmbedderOptions): Promise<void>;
1176
+ /**
1177
+ * Performs embedding extraction on the provided single image and waits
1178
+ * synchronously for the response. Only use this method when the
1179
+ * ImageEmbedder is created with running mode `image`.
1180
+ *
1181
+ * @param image The image to process.
1182
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1183
+ * to process the input image before running inference.
1184
+ * @return The classification result of the image
1185
+ */
1186
+ embed(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): ImageEmbedderResult;
1187
+ /**
1188
+ * Performs embedding extraction on the provided video frame and waits
1189
+ * synchronously for the response. Only use this method when the
1190
+ * ImageEmbedder is created with running mode `video`.
1191
+ *
1192
+ * @param imageFrame The image frame to process.
1193
+ * @param timestamp The timestamp of the current frame, in ms.
1194
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1195
+ * to process the input image before running inference.
1196
+ * @return The classification result of the image
1197
+ */
1198
+ embedForVideo(imageFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): ImageEmbedderResult;
1199
+ /**
1200
+ * Utility function to compute cosine similarity[1] between two `Embedding`
1201
+ * objects.
1202
+ *
1203
+ * [1]: https://en.wikipedia.org/wiki/Cosine_similarity
1204
+ *
1205
+ * @throws if the embeddings are of different types(float vs. quantized), have
1206
+ * different sizes, or have an L2-norm of 0.
1207
+ */
1208
+ static cosineSimilarity(u: Embedding, v: Embedding): number;
1209
+ }
1210
+
1211
+ /** Options for configuring a MediaPipe Image Embedder task. */
1212
+ export declare interface ImageEmbedderOptions extends EmbedderOptions, VisionTaskOptions {
1213
+ }
1214
+
1215
+ /** Embedding results for a given embedder model. */
1216
+ export declare interface ImageEmbedderResult {
1217
+ /**
1218
+ * The embedding results for each model head, i.e. one for each output tensor.
1219
+ */
1220
+ embeddings: Embedding[];
1221
+ /**
1222
+ * The optional timestamp (in milliseconds) of the start of the chunk of
1223
+ * data corresponding to these results.
1224
+ *
1225
+ * This is only used for embedding extraction on time series (e.g. audio
1226
+ * embedding). In these use cases, the amount of data to process might
1227
+ * exceed the maximum size that the model can process: to solve this, the
1228
+ * input data is split into multiple chunks starting at different timestamps.
1229
+ */
1230
+ timestampMs?: number;
1231
+ }
1232
+
1233
+ /**
1234
+ * Options for image processing.
1235
+ *
1236
+ * If both region-or-interest and rotation are specified, the crop around the
1237
+ * region-of-interest is extracted first, then the specified rotation is applied
1238
+ * to the crop.
1239
+ */
1240
+ declare interface ImageProcessingOptions {
1241
+ /**
1242
+ * The optional region-of-interest to crop from the image. If not specified,
1243
+ * the full image is used.
1244
+ *
1245
+ * Coordinates must be in [0,1] with 'left' < 'right' and 'top' < bottom.
1246
+ */
1247
+ regionOfInterest?: RectF;
1248
+ /**
1249
+ * The rotation to apply to the image (or cropped region-of-interest), in
1250
+ * degrees clockwise.
1251
+ *
1252
+ * The rotation must be a multiple (positive or negative) of 90°.
1253
+ */
1254
+ rotationDegrees?: number;
1255
+ }
1256
+
1257
+ /** Performs image segmentation on images. */
1258
+ export declare class ImageSegmenter extends VisionTaskRunner {
1259
+ /**
1260
+ * Initializes the Wasm runtime and creates a new image segmenter from the
1261
+ * provided options.
1262
+ * @param wasmFileset A configuration object that provides the location of
1263
+ * the Wasm binary and its loader.
1264
+ * @param imageSegmenterOptions The options for the Image Segmenter. Note
1265
+ * that either a path to the model asset or a model buffer needs to be
1266
+ * provided (via `baseOptions`).
1267
+ */
1268
+ static createFromOptions(wasmFileset: WasmFileset, imageSegmenterOptions: ImageSegmenterOptions): Promise<ImageSegmenter>;
1269
+ /**
1270
+ * Initializes the Wasm runtime and creates a new image segmenter based on
1271
+ * the provided model asset buffer.
1272
+ * @param wasmFileset A configuration object that provides the location of
1273
+ * the Wasm binary and its loader.
1274
+ * @param modelAssetBuffer A binary representation of the model.
1275
+ */
1276
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ImageSegmenter>;
1277
+ /**
1278
+ * Initializes the Wasm runtime and creates a new image segmenter based on
1279
+ * the path to the model asset.
1280
+ * @param wasmFileset A configuration object that provides the location of
1281
+ * the Wasm binary and its loader.
1282
+ * @param modelAssetPath The path to the model asset.
1283
+ */
1284
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageSegmenter>;
1285
+ private constructor();
1286
+ /**
1287
+ * Sets new options for the image segmenter.
1288
+ *
1289
+ * Calling `setOptions()` with a subset of options only affects those
1290
+ * options. You can reset an option back to its default value by
1291
+ * explicitly setting it to `undefined`.
1292
+ *
1293
+ * @param options The options for the image segmenter.
1294
+ */
1295
+ setOptions(options: ImageSegmenterOptions): Promise<void>;
1296
+ /**
1297
+ * Performs image segmentation on the provided single image and invokes the
1298
+ * callback with the response. The method returns synchronously once the
1299
+ * callback returns. Only use this method when the ImageSegmenter is
1300
+ * created with running mode `image`.
1301
+ *
1302
+ * @param image An image to process.
1303
+ * @param callback The callback that is invoked with the segmented masks. The
1304
+ * lifetime of the returned data is only guaranteed for the duration of the
1305
+ * callback.
1306
+ */
1307
+ segment(image: ImageSource, callback: ImageSegmenterCallback): void;
1308
+ /**
1309
+ * Performs image segmentation on the provided single image and invokes the
1310
+ * callback with the response. The method returns synchronously once the
1311
+ * callback returns. Only use this method when the ImageSegmenter is
1312
+ * created with running mode `image`.
1313
+ *
1314
+ * @param image An image to process.
1315
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1316
+ * to process the input image before running inference.
1317
+ * @param callback The callback that is invoked with the segmented masks. The
1318
+ * lifetime of the returned data is only guaranteed for the duration of the
1319
+ * callback.
1320
+ */
1321
+ segment(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: ImageSegmenterCallback): void;
1322
+ /**
1323
+ * Performs image segmentation on the provided single image and returns the
1324
+ * segmentation result. This method creates a copy of the resulting masks and
1325
+ * should not be used in high-throughput applictions. Only use this method
1326
+ * when the ImageSegmenter is created with running mode `image`.
1327
+ *
1328
+ * @param image An image to process.
1329
+ * @return The segmentation result. The data is copied to avoid lifetime
1330
+ * issues.
1331
+ */
1332
+ segment(image: ImageSource): ImageSegmenterResult;
1333
+ /**
1334
+ * Performs image segmentation on the provided single image and returns the
1335
+ * segmentation result. This method creates a copy of the resulting masks and
1336
+ * should not be used in high-v applictions. Only use this method when
1337
+ * the ImageSegmenter is created with running mode `image`.
1338
+ *
1339
+ * @param image An image to process.
1340
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1341
+ * to process the input image before running inference.
1342
+ * @return The segmentation result. The data is copied to avoid lifetime
1343
+ * issues.
1344
+ */
1345
+ segment(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
1346
+ /**
1347
+ * Performs image segmentation on the provided video frame and invokes the
1348
+ * callback with the response. The method returns synchronously once the
1349
+ * callback returns. Only use this method when the ImageSegmenter is
1350
+ * created with running mode `video`.
1351
+ *
1352
+ * @param videoFrame A video frame to process.
1353
+ * @param timestamp The timestamp of the current frame, in ms.
1354
+ * @param callback The callback that is invoked with the segmented masks. The
1355
+ * lifetime of the returned data is only guaranteed for the duration of the
1356
+ * callback.
1357
+ */
1358
+ segmentForVideo(videoFrame: ImageSource, timestamp: number, callback: ImageSegmenterCallback): void;
1359
+ /**
1360
+ * Performs image segmentation on the provided video frame and invokes the
1361
+ * callback with the response. The method returns synchronously once the
1362
+ * callback returns. Only use this method when the ImageSegmenter is
1363
+ * created with running mode `video`.
1364
+ *
1365
+ * @param videoFrame A video frame to process.
1366
+ * @param timestamp The timestamp of the current frame, in ms.
1367
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1368
+ * to process the input frame before running inference.
1369
+ * @param callback The callback that is invoked with the segmented masks. The
1370
+ * lifetime of the returned data is only guaranteed for the duration of the
1371
+ * callback.
1372
+ */
1373
+ segmentForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: ImageSegmenterCallback): void;
1374
+ /**
1375
+ * Performs image segmentation on the provided video frame and returns the
1376
+ * segmentation result. This method creates a copy of the resulting masks and
1377
+ * should not be used in high-throughput applictions. Only use this method
1378
+ * when the ImageSegmenter is created with running mode `video`.
1379
+ *
1380
+ * @param videoFrame A video frame to process.
1381
+ * @return The segmentation result. The data is copied to avoid lifetime
1382
+ * issues.
1383
+ */
1384
+ segmentForVideo(videoFrame: ImageSource, timestamp: number): ImageSegmenterResult;
1385
+ /**
1386
+ * Performs image segmentation on the provided video frame and returns the
1387
+ * segmentation result. This method creates a copy of the resulting masks and
1388
+ * should not be used in high-v applictions. Only use this method when
1389
+ * the ImageSegmenter is created with running mode `video`.
1390
+ *
1391
+ * @param videoFrame A video frame to process.
1392
+ * @param timestamp The timestamp of the current frame, in ms.
1393
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1394
+ * to process the input frame before running inference.
1395
+ * @return The segmentation result. The data is copied to avoid lifetime
1396
+ * issues.
1397
+ */
1398
+ segmentForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
1399
+ /**
1400
+ * Get the category label list of the ImageSegmenter can recognize. For
1401
+ * `CATEGORY_MASK` type, the index in the category mask corresponds to the
1402
+ * category in the label list. For `CONFIDENCE_MASK` type, the output mask
1403
+ * list at index corresponds to the category in the label list.
1404
+ *
1405
+ * If there is no labelmap provided in the model file, empty label array is
1406
+ * returned.
1407
+ *
1408
+ * @return The labels used by the current model.
1409
+ */
1410
+ getLabels(): string[];
1411
+ }
1412
+
1413
+ /**
1414
+ * A callback that receives the computed masks from the image segmenter. The
1415
+ * returned data is only valid for the duration of the callback. If
1416
+ * asynchronous processing is needed, all data needs to be copied before the
1417
+ * callback returns.
1418
+ */
1419
+ export declare type ImageSegmenterCallback = (result: ImageSegmenterResult) => void;
1420
+
1421
+ /** Options to configure the MediaPipe Image Segmenter Task */
1422
+ export declare interface ImageSegmenterOptions extends VisionTaskOptions {
1423
+ /**
1424
+ * The locale to use for display names specified through the TFLite Model
1425
+ * Metadata, if any. Defaults to English.
1426
+ */
1427
+ displayNamesLocale?: string | undefined;
1428
+ /** Whether to output confidence masks. Defaults to true. */
1429
+ outputConfidenceMasks?: boolean | undefined;
1430
+ /** Whether to output the category masks. Defaults to false. */
1431
+ outputCategoryMask?: boolean | undefined;
1432
+ }
1433
+
1434
+ /** The output result of ImageSegmenter. */
1435
+ export declare interface ImageSegmenterResult {
1436
+ /**
1437
+ * Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
1438
+ * `MPImage`s where, for each mask, each pixel represents the prediction
1439
+ * confidence, usually in the [0, 1] range.
1440
+ */
1441
+ confidenceMasks?: MPMask[];
1442
+ /**
1443
+ * A category mask represented as a `Uint8ClampedArray` or
1444
+ * `WebGLTexture`-backed `MPImage` where each pixel represents the class which
1445
+ * the pixel in the original image was predicted to belong to.
1446
+ */
1447
+ categoryMask?: MPMask;
1448
+ }
1449
+
1450
+ /**
1451
+ * Valid types of image sources which we can run our GraphRunner over.
1452
+ */
1453
+ export declare type ImageSource = HTMLCanvasElement | HTMLVideoElement | HTMLImageElement | ImageData | ImageBitmap;
1454
+
1455
+ /**
1456
+ * Performs interactive segmentation on images.
1457
+ *
1458
+ * Users can represent user interaction through `RegionOfInterest`, which gives
1459
+ * a hint to InteractiveSegmenter to perform segmentation focusing on the given
1460
+ * region of interest.
1461
+ *
1462
+ * The API expects a TFLite model with mandatory TFLite Model Metadata.
1463
+ *
1464
+ * Input tensor:
1465
+ * (kTfLiteUInt8/kTfLiteFloat32)
1466
+ * - image input of size `[batch x height x width x channels]`.
1467
+ * - batch inference is not supported (`batch` is required to be 1).
1468
+ * - RGB inputs is supported (`channels` is required to be 3).
1469
+ * - if type is kTfLiteFloat32, NormalizationOptions are required to be
1470
+ * attached to the metadata for input normalization.
1471
+ * Output tensors:
1472
+ * (kTfLiteUInt8/kTfLiteFloat32)
1473
+ * - list of segmented masks.
1474
+ * - if `output_type` is CATEGORY_MASK, uint8 Image, Image vector of size 1.
1475
+ * - if `output_type` is CONFIDENCE_MASK, float32 Image list of size
1476
+ * `channels`.
1477
+ * - batch is always 1
1478
+ */
1479
+ export declare class InteractiveSegmenter extends VisionTaskRunner {
1480
+ /**
1481
+ * Initializes the Wasm runtime and creates a new interactive segmenter from
1482
+ * the provided options.
1483
+ * @param wasmFileset A configuration object that provides the location of
1484
+ * the Wasm binary and its loader.
1485
+ * @param interactiveSegmenterOptions The options for the Interactive
1486
+ * Segmenter. Note that either a path to the model asset or a model buffer
1487
+ * needs to be provided (via `baseOptions`).
1488
+ * @return A new `InteractiveSegmenter`.
1489
+ */
1490
+ static createFromOptions(wasmFileset: WasmFileset, interactiveSegmenterOptions: InteractiveSegmenterOptions): Promise<InteractiveSegmenter>;
1491
+ /**
1492
+ * Initializes the Wasm runtime and creates a new interactive segmenter based
1493
+ * on the provided model asset buffer.
1494
+ * @param wasmFileset A configuration object that provides the location of
1495
+ * the Wasm binary and its loader.
1496
+ * @param modelAssetBuffer A binary representation of the model.
1497
+ * @return A new `InteractiveSegmenter`.
1498
+ */
1499
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<InteractiveSegmenter>;
1500
+ /**
1501
+ * Initializes the Wasm runtime and creates a new interactive segmenter based
1502
+ * on the path to the model asset.
1503
+ * @param wasmFileset A configuration object that provides the location of
1504
+ * the Wasm binary and its loader.
1505
+ * @param modelAssetPath The path to the model asset.
1506
+ * @return A new `InteractiveSegmenter`.
1507
+ */
1508
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<InteractiveSegmenter>;
1509
+ private constructor();
1510
+ /**
1511
+ * Sets new options for the interactive segmenter.
1512
+ *
1513
+ * Calling `setOptions()` with a subset of options only affects those
1514
+ * options. You can reset an option back to its default value by
1515
+ * explicitly setting it to `undefined`.
1516
+ *
1517
+ * @param options The options for the interactive segmenter.
1518
+ * @return A Promise that resolves when the settings have been applied.
1519
+ */
1520
+ setOptions(options: InteractiveSegmenterOptions): Promise<void>;
1521
+ /**
1522
+ * Performs interactive segmentation on the provided single image and invokes
1523
+ * the callback with the response. The method returns synchronously once the
1524
+ * callback returns. The `roi` parameter is used to represent a user's region
1525
+ * of interest for segmentation.
1526
+ *
1527
+ * @param image An image to process.
1528
+ * @param roi The region of interest for segmentation.
1529
+ * @param callback The callback that is invoked with the segmented masks. The
1530
+ * lifetime of the returned data is only guaranteed for the duration of the
1531
+ * callback.
1532
+ */
1533
+ segment(image: ImageSource, roi: RegionOfInterest, callback: InteractiveSegmenterCallback): void;
1534
+ /**
1535
+ * Performs interactive segmentation on the provided single image and invokes
1536
+ * the callback with the response. The method returns synchronously once the
1537
+ * callback returns. The `roi` parameter is used to represent a user's region
1538
+ * of interest for segmentation.
1539
+ *
1540
+ * The 'image_processing_options' parameter can be used to specify the
1541
+ * rotation to apply to the image before performing segmentation, by setting
1542
+ * its 'rotationDegrees' field. Note that specifying a region-of-interest
1543
+ * using the 'regionOfInterest' field is NOT supported and will result in an
1544
+ * error.
1545
+ *
1546
+ * @param image An image to process.
1547
+ * @param roi The region of interest for segmentation.
1548
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1549
+ * to process the input image before running inference.
1550
+ * @param callback The callback that is invoked with the segmented masks. The
1551
+ * lifetime of the returned data is only guaranteed for the duration of the
1552
+ * callback.
1553
+ */
1554
+ segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions, callback: InteractiveSegmenterCallback): void;
1555
+ /**
1556
+ * Performs interactive segmentation on the provided video frame and returns
1557
+ * the segmentation result. This method creates a copy of the resulting masks
1558
+ * and should not be used in high-throughput applictions. The `roi` parameter
1559
+ * is used to represent a user's region of interest for segmentation.
1560
+ *
1561
+ * @param image An image to process.
1562
+ * @param roi The region of interest for segmentation.
1563
+ * @return The segmentation result. The data is copied to avoid lifetime
1564
+ * limits.
1565
+ */
1566
+ segment(image: ImageSource, roi: RegionOfInterest): InteractiveSegmenterResult;
1567
+ /**
1568
+ * Performs interactive segmentation on the provided video frame and returns
1569
+ * the segmentation result. This method creates a copy of the resulting masks
1570
+ * and should not be used in high-throughput applictions. The `roi` parameter
1571
+ * is used to represent a user's region of interest for segmentation.
1572
+ *
1573
+ * The 'image_processing_options' parameter can be used to specify the
1574
+ * rotation to apply to the image before performing segmentation, by setting
1575
+ * its 'rotationDegrees' field. Note that specifying a region-of-interest
1576
+ * using the 'regionOfInterest' field is NOT supported and will result in an
1577
+ * error.
1578
+ *
1579
+ * @param image An image to process.
1580
+ * @param roi The region of interest for segmentation.
1581
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1582
+ * to process the input image before running inference.
1583
+ * @return The segmentation result. The data is copied to avoid lifetime
1584
+ * limits.
1585
+ */
1586
+ segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions): InteractiveSegmenterResult;
1587
+ }
1588
+
1589
+ /**
1590
+ * A callback that receives the computed masks from the interactive segmenter.
1591
+ * The returned data is only valid for the duration of the callback. If
1592
+ * asynchronous processing is needed, all data needs to be copied before the
1593
+ * callback returns.
1594
+ */
1595
+ export declare type InteractiveSegmenterCallback = (result: InteractiveSegmenterResult) => void;
1596
+
1597
+ /** Options to configure the MediaPipe Interactive Segmenter Task */
1598
+ export declare interface InteractiveSegmenterOptions extends TaskRunnerOptions {
1599
+ /** Whether to output confidence masks. Defaults to true. */
1600
+ outputConfidenceMasks?: boolean | undefined;
1601
+ /** Whether to output the category masks. Defaults to false. */
1602
+ outputCategoryMask?: boolean | undefined;
1603
+ }
1604
+
1605
+ /** The output result of InteractiveSegmenter. */
1606
+ export declare interface InteractiveSegmenterResult {
1607
+ /**
1608
+ * Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
1609
+ * `MPImage`s where, for each mask, each pixel represents the prediction
1610
+ * confidence, usually in the [0, 1] range.
1611
+ */
1612
+ confidenceMasks?: MPMask[];
1613
+ /**
1614
+ * A category mask represented as a `Uint8ClampedArray` or
1615
+ * `WebGLTexture`-backed `MPImage` where each pixel represents the class which
1616
+ * the pixel in the original image was predicted to belong to.
1617
+ */
1618
+ categoryMask?: MPMask;
1619
+ }
1620
+
1621
+ /**
1622
+ * Landmark represents a point in 3D space with x, y, z coordinates. The
1623
+ * landmark coordinates are in meters. z represents the landmark depth,
1624
+ * and the smaller the value the closer the world landmark is to the camera.
1625
+ */
1626
+ export declare interface Landmark {
1627
+ /** The x coordinates of the landmark. */
1628
+ x: number;
1629
+ /** The y coordinates of the landmark. */
1630
+ y: number;
1631
+ /** The z coordinates of the landmark. */
1632
+ z: number;
1633
+ }
1634
+
1635
+ /** Data that a user can use to specialize drawing options. */
1636
+ export declare interface LandmarkData {
1637
+ index?: number;
1638
+ from?: NormalizedLandmark;
1639
+ to?: NormalizedLandmark;
1640
+ }
1641
+
1642
+ /**
1643
+ * Copyright 2023 The MediaPipe Authors.
1644
+ *
1645
+ * Licensed under the Apache License, Version 2.0 (the "License");
1646
+ * you may not use this file except in compliance with the License.
1647
+ * You may obtain a copy of the License at
1648
+ *
1649
+ * http://www.apache.org/licenses/LICENSE-2.0
1650
+ *
1651
+ * Unless required by applicable law or agreed to in writing, software
1652
+ * distributed under the License is distributed on an "AS IS" BASIS,
1653
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1654
+ * See the License for the specific language governing permissions and
1655
+ * limitations under the License.
1656
+ */
1657
+ /** A two-dimensional matrix. */
1658
+ declare interface Matrix {
1659
+ /** The number of rows. */
1660
+ rows: number;
1661
+ /** The number of columns. */
1662
+ columns: number;
1663
+ /** The values as a flattened one-dimensional array. */
1664
+ data: number[];
1665
+ }
1666
+
1667
+ /**
1668
+ * The wrapper class for MediaPipe Image objects.
1669
+ *
1670
+ * Images are stored as `ImageData`, `ImageBitmap` or `WebGLTexture` objects.
1671
+ * You can convert the underlying type to any other type by passing the
1672
+ * desired type to `getAs...()`. As type conversions can be expensive, it is
1673
+ * recommended to limit these conversions. You can verify what underlying
1674
+ * types are already available by invoking `has...()`.
1675
+ *
1676
+ * Images that are returned from a MediaPipe Tasks are owned by by the
1677
+ * underlying C++ Task. If you need to extend the lifetime of these objects,
1678
+ * you can invoke the `clone()` method. To free up the resources obtained
1679
+ * during any clone or type conversion operation, it is important to invoke
1680
+ * `close()` on the `MPImage` instance.
1681
+ *
1682
+ * Converting to and from ImageBitmap requires that the MediaPipe task is
1683
+ * initialized with an `OffscreenCanvas`. As we require WebGL2 support, this
1684
+ * places some limitations on Browser support as outlined here:
1685
+ * https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
1686
+ */
1687
+ export declare class MPImage {
1688
+ /** Returns the canvas element that the image is bound to. */
1689
+ readonly canvas: HTMLCanvasElement | OffscreenCanvas | undefined;
1690
+ /** Returns the width of the image. */
1691
+ readonly width: number;
1692
+ /** Returns the height of the image. */
1693
+ readonly height: number;
1694
+ private constructor();
1695
+ /** Returns whether this `MPImage` contains a mask of type `ImageData`. */
1696
+ hasImageData(): boolean;
1697
+ /** Returns whether this `MPImage` contains a mask of type `ImageBitmap`. */
1698
+ hasImageBitmap(): boolean;
1699
+ /** Returns whether this `MPImage` contains a mask of type `WebGLTexture`. */
1700
+ hasWebGLTexture(): boolean;
1701
+ /**
1702
+ * Returns the underlying image as an `ImageData` object. Note that this
1703
+ * involves an expensive GPU to CPU transfer if the current image is only
1704
+ * available as an `ImageBitmap` or `WebGLTexture`.
1705
+ *
1706
+ * @return The current image as an ImageData object.
1707
+ */
1708
+ getAsImageData(): ImageData;
1709
+ /**
1710
+ * Returns the underlying image as an `ImageBitmap`. Note that
1711
+ * conversions to `ImageBitmap` are expensive, especially if the data
1712
+ * currently resides on CPU.
1713
+ *
1714
+ * Processing with `ImageBitmap`s requires that the MediaPipe Task was
1715
+ * initialized with an `OffscreenCanvas` with WebGL2 support. See
1716
+ * https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
1717
+ * for a list of supported platforms.
1718
+ *
1719
+ * @return The current image as an ImageBitmap object.
1720
+ */
1721
+ getAsImageBitmap(): ImageBitmap;
1722
+ /**
1723
+ * Returns the underlying image as a `WebGLTexture` object. Note that this
1724
+ * involves a CPU to GPU transfer if the current image is only available as
1725
+ * an `ImageData` object. The returned texture is bound to the current
1726
+ * canvas (see `.canvas`).
1727
+ *
1728
+ * @return The current image as a WebGLTexture.
1729
+ */
1730
+ getAsWebGLTexture(): WebGLTexture;
1731
+ /**
1732
+ * Creates a copy of the resources stored in this `MPImage`. You can invoke
1733
+ * this method to extend the lifetime of an image returned by a MediaPipe
1734
+ * Task. Note that performance critical applications should aim to only use
1735
+ * the `MPImage` within the MediaPipe Task callback so that copies can be
1736
+ * avoided.
1737
+ */
1738
+ clone(): MPImage;
1739
+ /**
1740
+ * Frees up any resources owned by this `MPImage` instance.
1741
+ *
1742
+ * Note that this method does not free images that are owned by the C++
1743
+ * Task, as these are freed automatically once you leave the MediaPipe
1744
+ * callback. Additionally, some shared state is freed only once you invoke the
1745
+ * Task's `close()` method.
1746
+ */
1747
+ close(): void;
1748
+ }
1749
+
1750
+ /**
1751
+ * The wrapper class for MediaPipe segmentation masks.
1752
+ *
1753
+ * Masks are stored as `Uint8Array`, `Float32Array` or `WebGLTexture` objects.
1754
+ * You can convert the underlying type to any other type by passing the desired
1755
+ * type to `getAs...()`. As type conversions can be expensive, it is recommended
1756
+ * to limit these conversions. You can verify what underlying types are already
1757
+ * available by invoking `has...()`.
1758
+ *
1759
+ * Masks that are returned from a MediaPipe Tasks are owned by by the
1760
+ * underlying C++ Task. If you need to extend the lifetime of these objects,
1761
+ * you can invoke the `clone()` method. To free up the resources obtained
1762
+ * during any clone or type conversion operation, it is important to invoke
1763
+ * `close()` on the `MPMask` instance.
1764
+ */
1765
+ export declare class MPMask {
1766
+ /** Returns the canvas element that the mask is bound to. */
1767
+ readonly canvas: HTMLCanvasElement | OffscreenCanvas | undefined;
1768
+ /** Returns the width of the mask. */
1769
+ readonly width: number;
1770
+ /** Returns the height of the mask. */
1771
+ readonly height: number;
1772
+ private constructor();
1773
+ /** Returns whether this `MPMask` contains a mask of type `Uint8Array`. */
1774
+ hasUint8Array(): boolean;
1775
+ /** Returns whether this `MPMask` contains a mask of type `Float32Array`. */
1776
+ hasFloat32Array(): boolean;
1777
+ /** Returns whether this `MPMask` contains a mask of type `WebGLTexture`. */
1778
+ hasWebGLTexture(): boolean;
1779
+ /**
1780
+ * Returns the underlying mask as a Uint8Array`. Note that this involves an
1781
+ * expensive GPU to CPU transfer if the current mask is only available as a
1782
+ * `WebGLTexture`.
1783
+ *
1784
+ * @return The current data as a Uint8Array.
1785
+ */
1786
+ getAsUint8Array(): Uint8Array;
1787
+ /**
1788
+ * Returns the underlying mask as a single channel `Float32Array`. Note that
1789
+ * this involves an expensive GPU to CPU transfer if the current mask is only
1790
+ * available as a `WebGLTexture`.
1791
+ *
1792
+ * @return The current mask as a Float32Array.
1793
+ */
1794
+ getAsFloat32Array(): Float32Array;
1795
+ /**
1796
+ * Returns the underlying mask as a `WebGLTexture` object. Note that this
1797
+ * involves a CPU to GPU transfer if the current mask is only available as
1798
+ * a CPU array. The returned texture is bound to the current canvas (see
1799
+ * `.canvas`).
1800
+ *
1801
+ * @return The current mask as a WebGLTexture.
1802
+ */
1803
+ getAsWebGLTexture(): WebGLTexture;
1804
+ /**
1805
+ * Creates a copy of the resources stored in this `MPMask`. You can
1806
+ * invoke this method to extend the lifetime of a mask returned by a
1807
+ * MediaPipe Task. Note that performance critical applications should aim to
1808
+ * only use the `MPMask` within the MediaPipe Task callback so that
1809
+ * copies can be avoided.
1810
+ */
1811
+ clone(): MPMask;
1812
+ /**
1813
+ * Frees up any resources owned by this `MPMask` instance.
1814
+ *
1815
+ * Note that this method does not free masks that are owned by the C++
1816
+ * Task, as these are freed automatically once you leave the MediaPipe
1817
+ * callback. Additionally, some shared state is freed only once you invoke
1818
+ * the Task's `close()` method.
1819
+ */
1820
+ close(): void;
1821
+ }
1822
+
1823
+ /**
1824
+ * Copyright 2023 The MediaPipe Authors.
1825
+ *
1826
+ * Licensed under the Apache License, Version 2.0 (the "License");
1827
+ * you may not use this file except in compliance with the License.
1828
+ * You may obtain a copy of the License at
1829
+ *
1830
+ * http://www.apache.org/licenses/LICENSE-2.0
1831
+ *
1832
+ * Unless required by applicable law or agreed to in writing, software
1833
+ * distributed under the License is distributed on an "AS IS" BASIS,
1834
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1835
+ * See the License for the specific language governing permissions and
1836
+ * limitations under the License.
1837
+ */
1838
+ /**
1839
+ * A keypoint, defined by the coordinates (x, y), normalized by the image
1840
+ * dimensions.
1841
+ */
1842
+ declare interface NormalizedKeypoint {
1843
+ /** X in normalized image coordinates. */
1844
+ x: number;
1845
+ /** Y in normalized image coordinates. */
1846
+ y: number;
1847
+ /** Optional label of the keypoint. */
1848
+ label?: string;
1849
+ /** Optional score of the keypoint. */
1850
+ score?: number;
1851
+ }
1852
+
1853
+ /**
1854
+ * Copyright 2022 The MediaPipe Authors.
1855
+ *
1856
+ * Licensed under the Apache License, Version 2.0 (the "License");
1857
+ * you may not use this file except in compliance with the License.
1858
+ * You may obtain a copy of the License at
1859
+ *
1860
+ * http://www.apache.org/licenses/LICENSE-2.0
1861
+ *
1862
+ * Unless required by applicable law or agreed to in writing, software
1863
+ * distributed under the License is distributed on an "AS IS" BASIS,
1864
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1865
+ * See the License for the specific language governing permissions and
1866
+ * limitations under the License.
1867
+ */
1868
+ /**
1869
+ * Normalized Landmark represents a point in 3D space with x, y, z coordinates.
1870
+ * x and y are normalized to [0.0, 1.0] by the image width and height
1871
+ * respectively. z represents the landmark depth, and the smaller the value the
1872
+ * closer the landmark is to the camera. The magnitude of z uses roughly the
1873
+ * same scale as x.
1874
+ */
1875
+ export declare interface NormalizedLandmark {
1876
+ /** The x coordinates of the normalized landmark. */
1877
+ x: number;
1878
+ /** The y coordinates of the normalized landmark. */
1879
+ y: number;
1880
+ /** The z coordinates of the normalized landmark. */
1881
+ z: number;
1882
+ }
1883
+
1884
+ /** Performs object detection on images. */
1885
+ export declare class ObjectDetector extends VisionTaskRunner {
1886
+ /**
1887
+ * Initializes the Wasm runtime and creates a new object detector from the
1888
+ * provided options.
1889
+ * @param wasmFileset A configuration object that provides the location of the
1890
+ * Wasm binary and its loader.
1891
+ * @param objectDetectorOptions The options for the Object Detector. Note that
1892
+ * either a path to the model asset or a model buffer needs to be
1893
+ * provided (via `baseOptions`).
1894
+ */
1895
+ static createFromOptions(wasmFileset: WasmFileset, objectDetectorOptions: ObjectDetectorOptions): Promise<ObjectDetector>;
1896
+ /**
1897
+ * Initializes the Wasm runtime and creates a new object detector based on the
1898
+ * provided model asset buffer.
1899
+ * @param wasmFileset A configuration object that provides the location of the
1900
+ * Wasm binary and its loader.
1901
+ * @param modelAssetBuffer A binary representation of the model.
1902
+ */
1903
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ObjectDetector>;
1904
+ /**
1905
+ * Initializes the Wasm runtime and creates a new object detector based on the
1906
+ * path to the model asset.
1907
+ * @param wasmFileset A configuration object that provides the location of the
1908
+ * Wasm binary and its loader.
1909
+ * @param modelAssetPath The path to the model asset.
1910
+ */
1911
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ObjectDetector>;
1912
+ private constructor();
1913
+ /**
1914
+ * Sets new options for the object detector.
1915
+ *
1916
+ * Calling `setOptions()` with a subset of options only affects those options.
1917
+ * You can reset an option back to its default value by explicitly setting it
1918
+ * to `undefined`.
1919
+ *
1920
+ * @param options The options for the object detector.
1921
+ */
1922
+ setOptions(options: ObjectDetectorOptions): Promise<void>;
1923
+ /**
1924
+ * Performs object detection on the provided single image and waits
1925
+ * synchronously for the response. Only use this method when the
1926
+ * ObjectDetector is created with running mode `image`.
1927
+ *
1928
+ * @param image An image to process.
1929
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1930
+ * to process the input image before running inference.
1931
+ * @return A result containing a list of detected objects.
1932
+ */
1933
+ detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
1934
+ /**
1935
+ * Performs object detection on the provided video frame and waits
1936
+ * synchronously for the response. Only use this method when the
1937
+ * ObjectDetector is created with running mode `video`.
1938
+ *
1939
+ * @param videoFrame A video frame to process.
1940
+ * @param timestamp The timestamp of the current frame, in ms.
1941
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
1942
+ * to process the input image before running inference.
1943
+ * @return A result containing a list of detected objects.
1944
+ */
1945
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
1946
+ }
1947
+
1948
+ /** Options to configure the MediaPipe Object Detector Task */
1949
+ export declare interface ObjectDetectorOptions extends VisionTaskOptions, ClassifierOptions {
1950
+ }
1951
+
1952
+ /** Performs pose landmarks detection on images. */
1953
+ export declare class PoseLandmarker extends VisionTaskRunner {
1954
+ /**
1955
+ * An array containing the pairs of pose landmark indices to be rendered with
1956
+ * connections.
1957
+ */
1958
+ static POSE_CONNECTIONS: Connection[];
1959
+ /**
1960
+ * Initializes the Wasm runtime and creates a new `PoseLandmarker` from the
1961
+ * provided options.
1962
+ * @param wasmFileset A configuration object that provides the location of the
1963
+ * Wasm binary and its loader.
1964
+ * @param poseLandmarkerOptions The options for the PoseLandmarker.
1965
+ * Note that either a path to the model asset or a model buffer needs to
1966
+ * be provided (via `baseOptions`).
1967
+ */
1968
+ static createFromOptions(wasmFileset: WasmFileset, poseLandmarkerOptions: PoseLandmarkerOptions): Promise<PoseLandmarker>;
1969
+ /**
1970
+ * Initializes the Wasm runtime and creates a new `PoseLandmarker` based on
1971
+ * the provided model asset buffer.
1972
+ * @param wasmFileset A configuration object that provides the location of the
1973
+ * Wasm binary and its loader.
1974
+ * @param modelAssetBuffer A binary representation of the model.
1975
+ */
1976
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<PoseLandmarker>;
1977
+ /**
1978
+ * Initializes the Wasm runtime and creates a new `PoseLandmarker` based on
1979
+ * the path to the model asset.
1980
+ * @param wasmFileset A configuration object that provides the location of the
1981
+ * Wasm binary and its loader.
1982
+ * @param modelAssetPath The path to the model asset.
1983
+ */
1984
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<PoseLandmarker>;
1985
+ private constructor();
1986
+ /**
1987
+ * Sets new options for this `PoseLandmarker`.
1988
+ *
1989
+ * Calling `setOptions()` with a subset of options only affects those options.
1990
+ * You can reset an option back to its default value by explicitly setting it
1991
+ * to `undefined`.
1992
+ *
1993
+ * @param options The options for the pose landmarker.
1994
+ */
1995
+ setOptions(options: PoseLandmarkerOptions): Promise<void>;
1996
+ /**
1997
+ * Performs pose detection on the provided single image and invokes the
1998
+ * callback with the response. The method returns synchronously once the
1999
+ * callback returns. Only use this method when the PoseLandmarker is created
2000
+ * with running mode `image`.
2001
+ *
2002
+ * @param image An image to process.
2003
+ * @param callback The callback that is invoked with the result. The
2004
+ * lifetime of the returned masks is only guaranteed for the duration of
2005
+ * the callback.
2006
+ */
2007
+ detect(image: ImageSource, callback: PoseLandmarkerCallback): void;
2008
+ /**
2009
+ * Performs pose detection on the provided single image and invokes the
2010
+ * callback with the response. The method returns synchronously once the
2011
+ * callback returns. Only use this method when the PoseLandmarker is created
2012
+ * with running mode `image`.
2013
+ *
2014
+ * @param image An image to process.
2015
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
2016
+ * to process the input image before running inference.
2017
+ * @param callback The callback that is invoked with the result. The
2018
+ * lifetime of the returned masks is only guaranteed for the duration of
2019
+ * the callback.
2020
+ */
2021
+ detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;
2022
+ /**
2023
+ * Performs pose detection on the provided single image and waits
2024
+ * synchronously for the response. This method creates a copy of the resulting
2025
+ * masks and should not be used in high-throughput applictions. Only
2026
+ * use this method when the PoseLandmarker is created with running mode
2027
+ * `image`.
2028
+ *
2029
+ * @param image An image to process.
2030
+ * @return The landmarker result. Any masks are copied to avoid lifetime
2031
+ * limits.
2032
+ * @return The detected pose landmarks.
2033
+ */
2034
+ detect(image: ImageSource): PoseLandmarkerResult;
2035
+ /**
2036
+ * Performs pose detection on the provided single image and waits
2037
+ * synchronously for the response. This method creates a copy of the resulting
2038
+ * masks and should not be used in high-throughput applictions. Only
2039
+ * use this method when the PoseLandmarker is created with running mode
2040
+ * `image`.
2041
+ *
2042
+ * @param image An image to process.
2043
+ * @return The landmarker result. Any masks are copied to avoid lifetime
2044
+ * limits.
2045
+ * @return The detected pose landmarks.
2046
+ */
2047
+ detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
2048
+ /**
2049
+ * Performs pose detection on the provided video frame and invokes the
2050
+ * callback with the response. The method returns synchronously once the
2051
+ * callback returns. Only use this method when the PoseLandmarker is created
2052
+ * with running mode `video`.
2053
+ *
2054
+ * @param videoFrame A video frame to process.
2055
+ * @param timestamp The timestamp of the current frame, in ms.
2056
+ * @param callback The callback that is invoked with the result. The
2057
+ * lifetime of the returned masks is only guaranteed for the duration of
2058
+ * the callback.
2059
+ */
2060
+ detectForVideo(videoFrame: ImageSource, timestamp: number, callback: PoseLandmarkerCallback): void;
2061
+ /**
2062
+ * Performs pose detection on the provided video frame and invokes the
2063
+ * callback with the response. The method returns synchronously once the
2064
+ * callback returns. Only use this method when the PoseLandmarker is created
2065
+ * with running mode `video`.
2066
+ *
2067
+ * @param videoFrame A video frame to process.
2068
+ * @param timestamp The timestamp of the current frame, in ms.
2069
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
2070
+ * to process the input image before running inference.
2071
+ * @param callback The callback that is invoked with the result. The
2072
+ * lifetime of the returned masks is only guaranteed for the duration of
2073
+ * the callback.
2074
+ */
2075
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;
2076
+ /**
2077
+ * Performs pose detection on the provided video frame and returns the result.
2078
+ * This method creates a copy of the resulting masks and should not be used
2079
+ * in high-throughput applictions. Only use this method when the
2080
+ * PoseLandmarker is created with running mode `video`.
2081
+ *
2082
+ * @param videoFrame A video frame to process.
2083
+ * @param timestamp The timestamp of the current frame, in ms.
2084
+ * @return The landmarker result. Any masks are copied to extend the
2085
+ * lifetime of the returned data.
2086
+ */
2087
+ detectForVideo(videoFrame: ImageSource, timestamp: number): PoseLandmarkerResult;
2088
+ /**
2089
+ * Performs pose detection on the provided video frame and returns the result.
2090
+ * This method creates a copy of the resulting masks and should not be used
2091
+ * in high-throughput applictions. The method returns synchronously once the
2092
+ * callback returns. Only use this method when the PoseLandmarker is created
2093
+ * with running mode `video`.
2094
+ *
2095
+ * @param videoFrame A video frame to process.
2096
+ * @param timestamp The timestamp of the current frame, in ms.
2097
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
2098
+ * to process the input image before running inference.
2099
+ * @return The landmarker result. Any masks are copied to extend the lifetime
2100
+ * of the returned data.
2101
+ */
2102
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
2103
+ }
2104
+
2105
+ /**
2106
+ * A callback that receives the result from the pose detector. The returned
2107
+ * masks are only valid for the duration of the callback. If asynchronous
2108
+ * processing is needed, the masks need to be copied before the callback
2109
+ * returns.
2110
+ */
2111
+ export declare type PoseLandmarkerCallback = (result: PoseLandmarkerResult) => void;
2112
+
2113
+ /** Options to configure the MediaPipe PoseLandmarker Task */
2114
+ export declare interface PoseLandmarkerOptions extends VisionTaskOptions {
2115
+ /**
2116
+ * The maximum number of poses can be detected by the PoseLandmarker.
2117
+ * Defaults to 1.
2118
+ */
2119
+ numPoses?: number | undefined;
2120
+ /**
2121
+ * The minimum confidence score for the pose detection to be considered
2122
+ * successful. Defaults to 0.5.
2123
+ */
2124
+ minPoseDetectionConfidence?: number | undefined;
2125
+ /**
2126
+ * The minimum confidence score of pose presence score in the pose landmark
2127
+ * detection. Defaults to 0.5.
2128
+ */
2129
+ minPosePresenceConfidence?: number | undefined;
2130
+ /**
2131
+ * The minimum confidence score for the pose tracking to be considered
2132
+ * successful. Defaults to 0.5.
2133
+ */
2134
+ minTrackingConfidence?: number | undefined;
2135
+ /** Whether to output segmentation masks. Defaults to false. */
2136
+ outputSegmentationMasks?: boolean | undefined;
2137
+ }
2138
+
2139
+ /**
2140
+ * Represents the pose landmarks deection results generated by `PoseLandmarker`.
2141
+ * Each vector element represents a single pose detected in the image.
2142
+ */
2143
+ export declare interface PoseLandmarkerResult {
2144
+ /** Pose landmarks of detected poses. */
2145
+ landmarks: NormalizedLandmark[][];
2146
+ /** Pose landmarks in world coordinates of detected poses. */
2147
+ worldLandmarks: Landmark[][];
2148
+ /** Segmentation mask for the detected pose. */
2149
+ segmentationMasks?: MPMask[];
2150
+ }
2151
+
2152
+ /**
2153
+ * Defines a rectangle, used e.g. as part of detection results or as input
2154
+ * region-of-interest.
2155
+ *
2156
+ * The coordinates are normalized with respect to the image dimensions, i.e.
2157
+ * generally in [0,1] but they may exceed these bounds if describing a region
2158
+ * overlapping the image. The origin is on the top-left corner of the image.
2159
+ */
2160
+ declare interface RectF {
2161
+ left: number;
2162
+ top: number;
2163
+ right: number;
2164
+ bottom: number;
2165
+ }
2166
+
2167
+ /** A Region-Of-Interest (ROI) to represent a region within an image. */
2168
+ export declare interface RegionOfInterest {
2169
+ /** The ROI in keypoint format. */
2170
+ keypoint?: NormalizedKeypoint;
2171
+ /** The ROI as scribbles over the object that the user wants to segment. */
2172
+ scribble?: NormalizedKeypoint[];
2173
+ }
2174
+
2175
+ /**
2176
+ * The two running modes of a vision task.
2177
+ * 1) The image mode for processing single image inputs.
2178
+ * 2) The video mode for processing decoded frames of a video.
2179
+ */
2180
+ declare type RunningMode = "IMAGE" | "VIDEO";
2181
+
2182
+ /** Base class for all MediaPipe Tasks. */
2183
+ declare abstract class TaskRunner {
2184
+ protected constructor();
2185
+ /** Configures the task with custom options. */
2186
+ abstract setOptions(options: TaskRunnerOptions): Promise<void>;
2187
+ /** Closes and cleans up the resources held by this task. */
2188
+ close(): void;
2189
+ }
2190
+
2191
+ /** Options to configure MediaPipe Tasks in general. */
2192
+ declare interface TaskRunnerOptions {
2193
+ /** Options to configure the loading of the model assets. */
2194
+ baseOptions?: BaseOptions_2;
2195
+ }
2196
+
2197
+ /** The options for configuring a MediaPipe vision task. */
2198
+ declare interface VisionTaskOptions extends TaskRunnerOptions {
2199
+ /**
2200
+ * The canvas element to bind textures to. This has to be set for GPU
2201
+ * processing. The task will initialize a WebGL context and throw an error if
2202
+ * this fails (e.g. if you have already initialized a different type of
2203
+ * context).
2204
+ */
2205
+ canvas?: HTMLCanvasElement | OffscreenCanvas;
2206
+ /**
2207
+ * The running mode of the task. Default to the image mode.
2208
+ * Vision tasks have two running modes:
2209
+ * 1) The image mode for processing single image inputs.
2210
+ * 2) The video mode for processing decoded frames of a video.
2211
+ */
2212
+ runningMode?: RunningMode;
2213
+ }
2214
+
2215
+ /** Base class for all MediaPipe Vision Tasks. */
2216
+ declare abstract class VisionTaskRunner extends TaskRunner {
2217
+ protected constructor();
2218
+ /** Configures the shared options of a vision task. */
2219
+ applyOptions(options: VisionTaskOptions): Promise<void>;
2220
+ /** Closes and cleans up the resources held by this task. */
2221
+ close(): void;
2222
+ }
2223
+
2224
+ /**
2225
+ * Copyright 2022 The MediaPipe Authors.
2226
+ *
2227
+ * Licensed under the Apache License, Version 2.0 (the "License");
2228
+ * you may not use this file except in compliance with the License.
2229
+ * You may obtain a copy of the License at
2230
+ *
2231
+ * http://www.apache.org/licenses/LICENSE-2.0
2232
+ *
2233
+ * Unless required by applicable law or agreed to in writing, software
2234
+ * distributed under the License is distributed on an "AS IS" BASIS,
2235
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2236
+ * See the License for the specific language governing permissions and
2237
+ * limitations under the License.
2238
+ */
2239
+ /** An object containing the locations of the Wasm assets */
2240
+ declare interface WasmFileset {
2241
+ /** The path to the Wasm loader script. */
2242
+ wasmLoaderPath: string;
2243
+ /** The path to the Wasm binary. */
2244
+ wasmBinaryPath: string;
2245
+ }
2246
+
2247
+ export { }