@pexip/media-processor 17.3.0 → 18.0.0
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/CHANGELOG.md +45 -0
- package/dist/common/backends/webgl/blender.d.ts +11 -0
- package/dist/common/backends/webgl/blender.js +104 -0
- package/dist/common/backends/webgl/blur.d.ts +5 -0
- package/dist/common/backends/webgl/blur.js +153 -0
- package/dist/common/backends/webgl/canvas.d.ts +5 -0
- package/dist/common/backends/webgl/canvas.js +77 -0
- package/dist/common/backends/webgl/renderer.d.ts +8 -0
- package/dist/common/backends/webgl/renderer.js +126 -0
- package/dist/common/backends/webgl/shaders/blendFragmentShader.d.ts +1 -0
- package/dist/common/backends/webgl/shaders/blendFragmentShader.js +63 -0
- package/dist/common/backends/webgl/shaders/dualFilterBlurFragmentShader.d.ts +1 -0
- package/dist/common/backends/webgl/shaders/dualFilterBlurFragmentShader.js +45 -0
- package/dist/common/backends/webgl/shaders/textureFragmentShader.d.ts +1 -0
- package/dist/common/backends/webgl/shaders/textureFragmentShader.js +16 -0
- package/dist/common/backends/webgl/shaders/vertexShader.d.ts +1 -0
- package/dist/common/backends/webgl/shaders/vertexShader.js +19 -0
- package/dist/common/backends/webgl/texture.d.ts +6 -0
- package/dist/common/backends/webgl/texture.js +94 -0
- package/dist/common/backends/webgl/types.d.ts +5 -0
- package/dist/common/backends/webgl/types.js +1 -0
- package/dist/common/backends/webgl/webgl.mock.js +8 -0
- package/dist/common/backends/webgl/webglUtils.d.ts +80 -0
- package/dist/common/backends/webgl/webglUtils.js +194 -0
- package/dist/common/canvasRenderUtils.d.ts +62 -0
- package/dist/{main/video → common}/canvasRenderUtils.js +100 -61
- package/dist/common/constants.d.ts +27 -0
- package/dist/common/constants.js +23 -0
- package/dist/common/index.d.ts +9 -0
- package/dist/common/index.js +9 -0
- package/dist/common/m3.d.ts +17 -0
- package/dist/common/m3.js +69 -0
- package/dist/common/tsconfig.tsbuildinfo +1 -0
- package/dist/common/types/media.d.ts +22 -0
- package/dist/common/types/media.js +1 -0
- package/dist/common/types/messageEvents.d.ts +31 -0
- package/dist/common/types/messageEvents.js +1 -0
- package/dist/common/types/processor.d.ts +15 -0
- package/dist/common/types/processor.js +1 -0
- package/dist/common/types/render.d.ts +38 -0
- package/dist/common/types/render.js +1 -0
- package/dist/common/types/segmentation.d.ts +99 -0
- package/dist/common/types/segmentation.js +4 -0
- package/dist/common/types/utils.d.ts +19 -0
- package/dist/common/types/utils.js +1 -0
- package/dist/common/utils.d.ts +35 -0
- package/dist/common/utils.js +129 -0
- package/dist/main/benchUtils.d.ts +3 -2
- package/dist/main/benchUtils.js +7 -6
- package/dist/main/index.d.ts +2 -0
- package/dist/main/index.js +2 -0
- package/dist/main/process.d.ts +1 -11
- package/dist/main/process.js +0 -20
- package/dist/main/tsconfig.tsbuildinfo +1 -1
- package/dist/main/types.d.ts +2 -2
- package/dist/main/video/canvasTransform.d.ts +14 -5
- package/dist/main/video/canvasTransform.js +101 -86
- package/dist/main/video/constants.d.ts +0 -6
- package/dist/main/video/constants.js +0 -6
- package/dist/main/video/index.d.ts +2 -2
- package/dist/main/video/index.js +2 -2
- package/dist/main/video/load.d.ts +0 -14
- package/dist/main/video/load.js +0 -8
- package/dist/main/video/segmenters/mediapipe.d.ts +9 -11
- package/dist/main/video/segmenters/mediapipe.js +127 -77
- package/dist/main/video/typeGuards.d.ts +0 -1
- package/dist/main/video/typeGuards.js +2 -8
- package/dist/main/video/types.d.ts +19 -61
- package/dist/main/video/types.js +1 -20
- package/dist/main/video/utils.d.ts +5 -12
- package/dist/main/video/utils.js +5 -152
- package/dist/main/video/video.js +1 -0
- package/dist/main/video/videoStreamTrackProcessor.js +7 -4
- package/dist/workers/global.d.js +0 -0
- package/dist/workers/mediaWorker.d.ts +1 -0
- package/dist/workers/mediaWorker.js +188 -0
- package/dist/workers/tsconfig.tsbuildinfo +1 -1
- package/dist/worklets/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -14
- package/dist/main/video/canvasRenderUtils.d.ts +0 -27
- package/dist/main/video/segmenters/index.d.ts +0 -1
- package/dist/main/video/segmenters/index.js +0 -1
- package/dist/workers/index.js +0 -1
- /package/dist/{workers/index.d.ts → common/backends/webgl/webgl.mock.d.ts} +0 -0
|
@@ -1,19 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { resize } from './utils';
|
|
2
|
+
export const getCanvasRenderingContext2D = (canvas, options) => {
|
|
3
|
+
const context = canvas.getContext('2d', options);
|
|
4
|
+
if (!context) {
|
|
5
|
+
throw new Error('Cannot get CanvasRenderingContext2D');
|
|
6
|
+
}
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
9
|
+
export const flipCanvasHorizontal = (canvas) => {
|
|
10
|
+
const ctx = getCanvasRenderingContext2D(canvas);
|
|
11
|
+
ctx.scale(-1, 1);
|
|
12
|
+
ctx.translate(-canvas.width, 0);
|
|
13
|
+
};
|
|
14
|
+
export const getImageSize = (image) => {
|
|
15
|
+
if ('VideoFrame' in globalThis && image instanceof VideoFrame) {
|
|
16
|
+
return { height: image.displayHeight, width: image.displayWidth };
|
|
17
|
+
}
|
|
18
|
+
if ('offsetHeight' in image &&
|
|
19
|
+
typeof image.offsetHeight === 'number' &&
|
|
20
|
+
image.offsetHeight !== 0 &&
|
|
21
|
+
'offsetWidth' in image &&
|
|
22
|
+
typeof image.offsetWidth === 'number' &&
|
|
23
|
+
image.offsetWidth !== 0) {
|
|
24
|
+
return { height: image.offsetHeight, width: image.offsetWidth };
|
|
25
|
+
}
|
|
26
|
+
if ('videoHeight' in image &&
|
|
27
|
+
typeof image.videoHeight === 'number' &&
|
|
28
|
+
image.videoHeight !== 0 &&
|
|
29
|
+
'videoWidth' in image &&
|
|
30
|
+
typeof image.videoWidth === 'number' &&
|
|
31
|
+
image.videoWidth !== 0) {
|
|
32
|
+
return { height: image.videoHeight, width: image.videoWidth };
|
|
33
|
+
}
|
|
34
|
+
if ('height' in image &&
|
|
35
|
+
image.height !== 0 &&
|
|
36
|
+
'width' in image &&
|
|
37
|
+
image.width !== 0) {
|
|
38
|
+
return { height: image.height, width: image.width };
|
|
39
|
+
}
|
|
40
|
+
return { height: 0, width: 0 };
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Create an OffscreenCanvas with provided width and height. When
|
|
44
|
+
* OffscreenCanvas is not available, a Canvas element is returned.
|
|
45
|
+
*
|
|
46
|
+
* @param width - canvas.width
|
|
47
|
+
* @param height - canvas.height
|
|
48
|
+
*/
|
|
49
|
+
export const createOffscreenCanvas = (width, height) => {
|
|
50
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
51
|
+
return offscreen;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Compare the provided width and height to see if they are the same
|
|
55
|
+
*
|
|
56
|
+
* @param widthA - The width of A
|
|
57
|
+
* @param heightA - The height of A
|
|
58
|
+
* @param widthB - The width of B
|
|
59
|
+
* @param heightB - The height of B
|
|
60
|
+
*/
|
|
61
|
+
export const isEqualSize = (widthA, heightA, widthB, heightB) => widthA === widthB && heightA === heightB;
|
|
62
|
+
export const clearCanvas = (canvas) => {
|
|
63
|
+
const ctx = getCanvasRenderingContext2D(canvas);
|
|
64
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
65
|
+
};
|
|
4
66
|
export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
5
67
|
const props = {
|
|
6
68
|
downScaleFactor: 3,
|
|
7
69
|
};
|
|
8
|
-
const getImage = (imageName) => {
|
|
9
|
-
const image = props[imageName];
|
|
10
|
-
if (!image) {
|
|
11
|
-
const img = new Image();
|
|
12
|
-
props[imageName] = img;
|
|
13
|
-
return img;
|
|
14
|
-
}
|
|
15
|
-
return image;
|
|
16
|
-
};
|
|
17
70
|
const getCanvas = (canvasName) => {
|
|
18
71
|
const canvas = props[canvasName];
|
|
19
72
|
if (!canvas) {
|
|
@@ -36,12 +89,7 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
36
89
|
/**
|
|
37
90
|
* Draw image on a 2D rendering context.
|
|
38
91
|
*/
|
|
39
|
-
const drawImage =
|
|
40
|
-
if (image instanceof Tensor) {
|
|
41
|
-
const pixels = await browser.toPixels(image);
|
|
42
|
-
const { height, width } = getImageSize(image);
|
|
43
|
-
image = new ImageData(pixels, width, height);
|
|
44
|
-
}
|
|
92
|
+
const drawImage = (ctx, image, sx, sy, sw, sh, dx, dy, dw, dh) => {
|
|
45
93
|
const source = image instanceof ImageData
|
|
46
94
|
? renderImageDataToOffScreenCanvas(image, 'drawImageDataCanvas')
|
|
47
95
|
: image;
|
|
@@ -58,23 +106,23 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
58
106
|
ctx.drawImage(source, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
59
107
|
}
|
|
60
108
|
};
|
|
61
|
-
const renderImageToCanvas =
|
|
109
|
+
const renderImageToCanvas = (image, canvas, dw = processingWidth, dh = processingHeight, options = {}) => {
|
|
62
110
|
const { height, width } = getImageSize(image);
|
|
63
|
-
const
|
|
111
|
+
const result = resize(width, height, dw, dh);
|
|
64
112
|
const ctx = getCanvasRenderingContext2D(canvas, options);
|
|
65
|
-
|
|
113
|
+
drawImage(ctx, image, result.sx, result.sy, result.sw, result.sh, result.dx, result.dy, result.dw, result.dh);
|
|
66
114
|
};
|
|
67
|
-
const renderImageToOffScreenCanvas =
|
|
115
|
+
const renderImageToOffScreenCanvas = (image, canvasName) => {
|
|
68
116
|
const canvas = getCanvas(canvasName);
|
|
69
|
-
|
|
117
|
+
renderImageToCanvas(image, canvas);
|
|
70
118
|
return canvas;
|
|
71
119
|
};
|
|
72
|
-
const drawWithCompositing =
|
|
120
|
+
const drawWithCompositing = (ctx, image, compositeOperation) => {
|
|
73
121
|
ctx.globalCompositeOperation = compositeOperation;
|
|
74
|
-
|
|
122
|
+
drawImage(ctx, image, 0, 0);
|
|
75
123
|
};
|
|
76
124
|
// method copied from blur in https://codepen.io/zhaojun/pen/zZmRQe
|
|
77
|
-
const cpuBlur =
|
|
125
|
+
const cpuBlur = (canvas, image, blur) => {
|
|
78
126
|
const ctx = getCanvasRenderingContext2D(canvas);
|
|
79
127
|
let sum = 0;
|
|
80
128
|
const delta = 5;
|
|
@@ -94,12 +142,12 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
94
142
|
Math.exp(-(x * x + y * y) / (2 * delta * delta))) /
|
|
95
143
|
sum) *
|
|
96
144
|
blur;
|
|
97
|
-
|
|
145
|
+
drawImage(ctx, image, x, y);
|
|
98
146
|
}
|
|
99
147
|
}
|
|
100
148
|
ctx.globalAlpha = 1;
|
|
101
149
|
};
|
|
102
|
-
const drawAndBlurImageOnCanvas =
|
|
150
|
+
const drawAndBlurImageOnCanvas = ({ image, blurAmount, canvas, preserveOldDrawing = true, }) => {
|
|
103
151
|
const { height, width } = getImageSize(image);
|
|
104
152
|
const ctx = getCanvasRenderingContext2D(canvas);
|
|
105
153
|
if (blurAmount <= 0) {
|
|
@@ -114,22 +162,23 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
114
162
|
if ('filter' in ctx) {
|
|
115
163
|
// Avoid the transparent edge by Gaussian blur
|
|
116
164
|
halfCtx.filter = `blur(${blurAmount}px)`;
|
|
117
|
-
|
|
118
|
-
|
|
165
|
+
drawImage(halfCtx, image, 0, 0, width, height, 0, 0, halfCanvas.width, halfCanvas.height);
|
|
166
|
+
drawImage(ctx, halfCanvas, 0, 0, width, height);
|
|
119
167
|
}
|
|
120
168
|
else {
|
|
121
169
|
// Safari doesn't support filter
|
|
122
170
|
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter
|
|
123
|
-
|
|
171
|
+
cpuBlur(canvas, image, blurAmount);
|
|
124
172
|
}
|
|
125
173
|
};
|
|
126
|
-
const drawAndBlurImageOnOffScreenCanvas =
|
|
174
|
+
const drawAndBlurImageOnOffScreenCanvas = ({ image, blurAmount, offscreenCanvasName, preserveOldDrawing, }) => {
|
|
127
175
|
const canvas = getCanvas(offscreenCanvasName);
|
|
176
|
+
clearCanvas(canvas);
|
|
128
177
|
if (blurAmount === 0) {
|
|
129
|
-
|
|
178
|
+
renderImageToCanvas(image, canvas);
|
|
130
179
|
}
|
|
131
180
|
else {
|
|
132
|
-
|
|
181
|
+
drawAndBlurImageOnCanvas({
|
|
133
182
|
image,
|
|
134
183
|
blurAmount,
|
|
135
184
|
canvas,
|
|
@@ -138,12 +187,18 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
138
187
|
}
|
|
139
188
|
return canvas;
|
|
140
189
|
};
|
|
141
|
-
const createPersonMask =
|
|
142
|
-
const backgroundMaskImage =
|
|
190
|
+
const createPersonMask = (segmentation, _foregroundThreshold, edgeBlurAmount) => {
|
|
191
|
+
const backgroundMaskImage = Array.isArray(segmentation)
|
|
192
|
+
? segmentation[0]?.canvas
|
|
193
|
+
: segmentation.canvas;
|
|
143
194
|
if (!backgroundMaskImage) {
|
|
144
195
|
return getCanvas('maskCanvas');
|
|
145
196
|
}
|
|
146
|
-
const backgroundMask =
|
|
197
|
+
const backgroundMask = drawAndBlurImageOnOffScreenCanvas({
|
|
198
|
+
image: backgroundMaskImage,
|
|
199
|
+
offscreenCanvasName: 'maskCanvas',
|
|
200
|
+
blurAmount: 0,
|
|
201
|
+
});
|
|
147
202
|
if (edgeBlurAmount === 0) {
|
|
148
203
|
return backgroundMask;
|
|
149
204
|
}
|
|
@@ -156,23 +211,8 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
156
211
|
});
|
|
157
212
|
}
|
|
158
213
|
};
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
await loadImage(image, url);
|
|
162
|
-
return image;
|
|
163
|
-
};
|
|
164
|
-
const loadAndDrawImageOnOffscreenCanvas = async (url, canvasName, imageName) => {
|
|
165
|
-
const image = await loadImageElement(url, imageName);
|
|
166
|
-
const canvas = getCanvas(canvasName);
|
|
167
|
-
const context = getCanvasRenderingContext2D(canvas);
|
|
168
|
-
const imageSize = getImageSize(image);
|
|
169
|
-
const rect = fitDestinationSize(imageSize.width, imageSize.height, processingWidth, processingHeight);
|
|
170
|
-
await drawImage(context, image, rect.x, rect.y, rect.width, rect.height);
|
|
171
|
-
return canvas;
|
|
172
|
-
};
|
|
173
|
-
const loadBackgroundImage = (url) => loadAndDrawImageOnOffscreenCanvas(url, 'backgroundImageCanvas', 'backgroundImage');
|
|
174
|
-
const drawBokehEffect = async (canvas, inputImage, backgroundImage, segmentations, foregroundThreshold = 0.5, backgroundBlurAmount = 3, edgeBlurAmount = 3, flipHorizontal = false) => {
|
|
175
|
-
const blurredImage = await drawAndBlurImageOnOffScreenCanvas({
|
|
214
|
+
const drawBokehEffect = (canvas, inputImage, backgroundImage, segmentations, foregroundThreshold = 0.5, backgroundBlurAmount = 3, edgeBlurAmount = 3, flipHorizontal = false) => {
|
|
215
|
+
const blurredImage = drawAndBlurImageOnOffScreenCanvas({
|
|
176
216
|
image: backgroundImage,
|
|
177
217
|
blurAmount: backgroundBlurAmount,
|
|
178
218
|
offscreenCanvasName: 'blurredCanvas',
|
|
@@ -181,31 +221,31 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
181
221
|
if (Array.isArray(segmentations) && segmentations.length === 0) {
|
|
182
222
|
return drawImage(ctx, blurredImage, 0, 0);
|
|
183
223
|
}
|
|
184
|
-
const personMask =
|
|
224
|
+
const personMask = createPersonMask(segmentations, foregroundThreshold, edgeBlurAmount);
|
|
185
225
|
ctx.save();
|
|
186
226
|
if (flipHorizontal) {
|
|
187
227
|
flipCanvasHorizontal(canvas);
|
|
188
228
|
}
|
|
189
229
|
// draw the original image on the final canvas
|
|
190
230
|
const { height, width } = getImageSize(inputImage);
|
|
191
|
-
|
|
231
|
+
drawImage(ctx, inputImage, 0, 0, width, height);
|
|
192
232
|
// "destination-in" - "The existing canvas content is kept where both the
|
|
193
233
|
// new shape and existing canvas content overlap. Everything else is made
|
|
194
234
|
// transparent."
|
|
195
235
|
// crop what's not the person using the mask from the original image
|
|
196
|
-
|
|
236
|
+
drawWithCompositing(ctx, personMask, 'destination-in');
|
|
197
237
|
// "destination-over" - "The existing canvas content is kept where both the
|
|
198
238
|
// new shape and existing canvas content overlap. Everything else is made
|
|
199
239
|
// transparent."
|
|
200
240
|
// draw the blurred background on top of the original image where it doesn't
|
|
201
241
|
// overlap.
|
|
202
|
-
|
|
242
|
+
drawWithCompositing(ctx, blurredImage, 'destination-over');
|
|
203
243
|
ctx.restore();
|
|
204
244
|
};
|
|
205
245
|
const drawBlurEffect = (canvas, inputImage, segmentations, foregroundThreshold = 0.5, backgroundBlurAmount = 3, edgeBlurAmount = 3, flipHorizontal = false) => drawBokehEffect(canvas, inputImage, inputImage, segmentations, foregroundThreshold, backgroundBlurAmount, edgeBlurAmount, flipHorizontal);
|
|
206
246
|
const drawOverlayEffect = (canvas, inputImage, backgroundImage, segmentations, foregroundThreshold = 0.5, backgroundBlurAmount = 0, edgeBlurAmount = 3, flipHorizontal = false) => drawBokehEffect(canvas, inputImage, backgroundImage, segmentations, foregroundThreshold, backgroundBlurAmount, edgeBlurAmount, flipHorizontal);
|
|
207
|
-
const evaluateInput =
|
|
208
|
-
const image =
|
|
247
|
+
const evaluateInput = (inputImage) => {
|
|
248
|
+
const image = renderImageToOffScreenCanvas(inputImage, 'inputCanvas');
|
|
209
249
|
return image;
|
|
210
250
|
};
|
|
211
251
|
return {
|
|
@@ -213,7 +253,6 @@ export const createCanvasRenderUtils = (processingWidth, processingHeight) => {
|
|
|
213
253
|
renderImageToCanvas,
|
|
214
254
|
drawBlurEffect,
|
|
215
255
|
drawOverlayEffect,
|
|
216
|
-
loadBackgroundImage,
|
|
217
256
|
renderImageToOffScreenCanvas,
|
|
218
257
|
renderImageDataToOffScreenCanvas,
|
|
219
258
|
drawAndBlurImageOnOffScreenCanvas,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type ExtractValueTypes<T> = T extends object ? T[keyof T] : never;
|
|
2
|
+
export declare const PROCESSING_WIDTH = 768;
|
|
3
|
+
export declare const PROCESSING_HEIGHT = 432;
|
|
4
|
+
export declare const FOREGROUND_THRESHOLD = 0.5;
|
|
5
|
+
export declare const BACKGROUND_BLUR_AMOUNT = 3;
|
|
6
|
+
export declare const EDGE_BLUR_AMOUNT = 3;
|
|
7
|
+
export declare const MASK_COMBINE_RATIO = 0.5;
|
|
8
|
+
export declare const PROCESS_STATUS: {
|
|
9
|
+
readonly New: "new";
|
|
10
|
+
readonly Error: "Error";
|
|
11
|
+
readonly Opened: "opened";
|
|
12
|
+
readonly Opening: "opening";
|
|
13
|
+
readonly Processing: "processing";
|
|
14
|
+
readonly Idle: "idle";
|
|
15
|
+
readonly Closing: "closing";
|
|
16
|
+
readonly Closed: "closed";
|
|
17
|
+
readonly Destroying: "destroying";
|
|
18
|
+
readonly Destroyed: "destroyed";
|
|
19
|
+
};
|
|
20
|
+
export type ProcessStatus = ExtractValueTypes<typeof PROCESS_STATUS>;
|
|
21
|
+
export declare const RENDER_EFFECT: {
|
|
22
|
+
readonly None: "none";
|
|
23
|
+
readonly Blur: "blur";
|
|
24
|
+
readonly Overlay: "overlay";
|
|
25
|
+
};
|
|
26
|
+
export type RenderEffects = ExtractValueTypes<typeof RENDER_EFFECT>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const PROCESSING_WIDTH = 768;
|
|
2
|
+
export const PROCESSING_HEIGHT = 432;
|
|
3
|
+
export const FOREGROUND_THRESHOLD = 0.5;
|
|
4
|
+
export const BACKGROUND_BLUR_AMOUNT = 3; // Between 1 and 20
|
|
5
|
+
export const EDGE_BLUR_AMOUNT = 3; // Between 0 and 20
|
|
6
|
+
export const MASK_COMBINE_RATIO = 0.5;
|
|
7
|
+
export const PROCESS_STATUS = {
|
|
8
|
+
New: 'new',
|
|
9
|
+
Error: 'Error',
|
|
10
|
+
Opened: 'opened',
|
|
11
|
+
Opening: 'opening',
|
|
12
|
+
Processing: 'processing',
|
|
13
|
+
Idle: 'idle',
|
|
14
|
+
Closing: 'closing',
|
|
15
|
+
Closed: 'closed',
|
|
16
|
+
Destroying: 'destroying',
|
|
17
|
+
Destroyed: 'destroyed',
|
|
18
|
+
};
|
|
19
|
+
export const RENDER_EFFECT = {
|
|
20
|
+
None: 'none',
|
|
21
|
+
Blur: 'blur',
|
|
22
|
+
Overlay: 'overlay',
|
|
23
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './types/segmentation';
|
|
2
|
+
export * from './types/media';
|
|
3
|
+
export * from './types/utils';
|
|
4
|
+
export * from './types/messageEvents';
|
|
5
|
+
export * from './types/render';
|
|
6
|
+
export * from './types/processor';
|
|
7
|
+
export * from './constants';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './types/segmentation';
|
|
2
|
+
export * from './types/media';
|
|
3
|
+
export * from './types/utils';
|
|
4
|
+
export * from './types/messageEvents';
|
|
5
|
+
export * from './types/render';
|
|
6
|
+
export * from './types/processor';
|
|
7
|
+
export * from './constants';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of 2D matrix math utilities
|
|
3
|
+
*/
|
|
4
|
+
export declare const m3: {
|
|
5
|
+
/**
|
|
6
|
+
* Create a 2D projection matrix that converts from pixels to clipspace with
|
|
7
|
+
* Y = 0 at the top
|
|
8
|
+
*/
|
|
9
|
+
projection: (width: number, height: number, flipY?: number) => [number, number, number, number, number, number, number, number, number];
|
|
10
|
+
translation: (tx: number, ty: number) => [number, number, number, number, number, number, number, number, number];
|
|
11
|
+
rotation: (angleInRadians: number) => [number, number, number, number, number, number, number, number, number];
|
|
12
|
+
scaling: (sx: number, sy: number) => [number, number, number, number, number, number, number, number, number];
|
|
13
|
+
multiply: (a: [number, number, number, number, number, number, number, number, number], b: [number, number, number, number, number, number, number, number, number]) => [number, number, number, number, number, number, number, number, number];
|
|
14
|
+
translate: (m: [number, number, number, number, number, number, number, number, number], tx: number, ty: number) => [number, number, number, number, number, number, number, number, number];
|
|
15
|
+
rotate: (m: [number, number, number, number, number, number, number, number, number], angleInRadians: number) => [number, number, number, number, number, number, number, number, number];
|
|
16
|
+
scale: (m: [number, number, number, number, number, number, number, number, number], sx: number, sy: number) => [number, number, number, number, number, number, number, number, number];
|
|
17
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of 2D matrix math utilities
|
|
3
|
+
*/
|
|
4
|
+
export const m3 = {
|
|
5
|
+
/**
|
|
6
|
+
* Create a 2D projection matrix that converts from pixels to clipspace with
|
|
7
|
+
* Y = 0 at the top
|
|
8
|
+
*/
|
|
9
|
+
// prettier-ignore
|
|
10
|
+
projection: (width, height, flipY = -1) => [
|
|
11
|
+
2 / width, 0, 0,
|
|
12
|
+
0, 2 / height * flipY, 0,
|
|
13
|
+
-1, 1 * -flipY, 1,
|
|
14
|
+
],
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
translation: (tx, ty) => [
|
|
17
|
+
1, 0, 0,
|
|
18
|
+
0, 1, 0,
|
|
19
|
+
tx, ty, 1,
|
|
20
|
+
],
|
|
21
|
+
rotation: (angleInRadians) => {
|
|
22
|
+
const c = Math.cos(angleInRadians);
|
|
23
|
+
const s = Math.sin(angleInRadians);
|
|
24
|
+
// prettier-ignore
|
|
25
|
+
return [
|
|
26
|
+
c, -s, 0,
|
|
27
|
+
s, c, 0,
|
|
28
|
+
0, 0, 1,
|
|
29
|
+
];
|
|
30
|
+
},
|
|
31
|
+
// prettier-ignore
|
|
32
|
+
scaling: (sx, sy) => [
|
|
33
|
+
sx, 0, 0,
|
|
34
|
+
0, sy, 0,
|
|
35
|
+
0, 0, 1,
|
|
36
|
+
],
|
|
37
|
+
multiply: (a, b) => {
|
|
38
|
+
const a00 = a[0 * 3 + 0];
|
|
39
|
+
const a01 = a[0 * 3 + 1];
|
|
40
|
+
const a02 = a[0 * 3 + 2];
|
|
41
|
+
const a10 = a[1 * 3 + 0];
|
|
42
|
+
const a11 = a[1 * 3 + 1];
|
|
43
|
+
const a12 = a[1 * 3 + 2];
|
|
44
|
+
const a20 = a[2 * 3 + 0];
|
|
45
|
+
const a21 = a[2 * 3 + 1];
|
|
46
|
+
const a22 = a[2 * 3 + 2];
|
|
47
|
+
const b00 = b[0 * 3 + 0];
|
|
48
|
+
const b01 = b[0 * 3 + 1];
|
|
49
|
+
const b02 = b[0 * 3 + 2];
|
|
50
|
+
const b10 = b[1 * 3 + 0];
|
|
51
|
+
const b11 = b[1 * 3 + 1];
|
|
52
|
+
const b12 = b[1 * 3 + 2];
|
|
53
|
+
const b20 = b[2 * 3 + 0];
|
|
54
|
+
const b21 = b[2 * 3 + 1];
|
|
55
|
+
const b22 = b[2 * 3 + 2];
|
|
56
|
+
// prettier-ignore
|
|
57
|
+
return [
|
|
58
|
+
b00 * a00 + b01 * a10 + b02 * a20, b00 * a01 + b01 * a11 + b02 * a21, b00 * a02 + b01 * a12 + b02 * a22,
|
|
59
|
+
b10 * a00 + b11 * a10 + b12 * a20, b10 * a01 + b11 * a11 + b12 * a21, b10 * a02 + b11 * a12 + b12 * a22,
|
|
60
|
+
b20 * a00 + b21 * a10 + b22 * a20, b20 * a01 + b21 * a11 + b22 * a21, b20 * a02 + b21 * a12 + b22 * a22,
|
|
61
|
+
];
|
|
62
|
+
},
|
|
63
|
+
translate: (m, tx, ty) => m3.multiply(m, m3.translation(tx, ty)),
|
|
64
|
+
rotate: (m, angleInRadians) => m3.multiply(m, m3.rotation(angleInRadians)),
|
|
65
|
+
scale: (m, sx, sy) => {
|
|
66
|
+
return m3.multiply(m, m3.scaling(sx, sy));
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
/* eslint-enable @typescript-eslint/no-non-null-assertion --- Matrix math*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es5.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2016.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2018.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2019.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2021.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2023.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.esnext.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.webworker.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2023.array.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.decorators.d.ts","../../../../.yarn/cache/typescript-patch-4778c7998b-c93786fcc9.zip/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../src/common/types/media.ts","../../src/common/types/segmentation.ts","../../src/common/utils.ts","../../src/common/canvasRenderUtils.ts","../../src/common/constants.ts","../../src/common/types/utils.ts","../../src/common/types/messageEvents.ts","../../src/common/types/render.ts","../../src/common/types/processor.ts","../../src/common/index.ts","../../src/common/m3.ts","../../src/common/backends/webgl/types.ts","../../src/common/backends/webgl/webglUtils.ts","../../src/common/backends/webgl/shaders/vertexShader.ts","../../src/common/backends/webgl/shaders/blendFragmentShader.ts","../../src/common/backends/webgl/blender.ts","../../src/common/backends/webgl/shaders/dualFilterBlurFragmentShader.ts","../../src/common/backends/webgl/blur.ts","../../src/common/backends/webgl/shaders/textureFragmentShader.ts","../../src/common/backends/webgl/canvas.ts","../../src/common/backends/webgl/texture.ts","../../src/common/backends/webgl/renderer.ts","../../src/common/backends/webgl/webgl.mock.ts","../../../../.yarn/cache/@types-audioworklet-npm-0.0.41-ec4bc90857-2bfd761ab7.zip/node_modules/@types/audioworklet/iterable.d.ts","../../../../.yarn/cache/@types-audioworklet-npm-0.0.41-ec4bc90857-2bfd761ab7.zip/node_modules/@types/audioworklet/index.d.ts","../../../../.yarn/cache/@types-dom-webcodecs-npm-0.1.10-02a2fa8a5c-dd7b1410da.zip/node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts","../../../../.yarn/cache/@types-dom-webcodecs-npm-0.1.10-02a2fa8a5c-dd7b1410da.zip/node_modules/@types/dom-webcodecs/index.d.ts","../../../../.yarn/cache/@types-offscreencanvas-npm-2019.7.3-a966f946e3-53a394a65a.zip/node_modules/@types/offscreencanvas/index.d.ts","../../../../.yarn/cache/@types-trusted-types-npm-2.0.6-c4c3cd363b-04250c7175.zip/node_modules/@types/trusted-types/lib/index.d.ts","../../../../.yarn/cache/@types-trusted-types-npm-2.0.6-c4c3cd363b-04250c7175.zip/node_modules/@types/trusted-types/index.d.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c",{"version":"5746fca0ef5189a855357e258108524603574457c811ce8143e3279efde9f5b6","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"4350e5922fecd4bedda2964d69c213a1436349d0b8d260dd902795f5b94dc74b","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"8c2a802249238599805778a522f91d2727f24dce34e778022eb68936dd9a1c8b","signature":"a8c26adbb4381a5434218f5b71e4046d90a5ea69fc7a921fe4b04d238796763d"},{"version":"a08d1f5dfc5c07306e05765720128e6798fa01d9c068faa873060c290cbcb957","signature":"1f18d5c5b09877bd4bbc23925b3e565c45562db3a1101aed386a290ef6994b4d"},{"version":"397eb57a050bc0c26faf0f9d4bccf855b94d64065dfb636169f3968406450b0e","signature":"a8bf4d5c321c6a5c9bf359dc4db5d28c8e41bfa493a4fcc9a5980b2904aba08b"},{"version":"e43373cc05746b0b6808489e8afb58cb8365338261ffb1c83b27ab97ad79eda7","signature":"43187e85542faa586562489e51d75cd5c880e770d95f76ae16b2cc20d19dd5bd"},{"version":"dd8ec28c4329cc00d00a347da73a49f9ba0719171ea014304b020307b18743ed","signature":"d54f7ec4fd9014241946eba0afae7eedce54b6a2bacd11bb45beaa4e1aba5eab"},{"version":"2e9ec5a91a2b0fce67e8c7b3511584cedc0cac1c1b26f9b8cda43b1fecf00b18","signature":"8614f7b7029832d4cf36ff07ca0557178641bf435d2b4efb49020b9b6e8f0ba7"},{"version":"9d58767925265ec372233194af049798afc79cae8faff79bb153cbd4f2597c57","signature":"6971a1c1d85e303aec5977bc6cdd0cb69b0a0dadfc99876493ac7ecbd9988f25"},{"version":"13033d2a7d004a776a4d6cebb13da86e154bb62f21769ccd7f05a68dc6d1de32","signature":"f619393aa4d956552141074b1abf284197acdfe8360c6bf70701919f52979475"},{"version":"0337a059b2e9a6efcb18309275f00ff4a54dc72299978c38ec908f4e532e8807","signature":"b85b0e5aac0caaa83157b8e1d6c7f907df1c193694f1aee2ab033adca5b585b4"},{"version":"4cd8a695e950f2a67533815d56f4d6cd4ed24d01ec86cce43e13666e82a410f9","signature":"29b06064df3a892c1129444b7ed8976e24a495c1b9b7d7bc2025aae46a2c62af"},{"version":"4917a07a74f59772f5ce8a40d8aa1290c379814765c515fb5431aa796066b148","signature":"f33683933e790ae378752362c5cf07f376b9a04f7f20081ca4759cb2a1cd096e"},"70f51cbe96df167534a4a4465196e6a4ee03ec99434305a4deee7da55c013d6f",{"version":"aa6c7320117bf3585901f97dd0f781faeda5dcb1f7bfce75265aa612e645bee2","signature":"24c9e3c50ed05045922debe2bcf4c7eebbeb82d4da38b664a897e1f09fa28617"},{"version":"42ecca925b84e401aaf8675d0bd9166b8387e52765ccf60fe7a235f7665b55df","signature":"121a2d7883ae582dc2c0a09c9217111179aff6fda6506e0d14d7f93024a7b772"},{"version":"1a2125bf9c12b0a22e409e7fd38a986970a48e59bbf4828f0923e1883c23c609","signature":"107b3b06e042381c5a3ac2a64680ca9becf63cadcc15e6bde3cfdeefc8d33e07"},{"version":"331377f7016f158bf3d22f3b23b8489c221c3d238229d8a03b0ec0ef8747e80a","signature":"28db6ccb86fc6ecdad111e4f77ae0a7eab0cdb9bc995433163b3aba70d88d330"},{"version":"c62b257d31f31515453fd43274dc1fe3f4d31fbd606d1b8ac26c3f935781b51f","signature":"1871952a5d71be12a10be4b9e7a250866769e45996c67d8b4bdbc23d17545e60"},{"version":"fff19207dbf36694284c35d0e00f42ea1231b9d6fb16592e4ada25f22245c32e","signature":"5112a5958f144c56e14d725133c963f7aaa7a5a22645e67c51dc8851e1ce6e17"},{"version":"a2af152c49ab4b88c05b8a6b64eb8a233c70cfec80f9dc8429df82795d3f43d1","signature":"d4360888d9fab8c5e360e02d8a570eae7a484f68fea61b1fa942b1d0e5fdd1cc"},{"version":"58e18a5684ca543eb46fdc67f2c4bdd7500d13b1408e17f1820474c25916b0b6","signature":"e08a2723b8e38f541725037ccfa3c5323347acfb75f3e1250b62ec29307bea4c"},{"version":"c1c0b7555cbb3bcf694556d463e8c06fc9dcf91f89dafc2b17e499a7aa8f3e81","signature":"5ac875485bd6c3e7a31581578fab7372807501d3d7378ea2df9bdace07cb56b9"},{"version":"fca063f982a41c4f86b30dde67114cdc8b7aed0c9a585989404a6db762679c2e","signature":"ebbb2de3a3b02d66ae958deb69d66fbfdd4bdff577e2ac5403218dd377c6fd40"},{"version":"702534fa9a0be7699fabad7fd3b4afcfe1658af1bdbc13b001877402fd2d8e96","signature":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","affectsGlobalScope":true},{"version":"b38d0bfd2d1c1536d40fc5941fab5c5dd2749fb874fb57c451211ab806a3be8a","affectsGlobalScope":true},{"version":"8c63699627e2dd957f31dddfaf644a96ccf92eec6e9277a430421ae2d7e98b00","affectsGlobalScope":true},{"version":"da4a8f6629bc630a6b85d0899ca3f610402794a1535d3eb8be826acef5efedfb","affectsGlobalScope":true},{"version":"3c57b01d6648405ea1784c0176e2ad77f77568e7a84d5cb4fc8eefabf00ca22b","affectsGlobalScope":true},{"version":"921394bdf2d9f67c9e30d98c4b1c56a899ac06770e5ce3389f95b6b85a58e009","affectsGlobalScope":true},"15fe687c59d62741b4494d5e623d497d55eb38966ecf5bea7f36e48fc3fbe15e",{"version":"a4a5a79b9d9b4e4dfa18279d85686fac7eb155b828ddf7a677ceb57f9384f043","affectsGlobalScope":true}],"root":[[65,87]],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":false,"esModuleInterop":true,"jsx":2,"module":99,"noImplicitAny":true,"noUncheckedIndexedAccess":true,"outDir":"..","rootDir":"../../src","skipLibCheck":true,"sourceMap":false,"strict":true,"target":7},"fileIdsList":[[88],[90],[93],[67,72,75,76,77,78,79],[67,75,76,77,78,81],[75,76,77,78,83],[65,66,67,69,72,77,80,82,84,85],[65,67,75,76,77,78,83],[66,76],[65,67],[65,66,67,69,70,71,72,73],[70],[65,66,71,72],[65,66,69],[65,66],[72,76],[76],[65,72],[65,76],[65]],"referencedMap":[[89,1],[91,2],[94,3],[80,4],[82,5],[84,6],[86,7],[85,8],[77,9],[68,10],[74,11],[75,12],[73,13],[72,14],[67,15]],"exportedModulesMap":[[89,1],[91,2],[94,3],[80,16],[82,17],[84,17],[86,18],[85,19],[77,9],[68,20],[74,11],[73,13],[72,14],[67,15]],"semanticDiagnosticsPerFile":[89,88,91,90,92,94,93,63,64,14,13,2,15,16,17,18,19,20,21,22,3,4,23,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,59,10,1,11,62,61,60,12,80,82,84,86,79,81,83,78,85,76,87,77,68,69,74,75,65,71,73,72,66,70,67],"latestChangedDtsFile":"./backends/webgl/webgl.mock.d.ts"},"version":"5.3.3"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Segmentation {
|
|
2
|
+
canvas: OffscreenCanvas | undefined;
|
|
3
|
+
}
|
|
4
|
+
export type ProcessInputType = VideoFrame | ImageData | OffscreenCanvas | ImageBitmap;
|
|
5
|
+
export type ImageType = CanvasImageSource | ProcessInputType | VideoFrame;
|
|
6
|
+
export interface VideoFrameLike {
|
|
7
|
+
frame: VideoFrame | ImageBitmap;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ImageRecord {
|
|
13
|
+
key: string;
|
|
14
|
+
image: ImageBitmap;
|
|
15
|
+
}
|
|
16
|
+
export interface Rect {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
export type ImageMapIterable = Iterable<readonly [string, ImageBitmap]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ProcessEventOpen<T> {
|
|
2
|
+
type: 'open';
|
|
3
|
+
data: T;
|
|
4
|
+
}
|
|
5
|
+
export interface ProcessEventProcess<T> {
|
|
6
|
+
type: 'process';
|
|
7
|
+
data: T;
|
|
8
|
+
}
|
|
9
|
+
export interface ProcessEventUpdate<T> {
|
|
10
|
+
type: 'update';
|
|
11
|
+
data: T;
|
|
12
|
+
}
|
|
13
|
+
export interface ProcessEventClose {
|
|
14
|
+
type: 'close';
|
|
15
|
+
}
|
|
16
|
+
export interface ProcessEventDestroy {
|
|
17
|
+
type: 'destroy';
|
|
18
|
+
}
|
|
19
|
+
export type ProcessEvents<T, I> = ProcessEventOpen<T> | ProcessEventProcess<I> | ProcessEventUpdate<T> | ProcessEventClose | ProcessEventDestroy;
|
|
20
|
+
export interface ProcessWorkerEventError {
|
|
21
|
+
type: 'error';
|
|
22
|
+
error: Error;
|
|
23
|
+
}
|
|
24
|
+
export interface ProcessWorkerEventProcessed<T> {
|
|
25
|
+
type: 'processed';
|
|
26
|
+
data?: T;
|
|
27
|
+
}
|
|
28
|
+
export interface ProcessWorkerEventOpened {
|
|
29
|
+
type: 'opened';
|
|
30
|
+
}
|
|
31
|
+
export type ProcessWorkerEvents<T> = ProcessWorkerEventError | ProcessWorkerEventProcessed<T> | ProcessWorkerEventOpened;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SegmenterOptions, ImageSegmenterOptions } from './segmentation';
|
|
2
|
+
import type { VideoFrameLike, ImageRecord } from './media';
|
|
3
|
+
import type { RendererOptions } from './render';
|
|
4
|
+
import type { ProcessEvents, ProcessWorkerEvents } from './messageEvents';
|
|
5
|
+
export interface ProcessorOptions extends SegmenterOptions {
|
|
6
|
+
renderOptions?: RendererOptions;
|
|
7
|
+
backgroundImage?: ImageRecord;
|
|
8
|
+
}
|
|
9
|
+
export interface ProcessorProcessOptions {
|
|
10
|
+
videoFrame: VideoFrameLike;
|
|
11
|
+
imageSegmenterOptions?: ImageSegmenterOptions;
|
|
12
|
+
renderOptions?: RendererOptions;
|
|
13
|
+
}
|
|
14
|
+
export type ProcessorEvents = ProcessEvents<ProcessorOptions, ProcessorProcessOptions>;
|
|
15
|
+
export type ProcessorWorkerEvents = ProcessWorkerEvents<VideoFrameLike>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RenderEffects } from '../constants';
|
|
2
|
+
import type { MPMask } from './segmentation';
|
|
3
|
+
import type { VideoFrameLike, ImageRecord } from './media';
|
|
4
|
+
export interface RendererOptions {
|
|
5
|
+
backgroundImageUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Confident score threshold to be considered as the foreground between
|
|
8
|
+
* 0 and 1
|
|
9
|
+
* */
|
|
10
|
+
foregroundThreshold: number;
|
|
11
|
+
/**
|
|
12
|
+
* Between 0 and 10
|
|
13
|
+
*/
|
|
14
|
+
backgroundBlurAmount: number;
|
|
15
|
+
/**
|
|
16
|
+
* Range in between 0 and 20
|
|
17
|
+
* @defaultValue `3`
|
|
18
|
+
*/
|
|
19
|
+
edgeBlurAmount: number;
|
|
20
|
+
/**
|
|
21
|
+
* The ratio used for smoothing the mask between 0 and 1
|
|
22
|
+
*/
|
|
23
|
+
maskCombineRatio: number;
|
|
24
|
+
/**
|
|
25
|
+
* Effects
|
|
26
|
+
*/
|
|
27
|
+
effects: RenderEffects;
|
|
28
|
+
}
|
|
29
|
+
type Options = Partial<RendererOptions> & {
|
|
30
|
+
backgroundImage?: ImageRecord;
|
|
31
|
+
};
|
|
32
|
+
export interface Renderer {
|
|
33
|
+
init(options?: Options): void;
|
|
34
|
+
render(mask: MPMask, frame: VideoFrameLike, options?: RendererOptions): void;
|
|
35
|
+
update(options: Options): void;
|
|
36
|
+
release(): void;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|