@mediapipe/tasks-text 0.1.0-alpha-1 → 0.1.0-alpha-3
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.
- package/README.md +34 -0
- package/package.json +1 -1
- package/text.d.ts +11 -1128
- package/text_bundle.js +1 -1
- package/wasm/text_wasm_internal.js +227 -389
- package/wasm/text_wasm_internal.wasm +0 -0
- package/wasm/text_wasm_nosimd_internal.js +227 -389
- package/wasm/text_wasm_nosimd_internal.wasm +0 -0
package/text.d.ts
CHANGED
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
/// <reference types="@types/offscreencanvas" />
|
|
2
|
-
|
|
3
|
-
import * as jspb from 'google-protobuf';
|
|
4
|
-
|
|
5
|
-
declare class Acceleration extends jspb.Message {
|
|
6
|
-
hasXnnpack(): boolean;
|
|
7
|
-
clearXnnpack(): void;
|
|
8
|
-
getXnnpack(): mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.Xnnpack | undefined;
|
|
9
|
-
setXnnpack(value?: mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.Xnnpack): void;
|
|
10
|
-
|
|
11
|
-
hasGpu(): boolean;
|
|
12
|
-
clearGpu(): void;
|
|
13
|
-
getGpu(): mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.Gpu | undefined;
|
|
14
|
-
setGpu(value?: mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.Gpu): void;
|
|
15
|
-
|
|
16
|
-
hasTflite(): boolean;
|
|
17
|
-
clearTflite(): void;
|
|
18
|
-
getTflite(): mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.TfLite | undefined;
|
|
19
|
-
setTflite(value?: mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.TfLite): void;
|
|
20
|
-
|
|
21
|
-
getDelegateCase(): Acceleration.DelegateCase;
|
|
22
|
-
serializeBinary(): Uint8Array;
|
|
23
|
-
toObject(includeInstance?: boolean): Acceleration.AsObject;
|
|
24
|
-
static toObject(includeInstance: boolean, msg: Acceleration): Acceleration.AsObject;
|
|
25
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
26
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
27
|
-
static serializeBinaryToWriter(message: Acceleration, writer: jspb.BinaryWriter): void;
|
|
28
|
-
static deserializeBinary(bytes: Uint8Array): Acceleration;
|
|
29
|
-
static deserializeBinaryFromReader(message: Acceleration, reader: jspb.BinaryReader): Acceleration;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare namespace Acceleration {
|
|
33
|
-
type AsObject = {
|
|
34
|
-
xnnpack?: mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.Xnnpack.AsObject,
|
|
35
|
-
gpu?: mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.Gpu.AsObject,
|
|
36
|
-
tflite?: mediapipe_calculators_tensor_inference_calculator_pb.InferenceCalculatorOptions.Delegate.TfLite.AsObject,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
enum DelegateCase {
|
|
40
|
-
DELEGATE_NOT_SET = 0,
|
|
41
|
-
XNNPACK = 1,
|
|
42
|
-
GPU = 2,
|
|
43
|
-
TFLITE = 4,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
1
|
/**
|
|
48
2
|
* Copyright 2022 The MediaPipe Authors. All Rights Reserved.
|
|
49
3
|
*
|
|
@@ -60,7 +14,7 @@ declare namespace Acceleration {
|
|
|
60
14
|
* limitations under the License.
|
|
61
15
|
*/
|
|
62
16
|
/** Options to configure MediaPipe model loading and processing. */
|
|
63
|
-
declare interface
|
|
17
|
+
declare interface BaseOptions_2 {
|
|
64
18
|
/**
|
|
65
19
|
* The model path to the model asset file. Only one of `modelAssetPath` or
|
|
66
20
|
* `modelAssetBuffer` can be set.
|
|
@@ -72,41 +26,7 @@ declare interface BaseOptions {
|
|
|
72
26
|
*/
|
|
73
27
|
modelAssetBuffer?: Uint8Array | undefined;
|
|
74
28
|
/** Overrides the default backend to use for the provided model. */
|
|
75
|
-
delegate?:
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
declare class BaseOptions_2 extends jspb.Message {
|
|
79
|
-
hasModelAsset(): boolean;
|
|
80
|
-
clearModelAsset(): void;
|
|
81
|
-
getModelAsset(): mediapipe_tasks_cc_core_proto_external_file_pb.ExternalFile | undefined;
|
|
82
|
-
setModelAsset(value?: mediapipe_tasks_cc_core_proto_external_file_pb.ExternalFile): void;
|
|
83
|
-
|
|
84
|
-
hasUseStreamMode(): boolean;
|
|
85
|
-
clearUseStreamMode(): void;
|
|
86
|
-
getUseStreamMode(): boolean | undefined;
|
|
87
|
-
setUseStreamMode(value: boolean): void;
|
|
88
|
-
|
|
89
|
-
hasAcceleration(): boolean;
|
|
90
|
-
clearAcceleration(): void;
|
|
91
|
-
getAcceleration(): mediapipe_tasks_cc_core_proto_acceleration_pb.Acceleration | undefined;
|
|
92
|
-
setAcceleration(value?: mediapipe_tasks_cc_core_proto_acceleration_pb.Acceleration): void;
|
|
93
|
-
|
|
94
|
-
serializeBinary(): Uint8Array;
|
|
95
|
-
toObject(includeInstance?: boolean): BaseOptions_2.AsObject;
|
|
96
|
-
static toObject(includeInstance: boolean, msg: BaseOptions_2): BaseOptions_2.AsObject;
|
|
97
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
98
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
99
|
-
static serializeBinaryToWriter(message: BaseOptions_2, writer: jspb.BinaryWriter): void;
|
|
100
|
-
static deserializeBinary(bytes: Uint8Array): BaseOptions_2;
|
|
101
|
-
static deserializeBinaryFromReader(message: BaseOptions_2, reader: jspb.BinaryReader): BaseOptions_2;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
declare namespace BaseOptions_2 {
|
|
105
|
-
type AsObject = {
|
|
106
|
-
modelAsset?: mediapipe_tasks_cc_core_proto_external_file_pb.ExternalFile.AsObject,
|
|
107
|
-
useStreamMode?: boolean,
|
|
108
|
-
acceleration?: mediapipe_tasks_cc_core_proto_acceleration_pb.Acceleration.AsObject,
|
|
109
|
-
}
|
|
29
|
+
delegate?: "CPU" | "GPU" | undefined;
|
|
110
30
|
}
|
|
111
31
|
|
|
112
32
|
/**
|
|
@@ -284,113 +204,6 @@ export declare interface Embedding {
|
|
|
284
204
|
headName: string;
|
|
285
205
|
}
|
|
286
206
|
|
|
287
|
-
/** A listener that will be invoked with an absl::StatusCode and message. */
|
|
288
|
-
declare type ErrorListener = (code: number, message: string) => void;
|
|
289
|
-
|
|
290
|
-
declare class ExternalFile extends jspb.Message {
|
|
291
|
-
hasFileContent(): boolean;
|
|
292
|
-
clearFileContent(): void;
|
|
293
|
-
getFileContent(): Uint8Array | string;
|
|
294
|
-
getFileContent_asU8(): Uint8Array;
|
|
295
|
-
getFileContent_asB64(): string;
|
|
296
|
-
setFileContent(value: Uint8Array | string): void;
|
|
297
|
-
|
|
298
|
-
hasFileName(): boolean;
|
|
299
|
-
clearFileName(): void;
|
|
300
|
-
getFileName(): string | undefined;
|
|
301
|
-
setFileName(value: string): void;
|
|
302
|
-
|
|
303
|
-
hasFileDescriptorMeta(): boolean;
|
|
304
|
-
clearFileDescriptorMeta(): void;
|
|
305
|
-
getFileDescriptorMeta(): FileDescriptorMeta | undefined;
|
|
306
|
-
setFileDescriptorMeta(value?: FileDescriptorMeta): void;
|
|
307
|
-
|
|
308
|
-
hasFilePointerMeta(): boolean;
|
|
309
|
-
clearFilePointerMeta(): void;
|
|
310
|
-
getFilePointerMeta(): FilePointerMeta | undefined;
|
|
311
|
-
setFilePointerMeta(value?: FilePointerMeta): void;
|
|
312
|
-
|
|
313
|
-
serializeBinary(): Uint8Array;
|
|
314
|
-
toObject(includeInstance?: boolean): ExternalFile.AsObject;
|
|
315
|
-
static toObject(includeInstance: boolean, msg: ExternalFile): ExternalFile.AsObject;
|
|
316
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
317
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
318
|
-
static serializeBinaryToWriter(message: ExternalFile, writer: jspb.BinaryWriter): void;
|
|
319
|
-
static deserializeBinary(bytes: Uint8Array): ExternalFile;
|
|
320
|
-
static deserializeBinaryFromReader(message: ExternalFile, reader: jspb.BinaryReader): ExternalFile;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
declare namespace ExternalFile {
|
|
324
|
-
type AsObject = {
|
|
325
|
-
fileContent: Uint8Array | string,
|
|
326
|
-
fileName?: string,
|
|
327
|
-
fileDescriptorMeta?: FileDescriptorMeta.AsObject,
|
|
328
|
-
filePointerMeta?: FilePointerMeta.AsObject,
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
declare class FileDescriptorMeta extends jspb.Message {
|
|
333
|
-
hasFd(): boolean;
|
|
334
|
-
clearFd(): void;
|
|
335
|
-
getFd(): number | undefined;
|
|
336
|
-
setFd(value: number): void;
|
|
337
|
-
|
|
338
|
-
hasLength(): boolean;
|
|
339
|
-
clearLength(): void;
|
|
340
|
-
getLength(): number | undefined;
|
|
341
|
-
setLength(value: number): void;
|
|
342
|
-
|
|
343
|
-
hasOffset(): boolean;
|
|
344
|
-
clearOffset(): void;
|
|
345
|
-
getOffset(): number | undefined;
|
|
346
|
-
setOffset(value: number): void;
|
|
347
|
-
|
|
348
|
-
serializeBinary(): Uint8Array;
|
|
349
|
-
toObject(includeInstance?: boolean): FileDescriptorMeta.AsObject;
|
|
350
|
-
static toObject(includeInstance: boolean, msg: FileDescriptorMeta): FileDescriptorMeta.AsObject;
|
|
351
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
352
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
353
|
-
static serializeBinaryToWriter(message: FileDescriptorMeta, writer: jspb.BinaryWriter): void;
|
|
354
|
-
static deserializeBinary(bytes: Uint8Array): FileDescriptorMeta;
|
|
355
|
-
static deserializeBinaryFromReader(message: FileDescriptorMeta, reader: jspb.BinaryReader): FileDescriptorMeta;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
declare namespace FileDescriptorMeta {
|
|
359
|
-
type AsObject = {
|
|
360
|
-
fd?: number,
|
|
361
|
-
length?: number,
|
|
362
|
-
offset?: number,
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
declare class FilePointerMeta extends jspb.Message {
|
|
367
|
-
hasPointer(): boolean;
|
|
368
|
-
clearPointer(): void;
|
|
369
|
-
getPointer(): number | undefined;
|
|
370
|
-
setPointer(value: number): void;
|
|
371
|
-
|
|
372
|
-
hasLength(): boolean;
|
|
373
|
-
clearLength(): void;
|
|
374
|
-
getLength(): number | undefined;
|
|
375
|
-
setLength(value: number): void;
|
|
376
|
-
|
|
377
|
-
serializeBinary(): Uint8Array;
|
|
378
|
-
toObject(includeInstance?: boolean): FilePointerMeta.AsObject;
|
|
379
|
-
static toObject(includeInstance: boolean, msg: FilePointerMeta): FilePointerMeta.AsObject;
|
|
380
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
381
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
382
|
-
static serializeBinaryToWriter(message: FilePointerMeta, writer: jspb.BinaryWriter): void;
|
|
383
|
-
static deserializeBinary(bytes: Uint8Array): FilePointerMeta;
|
|
384
|
-
static deserializeBinaryFromReader(message: FilePointerMeta, reader: jspb.BinaryReader): FilePointerMeta;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
declare namespace FilePointerMeta {
|
|
388
|
-
type AsObject = {
|
|
389
|
-
pointer?: number,
|
|
390
|
-
length?: number,
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
207
|
/**
|
|
395
208
|
* Resolves the files required for the MediaPipe Task APIs.
|
|
396
209
|
*
|
|
@@ -443,870 +256,21 @@ export declare class FilesetResolver {
|
|
|
443
256
|
static forVisionTasks(basePath?: string): Promise<WasmFileset>;
|
|
444
257
|
}
|
|
445
258
|
|
|
446
|
-
/**
|
|
447
|
-
* Simple class to run an arbitrary image-in/image-out MediaPipe graph (i.e.
|
|
448
|
-
* as created by wasm_mediapipe_demo BUILD macro), and either render results
|
|
449
|
-
* into canvas, or else return the output WebGLTexture. Takes a WebAssembly
|
|
450
|
-
* Module (must be instantiated to self.Module).
|
|
451
|
-
*/
|
|
452
|
-
declare class GraphRunner {
|
|
453
|
-
readonly wasmModule: WasmModule;
|
|
454
|
-
readonly hasMultiStreamSupport: boolean;
|
|
455
|
-
autoResizeCanvas: boolean;
|
|
456
|
-
audioPtr: number | null;
|
|
457
|
-
audioSize: number;
|
|
458
|
-
/**
|
|
459
|
-
* Creates a new MediaPipe WASM module. Must be called *after* wasm Module has
|
|
460
|
-
* initialized. Note that we take control of the GL canvas from here on out,
|
|
461
|
-
* and will resize it to fit input.
|
|
462
|
-
*
|
|
463
|
-
* @param module The underlying Wasm Module to use.
|
|
464
|
-
* @param glCanvas The type of the GL canvas to use, or `null` if no GL
|
|
465
|
-
* canvas should be initialzed. Initializes an offscreen canvas if not
|
|
466
|
-
* provided.
|
|
467
|
-
*/
|
|
468
|
-
constructor(module: WasmModule, glCanvas?: HTMLCanvasElement | OffscreenCanvas | null);
|
|
469
|
-
/**
|
|
470
|
-
* Convenience helper to load a MediaPipe graph from a file and pass it to
|
|
471
|
-
* setGraph.
|
|
472
|
-
* @param graphFile The url of the MediaPipe graph file to load.
|
|
473
|
-
*/
|
|
474
|
-
initializeGraph(graphFile: string): Promise<void>;
|
|
475
|
-
/**
|
|
476
|
-
* Convenience helper for calling setGraph with a string representing a text
|
|
477
|
-
* proto config.
|
|
478
|
-
* @param graphConfig The text proto graph config, expected to be a string in
|
|
479
|
-
* default JavaScript UTF-16 format.
|
|
480
|
-
*/
|
|
481
|
-
setGraphFromString(graphConfig: string): void;
|
|
482
|
-
/**
|
|
483
|
-
* Takes the raw data from a MediaPipe graph, and passes it to C++ to be run
|
|
484
|
-
* over the video stream. Will replace the previously running MediaPipe graph,
|
|
485
|
-
* if there is one.
|
|
486
|
-
* @param graphData The raw MediaPipe graph data, either in binary
|
|
487
|
-
* protobuffer format (.binarypb), or else in raw text format (.pbtxt or
|
|
488
|
-
* .textproto).
|
|
489
|
-
* @param isBinary This should be set to true if the graph is in
|
|
490
|
-
* binary format, and false if it is in human-readable text format.
|
|
491
|
-
*/
|
|
492
|
-
setGraph(graphData: Uint8Array, isBinary: boolean): void;
|
|
493
|
-
/**
|
|
494
|
-
* Configures the current graph to handle audio processing in a certain way
|
|
495
|
-
* for all its audio input streams. Additionally can configure audio headers
|
|
496
|
-
* (both input side packets as well as input stream headers), but these
|
|
497
|
-
* configurations only take effect if called before the graph is set/started.
|
|
498
|
-
* @param numChannels The number of channels of audio input. Only 1
|
|
499
|
-
* is supported for now.
|
|
500
|
-
* @param numSamples The number of samples that are taken in each
|
|
501
|
-
* audio capture.
|
|
502
|
-
* @param sampleRate The rate, in Hz, of the sampling.
|
|
503
|
-
* @param streamName The optional name of the input stream to additionally
|
|
504
|
-
* configure with audio information. This configuration only occurs before
|
|
505
|
-
* the graph is set/started. If unset, a default stream name will be used.
|
|
506
|
-
* @param headerName The optional name of the header input side packet to
|
|
507
|
-
* additionally configure with audio information. This configuration only
|
|
508
|
-
* occurs before the graph is set/started. If unset, a default header name
|
|
509
|
-
* will be used.
|
|
510
|
-
*/
|
|
511
|
-
configureAudio(numChannels: number, numSamples: number, sampleRate: number, streamName?: string, headerName?: string): void;
|
|
512
|
-
/**
|
|
513
|
-
* Allows disabling automatic canvas resizing, in case clients want to control
|
|
514
|
-
* control this.
|
|
515
|
-
* @param resize True will re-enable automatic canvas resizing, while false
|
|
516
|
-
* will disable the feature.
|
|
517
|
-
*/
|
|
518
|
-
setAutoResizeCanvas(resize: boolean): void;
|
|
519
|
-
/**
|
|
520
|
-
* Allows disabling the automatic render-to-screen code, in case clients don't
|
|
521
|
-
* need/want this. In particular, this removes the requirement for pipelines
|
|
522
|
-
* to have access to GPU resources, as well as the requirement for graphs to
|
|
523
|
-
* have "input_frames_gpu" and "output_frames_gpu" streams defined, so pure
|
|
524
|
-
* CPU pipelines and non-video pipelines can be created.
|
|
525
|
-
* NOTE: This only affects future graph initializations (via setGraph or
|
|
526
|
-
* initializeGraph), and does NOT affect the currently running graph, so
|
|
527
|
-
* calls to this should be made *before* setGraph/initializeGraph for the
|
|
528
|
-
* graph file being targeted.
|
|
529
|
-
* @param enabled True will re-enable automatic render-to-screen code and
|
|
530
|
-
* cause GPU resources to once again be requested, while false will
|
|
531
|
-
* disable the feature.
|
|
532
|
-
*/
|
|
533
|
-
setAutoRenderToScreen(enabled: boolean): void;
|
|
534
|
-
/**
|
|
535
|
-
* Bind texture to our internal canvas, and upload image source to GPU.
|
|
536
|
-
* Returns tuple [width, height] of texture. Intended for internal usage.
|
|
537
|
-
*/
|
|
538
|
-
bindTextureToStream(imageSource: ImageSource, streamNamePtr?: number): [
|
|
539
|
-
number,
|
|
540
|
-
number
|
|
541
|
-
];
|
|
542
|
-
/**
|
|
543
|
-
* Takes the raw data from a JS image source, and sends it to C++ to be
|
|
544
|
-
* processed, waiting synchronously for the response. Note that we will resize
|
|
545
|
-
* our GL canvas to fit the input, so input size should only change
|
|
546
|
-
* infrequently.
|
|
547
|
-
* @param imageSource An image source to process.
|
|
548
|
-
* @param timestamp The timestamp of the current frame, in ms.
|
|
549
|
-
* @return texture? The WebGL texture reference, if one was produced.
|
|
550
|
-
*/
|
|
551
|
-
processGl(imageSource: ImageSource, timestamp: number): WebGLTexture | undefined;
|
|
552
|
-
/**
|
|
553
|
-
* Converts JavaScript string input parameters into C++ c-string pointers.
|
|
554
|
-
* See b/204830158 for more details. Intended for internal usage.
|
|
555
|
-
*/
|
|
556
|
-
wrapStringPtr(stringData: string, stringPtrFunc: (ptr: number) => void): void;
|
|
557
|
-
/**
|
|
558
|
-
* Converts JavaScript string input parameters into C++ c-string pointers.
|
|
559
|
-
* See b/204830158 for more details.
|
|
560
|
-
*/
|
|
561
|
-
wrapStringPtrPtr(stringData: string[], ptrFunc: (ptr: number) => void): void;
|
|
562
|
-
/**
|
|
563
|
-
* Ensures existence of the simple listeners table and registers the callback.
|
|
564
|
-
* Intended for internal usage.
|
|
565
|
-
*/
|
|
566
|
-
setListener<T>(outputStreamName: string, callbackFcn: (data: T) => void): void;
|
|
567
|
-
/**
|
|
568
|
-
* Ensures existence of the vector listeners table and registers the callback.
|
|
569
|
-
* Intended for internal usage.
|
|
570
|
-
*/
|
|
571
|
-
setVectorListener<T>(outputStreamName: string, callbackFcn: (data: T[]) => void): void;
|
|
572
|
-
/**
|
|
573
|
-
* Attaches a listener that will be invoked when the MediaPipe framework
|
|
574
|
-
* returns an error.
|
|
575
|
-
*/
|
|
576
|
-
attachErrorListener(callbackFcn: (code: number, message: string) => void): void;
|
|
577
|
-
/**
|
|
578
|
-
* Takes the raw data from a JS audio capture array, and sends it to C++ to be
|
|
579
|
-
* processed.
|
|
580
|
-
* @param audioData An array of raw audio capture data, like
|
|
581
|
-
* from a call to getChannelData on an AudioBuffer.
|
|
582
|
-
* @param streamName The name of the MediaPipe graph stream to add the audio
|
|
583
|
-
* data to.
|
|
584
|
-
* @param timestamp The timestamp of the current frame, in ms.
|
|
585
|
-
*/
|
|
586
|
-
addAudioToStream(audioData: Float32Array, streamName: string, timestamp: number): void;
|
|
587
|
-
/**
|
|
588
|
-
* Takes the raw data from a JS audio capture array, and sends it to C++ to be
|
|
589
|
-
* processed, shaping the audioData array into an audio matrix according to
|
|
590
|
-
* the numChannels and numSamples parameters.
|
|
591
|
-
* @param audioData An array of raw audio capture data, like
|
|
592
|
-
* from a call to getChannelData on an AudioBuffer.
|
|
593
|
-
* @param numChannels The number of audio channels this data represents. If 0
|
|
594
|
-
* is passed, then the value will be taken from the last call to
|
|
595
|
-
* configureAudio.
|
|
596
|
-
* @param numSamples The number of audio samples captured in this data packet.
|
|
597
|
-
* If 0 is passed, then the value will be taken from the last call to
|
|
598
|
-
* configureAudio.
|
|
599
|
-
* @param streamName The name of the MediaPipe graph stream to add the audio
|
|
600
|
-
* data to.
|
|
601
|
-
* @param timestamp The timestamp of the current frame, in ms.
|
|
602
|
-
*/
|
|
603
|
-
addAudioToStreamWithShape(audioData: Float32Array, numChannels: number, numSamples: number, streamName: string, timestamp: number): void;
|
|
604
|
-
/**
|
|
605
|
-
* Takes the relevant information from the HTML video or image element, and
|
|
606
|
-
* passes it into the WebGL-based graph for processing on the given stream at
|
|
607
|
-
* the given timestamp. Can be used for additional auxiliary GpuBuffer input
|
|
608
|
-
* streams. Processing will not occur until a blocking call (like
|
|
609
|
-
* processVideoGl or finishProcessing) is made. For use with
|
|
610
|
-
* 'gl_graph_runner_internal_multi_input'.
|
|
611
|
-
* @param imageSource Reference to the video frame we wish to add into our
|
|
612
|
-
* graph.
|
|
613
|
-
* @param streamName The name of the MediaPipe graph stream to add the frame
|
|
614
|
-
* to.
|
|
615
|
-
* @param timestamp The timestamp of the input frame, in ms.
|
|
616
|
-
*/
|
|
617
|
-
addGpuBufferToStream(imageSource: ImageSource, streamName: string, timestamp: number): void;
|
|
618
|
-
/**
|
|
619
|
-
* Sends a boolean packet into the specified stream at the given timestamp.
|
|
620
|
-
* @param data The boolean data to send.
|
|
621
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
622
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
623
|
-
*/
|
|
624
|
-
addBoolToStream(data: boolean, streamName: string, timestamp: number): void;
|
|
625
|
-
/**
|
|
626
|
-
* Sends a double packet into the specified stream at the given timestamp.
|
|
627
|
-
* @param data The double data to send.
|
|
628
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
629
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
630
|
-
*/
|
|
631
|
-
addDoubleToStream(data: number, streamName: string, timestamp: number): void;
|
|
632
|
-
/**
|
|
633
|
-
* Sends a float packet into the specified stream at the given timestamp.
|
|
634
|
-
* @param data The float data to send.
|
|
635
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
636
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
637
|
-
*/
|
|
638
|
-
addFloatToStream(data: number, streamName: string, timestamp: number): void;
|
|
639
|
-
/**
|
|
640
|
-
* Sends an integer packet into the specified stream at the given timestamp.
|
|
641
|
-
* @param data The integer data to send.
|
|
642
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
643
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
644
|
-
*/
|
|
645
|
-
addIntToStream(data: number, streamName: string, timestamp: number): void;
|
|
646
|
-
/**
|
|
647
|
-
* Sends a string packet into the specified stream at the given timestamp.
|
|
648
|
-
* @param data The string data to send.
|
|
649
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
650
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
651
|
-
*/
|
|
652
|
-
addStringToStream(data: string, streamName: string, timestamp: number): void;
|
|
653
|
-
/**
|
|
654
|
-
* Sends a Record<string, string> packet into the specified stream at the
|
|
655
|
-
* given timestamp.
|
|
656
|
-
* @param data The records to send (will become a
|
|
657
|
-
* std::flat_hash_map<std::string, std::string).
|
|
658
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
659
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
660
|
-
*/
|
|
661
|
-
addStringRecordToStream(data: Record<string, string>, streamName: string, timestamp: number): void;
|
|
662
|
-
/**
|
|
663
|
-
* Sends a serialized protobuffer packet into the specified stream at the
|
|
664
|
-
* given timestamp, to be parsed into the specified protobuffer type.
|
|
665
|
-
* @param data The binary (serialized) raw protobuffer data.
|
|
666
|
-
* @param protoType The C++ namespaced type this protobuffer data corresponds
|
|
667
|
-
* to. It will be converted to this type when output as a packet into the
|
|
668
|
-
* graph.
|
|
669
|
-
* @param streamName The name of the graph input stream to send data into.
|
|
670
|
-
* @param timestamp The timestamp of the input data, in ms.
|
|
671
|
-
*/
|
|
672
|
-
addProtoToStream(data: Uint8Array, protoType: string, streamName: string, timestamp: number): void;
|
|
673
|
-
/**
|
|
674
|
-
* Attaches a boolean packet to the specified input_side_packet.
|
|
675
|
-
* @param data The boolean data to send.
|
|
676
|
-
* @param sidePacketName The name of the graph input side packet to send data
|
|
677
|
-
* into.
|
|
678
|
-
*/
|
|
679
|
-
addBoolToInputSidePacket(data: boolean, sidePacketName: string): void;
|
|
680
|
-
/**
|
|
681
|
-
* Attaches a double packet to the specified input_side_packet.
|
|
682
|
-
* @param data The double data to send.
|
|
683
|
-
* @param sidePacketName The name of the graph input side packet to send data
|
|
684
|
-
* into.
|
|
685
|
-
*/
|
|
686
|
-
addDoubleToInputSidePacket(data: number, sidePacketName: string): void;
|
|
687
|
-
/**
|
|
688
|
-
* Attaches a float packet to the specified input_side_packet.
|
|
689
|
-
* @param data The float data to send.
|
|
690
|
-
* @param sidePacketName The name of the graph input side packet to send data
|
|
691
|
-
* into.
|
|
692
|
-
*/
|
|
693
|
-
addFloatToInputSidePacket(data: number, sidePacketName: string): void;
|
|
694
|
-
/**
|
|
695
|
-
* Attaches a integer packet to the specified input_side_packet.
|
|
696
|
-
* @param data The integer data to send.
|
|
697
|
-
* @param sidePacketName The name of the graph input side packet to send data
|
|
698
|
-
* into.
|
|
699
|
-
*/
|
|
700
|
-
addIntToInputSidePacket(data: number, sidePacketName: string): void;
|
|
701
|
-
/**
|
|
702
|
-
* Attaches a string packet to the specified input_side_packet.
|
|
703
|
-
* @param data The string data to send.
|
|
704
|
-
* @param sidePacketName The name of the graph input side packet to send data
|
|
705
|
-
* into.
|
|
706
|
-
*/
|
|
707
|
-
addStringToInputSidePacket(data: string, sidePacketName: string): void;
|
|
708
|
-
/**
|
|
709
|
-
* Attaches a serialized proto packet to the specified input_side_packet.
|
|
710
|
-
* @param data The binary (serialized) raw protobuffer data.
|
|
711
|
-
* @param protoType The C++ namespaced type this protobuffer data corresponds
|
|
712
|
-
* to. It will be converted to this type for use in the graph.
|
|
713
|
-
* @param sidePacketName The name of the graph input side packet to send data
|
|
714
|
-
* into.
|
|
715
|
-
*/
|
|
716
|
-
addProtoToInputSidePacket(data: Uint8Array, protoType: string, sidePacketName: string): void;
|
|
717
|
-
/**
|
|
718
|
-
* Attaches a boolean packet listener to the specified output_stream.
|
|
719
|
-
* @param outputStreamName The name of the graph output stream to grab boolean
|
|
720
|
-
* data from.
|
|
721
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
722
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
723
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
724
|
-
* should not perform overly complicated (or any async) behavior.
|
|
725
|
-
*/
|
|
726
|
-
attachBoolListener(outputStreamName: string, callbackFcn: (data: boolean) => void): void;
|
|
727
|
-
/**
|
|
728
|
-
* Attaches a bool[] packet listener to the specified output_stream.
|
|
729
|
-
* @param outputStreamName The name of the graph output stream to grab
|
|
730
|
-
* std::vector<bool> data from.
|
|
731
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
732
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
733
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
734
|
-
* should not perform overly complicated (or any async) behavior.
|
|
735
|
-
*/
|
|
736
|
-
attachBoolVectorListener(outputStreamName: string, callbackFcn: (data: boolean[]) => void): void;
|
|
737
|
-
/**
|
|
738
|
-
* Attaches an int packet listener to the specified output_stream.
|
|
739
|
-
* @param outputStreamName The name of the graph output stream to grab int
|
|
740
|
-
* data from.
|
|
741
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
742
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
743
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
744
|
-
* should not perform overly complicated (or any async) behavior.
|
|
745
|
-
*/
|
|
746
|
-
attachIntListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
747
|
-
/**
|
|
748
|
-
* Attaches an int[] packet listener to the specified output_stream.
|
|
749
|
-
* @param outputStreamName The name of the graph output stream to grab
|
|
750
|
-
* std::vector<int> data from.
|
|
751
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
752
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
753
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
754
|
-
* should not perform overly complicated (or any async) behavior.
|
|
755
|
-
*/
|
|
756
|
-
attachIntVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
757
|
-
/**
|
|
758
|
-
* Attaches a double packet listener to the specified output_stream.
|
|
759
|
-
* @param outputStreamName The name of the graph output stream to grab double
|
|
760
|
-
* data from.
|
|
761
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
762
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
763
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
764
|
-
* should not perform overly complicated (or any async) behavior.
|
|
765
|
-
*/
|
|
766
|
-
attachDoubleListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
767
|
-
/**
|
|
768
|
-
* Attaches a double[] packet listener to the specified output_stream.
|
|
769
|
-
* @param outputStreamName The name of the graph output stream to grab
|
|
770
|
-
* std::vector<double> data from.
|
|
771
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
772
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
773
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
774
|
-
* should not perform overly complicated (or any async) behavior.
|
|
775
|
-
*/
|
|
776
|
-
attachDoubleVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
777
|
-
/**
|
|
778
|
-
* Attaches a float packet listener to the specified output_stream.
|
|
779
|
-
* @param outputStreamName The name of the graph output stream to grab float
|
|
780
|
-
* data from.
|
|
781
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
782
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
783
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
784
|
-
* should not perform overly complicated (or any async) behavior.
|
|
785
|
-
*/
|
|
786
|
-
attachFloatListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
787
|
-
/**
|
|
788
|
-
* Attaches a float[] packet listener to the specified output_stream.
|
|
789
|
-
* @param outputStreamName The name of the graph output stream to grab
|
|
790
|
-
* std::vector<float> data from.
|
|
791
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
792
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
793
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
794
|
-
* should not perform overly complicated (or any async) behavior.
|
|
795
|
-
*/
|
|
796
|
-
attachFloatVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
797
|
-
/**
|
|
798
|
-
* Attaches a string packet listener to the specified output_stream.
|
|
799
|
-
* @param outputStreamName The name of the graph output stream to grab string
|
|
800
|
-
* data from.
|
|
801
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
802
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
803
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
804
|
-
* should not perform overly complicated (or any async) behavior.
|
|
805
|
-
*/
|
|
806
|
-
attachStringListener(outputStreamName: string, callbackFcn: (data: string) => void): void;
|
|
807
|
-
/**
|
|
808
|
-
* Attaches a string[] packet listener to the specified output_stream.
|
|
809
|
-
* @param outputStreamName The name of the graph output stream to grab
|
|
810
|
-
* std::vector<std::string> data from.
|
|
811
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
812
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
813
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
814
|
-
* should not perform overly complicated (or any async) behavior.
|
|
815
|
-
*/
|
|
816
|
-
attachStringVectorListener(outputStreamName: string, callbackFcn: (data: string[]) => void): void;
|
|
817
|
-
/**
|
|
818
|
-
* Attaches a serialized proto packet listener to the specified output_stream.
|
|
819
|
-
* @param outputStreamName The name of the graph output stream to grab binary
|
|
820
|
-
* serialized proto data from (in Uint8Array format).
|
|
821
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
822
|
-
* it is received. Note that by default the data is only guaranteed to
|
|
823
|
-
* exist for the duration of the callback, and the callback will be called
|
|
824
|
-
* inline, so it should not perform overly complicated (or any async)
|
|
825
|
-
* behavior. If the proto data needs to be able to outlive the call, you
|
|
826
|
-
* may set the optional makeDeepCopy parameter to true, or can manually
|
|
827
|
-
* deep-copy the data yourself.
|
|
828
|
-
* @param makeDeepCopy Optional convenience parameter which, if set to true,
|
|
829
|
-
* will override the default memory management behavior and make a deep
|
|
830
|
-
* copy of the underlying data, rather than just returning a view into the
|
|
831
|
-
* C++-managed memory. At the cost of a data copy, this allows the
|
|
832
|
-
* returned data to outlive the callback lifetime (and it will be cleaned
|
|
833
|
-
* up automatically by JS garbage collection whenever the user is finished
|
|
834
|
-
* with it).
|
|
835
|
-
*/
|
|
836
|
-
attachProtoListener(outputStreamName: string, callbackFcn: (data: Uint8Array) => void, makeDeepCopy?: boolean): void;
|
|
837
|
-
/**
|
|
838
|
-
* Attaches a listener for an array of serialized proto packets to the
|
|
839
|
-
* specified output_stream.
|
|
840
|
-
* @param outputStreamName The name of the graph output stream to grab a
|
|
841
|
-
* vector of binary serialized proto data from (in Uint8Array[] format).
|
|
842
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
843
|
-
* it is received. Note that by default the data is only guaranteed to
|
|
844
|
-
* exist for the duration of the callback, and the callback will be called
|
|
845
|
-
* inline, so it should not perform overly complicated (or any async)
|
|
846
|
-
* behavior. If the proto data needs to be able to outlive the call, you
|
|
847
|
-
* may set the optional makeDeepCopy parameter to true, or can manually
|
|
848
|
-
* deep-copy the data yourself.
|
|
849
|
-
* @param makeDeepCopy Optional convenience parameter which, if set to true,
|
|
850
|
-
* will override the default memory management behavior and make a deep
|
|
851
|
-
* copy of the underlying data, rather than just returning a view into the
|
|
852
|
-
* C++-managed memory. At the cost of a data copy, this allows the
|
|
853
|
-
* returned data to outlive the callback lifetime (and it will be cleaned
|
|
854
|
-
* up automatically by JS garbage collection whenever the user is finished
|
|
855
|
-
* with it).
|
|
856
|
-
*/
|
|
857
|
-
attachProtoVectorListener(outputStreamName: string, callbackFcn: (data: Uint8Array[]) => void, makeDeepCopy?: boolean): void;
|
|
858
|
-
/**
|
|
859
|
-
* Attaches an audio packet listener to the specified output_stream, to be
|
|
860
|
-
* given a Float32Array as output.
|
|
861
|
-
* @param outputStreamName The name of the graph output stream to grab audio
|
|
862
|
-
* data from.
|
|
863
|
-
* @param callbackFcn The function that will be called back with the data, as
|
|
864
|
-
* it is received. Note that the data is only guaranteed to exist for the
|
|
865
|
-
* duration of the callback, and the callback will be called inline, so it
|
|
866
|
-
* should not perform overly complicated (or any async) behavior. If the
|
|
867
|
-
* audio data needs to be able to outlive the call, you may set the
|
|
868
|
-
* optional makeDeepCopy parameter to true, or can manually deep-copy the
|
|
869
|
-
* data yourself.
|
|
870
|
-
* @param makeDeepCopy Optional convenience parameter which, if set to true,
|
|
871
|
-
* will override the default memory management behavior and make a deep
|
|
872
|
-
* copy of the underlying data, rather than just returning a view into the
|
|
873
|
-
* C++-managed memory. At the cost of a data copy, this allows the
|
|
874
|
-
* returned data to outlive the callback lifetime (and it will be cleaned
|
|
875
|
-
* up automatically by JS garbage collection whenever the user is finished
|
|
876
|
-
* with it).
|
|
877
|
-
*/
|
|
878
|
-
attachAudioListener(outputStreamName: string, callbackFcn: (data: Float32Array) => void, makeDeepCopy?: boolean): void;
|
|
879
|
-
/**
|
|
880
|
-
* Forces all queued-up packets to be pushed through the MediaPipe graph as
|
|
881
|
-
* far as possible, performing all processing until no more processing can be
|
|
882
|
-
* done.
|
|
883
|
-
*/
|
|
884
|
-
finishProcessing(): void;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
/** An implementation of the GraphRunner that supports image operations */
|
|
888
|
-
declare class GraphRunnerImageLib extends GraphRunnerImageLibType {
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
declare const GraphRunnerImageLibType: (new (...args: any[]) => {
|
|
892
|
-
registerModelResourcesGraphService(): void;
|
|
893
|
-
readonly wasmModule: WasmModule;
|
|
894
|
-
readonly hasMultiStreamSupport: boolean;
|
|
895
|
-
autoResizeCanvas: boolean;
|
|
896
|
-
audioPtr: number | null;
|
|
897
|
-
audioSize: number;
|
|
898
|
-
initializeGraph(graphFile: string): Promise<void>;
|
|
899
|
-
setGraphFromString(graphConfig: string): void;
|
|
900
|
-
setGraph(graphData: Uint8Array, isBinary: boolean): void;
|
|
901
|
-
configureAudio(numChannels: number, numSamples: number, sampleRate: number, streamName?: string | undefined, headerName?: string | undefined): void;
|
|
902
|
-
setAutoResizeCanvas(resize: boolean): void;
|
|
903
|
-
setAutoRenderToScreen(enabled: boolean): void;
|
|
904
|
-
bindTextureToStream(imageSource: ImageSource, streamNamePtr?: number | undefined): [number, number];
|
|
905
|
-
processGl(imageSource: ImageSource, timestamp: number): WebGLTexture | undefined;
|
|
906
|
-
wrapStringPtr(stringData: string, stringPtrFunc: (ptr: number) => void): void;
|
|
907
|
-
wrapStringPtrPtr(stringData: string[], ptrFunc: (ptr: number) => void): void;
|
|
908
|
-
setListener<T>(outputStreamName: string, callbackFcn: (data: T) => void): void;
|
|
909
|
-
setVectorListener<T_1>(outputStreamName: string, callbackFcn: (data: T_1[]) => void): void;
|
|
910
|
-
attachErrorListener(callbackFcn: (code: number, message: string) => void): void;
|
|
911
|
-
addAudioToStream(audioData: Float32Array, streamName: string, timestamp: number): void;
|
|
912
|
-
addAudioToStreamWithShape(audioData: Float32Array, numChannels: number, numSamples: number, streamName: string, timestamp: number): void;
|
|
913
|
-
addGpuBufferToStream(imageSource: ImageSource, streamName: string, timestamp: number): void;
|
|
914
|
-
addBoolToStream(data: boolean, streamName: string, timestamp: number): void;
|
|
915
|
-
addDoubleToStream(data: number, streamName: string, timestamp: number): void;
|
|
916
|
-
addFloatToStream(data: number, streamName: string, timestamp: number): void;
|
|
917
|
-
addIntToStream(data: number, streamName: string, timestamp: number): void;
|
|
918
|
-
addStringToStream(data: string, streamName: string, timestamp: number): void;
|
|
919
|
-
addStringRecordToStream(data: Record<string, string>, streamName: string, timestamp: number): void;
|
|
920
|
-
addProtoToStream(data: Uint8Array, protoType: string, streamName: string, timestamp: number): void;
|
|
921
|
-
addBoolToInputSidePacket(data: boolean, sidePacketName: string): void;
|
|
922
|
-
addDoubleToInputSidePacket(data: number, sidePacketName: string): void;
|
|
923
|
-
addFloatToInputSidePacket(data: number, sidePacketName: string): void;
|
|
924
|
-
addIntToInputSidePacket(data: number, sidePacketName: string): void;
|
|
925
|
-
addStringToInputSidePacket(data: string, sidePacketName: string): void;
|
|
926
|
-
addProtoToInputSidePacket(data: Uint8Array, protoType: string, sidePacketName: string): void;
|
|
927
|
-
attachBoolListener(outputStreamName: string, callbackFcn: (data: boolean) => void): void;
|
|
928
|
-
attachBoolVectorListener(outputStreamName: string, callbackFcn: (data: boolean[]) => void): void;
|
|
929
|
-
attachIntListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
930
|
-
attachIntVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
931
|
-
attachDoubleListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
932
|
-
attachDoubleVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
933
|
-
attachFloatListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
934
|
-
attachFloatVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
935
|
-
attachStringListener(outputStreamName: string, callbackFcn: (data: string) => void): void;
|
|
936
|
-
attachStringVectorListener(outputStreamName: string, callbackFcn: (data: string[]) => void): void;
|
|
937
|
-
attachProtoListener(outputStreamName: string, callbackFcn: (data: Uint8Array) => void, makeDeepCopy?: boolean | undefined): void;
|
|
938
|
-
attachProtoVectorListener(outputStreamName: string, callbackFcn: (data: Uint8Array[]) => void, makeDeepCopy?: boolean | undefined): void;
|
|
939
|
-
attachAudioListener(outputStreamName: string, callbackFcn: (data: Float32Array) => void, makeDeepCopy?: boolean | undefined): void;
|
|
940
|
-
finishProcessing(): void;
|
|
941
|
-
}) & (new (...args: any[]) => {
|
|
942
|
-
addGpuBufferAsImageToStream(imageSource: ImageSource, streamName: string, timestamp: number): void;
|
|
943
|
-
readonly wasmModule: WasmModule;
|
|
944
|
-
readonly hasMultiStreamSupport: boolean;
|
|
945
|
-
autoResizeCanvas: boolean;
|
|
946
|
-
audioPtr: number | null;
|
|
947
|
-
audioSize: number;
|
|
948
|
-
initializeGraph(graphFile: string): Promise<void>;
|
|
949
|
-
setGraphFromString(graphConfig: string): void;
|
|
950
|
-
setGraph(graphData: Uint8Array, isBinary: boolean): void;
|
|
951
|
-
configureAudio(numChannels: number, numSamples: number, sampleRate: number, streamName?: string | undefined, headerName?: string | undefined): void;
|
|
952
|
-
setAutoResizeCanvas(resize: boolean): void;
|
|
953
|
-
setAutoRenderToScreen(enabled: boolean): void;
|
|
954
|
-
bindTextureToStream(imageSource: ImageSource, streamNamePtr?: number | undefined): [number, number];
|
|
955
|
-
processGl(imageSource: ImageSource, timestamp: number): WebGLTexture | undefined;
|
|
956
|
-
wrapStringPtr(stringData: string, stringPtrFunc: (ptr: number) => void): void;
|
|
957
|
-
wrapStringPtrPtr(stringData: string[], ptrFunc: (ptr: number) => void): void;
|
|
958
|
-
setListener<T_2>(outputStreamName: string, callbackFcn: (data: T_2) => void): void;
|
|
959
|
-
setVectorListener<T_1_1>(outputStreamName: string, callbackFcn: (data: T_1_1[]) => void): void;
|
|
960
|
-
attachErrorListener(callbackFcn: (code: number, message: string) => void): void; /**
|
|
961
|
-
* Creates a new instance of a Mediapipe Task. Determines if SIMD is
|
|
962
|
-
* supported and loads the relevant WASM binary.
|
|
963
|
-
* @return A fully instantiated instance of `T`.
|
|
964
|
-
*/
|
|
965
|
-
addAudioToStream(audioData: Float32Array, streamName: string, timestamp: number): void;
|
|
966
|
-
addAudioToStreamWithShape(audioData: Float32Array, numChannels: number, numSamples: number, streamName: string, timestamp: number): void;
|
|
967
|
-
addGpuBufferToStream(imageSource: ImageSource, streamName: string, timestamp: number): void;
|
|
968
|
-
addBoolToStream(data: boolean, streamName: string, timestamp: number): void;
|
|
969
|
-
addDoubleToStream(data: number, streamName: string, timestamp: number): void;
|
|
970
|
-
addFloatToStream(data: number, streamName: string, timestamp: number): void;
|
|
971
|
-
addIntToStream(data: number, streamName: string, timestamp: number): void;
|
|
972
|
-
addStringToStream(data: string, streamName: string, timestamp: number): void;
|
|
973
|
-
addStringRecordToStream(data: Record<string, string>, streamName: string, timestamp: number): void;
|
|
974
|
-
addProtoToStream(data: Uint8Array, protoType: string, streamName: string, timestamp: number): void;
|
|
975
|
-
addBoolToInputSidePacket(data: boolean, sidePacketName: string): void;
|
|
976
|
-
addDoubleToInputSidePacket(data: number, sidePacketName: string): void;
|
|
977
|
-
addFloatToInputSidePacket(data: number, sidePacketName: string): void;
|
|
978
|
-
addIntToInputSidePacket(data: number, sidePacketName: string): void;
|
|
979
|
-
addStringToInputSidePacket(data: string, sidePacketName: string): void;
|
|
980
|
-
addProtoToInputSidePacket(data: Uint8Array, protoType: string, sidePacketName: string): void;
|
|
981
|
-
attachBoolListener(outputStreamName: string, callbackFcn: (data: boolean) => void): void;
|
|
982
|
-
attachBoolVectorListener(outputStreamName: string, callbackFcn: (data: boolean[]) => void): void;
|
|
983
|
-
attachIntListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
984
|
-
attachIntVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
985
|
-
attachDoubleListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
986
|
-
attachDoubleVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
987
|
-
attachFloatListener(outputStreamName: string, callbackFcn: (data: number) => void): void;
|
|
988
|
-
attachFloatVectorListener(outputStreamName: string, callbackFcn: (data: number[]) => void): void;
|
|
989
|
-
attachStringListener(outputStreamName: string, callbackFcn: (data: string) => void): void;
|
|
990
|
-
attachStringVectorListener(outputStreamName: string, callbackFcn: (data: string[]) => void): void;
|
|
991
|
-
attachProtoListener(outputStreamName: string, callbackFcn: (data: Uint8Array) => void, makeDeepCopy?: boolean | undefined): void;
|
|
992
|
-
attachProtoVectorListener(outputStreamName: string, callbackFcn: (data: Uint8Array[]) => void, makeDeepCopy?: boolean | undefined): void;
|
|
993
|
-
attachAudioListener(outputStreamName: string, callbackFcn: (data: Float32Array) => void, makeDeepCopy?: boolean | undefined): void;
|
|
994
|
-
finishProcessing(): void;
|
|
995
|
-
}) & typeof GraphRunner;
|
|
996
|
-
|
|
997
|
-
/**
|
|
998
|
-
* Valid types of image sources which we can run our GraphRunner over.
|
|
999
|
-
*/
|
|
1000
|
-
declare type ImageSource = HTMLCanvasElement | HTMLVideoElement | HTMLImageElement | ImageData | ImageBitmap;
|
|
1001
|
-
|
|
1002
|
-
declare class InferenceCalculatorOptions extends jspb.Message {
|
|
1003
|
-
hasModelPath(): boolean;
|
|
1004
|
-
clearModelPath(): void;
|
|
1005
|
-
getModelPath(): string | undefined;
|
|
1006
|
-
setModelPath(value: string): void;
|
|
1007
|
-
|
|
1008
|
-
hasUseGpu(): boolean;
|
|
1009
|
-
clearUseGpu(): void;
|
|
1010
|
-
getUseGpu(): boolean | undefined;
|
|
1011
|
-
setUseGpu(value: boolean): void;
|
|
1012
|
-
|
|
1013
|
-
hasUseNnapi(): boolean;
|
|
1014
|
-
clearUseNnapi(): void;
|
|
1015
|
-
getUseNnapi(): boolean | undefined;
|
|
1016
|
-
setUseNnapi(value: boolean): void;
|
|
1017
|
-
|
|
1018
|
-
hasCpuNumThread(): boolean;
|
|
1019
|
-
clearCpuNumThread(): void;
|
|
1020
|
-
getCpuNumThread(): number | undefined;
|
|
1021
|
-
setCpuNumThread(value: number): void;
|
|
1022
|
-
|
|
1023
|
-
hasDelegate(): boolean;
|
|
1024
|
-
clearDelegate(): void;
|
|
1025
|
-
getDelegate(): InferenceCalculatorOptions.Delegate | undefined;
|
|
1026
|
-
setDelegate(value?: InferenceCalculatorOptions.Delegate): void;
|
|
1027
|
-
|
|
1028
|
-
serializeBinary(): Uint8Array;
|
|
1029
|
-
toObject(includeInstance?: boolean): InferenceCalculatorOptions.AsObject;
|
|
1030
|
-
static toObject(includeInstance: boolean, msg: InferenceCalculatorOptions): InferenceCalculatorOptions.AsObject;
|
|
1031
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
1032
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
1033
|
-
static serializeBinaryToWriter(message: InferenceCalculatorOptions, writer: jspb.BinaryWriter): void;
|
|
1034
|
-
static deserializeBinary(bytes: Uint8Array): InferenceCalculatorOptions;
|
|
1035
|
-
static deserializeBinaryFromReader(message: InferenceCalculatorOptions, reader: jspb.BinaryReader): InferenceCalculatorOptions;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
declare namespace InferenceCalculatorOptions {
|
|
1039
|
-
type AsObject = {
|
|
1040
|
-
modelPath?: string,
|
|
1041
|
-
useGpu?: boolean,
|
|
1042
|
-
useNnapi?: boolean,
|
|
1043
|
-
cpuNumThread?: number,
|
|
1044
|
-
delegate?: InferenceCalculatorOptions.Delegate.AsObject,
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
class Delegate extends jspb.Message {
|
|
1048
|
-
hasTflite(): boolean;
|
|
1049
|
-
clearTflite(): void;
|
|
1050
|
-
getTflite(): InferenceCalculatorOptions.Delegate.TfLite | undefined;
|
|
1051
|
-
setTflite(value?: InferenceCalculatorOptions.Delegate.TfLite): void;
|
|
1052
|
-
|
|
1053
|
-
hasGpu(): boolean;
|
|
1054
|
-
clearGpu(): void;
|
|
1055
|
-
getGpu(): InferenceCalculatorOptions.Delegate.Gpu | undefined;
|
|
1056
|
-
setGpu(value?: InferenceCalculatorOptions.Delegate.Gpu): void;
|
|
1057
|
-
|
|
1058
|
-
hasNnapi(): boolean;
|
|
1059
|
-
clearNnapi(): void;
|
|
1060
|
-
getNnapi(): InferenceCalculatorOptions.Delegate.Nnapi | undefined;
|
|
1061
|
-
setNnapi(value?: InferenceCalculatorOptions.Delegate.Nnapi): void;
|
|
1062
|
-
|
|
1063
|
-
hasXnnpack(): boolean;
|
|
1064
|
-
clearXnnpack(): void;
|
|
1065
|
-
getXnnpack(): InferenceCalculatorOptions.Delegate.Xnnpack | undefined;
|
|
1066
|
-
setXnnpack(value?: InferenceCalculatorOptions.Delegate.Xnnpack): void;
|
|
1067
|
-
|
|
1068
|
-
getDelegateCase(): Delegate.DelegateCase;
|
|
1069
|
-
serializeBinary(): Uint8Array;
|
|
1070
|
-
toObject(includeInstance?: boolean): Delegate.AsObject;
|
|
1071
|
-
static toObject(includeInstance: boolean, msg: Delegate): Delegate.AsObject;
|
|
1072
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
1073
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
1074
|
-
static serializeBinaryToWriter(message: Delegate, writer: jspb.BinaryWriter): void;
|
|
1075
|
-
static deserializeBinary(bytes: Uint8Array): Delegate;
|
|
1076
|
-
static deserializeBinaryFromReader(message: Delegate, reader: jspb.BinaryReader): Delegate;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
namespace Delegate {
|
|
1080
|
-
type AsObject = {
|
|
1081
|
-
tflite?: InferenceCalculatorOptions.Delegate.TfLite.AsObject,
|
|
1082
|
-
gpu?: InferenceCalculatorOptions.Delegate.Gpu.AsObject,
|
|
1083
|
-
nnapi?: InferenceCalculatorOptions.Delegate.Nnapi.AsObject,
|
|
1084
|
-
xnnpack?: InferenceCalculatorOptions.Delegate.Xnnpack.AsObject,
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
class TfLite extends jspb.Message {
|
|
1088
|
-
serializeBinary(): Uint8Array;
|
|
1089
|
-
toObject(includeInstance?: boolean): TfLite.AsObject;
|
|
1090
|
-
static toObject(includeInstance: boolean, msg: TfLite): TfLite.AsObject;
|
|
1091
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
1092
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
1093
|
-
static serializeBinaryToWriter(message: TfLite, writer: jspb.BinaryWriter): void;
|
|
1094
|
-
static deserializeBinary(bytes: Uint8Array): TfLite;
|
|
1095
|
-
static deserializeBinaryFromReader(message: TfLite, reader: jspb.BinaryReader): TfLite;
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
namespace TfLite {
|
|
1099
|
-
type AsObject = {
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
class Gpu extends jspb.Message {
|
|
1104
|
-
hasUseAdvancedGpuApi(): boolean;
|
|
1105
|
-
clearUseAdvancedGpuApi(): void;
|
|
1106
|
-
getUseAdvancedGpuApi(): boolean | undefined;
|
|
1107
|
-
setUseAdvancedGpuApi(value: boolean): void;
|
|
1108
|
-
|
|
1109
|
-
hasApi(): boolean;
|
|
1110
|
-
clearApi(): void;
|
|
1111
|
-
getApi(): InferenceCalculatorOptions.Delegate.Gpu.ApiMap[keyof InferenceCalculatorOptions.Delegate.Gpu.ApiMap] | undefined;
|
|
1112
|
-
setApi(value: InferenceCalculatorOptions.Delegate.Gpu.ApiMap[keyof InferenceCalculatorOptions.Delegate.Gpu.ApiMap]): void;
|
|
1113
|
-
|
|
1114
|
-
hasAllowPrecisionLoss(): boolean;
|
|
1115
|
-
clearAllowPrecisionLoss(): void;
|
|
1116
|
-
getAllowPrecisionLoss(): boolean | undefined;
|
|
1117
|
-
setAllowPrecisionLoss(value: boolean): void;
|
|
1118
|
-
|
|
1119
|
-
hasCachedKernelPath(): boolean;
|
|
1120
|
-
clearCachedKernelPath(): void;
|
|
1121
|
-
getCachedKernelPath(): string | undefined;
|
|
1122
|
-
setCachedKernelPath(value: string): void;
|
|
1123
|
-
|
|
1124
|
-
hasSerializedModelDir(): boolean;
|
|
1125
|
-
clearSerializedModelDir(): void;
|
|
1126
|
-
getSerializedModelDir(): string | undefined;
|
|
1127
|
-
setSerializedModelDir(value: string): void;
|
|
1128
|
-
|
|
1129
|
-
hasModelToken(): boolean;
|
|
1130
|
-
clearModelToken(): void;
|
|
1131
|
-
getModelToken(): string | undefined;
|
|
1132
|
-
setModelToken(value: string): void;
|
|
1133
|
-
|
|
1134
|
-
hasUsage(): boolean;
|
|
1135
|
-
clearUsage(): void;
|
|
1136
|
-
getUsage(): InferenceCalculatorOptions.Delegate.Gpu.InferenceUsageMap[keyof InferenceCalculatorOptions.Delegate.Gpu.InferenceUsageMap] | undefined;
|
|
1137
|
-
setUsage(value: InferenceCalculatorOptions.Delegate.Gpu.InferenceUsageMap[keyof InferenceCalculatorOptions.Delegate.Gpu.InferenceUsageMap]): void;
|
|
1138
|
-
|
|
1139
|
-
serializeBinary(): Uint8Array;
|
|
1140
|
-
toObject(includeInstance?: boolean): Gpu.AsObject;
|
|
1141
|
-
static toObject(includeInstance: boolean, msg: Gpu): Gpu.AsObject;
|
|
1142
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
1143
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
1144
|
-
static serializeBinaryToWriter(message: Gpu, writer: jspb.BinaryWriter): void;
|
|
1145
|
-
static deserializeBinary(bytes: Uint8Array): Gpu;
|
|
1146
|
-
static deserializeBinaryFromReader(message: Gpu, reader: jspb.BinaryReader): Gpu;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
namespace Gpu {
|
|
1150
|
-
type AsObject = {
|
|
1151
|
-
useAdvancedGpuApi?: boolean,
|
|
1152
|
-
api?: InferenceCalculatorOptions.Delegate.Gpu.ApiMap[keyof InferenceCalculatorOptions.Delegate.Gpu.ApiMap],
|
|
1153
|
-
allowPrecisionLoss?: boolean,
|
|
1154
|
-
cachedKernelPath?: string,
|
|
1155
|
-
serializedModelDir?: string,
|
|
1156
|
-
modelToken?: string,
|
|
1157
|
-
usage?: InferenceCalculatorOptions.Delegate.Gpu.InferenceUsageMap[keyof InferenceCalculatorOptions.Delegate.Gpu.InferenceUsageMap],
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
interface ApiMap {
|
|
1161
|
-
ANY: 0;
|
|
1162
|
-
OPENGL: 1;
|
|
1163
|
-
OPENCL: 2;
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
const Api: ApiMap;
|
|
1167
|
-
|
|
1168
|
-
interface InferenceUsageMap {
|
|
1169
|
-
UNSPECIFIED: 0;
|
|
1170
|
-
FAST_SINGLE_ANSWER: 1;
|
|
1171
|
-
SUSTAINED_SPEED: 2;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
const InferenceUsage: InferenceUsageMap;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
class Nnapi extends jspb.Message {
|
|
1178
|
-
hasCacheDir(): boolean;
|
|
1179
|
-
clearCacheDir(): void;
|
|
1180
|
-
getCacheDir(): string | undefined;
|
|
1181
|
-
setCacheDir(value: string): void;
|
|
1182
|
-
|
|
1183
|
-
hasModelToken(): boolean;
|
|
1184
|
-
clearModelToken(): void;
|
|
1185
|
-
getModelToken(): string | undefined;
|
|
1186
|
-
setModelToken(value: string): void;
|
|
1187
|
-
|
|
1188
|
-
hasAcceleratorName(): boolean;
|
|
1189
|
-
clearAcceleratorName(): void;
|
|
1190
|
-
getAcceleratorName(): string | undefined;
|
|
1191
|
-
setAcceleratorName(value: string): void;
|
|
1192
|
-
|
|
1193
|
-
serializeBinary(): Uint8Array;
|
|
1194
|
-
toObject(includeInstance?: boolean): Nnapi.AsObject;
|
|
1195
|
-
static toObject(includeInstance: boolean, msg: Nnapi): Nnapi.AsObject;
|
|
1196
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
1197
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
1198
|
-
static serializeBinaryToWriter(message: Nnapi, writer: jspb.BinaryWriter): void;
|
|
1199
|
-
static deserializeBinary(bytes: Uint8Array): Nnapi;
|
|
1200
|
-
static deserializeBinaryFromReader(message: Nnapi, reader: jspb.BinaryReader): Nnapi;
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
namespace Nnapi {
|
|
1204
|
-
type AsObject = {
|
|
1205
|
-
cacheDir?: string,
|
|
1206
|
-
modelToken?: string,
|
|
1207
|
-
acceleratorName?: string,
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
class Xnnpack extends jspb.Message {
|
|
1212
|
-
hasNumThreads(): boolean;
|
|
1213
|
-
clearNumThreads(): void;
|
|
1214
|
-
getNumThreads(): number | undefined;
|
|
1215
|
-
setNumThreads(value: number): void;
|
|
1216
|
-
|
|
1217
|
-
serializeBinary(): Uint8Array;
|
|
1218
|
-
toObject(includeInstance?: boolean): Xnnpack.AsObject;
|
|
1219
|
-
static toObject(includeInstance: boolean, msg: Xnnpack): Xnnpack.AsObject;
|
|
1220
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
1221
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
1222
|
-
static serializeBinaryToWriter(message: Xnnpack, writer: jspb.BinaryWriter): void;
|
|
1223
|
-
static deserializeBinary(bytes: Uint8Array): Xnnpack;
|
|
1224
|
-
static deserializeBinaryFromReader(message: Xnnpack, reader: jspb.BinaryReader): Xnnpack;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
namespace Xnnpack {
|
|
1228
|
-
type AsObject = {
|
|
1229
|
-
numThreads?: number,
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
enum DelegateCase {
|
|
1234
|
-
DELEGATE_NOT_SET = 0,
|
|
1235
|
-
TFLITE = 1,
|
|
1236
|
-
GPU = 2,
|
|
1237
|
-
NNAPI = 3,
|
|
1238
|
-
XNNPACK = 4,
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
const ext: jspb.ExtensionFieldInfo<InferenceCalculatorOptions>;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
declare namespace mediapipe_calculators_tensor_inference_calculator_pb {
|
|
1246
|
-
export {
|
|
1247
|
-
InferenceCalculatorOptions
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
declare namespace mediapipe_tasks_cc_core_proto_acceleration_pb {
|
|
1252
|
-
export {
|
|
1253
|
-
Acceleration
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
declare namespace mediapipe_tasks_cc_core_proto_external_file_pb {
|
|
1258
|
-
export {
|
|
1259
|
-
ExternalFile,
|
|
1260
|
-
FileDescriptorMeta,
|
|
1261
|
-
FilePointerMeta
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
259
|
/** Base class for all MediaPipe Tasks. */
|
|
1266
|
-
declare abstract class TaskRunner
|
|
1267
|
-
protected
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
/**
|
|
1271
|
-
* Creates a new instance of a Mediapipe Task. Determines if SIMD is
|
|
1272
|
-
* supported and loads the relevant WASM binary.
|
|
1273
|
-
* @return A fully instantiated instance of `T`.
|
|
1274
|
-
*/
|
|
1275
|
-
protected static createInstance<T extends TaskRunner<O>, O extends TaskRunnerOptions>(type: WasmMediaPipeConstructor<T>, initializeCanvas: boolean, fileset: WasmFileset, options: O): Promise<T>;
|
|
1276
|
-
constructor(wasmModule: WasmModule, glCanvas?: HTMLCanvasElement | OffscreenCanvas | null);
|
|
1277
|
-
/** Configures the shared options of a MediaPipe Task. */
|
|
1278
|
-
setOptions(options: O): Promise<void>;
|
|
1279
|
-
/**
|
|
1280
|
-
* Takes the raw data from a MediaPipe graph, and passes it to C++ to be run
|
|
1281
|
-
* over the video stream. Will replace the previously running MediaPipe graph,
|
|
1282
|
-
* if there is one.
|
|
1283
|
-
* @param graphData The raw MediaPipe graph data, either in binary
|
|
1284
|
-
* protobuffer format (.binarypb), or else in raw text format (.pbtxt or
|
|
1285
|
-
* .textproto).
|
|
1286
|
-
* @param isBinary This should be set to true if the graph is in
|
|
1287
|
-
* binary format, and false if it is in human-readable text format.
|
|
1288
|
-
*/
|
|
1289
|
-
protected setGraph(graphData: Uint8Array, isBinary: boolean): void;
|
|
1290
|
-
/**
|
|
1291
|
-
* Forces all queued-up packets to be pushed through the MediaPipe graph as
|
|
1292
|
-
* far as possible, performing all processing until no more processing can be
|
|
1293
|
-
* done.
|
|
1294
|
-
*/
|
|
1295
|
-
protected finishProcessing(): void;
|
|
1296
|
-
/** Throws the error from the error listener if an error was raised. */
|
|
1297
|
-
private handleErrors;
|
|
260
|
+
declare abstract class TaskRunner {
|
|
261
|
+
protected constructor();
|
|
262
|
+
/** Configures the task with custom options. */
|
|
263
|
+
abstract setOptions(options: TaskRunnerOptions): Promise<void>;
|
|
1298
264
|
}
|
|
1299
265
|
|
|
1300
266
|
/** Options to configure MediaPipe Tasks in general. */
|
|
1301
267
|
declare interface TaskRunnerOptions {
|
|
1302
268
|
/** Options to configure the loading of the model assets. */
|
|
1303
|
-
baseOptions?:
|
|
269
|
+
baseOptions?: BaseOptions_2;
|
|
1304
270
|
}
|
|
1305
271
|
|
|
1306
272
|
/** Performs Natural Language classification. */
|
|
1307
|
-
export declare class TextClassifier extends TaskRunner
|
|
1308
|
-
private classificationResult;
|
|
1309
|
-
private readonly options;
|
|
273
|
+
export declare class TextClassifier extends TaskRunner {
|
|
1310
274
|
/**
|
|
1311
275
|
* Initializes the Wasm runtime and creates a new text classifier from the
|
|
1312
276
|
* provided options.
|
|
@@ -1333,7 +297,7 @@ export declare class TextClassifier extends TaskRunner<TextClassifierOptions> {
|
|
|
1333
297
|
* @param modelAssetPath The path to the model asset.
|
|
1334
298
|
*/
|
|
1335
299
|
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<TextClassifier>;
|
|
1336
|
-
constructor(
|
|
300
|
+
private constructor();
|
|
1337
301
|
/**
|
|
1338
302
|
* Sets new options for the text classifier.
|
|
1339
303
|
*
|
|
@@ -1344,8 +308,6 @@ export declare class TextClassifier extends TaskRunner<TextClassifierOptions> {
|
|
|
1344
308
|
* @param options The options for the text classifier.
|
|
1345
309
|
*/
|
|
1346
310
|
setOptions(options: TextClassifierOptions): Promise<void>;
|
|
1347
|
-
protected get baseOptions(): BaseOptions_2;
|
|
1348
|
-
protected set baseOptions(proto: BaseOptions_2);
|
|
1349
311
|
/**
|
|
1350
312
|
* Performs Natural Language classification on the provided text and waits
|
|
1351
313
|
* synchronously for the response.
|
|
@@ -1354,8 +316,6 @@ export declare class TextClassifier extends TaskRunner<TextClassifierOptions> {
|
|
|
1354
316
|
* @return The classification result of the text
|
|
1355
317
|
*/
|
|
1356
318
|
classify(text: string): TextClassifierResult;
|
|
1357
|
-
/** Updates the MediaPipe graph configuration. */
|
|
1358
|
-
private refreshGraph;
|
|
1359
319
|
}
|
|
1360
320
|
|
|
1361
321
|
/** Options to configure the MediaPipe Text Classifier Task */
|
|
@@ -1381,9 +341,7 @@ export declare interface TextClassifierResult {
|
|
|
1381
341
|
/**
|
|
1382
342
|
* Performs embedding extraction on text.
|
|
1383
343
|
*/
|
|
1384
|
-
export declare class TextEmbedder extends TaskRunner
|
|
1385
|
-
private embeddingResult;
|
|
1386
|
-
private readonly options;
|
|
344
|
+
export declare class TextEmbedder extends TaskRunner {
|
|
1387
345
|
/**
|
|
1388
346
|
* Initializes the Wasm runtime and creates a new text embedder from the
|
|
1389
347
|
* provided options.
|
|
@@ -1410,7 +368,7 @@ export declare class TextEmbedder extends TaskRunner<TextEmbedderOptions> {
|
|
|
1410
368
|
* @param modelAssetPath The path to the TFLite model.
|
|
1411
369
|
*/
|
|
1412
370
|
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<TextEmbedder>;
|
|
1413
|
-
constructor(
|
|
371
|
+
private constructor();
|
|
1414
372
|
/**
|
|
1415
373
|
* Sets new options for the text embedder.
|
|
1416
374
|
*
|
|
@@ -1421,8 +379,6 @@ export declare class TextEmbedder extends TaskRunner<TextEmbedderOptions> {
|
|
|
1421
379
|
* @param options The options for the text embedder.
|
|
1422
380
|
*/
|
|
1423
381
|
setOptions(options: TextEmbedderOptions): Promise<void>;
|
|
1424
|
-
protected get baseOptions(): BaseOptions_2;
|
|
1425
|
-
protected set baseOptions(proto: BaseOptions_2);
|
|
1426
382
|
/**
|
|
1427
383
|
* Performs embeding extraction on the provided text and waits synchronously
|
|
1428
384
|
* for the response.
|
|
@@ -1441,8 +397,6 @@ export declare class TextEmbedder extends TaskRunner<TextEmbedderOptions> {
|
|
|
1441
397
|
* different sizes, or have an L2-norm of 0.
|
|
1442
398
|
*/
|
|
1443
399
|
static cosineSimilarity(u: Embedding, v: Embedding): number;
|
|
1444
|
-
/** Updates the MediaPipe graph configuration. */
|
|
1445
|
-
private refreshGraph;
|
|
1446
400
|
}
|
|
1447
401
|
|
|
1448
402
|
/** Options to configure the MediaPipe Text Embedder Task */
|
|
@@ -1490,75 +444,4 @@ declare interface WasmFileset {
|
|
|
1490
444
|
wasmBinaryPath: string;
|
|
1491
445
|
}
|
|
1492
446
|
|
|
1493
|
-
/**
|
|
1494
|
-
* Internal type of constructors used for initializing GraphRunner and
|
|
1495
|
-
* subclasses.
|
|
1496
|
-
*/
|
|
1497
|
-
declare type WasmMediaPipeConstructor<LibType> = (new (module: WasmModule, canvas?: HTMLCanvasElement | OffscreenCanvas | null) => LibType);
|
|
1498
|
-
|
|
1499
|
-
/**
|
|
1500
|
-
* Declarations for Emscripten's WebAssembly Module behavior, so TS compiler
|
|
1501
|
-
* doesn't break our JS/C++ bridge.
|
|
1502
|
-
*/
|
|
1503
|
-
declare interface WasmModule {
|
|
1504
|
-
canvas: HTMLCanvasElement | OffscreenCanvas | null;
|
|
1505
|
-
HEAPU8: Uint8Array;
|
|
1506
|
-
HEAPU32: Uint32Array;
|
|
1507
|
-
HEAPF32: Float32Array;
|
|
1508
|
-
HEAPF64: Float64Array;
|
|
1509
|
-
errorListener?: ErrorListener;
|
|
1510
|
-
_bindTextureToCanvas: () => boolean;
|
|
1511
|
-
_changeBinaryGraph: (size: number, dataPtr: number) => void;
|
|
1512
|
-
_changeTextGraph: (size: number, dataPtr: number) => void;
|
|
1513
|
-
_free: (ptr: number) => void;
|
|
1514
|
-
_malloc: (size: number) => number;
|
|
1515
|
-
_processFrame: (width: number, height: number, timestamp: number) => void;
|
|
1516
|
-
_setAutoRenderToScreen: (enabled: boolean) => void;
|
|
1517
|
-
_waitUntilIdle: () => void;
|
|
1518
|
-
dataFileDownloads?: {
|
|
1519
|
-
[url: string]: {
|
|
1520
|
-
loaded: number;
|
|
1521
|
-
total: number;
|
|
1522
|
-
};
|
|
1523
|
-
};
|
|
1524
|
-
stringToNewUTF8: (data: string) => number;
|
|
1525
|
-
_bindTextureToStream: (streamNamePtr: number) => void;
|
|
1526
|
-
_addBoundTextureToStream: (streamNamePtr: number, width: number, height: number, timestamp: number) => void;
|
|
1527
|
-
_addBoolToInputStream: (data: boolean, streamNamePtr: number, timestamp: number) => void;
|
|
1528
|
-
_addDoubleToInputStream: (data: number, streamNamePtr: number, timestamp: number) => void;
|
|
1529
|
-
_addFloatToInputStream: (data: number, streamNamePtr: number, timestamp: number) => void;
|
|
1530
|
-
_addIntToInputStream: (data: number, streamNamePtr: number, timestamp: number) => void;
|
|
1531
|
-
_addStringToInputStream: (dataPtr: number, streamNamePtr: number, timestamp: number) => void;
|
|
1532
|
-
_addFlatHashMapToInputStream: (keysPtr: number, valuesPtr: number, count: number, streamNamePtr: number, timestamp: number) => void;
|
|
1533
|
-
_addProtoToInputStream: (dataPtr: number, dataSize: number, protoNamePtr: number, streamNamePtr: number, timestamp: number) => void;
|
|
1534
|
-
_addBoolToInputSidePacket: (data: boolean, streamNamePtr: number) => void;
|
|
1535
|
-
_addDoubleToInputSidePacket: (data: number, streamNamePtr: number) => void;
|
|
1536
|
-
_addFloatToInputSidePacket: (data: number, streamNamePtr: number) => void;
|
|
1537
|
-
_addIntToInputSidePacket: (data: number, streamNamePtr: number) => void;
|
|
1538
|
-
_addStringToInputSidePacket: (dataPtr: number, streamNamePtr: number) => void;
|
|
1539
|
-
_addProtoToInputSidePacket: (dataPtr: number, dataSize: number, protoNamePtr: number, streamNamePtr: number) => void;
|
|
1540
|
-
simpleListeners?: {
|
|
1541
|
-
[outputStreamName: string]: (data: unknown) => void;
|
|
1542
|
-
};
|
|
1543
|
-
vectorListeners?: {
|
|
1544
|
-
[outputStreamName: string]: (data: unknown, index: number, length: number) => void;
|
|
1545
|
-
};
|
|
1546
|
-
_attachBoolListener: (streamNamePtr: number) => void;
|
|
1547
|
-
_attachBoolVectorListener: (streamNamePtr: number) => void;
|
|
1548
|
-
_attachDoubleListener: (streamNamePtr: number) => void;
|
|
1549
|
-
_attachDoubleVectorListener: (streamNamePtr: number) => void;
|
|
1550
|
-
_attachFloatListener: (streamNamePtr: number) => void;
|
|
1551
|
-
_attachFloatVectorListener: (streamNamePtr: number) => void;
|
|
1552
|
-
_attachIntListener: (streamNamePtr: number) => void;
|
|
1553
|
-
_attachIntVectorListener: (streamNamePtr: number) => void;
|
|
1554
|
-
_attachStringListener: (streamNamePtr: number) => void;
|
|
1555
|
-
_attachStringVectorListener: (streamNamePtr: number) => void;
|
|
1556
|
-
_attachProtoListener: (streamNamePtr: number, makeDeepCopy?: boolean) => void;
|
|
1557
|
-
_attachProtoVectorListener: (streamNamePtr: number, makeDeepCopy?: boolean) => void;
|
|
1558
|
-
_attachAudioListener: (streamNamePtr: number, makeDeepCopy?: boolean) => void;
|
|
1559
|
-
_addAudioToInputStream: (dataPtr: number, numChannels: number, numSamples: number, streamNamePtr: number, timestamp: number) => void;
|
|
1560
|
-
_configureAudio: (channels: number, samples: number, sampleRate: number, streamNamePtr: number, headerNamePtr: number) => void;
|
|
1561
|
-
_processGl: (frameDataPtr: number) => number;
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
447
|
export { }
|