@vonage/ml-transformers 3.2.0 → 4.0.1
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/dist/docs/assets/highlight.css +14 -28
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/MediapipeHelper.html +1 -1
- package/dist/docs/classes/VonageMediaProcessor.html +28 -28
- package/dist/docs/enums/BlurRadius.html +3 -9
- package/dist/docs/enums/ErrorFunction.html +9 -0
- package/dist/docs/enums/PipelineInfoData.html +19 -0
- package/dist/docs/enums/SelfieSegmentationType.html +5 -0
- package/dist/docs/enums/WarningType.html +5 -0
- package/dist/docs/index.html +1 -1
- package/dist/docs/interfaces/HolisticOptions.html +1 -1
- package/dist/docs/interfaces/PoseOptions.html +1 -1
- package/dist/docs/modules.html +179 -69
- package/dist/ml-transformers.es.js +12697 -8028
- package/dist/ml-transformers.umd.js +366 -32
- package/dist/types/main.d.ts +84 -86
- package/dist/types/src/{vonage/VonageMediaProcessor.d.ts → facades/vonage-media-processor.d.ts} +0 -0
- package/dist/types/src/filters/background-filter.d.ts +27 -0
- package/dist/types/src/filters/resize-filter.d.ts +12 -0
- package/dist/types/src/processors/processor-main.d.ts +32 -0
- package/dist/types/src/processors/processor-worker.d.ts +23 -0
- package/dist/types/src/transformers/background-transformer.d.ts +14 -0
- package/dist/types/src/types.d.ts +82 -57
- package/dist/types/src/{vonage/VonageAssetsLoaderHelper.d.ts → utils/assets-loader.d.ts} +0 -0
- package/dist/types/src/utils/{Tools.d.ts → error.d.ts} +0 -0
- package/dist/types/src/{transformers/MediapipeHelper.d.ts → utils/mediapipe.d.ts} +2 -3
- package/dist/types/src/utils/{utils.d.ts → support.d.ts} +2 -2
- package/dist/types/src/utils/webgl.d.ts +27 -0
- package/dist/types/src/wasm/selfie-segmentation/loader.d.ts +28 -0
- package/dist/types/src/wasm/selfie-segmentation/wrapper.d.ts +15 -0
- package/dist/types/src/webgl/pipelines/background-blur.d.ts +9 -0
- package/dist/types/src/webgl/pipelines/background-image.d.ts +11 -0
- package/dist/types/src/webgl/pipelines/background-video.d.ts +8 -0
- package/dist/types/src/webgl/pipelines/foreground-blur.d.ts +9 -0
- package/dist/types/src/webgl/pipelines/improve-segmentation-mask.d.ts +23 -0
- package/dist/types/src/webgl/pipelines/output-mask.d.ts +10 -0
- package/dist/types/src/webgl/pipelines/resize-image.d.ts +8 -0
- package/dist/types/src/webgl/programs/blur/blur.d.ts +20 -0
- package/dist/types/src/webgl/programs/blur-masked/blur-masked.d.ts +12 -0
- package/dist/types/src/webgl/programs/expend/expend.d.ts +5 -0
- package/dist/types/src/webgl/programs/flickering/flickering.d.ts +5 -0
- package/dist/types/src/webgl/programs/highpass/highpass.d.ts +5 -0
- package/dist/types/src/webgl/programs/joint-bilateral/joint-bilateral.d.ts +5 -0
- package/dist/types/src/webgl/programs/minimum-surface/minimum-surface.d.ts +5 -0
- package/dist/types/src/webgl/programs/mix/mix.d.ts +5 -0
- package/dist/types/src/webgl/programs/power/power.d.ts +5 -0
- package/dist/types/src/webgl/programs/refine-mask/refine-mask.d.ts +5 -0
- package/dist/types/src/webgl/programs/render-texture/render-texture.d.ts +5 -0
- package/dist/types/src/webgl/programs/smooth/smooth.d.ts +5 -0
- package/dist/types/src/webgl/programs/track/track.d.ts +5 -0
- package/dist/types/src/webgl/webgl-pipeline-program-double-buffer.d.ts +15 -0
- package/dist/types/src/webgl/webgl-pipeline-program.d.ts +82 -0
- package/dist/types/src/webgl/webgl-pipeline.d.ts +35 -0
- package/dist/types/src/webgl/webgl-transormer-pipeline.d.ts +6 -0
- package/package.json +69 -69
- package/dist/types/src/transformers/BackgroundTransformer.d.ts +0 -32
- package/dist/types/src/transformers/BlurPostProcess.d.ts +0 -11
- package/dist/types/src/transformers/PostProcessInterface.d.ts +0 -6
- package/dist/types/src/transformers/Queue.d.ts +0 -13
- package/dist/types/src/transformers/SilueteBlurPostProcess.d.ts +0 -11
- package/dist/types/src/transformers/VideoPostProcess.d.ts +0 -14
- package/dist/types/src/transformers/VirtualPostProcess.d.ts +0 -11
- package/dist/types/src/transformers/VonageTransformerConfig.d.ts +0 -1
- package/dist/types/src/vonage/VonageMediaProcessorThread.d.ts +0 -6
- package/dist/types/src/vonage/VonageMediaProcessorWorker.d.ts +0 -28
package/dist/types/main.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BlurRadius, BackgroundBlurConfig, VirtualBackgroundConfig, AssetBackgroundConfig, VideoBackgroundConfig, MediaProcessorBaseConfig,
|
|
3
|
-
import { isSupported } from "./src/utils/
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { WarningType, ErrorFunction, PipelineInfoData } from "@vonage/media-processor";
|
|
2
|
+
import { BlurRadius, BackgroundBlurConfig, VirtualBackgroundConfig, AssetBackgroundConfig, VideoBackgroundConfig, MediaProcessorBaseConfig, SilhouetteBlurConfig, MediapipeConfig, MediaPipeResults, MediaPipeResultsListener, MediaPipeModelType, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, PoseResults, PoseOptions, SelfieSegmentationResults, SelfieSegmentationOptions, MediaPipeModelConfig } from "./src/types";
|
|
3
|
+
import { isSupported } from "./src/utils/support";
|
|
4
|
+
import { MediapipeHelper } from "./src/utils/mediapipe";
|
|
5
|
+
import { VonageMediaProcessor } from "./src/facades/vonage-media-processor";
|
|
6
|
+
import VonageSelfieSegmentation from "./libs/selfie-segmentation-helper";
|
|
7
|
+
/**
|
|
8
|
+
* MediaPipe Selfie Segmentation static metadata.
|
|
9
|
+
* @returns
|
|
10
|
+
* An object containing MediaPipe Selfie Segmentation metadata:
|
|
11
|
+
* - VERSION
|
|
12
|
+
*/
|
|
13
|
+
declare function getVonageSelfieSegmentation(): VonageSelfieSegmentation;
|
|
14
|
+
import VonageHands from "./libs/hands-helper";
|
|
6
15
|
/**
|
|
7
16
|
* Vonage Mediapipe objects info (it will be used by the @mediapipe/drawing_utils package which is not included by this library).
|
|
8
17
|
* @param VonageSelfiesegmentation:
|
|
@@ -10,7 +19,16 @@ import MediapipeHelper from "./src/transformers/MediapipeHelper";
|
|
|
10
19
|
* @param VonageHands:
|
|
11
20
|
* - VERSION
|
|
12
21
|
* - HAND_CONNECTIONS
|
|
13
|
-
|
|
22
|
+
*/
|
|
23
|
+
declare function getVonageHands(): VonageHands;
|
|
24
|
+
import VonageHolistic from "./libs/holistic-helper";
|
|
25
|
+
/**
|
|
26
|
+
* MediaPipe Holistic static metadata.
|
|
27
|
+
* This metadata is needed while using MediaPipe.
|
|
28
|
+
* [drawing utils](https://www.npmjs.com/package/@mediapipe/drawing_utils).
|
|
29
|
+
* And [control utils](https://www.npmjs.com/package/@mediapipe/control_utils).
|
|
30
|
+
* @returns
|
|
31
|
+
* An object containing MediaPipe Holistic metadata:
|
|
14
32
|
* - VERSION
|
|
15
33
|
* - FACE_GEOMETRY
|
|
16
34
|
* - FACEMESH_LIPS
|
|
@@ -29,7 +47,16 @@ import MediapipeHelper from "./src/transformers/MediapipeHelper";
|
|
|
29
47
|
* - POSE_LANDMARKS_LEFT
|
|
30
48
|
* - POSE_LANDMARKS_RIGHT
|
|
31
49
|
* - POSE_LANDMARKS_NEUTRAL
|
|
32
|
-
|
|
50
|
+
*/
|
|
51
|
+
declare function getVonageHolistic(): VonageHolistic;
|
|
52
|
+
import VonageFaceDetection from "./libs/face-detection-helper";
|
|
53
|
+
/**
|
|
54
|
+
* MediaPipe Face Detection static metadata.
|
|
55
|
+
* This metadata is needed while using MediaPipe.
|
|
56
|
+
* [drawing utils](https://www.npmjs.com/package/@mediapipe/drawing_utils).
|
|
57
|
+
* And [control utils](https://www.npmjs.com/package/@mediapipe/control_utils).
|
|
58
|
+
* @returns
|
|
59
|
+
* An object containing MediaPipe Face Detection metadata:
|
|
33
60
|
* - VERSION
|
|
34
61
|
* - FACEDETECTION_LIPS
|
|
35
62
|
* - FACEDETECTION_LEFT_EYE
|
|
@@ -39,7 +66,16 @@ import MediapipeHelper from "./src/transformers/MediapipeHelper";
|
|
|
39
66
|
* - FACEDETECTION_FACE_OVAL
|
|
40
67
|
* - FACEDETECTION_CONTOURS
|
|
41
68
|
* - FACEDETECTION_TESSELATION
|
|
42
|
-
|
|
69
|
+
*/
|
|
70
|
+
declare function getVonageFaceDetection(): VonageFaceDetection;
|
|
71
|
+
import VonageFaceMash from "./libs/face-mash-helper";
|
|
72
|
+
/**
|
|
73
|
+
* MediaPipe Face Mash static metadata.
|
|
74
|
+
* This metadata is needed while using MediaPipe.
|
|
75
|
+
* [drawing utils](https://www.npmjs.com/package/@mediapipe/drawing_utils).
|
|
76
|
+
* And [control utils](https://www.npmjs.com/package/@mediapipe/control_utils).
|
|
77
|
+
* @returns
|
|
78
|
+
* An object containing MediaPipe Face Mash metadata:
|
|
43
79
|
* - VERSION
|
|
44
80
|
* - FACE_GEOMETRY
|
|
45
81
|
* - FACEMESH_LIPS
|
|
@@ -52,11 +88,30 @@ import MediapipeHelper from "./src/transformers/MediapipeHelper";
|
|
|
52
88
|
* - FACEMESH_FACE_OVAL
|
|
53
89
|
* - FACEMESH_CONTOURS
|
|
54
90
|
* - FACEMESH_TESSELATION
|
|
55
|
-
|
|
91
|
+
*/
|
|
92
|
+
declare function getVonageFaceMash(): VonageFaceMash;
|
|
93
|
+
import VonageObjectron from "./libs/objectron-helper";
|
|
94
|
+
/**
|
|
95
|
+
* MediaPipe Objectron static metadata.
|
|
96
|
+
* This metadata is needed while using MediaPipe.
|
|
97
|
+
* [drawing utils](https://www.npmjs.com/package/@mediapipe/drawing_utils).
|
|
98
|
+
* And [control utils](https://www.npmjs.com/package/@mediapipe/control_utils).
|
|
99
|
+
* @returns
|
|
100
|
+
* An object containing MediaPipe Objectron metadata:
|
|
101
|
+
* - VERSION
|
|
56
102
|
* - VERSION
|
|
57
103
|
* - BOX_CONNECTIONS
|
|
58
104
|
* - BOX_KEYPOINTS
|
|
59
|
-
|
|
105
|
+
*/
|
|
106
|
+
declare function getVonageObjectron(): VonageObjectron;
|
|
107
|
+
import VonagePose from "./libs/pose-helper";
|
|
108
|
+
/**
|
|
109
|
+
* MediaPipe Pose static metadata.
|
|
110
|
+
* This metadata is needed while using MediaPipe.
|
|
111
|
+
* [drawing utils](https://www.npmjs.com/package/@mediapipe/drawing_utils).
|
|
112
|
+
* And [control utils](https://www.npmjs.com/package/@mediapipe/control_utils).
|
|
113
|
+
* @returns
|
|
114
|
+
* An object containing MediaPipe Pose metadata:
|
|
60
115
|
* - VERSION
|
|
61
116
|
* - POSE_CONNECTIONS
|
|
62
117
|
* - POSE_LANDMARKS
|
|
@@ -64,89 +119,32 @@ import MediapipeHelper from "./src/transformers/MediapipeHelper";
|
|
|
64
119
|
* - POSE_LANDMARKS_RIGHT
|
|
65
120
|
* - POSE_LANDMARKS_NEUTRAL
|
|
66
121
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
122
|
+
declare function getVonagePose(): VonagePose;
|
|
123
|
+
/**
|
|
124
|
+
* Selfie segmentation algorithm type
|
|
125
|
+
* Fast can flickering but has low impact on performance
|
|
126
|
+
* Precise avoid glitches and flickering, but is most costly
|
|
127
|
+
*/
|
|
128
|
+
export declare enum SelfieSegmentationType {
|
|
129
|
+
FAST = "FAST",
|
|
130
|
+
PRECISE = "PRECISE"
|
|
131
|
+
}
|
|
75
132
|
/**
|
|
76
133
|
* BackgroundOptions background options
|
|
77
134
|
*/
|
|
78
|
-
declare type BackgroundOptions =
|
|
135
|
+
declare type BackgroundOptions = {
|
|
136
|
+
selfieSegmentationType?: SelfieSegmentationType;
|
|
137
|
+
} & (BackgroundBlurConfig | ((VirtualBackgroundConfig | VideoBackgroundConfig) & AssetBackgroundConfig) | SilhouetteBlurConfig);
|
|
79
138
|
/**
|
|
80
139
|
* MediaProcessorConfig specifies the transformer logic to be performed.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
*
|
|
84
|
-
* ```ts
|
|
85
|
-
* let config: MediaProcessorConfig;
|
|
86
|
-
* if(typeType === 'blur'){
|
|
87
|
-
* config = {
|
|
88
|
-
* mediapipeBaseAssetsUri: 'https://example.com', // mediapipeBaseAssetsUri is optional we provide static assets for it
|
|
89
|
-
* transformerType: 'BackgroundBlur',
|
|
90
|
-
* radius: blurLevelType === 'low' ? BlurRadius.Low : BlurRadius.High,
|
|
91
|
-
* };
|
|
92
|
-
* } else if(typeType === 'virtual'){
|
|
93
|
-
* config = {
|
|
94
|
-
* mediapipeBaseAssetsUri: 'https://example.com', // mediapipeBaseAssetsUri is optional we provide static assets for it
|
|
95
|
-
* transformerType: 'VirtualBackground',
|
|
96
|
-
* backgroundAssetUri: location.href + "images/vonage.jpeg"
|
|
97
|
-
* }
|
|
98
|
-
* } else if(typeType === 'video') {
|
|
99
|
-
* config = {
|
|
100
|
-
* mediapipeBaseAssetsUri: 'https://example.com', // mediapipeBaseAssetsUri is optional we provide static assets for it
|
|
101
|
-
* transformerType: 'VideoBackground',
|
|
102
|
-
* backgroundAssetUri: location.href + 'videos/bbb.mp4'
|
|
103
|
-
* };
|
|
104
|
-
* } else if(typeType === 'siluete') {
|
|
105
|
-
* config = {
|
|
106
|
-
* mediapipeBaseAssetsUri: 'https://example.com', // mediapipeBaseAssetsUri is optional we provide static assets for it
|
|
107
|
-
* transformerType: 'SilueteBlur',
|
|
108
|
-
* radius: blurLevelType === 'low' ? BlurRadius.Low : BlurRadius.High,
|
|
109
|
-
* };
|
|
110
|
-
* }
|
|
111
|
-
* ```
|
|
112
140
|
*/
|
|
113
141
|
declare type MediaProcessorConfig = MediaProcessorBaseConfig & BackgroundOptions;
|
|
114
|
-
export declare function createVonageMediaProcessor(config: MediaProcessorConfig): Promise<VonageMediaProcessor>;
|
|
115
|
-
/**
|
|
116
|
-
* Registers for error and warn events that come from the library on run time.
|
|
117
|
-
* see @EventDataMap for more info.
|
|
118
|
-
* @deprecated Use the function {@link createMediaProcessor} to instantiate a processor directly.
|
|
119
|
-
*/
|
|
120
|
-
declare function getVonageEventEmitter(): Emittery<EventDataMap>;
|
|
121
|
-
/**
|
|
122
|
-
* Sets the expected rate of the track per second.
|
|
123
|
-
* The media processor will use this number for calculating drops in the rate.
|
|
124
|
-
* This could happen when the transformation will take more time than expected.
|
|
125
|
-
* This will not cause an error, just warning to the client.
|
|
126
|
-
* Mostly:
|
|
127
|
-
* Video: 30 frames per second
|
|
128
|
-
* Audio: 50 audio data per second for OPUS
|
|
129
|
-
* @deprecated Use the function {@link createMediaProcessor} to instantiate a processor directly.
|
|
130
|
-
* @param trackExpectedRate - number holds the predicted track rate. -1 for disable this monitor.
|
|
131
|
-
*/
|
|
132
|
-
declare function setTrackExpectedRate(trackExpectedRate: number): void;
|
|
133
142
|
/**
|
|
134
|
-
* builder function to create
|
|
135
|
-
* This function hides all the functionality of the @vonage/media-processor library.
|
|
136
|
-
* using this create function promises the user the best performance of background operations.
|
|
137
|
-
* @deprecated Use the function {@link createMediaProcessor} to instantiate a processor directly.
|
|
143
|
+
* builder function to create MediaProcessor
|
|
138
144
|
* @param config - see `MediaProcessorConfig` definition
|
|
139
|
-
* @returns - `
|
|
145
|
+
* @returns - `MediaProcessor` provide interface to configure ml-transformer or retrieving connector
|
|
140
146
|
*/
|
|
141
|
-
declare function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* while using this function the library promise a full resource cleanup.
|
|
146
|
-
* @deprecated Use the function {@link createMediaProcessor} to instantiate a processor directly.
|
|
147
|
-
* @param backgroundOptions - see `BackgroundOptions` definition
|
|
148
|
-
* @returns - Promise<void>
|
|
149
|
-
*/
|
|
150
|
-
declare function setBackgroundOptions(backgroundOptions: BackgroundOptions): Promise<void>;
|
|
151
|
-
export type { MediaProcessorBaseConfig, BackgroundBlurConfig, VirtualBackgroundConfig, VideoBackgroundConfig, AssetBackgroundConfig, SilueteBlurConfig, MediaProcessorConfig, BackgroundOptions, MediapipeConfig, MediaPipeResults, MediaPipeModelType, MediaPipeResultsListener, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, SelfieSegmentationOptions, SelfieSegmentationResults, PoseResults, PoseOptions, MediaPipeModelConfig, };
|
|
152
|
-
export { VonageMediaProcessor, BlurRadius, createVonageMediaProcessorConnector, getVonageEventEmitter, setTrackExpectedRate, isSupported, MediapipeHelper, setBackgroundOptions, VonageSelfiesegmentation, VonageFacedetection, VonageFacemash, VonageHands, VonageHolistic, VonageObjectron, VonagePose, };
|
|
147
|
+
export declare function createVonageMediaProcessor(config: MediaProcessorConfig): Promise<VonageMediaProcessor>;
|
|
148
|
+
export type { EventDataMap, WarnData, ErrorData, EventMetaData, DropInfo, } from "@vonage/media-processor";
|
|
149
|
+
export type { MediaProcessorBaseConfig, BackgroundBlurConfig, VirtualBackgroundConfig, VideoBackgroundConfig, AssetBackgroundConfig, SilhouetteBlurConfig, MediaProcessorConfig, BackgroundOptions, MediapipeConfig, MediaPipeResults, MediaPipeModelType, MediaPipeResultsListener, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, SelfieSegmentationOptions, SelfieSegmentationResults, PoseResults, PoseOptions, MediaPipeModelConfig, };
|
|
150
|
+
export { VonageMediaProcessor, BlurRadius, isSupported, MediapipeHelper, getVonageSelfieSegmentation, getVonageFaceDetection, getVonageFaceMash, getVonageHands, getVonageHolistic, getVonageObjectron, getVonagePose, WarningType, PipelineInfoData, ErrorFunction, };
|
package/dist/types/src/{vonage/VonageMediaProcessor.d.ts → facades/vonage-media-processor.d.ts}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BackgroundOptions } from "../../main";
|
|
2
|
+
import { FlickeringOptions } from "../webgl/pipelines/improve-segmentation-mask";
|
|
3
|
+
export interface BackgroundFilterConfig {
|
|
4
|
+
maskWidth: number;
|
|
5
|
+
maskHeight: number;
|
|
6
|
+
foregroundWidth: number;
|
|
7
|
+
foregroundHeight: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class BackgroundFilter {
|
|
10
|
+
private improveMaskSegmentation;
|
|
11
|
+
private backgroundResizer;
|
|
12
|
+
private backgroundImage;
|
|
13
|
+
private backgroundVideo;
|
|
14
|
+
private activePipeline?;
|
|
15
|
+
canvas: OffscreenCanvas;
|
|
16
|
+
private options?;
|
|
17
|
+
readonly context: WebGLRenderingContext;
|
|
18
|
+
private virtualBGImage?;
|
|
19
|
+
constructor(config: BackgroundFilterConfig);
|
|
20
|
+
setBackgroundOptions(options: BackgroundOptions): void;
|
|
21
|
+
setFlickeringOptions(options: FlickeringOptions): void;
|
|
22
|
+
setVideoBGReadable(videoBGReadable: ReadableStream): void;
|
|
23
|
+
setVirtualBGImage(image: ImageBitmap): Promise<void>;
|
|
24
|
+
process(foreground: ImageBitmap, mask?: ImageBitmap): Promise<void>;
|
|
25
|
+
resizeForeground(width: number, height: number): Promise<void>;
|
|
26
|
+
private getBlurSize;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ResizeFilterConfig {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class ResizeFilter {
|
|
6
|
+
private resize;
|
|
7
|
+
private canvas;
|
|
8
|
+
readonly context: WebGLRenderingContext;
|
|
9
|
+
constructor(config: ResizeFilterConfig);
|
|
10
|
+
resizeForeground(width: number, height: number): void;
|
|
11
|
+
process(image: ImageBitmap): Promise<OffscreenCanvas>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EventDataMap, MediaProcessorInterface } from "@vonage/media-processor";
|
|
2
|
+
import Emittery from "emittery";
|
|
3
|
+
import { BackgroundOptions, MediaProcessorConfig } from "../../main";
|
|
4
|
+
import { FlickeringOptions } from "../webgl/pipelines/improve-segmentation-mask";
|
|
5
|
+
export declare enum WorkerOperations {
|
|
6
|
+
init = "init",
|
|
7
|
+
transform = "transform",
|
|
8
|
+
destroy = "destroy",
|
|
9
|
+
setBackgroundOptions = "setBackgroundOptions",
|
|
10
|
+
setVideoBGReadable = "setVideoBGReadable",
|
|
11
|
+
setVirtualBGImage = "setVirtualBGImage",
|
|
12
|
+
setTrackExpectedRate = "setTrackExpectedRate"
|
|
13
|
+
}
|
|
14
|
+
export interface InnerEventDataMap {
|
|
15
|
+
initResults: string;
|
|
16
|
+
transformResults: string;
|
|
17
|
+
destroyResults: string;
|
|
18
|
+
setBackgroundOptionsResults: string;
|
|
19
|
+
setVideoBGReadableResults: string;
|
|
20
|
+
setVirtualBGImageResults: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class ProcessorMain extends Emittery<EventDataMap> implements MediaProcessorInterface {
|
|
23
|
+
private rate;
|
|
24
|
+
private worker?;
|
|
25
|
+
init(config: MediaProcessorConfig): Promise<void>;
|
|
26
|
+
setTrackExpectedRate(rate: number): Promise<void>;
|
|
27
|
+
setBackgroundOptions(options: BackgroundOptions): Promise<void>;
|
|
28
|
+
transform(readable: ReadableStream<any>, writable: WritableStream<any>): Promise<void>;
|
|
29
|
+
destroy(): Promise<void>;
|
|
30
|
+
setFlickeringOptions(options: FlickeringOptions): Promise<void>;
|
|
31
|
+
private listenWorker;
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EventDataMap, VonageMetadata } from "@vonage/media-processor";
|
|
2
|
+
import { BackgroundOptions, MediaProcessorConfig } from "../../main";
|
|
3
|
+
import { FlickeringOptions } from "../webgl/pipelines/improve-segmentation-mask";
|
|
4
|
+
export interface MediaProcessorEvent {
|
|
5
|
+
name: keyof EventDataMap;
|
|
6
|
+
data: any;
|
|
7
|
+
}
|
|
8
|
+
export declare class ProcessorWorker {
|
|
9
|
+
private backgroundTransformer;
|
|
10
|
+
private mediaProcessor;
|
|
11
|
+
private rate;
|
|
12
|
+
private resolveOnMediaProcessor?;
|
|
13
|
+
init(config: MediaProcessorConfig): Promise<void>;
|
|
14
|
+
onMediaProcessorEvent(): Promise<MediaProcessorEvent>;
|
|
15
|
+
setTrackExpectedRate(rate: number): Promise<void>;
|
|
16
|
+
transform(readable: ReadableStream<any>, writable: WritableStream<any>): Promise<void>;
|
|
17
|
+
setBackgroundOptions(options: BackgroundOptions): Promise<void>;
|
|
18
|
+
setVideoBGReadable(stream: ReadableStream): void;
|
|
19
|
+
setVirtualBGImage(image: ImageBitmap): Promise<void>;
|
|
20
|
+
terminate(): Promise<void>;
|
|
21
|
+
setFlickeringOptions(options: FlickeringOptions): void;
|
|
22
|
+
setVonageMetadata(metadata: VonageMetadata): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="dom-webcodecs" />
|
|
2
|
+
import { BackgroundOptions, MediaProcessorConfig } from "../../main";
|
|
3
|
+
import { FlickeringOptions } from "../webgl/pipelines/improve-segmentation-mask";
|
|
4
|
+
export declare class BackgroundTransformer {
|
|
5
|
+
private selfieSegmentation;
|
|
6
|
+
private backgroundFilter?;
|
|
7
|
+
init(config: MediaProcessorConfig): Promise<void>;
|
|
8
|
+
private previousDimensions;
|
|
9
|
+
transform?(frame: VideoFrame, controller: TransformStreamDefaultController): Promise<void>;
|
|
10
|
+
setBackgroundOptions(options: BackgroundOptions): Promise<void>;
|
|
11
|
+
setVideoBGReadable(stream: ReadableStream): Promise<void>;
|
|
12
|
+
setVirtualBGImage(image: ImageBitmap): Promise<void>;
|
|
13
|
+
setFlickeringOptions(options: FlickeringOptions): void;
|
|
14
|
+
}
|
|
@@ -1,99 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
* VonageTransformerType which type of transformer to create.
|
|
10
|
-
*/
|
|
11
|
-
export declare type VonageTransformerType = 'BackgroundBlur' | 'VirtualBackground' | 'VideoBackground' | 'SilueteBlur';
|
|
1
|
+
import { Options as FaceDetectionOptions, Results as FaceDetectionResults } from "@mediapipe/face_detection";
|
|
2
|
+
import { Options as FaceMeshOptions, Results as FaceMeshResults } from "@mediapipe/face_mesh";
|
|
3
|
+
import { Options as HandsOptions, Results as HandsResults } from "@mediapipe/hands";
|
|
4
|
+
import { Options as HolisticOptions, Results as HolisticResults } from "@mediapipe/holistic";
|
|
5
|
+
import { Options as ObjectronOptions, Results as ObjectronResults } from "@mediapipe/objectron";
|
|
6
|
+
import { Options as PoseOptions, Results as PoseResults } from "@mediapipe/pose";
|
|
7
|
+
import { Options as SelfieSegmentationOptions, Results as SelfieSegmentationResults } from "@mediapipe/selfie_segmentation";
|
|
8
|
+
import { TextureFunc } from "twgl.js";
|
|
12
9
|
/**
|
|
13
10
|
* BlurRadius specifies how much bluring filter to apply by a given transformer.
|
|
14
|
-
* @Low - 5px blur
|
|
15
|
-
* @High - 10px blur
|
|
16
11
|
*/
|
|
17
12
|
export declare enum BlurRadius {
|
|
18
13
|
/**
|
|
19
|
-
* Low bluring filtering.
|
|
14
|
+
* Low bluring filtering (5px).
|
|
20
15
|
*/
|
|
21
16
|
Low = "Low",
|
|
22
17
|
/**
|
|
23
|
-
* High bluring filtering.
|
|
18
|
+
* High bluring filtering (10px).
|
|
24
19
|
*/
|
|
25
20
|
High = "High"
|
|
26
21
|
}
|
|
27
22
|
/**
|
|
28
|
-
* MediaProcessorBaseConfig specifies the absolute URL for the path where the mediapipe assets used by the transformers from this library are stored.
|
|
29
|
-
* Vonage hosts static assets of mediapipe that will be used in case this property is not set.
|
|
30
|
-
* Vonage promises to take care of maintaining all versioning.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
* selfie_segmentation_solution_simd_wasm_bin.js
|
|
44
|
-
* selfie_segmentation_solution_simd_wasm_bin.wasm
|
|
45
|
-
* selfie_segmentation_solution_wasm_bin.js
|
|
46
|
-
* selfie_segmentation_solution_wasm_bin.wasm
|
|
47
|
-
* selfie_segmentation.binarypb
|
|
48
|
-
* selfie_segmentation.tflite
|
|
49
|
-
* please keep in mind that the assets list can change between versions!
|
|
50
|
-
* all assets can be taken from `node_modules/@mediapipe/selfie_segmentation`
|
|
51
|
-
*/
|
|
23
|
+
* MediaProcessorBaseConfig specifies the absolute URL for the path where the mediapipe assets used by the transformers from this library are stored.
|
|
24
|
+
* Vonage hosts static assets of mediapipe that will be used in case this property is not set.
|
|
25
|
+
* Vonage promises to take care of maintaining all versioning.
|
|
26
|
+
* **WARNING**. By using this option the developer takes responsibility of the assets and their versioning.
|
|
27
|
+
* *mediapipe selfie segmintaion got those assets:*
|
|
28
|
+
* *selfie_segmentation_landscape.tflite*
|
|
29
|
+
* *selfie_segmentation_solution_simd_wasm_bin.js*
|
|
30
|
+
* *selfie_segmentation_solution_simd_wasm_bin.wasm*
|
|
31
|
+
* *selfie_segmentation_solution_wasm_bin.js*
|
|
32
|
+
* *selfie_segmentation_solution_wasm_bin.wasm*
|
|
33
|
+
* *selfie_segmentation.binarypb*
|
|
34
|
+
* *selfie_segmentation.tflite*
|
|
35
|
+
* Please keep in mind that the assets list can change between versions.
|
|
36
|
+
* All assets can be taken from `node_modules/@mediapipe/selfie_segmentation`
|
|
37
|
+
*/
|
|
52
38
|
export declare type MediaProcessorBaseConfig = {
|
|
39
|
+
/**
|
|
40
|
+
* A uri path to mediapipe assets.
|
|
41
|
+
*/
|
|
53
42
|
mediapipeBaseAssetsUri?: string;
|
|
43
|
+
wasmAssetUriPath?: string;
|
|
44
|
+
tfliteAssetUriPath?: string;
|
|
54
45
|
};
|
|
55
46
|
/**
|
|
56
47
|
* BackgroundBlurConfig specifies the configuration for a transformer logic that performs background blurring.
|
|
57
|
-
* @radius - @BlurRadius or number indicating the blur radius.
|
|
58
|
-
* ```ts
|
|
59
|
-
* let blurConfig: BackgroundBlurConfig = {
|
|
60
|
-
* transformerType: 'BackgroundBlur',
|
|
61
|
-
* radius: 8
|
|
62
|
-
* }
|
|
63
|
-
* // ..
|
|
64
|
-
* ctx.filter = 'blur(8px)'
|
|
65
|
-
* ```
|
|
66
48
|
*/
|
|
67
49
|
export declare type BackgroundBlurConfig = {
|
|
68
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Type of post process.
|
|
52
|
+
*/
|
|
53
|
+
transformerType: "BackgroundBlur";
|
|
54
|
+
/**
|
|
55
|
+
* Using a number will use it as canvas filter.
|
|
56
|
+
*/
|
|
69
57
|
radius?: BlurRadius | number;
|
|
70
58
|
};
|
|
71
59
|
/**
|
|
72
60
|
* AssetBackgroundConfig specifies the absolute URL to the image or video file used for background replacement.
|
|
73
61
|
*/
|
|
74
62
|
export declare type AssetBackgroundConfig = {
|
|
63
|
+
/**
|
|
64
|
+
* URI for image or video asset.
|
|
65
|
+
*/
|
|
75
66
|
backgroundAssetUri: string;
|
|
76
67
|
};
|
|
77
68
|
/**
|
|
78
69
|
* VirtualBackgroundConfig specifies the configuration for a transformer logic that performs background replacement with a given image.
|
|
79
70
|
*/
|
|
80
71
|
export declare type VirtualBackgroundConfig = {
|
|
81
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Type of post process.
|
|
74
|
+
*/
|
|
75
|
+
transformerType: "VirtualBackground";
|
|
82
76
|
};
|
|
83
77
|
/**
|
|
84
78
|
* VirtualBackgroundConfig specifies the configuration for a transformer logic that performs background replacement with a given video.
|
|
85
79
|
*/
|
|
86
80
|
export declare type VideoBackgroundConfig = {
|
|
87
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Type of post process.
|
|
83
|
+
*/
|
|
84
|
+
transformerType: "VideoBackground";
|
|
88
85
|
};
|
|
89
86
|
/**
|
|
90
|
-
*
|
|
87
|
+
* SilhouetteBlurConfig specifies the configuration for a transformer logic that performs siluete blurring.
|
|
91
88
|
*/
|
|
92
|
-
export declare type
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
export declare type SilhouetteBlurConfig = {
|
|
90
|
+
/**
|
|
91
|
+
* Type of post process.
|
|
92
|
+
*/
|
|
93
|
+
transformerType: "SilhouetteBlur";
|
|
94
|
+
/**
|
|
95
|
+
* Using a number will use it as canvas filter.
|
|
96
|
+
*/
|
|
97
|
+
radius?: BlurRadius | number;
|
|
95
98
|
};
|
|
96
|
-
export type { FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, SelfieSegmentationResults, SelfieSegmentationOptions, PoseResults, PoseOptions };
|
|
99
|
+
export type { FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, SelfieSegmentationResults, SelfieSegmentationOptions, PoseResults, PoseOptions, };
|
|
97
100
|
/**
|
|
98
101
|
* MediaPipeResults types of results object of MediaPipe
|
|
99
102
|
*/
|
|
@@ -103,7 +106,7 @@ export declare type MediaPipeResults = FaceDetectionResults | FaceMeshResults |
|
|
|
103
106
|
* @results - The results object from MediaPipe
|
|
104
107
|
* @returns - can return a promise of void
|
|
105
108
|
*/
|
|
106
|
-
export declare type MediaPipeResultsListener = <T extends MediaPipeResults>(results: T) =>
|
|
109
|
+
export declare type MediaPipeResultsListener = <T extends MediaPipeResults>(results: T) => Promise<void> | void;
|
|
107
110
|
/**
|
|
108
111
|
* MediaPipeModelType supported models types
|
|
109
112
|
*/
|
|
@@ -132,3 +135,25 @@ export declare type MediaPipeModelConfig = {
|
|
|
132
135
|
export declare type MediapipeConfig = {
|
|
133
136
|
mediaPipeModelConfigArray: Array<MediaPipeModelConfig>;
|
|
134
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Vector containing 3 numbers
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
export declare type vec3 = [number, number, number];
|
|
143
|
+
/**
|
|
144
|
+
* Vector containing 4 numbers
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
export declare type vec4 = [number, number, number, number];
|
|
148
|
+
/**
|
|
149
|
+
* Valid data to feed webgl texture
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
export declare type TextureSource = string | number[] | ArrayBufferView | TexImageSource | TexImageSource[] | string[] | TextureFunc | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Valid uniform data map
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
export declare type UniformDataMap = {
|
|
158
|
+
[key: string]: number | number[] | WebGLTexture;
|
|
159
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MediapipeConfig, MediaPipeModelType } from
|
|
2
|
-
declare class MediapipeHelper {
|
|
1
|
+
import { MediapipeConfig, MediaPipeModelType } from "../types";
|
|
2
|
+
export declare class MediapipeHelper {
|
|
3
3
|
private mediapipeMap_;
|
|
4
4
|
private static defaultAssetsBaseUrl;
|
|
5
5
|
constructor();
|
|
@@ -9,4 +9,3 @@ declare class MediapipeHelper {
|
|
|
9
9
|
send(image: HTMLVideoElement | HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas, modelType?: MediaPipeModelType): Promise<void>;
|
|
10
10
|
reset(modelType?: MediaPipeModelType): void;
|
|
11
11
|
}
|
|
12
|
-
export default MediapipeHelper;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Check if the current browser is officially supported by the library.
|
|
3
|
-
*
|
|
4
|
-
* @returns
|
|
3
|
+
* **If this function is rejected the library might be able to run but the performance is unknown**
|
|
4
|
+
* @returns
|
|
5
5
|
*/
|
|
6
6
|
export declare function isSupported(): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="dom-webcodecs" />
|
|
2
|
+
/// <reference types="dom-webcodecs" />
|
|
3
|
+
/// <reference types="offscreencanvas" />
|
|
4
|
+
import { TextureSource, vec4 } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Render a VideoFrame within a canvas
|
|
7
|
+
* @param frame VideoFrame to render
|
|
8
|
+
* @param context Canvas context to render in
|
|
9
|
+
*/
|
|
10
|
+
export declare function frameToCanvas(frame: VideoFrame, context: OffscreenCanvasRenderingContext2D): void;
|
|
11
|
+
/**
|
|
12
|
+
* Create and fill a webgl texture
|
|
13
|
+
* If source is a texture, it will just be returned without creating a new texture
|
|
14
|
+
* @param context Webgl context to create the texture on
|
|
15
|
+
* @param source Source used to fill the texture
|
|
16
|
+
* @returns Created texture, or source if it's a WebGLTexture
|
|
17
|
+
*/
|
|
18
|
+
export declare function texture(context: WebGLRenderingContext, source?: TextureSource | WebGLTexture): WebGLTexture;
|
|
19
|
+
/**
|
|
20
|
+
* Create a webgl texture and fill it with a color
|
|
21
|
+
* @param context Webgl context to create the texture on
|
|
22
|
+
* @param width Width of the texture
|
|
23
|
+
* @param height Height of the texture
|
|
24
|
+
* @param color Color to fill the texture with
|
|
25
|
+
* @returns Created texture
|
|
26
|
+
*/
|
|
27
|
+
export declare function textureWithColor(context: WebGLRenderingContext, width: number, height: number, color: vec4): WebGLTexture;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
export interface TFLite extends EmscriptenModule {
|
|
3
|
+
_getModelBufferMemoryOffset(): number;
|
|
4
|
+
_getInputMemoryOffset(): number;
|
|
5
|
+
_getInputHeight(): number;
|
|
6
|
+
_getInputWidth(): number;
|
|
7
|
+
_getInputChannelCount(): number;
|
|
8
|
+
_getOutputMemoryOffset(): number;
|
|
9
|
+
_getOutputHeight(): number;
|
|
10
|
+
_getOutputWidth(): number;
|
|
11
|
+
_getOutputChannelCount(): number;
|
|
12
|
+
_loadModel(bufferSize: number): number;
|
|
13
|
+
_runInference(): number;
|
|
14
|
+
}
|
|
15
|
+
export declare class VonageTFLiteInfo {
|
|
16
|
+
selectedTFLite: TFLite;
|
|
17
|
+
isSIMDSupported: boolean;
|
|
18
|
+
isThreadsSupported: boolean;
|
|
19
|
+
inputWidth: number;
|
|
20
|
+
inputHeight: number;
|
|
21
|
+
inputChannelCount: number;
|
|
22
|
+
inputMemoryOffset: number;
|
|
23
|
+
outputWidth: number;
|
|
24
|
+
outputHeight: number;
|
|
25
|
+
outputChannelCount: number;
|
|
26
|
+
outputMemoryOffset: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function loadSelfieSegmentation(wasmUri?: string, tfliteUri?: string): Promise<VonageTFLiteInfo>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class SelfieSegmentation {
|
|
2
|
+
private canvas;
|
|
3
|
+
private context;
|
|
4
|
+
private pixelCount;
|
|
5
|
+
private inputOffset;
|
|
6
|
+
private outputOffset;
|
|
7
|
+
private infos?;
|
|
8
|
+
private mask?;
|
|
9
|
+
init(wasmAssetUriPath?: string, tfliteAssetUriPath?: string): Promise<void>;
|
|
10
|
+
getOutputDimensions(): {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
14
|
+
process(input: ImageBitmap): Promise<ImageBitmap | void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextureSource } from "../../types";
|
|
2
|
+
import { WebglTransformerPipeline } from "../webgl-transormer-pipeline";
|
|
3
|
+
export declare class BackgroundBlur extends WebglTransformerPipeline {
|
|
4
|
+
private readonly context;
|
|
5
|
+
inputImage?: ImageBitmap | TextureSource | WebGLTexture;
|
|
6
|
+
inputMask?: ImageBitmap | TextureSource | WebGLTexture;
|
|
7
|
+
constructor(context: WebGLRenderingContext, radius: number);
|
|
8
|
+
setData(image?: ImageBitmap | TextureSource | WebGLTexture, mask?: ImageBitmap | TextureSource | WebGLTexture): void;
|
|
9
|
+
}
|