@pexip/media-processor 22.0.0 → 22.2.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 +41 -0
- package/api-docs/README.mdx +4 -1
- package/api-docs/functions/avg.mdx +1 -1
- package/api-docs/functions/createAnalyzerGraphNode.mdx +3 -1
- package/api-docs/functions/createAnalyzerSubscribableGraphNode.mdx +3 -1
- package/api-docs/functions/createAsyncCallbackLoop.mdx +6 -6
- package/api-docs/functions/createAudioDestinationGraphNode.mdx +1 -1
- package/api-docs/functions/createAudioSignalDetector.mdx +4 -4
- package/api-docs/functions/createAudioStats.mdx +1 -1
- package/api-docs/functions/createBenchmark.mdx +7 -6
- package/api-docs/functions/createChannelMergerGraphNode.mdx +1 -1
- package/api-docs/functions/createChannelSplitterGraphNode.mdx +1 -1
- package/api-docs/functions/createDelayGraphNode.mdx +1 -1
- package/api-docs/functions/createDenoiseWorkletGraphNode.mdx +2 -2
- package/api-docs/functions/createFrameCallbackRequest.mdx +3 -3
- package/api-docs/functions/createGainGraphNode.mdx +3 -1
- package/api-docs/functions/createMediaElementSourceGraphNode.mdx +1 -1
- package/api-docs/functions/createReadWritableStreamFallbackInputProcessAdaptor.mdx +1 -1
- package/api-docs/functions/createSegmenter.mdx +1 -1
- package/api-docs/functions/createStreamDestinationGraphNode.mdx +1 -1
- package/api-docs/functions/createStreamSourceGraphNode.mdx +1 -1
- package/api-docs/functions/createVADetector.mdx +3 -3
- package/api-docs/functions/createVoiceDetectorFromProbability.mdx +1 -1
- package/api-docs/functions/createVoiceDetectorFromTimeData.mdx +3 -1
- package/api-docs/functions/createWindowedStats.mdx +2 -2
- package/api-docs/functions/getBezierCurveControlPoints.mdx +3 -1
- package/api-docs/functions/labelComponents.mdx +3 -1
- package/api-docs/functions/loadScript.mdx +1 -1
- package/api-docs/functions/loadWasms.mdx +1 -1
- package/api-docs/functions/nearestPowerOfTwo.mdx +1 -1
- package/api-docs/functions/playVideo.mdx +6 -4
- package/api-docs/functions/processAverageVolume.mdx +1 -1
- package/api-docs/functions/rms.mdx +1 -1
- package/api-docs/functions/subscribeWorkletNode.mdx +1 -1
- package/api-docs/functions/sum.mdx +1 -1
- package/api-docs/interfaces/AnalyzerSubscribableOptions.mdx +5 -3
- package/api-docs/interfaces/AudioGraph.mdx +2 -2
- package/api-docs/interfaces/AudioNodeInit.mdx +10 -6
- package/api-docs/interfaces/AudioNodeProps.mdx +3 -3
- package/api-docs/interfaces/Benchmark.mdx +3 -3
- package/api-docs/interfaces/Clock.mdx +1 -1
- package/api-docs/interfaces/Denoise.mdx +2 -2
- package/api-docs/interfaces/InputProcessAdaptor.mdx +6 -2
- package/api-docs/interfaces/MPMask.mdx +1 -1
- package/api-docs/interfaces/Process.mdx +5 -5
- package/api-docs/interfaces/ProcessWorkerDebugMessage.mdx +1 -1
- package/api-docs/interfaces/ProcessWorkerEventClosed.mdx +5 -0
- package/api-docs/interfaces/ProcessorEvent.mdx +2 -1
- package/api-docs/interfaces/ProcessorProcessOptions.mdx +2 -2
- package/api-docs/interfaces/ProcessorUpdateOptions.mdx +3 -1
- package/api-docs/interfaces/ReadWritableStream.mdx +2 -2
- package/api-docs/interfaces/RenderEventHandlers.mdx +3 -3
- package/api-docs/interfaces/Renderer.mdx +3 -1
- package/api-docs/interfaces/RendererOptions.mdx +5 -5
- package/api-docs/interfaces/Runner.mdx +3 -3
- package/api-docs/interfaces/Segmentation.mdx +1 -1
- package/api-docs/interfaces/Segmenter.mdx +39 -19
- package/api-docs/interfaces/VideoFrameLike.mdx +1 -1
- package/api-docs/interfaces/VideoProcessor.mdx +7 -7
- package/api-docs/interfaces/WorkletMessagePortOptions.mdx +2 -2
- package/api-docs/type-aliases/AsyncCallback.mdx +1 -1
- package/api-docs/type-aliases/Callback.mdx +2 -2
- package/api-docs/type-aliases/ExtractMessageEventType.mdx +1 -1
- package/api-docs/type-aliases/IncludeMessageEventDataType.mdx +1 -1
- package/api-docs/type-aliases/Logger.mdx +12 -0
- package/api-docs/type-aliases/OptionalKeys.mdx +1 -1
- package/api-docs/type-aliases/ProcessWorkerEvents.mdx +1 -0
- package/api-docs/type-aliases/RunnerCreator.mdx +3 -3
- package/api-docs/type-aliases/TupleOf.mdx +1 -1
- package/api-docs/variables/RENDER_BACKEND.mdx +1 -0
- package/api-docs/variables/cloneImageRecord.mdx +3 -1
- package/api-docs/variables/createLazyProps.mdx +1 -1
- package/api-docs/variables/createObjectUpdater.mdx +2 -2
- package/api-docs/variables/createRemoteImageBitmap.mdx +5 -5
- package/api-docs/variables/getCanUseWebGL.mdx +7 -0
- package/api-docs/variables/handleWebGLContextLoss.mdx +1 -1
- package/api-docs/variables/urls.mdx +2 -2
- package/dist/common/backends/canvas2d/renderer.d.ts +2 -0
- package/dist/common/backends/canvas2d/renderer.js +36 -0
- package/dist/common/backends/webgl/blur.d.ts +1 -1
- package/dist/common/backends/webgl/blur.js +11 -25
- package/dist/common/backends/webgl/renderer.js +4 -4
- package/dist/common/backends/webgpu/dualFilterBlur.js +93 -114
- package/dist/common/canvasRenderUtils.d.ts +23 -4
- package/dist/common/canvasRenderUtils.js +48 -11
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +1 -0
- package/dist/common/inferencer.d.ts +18 -0
- package/dist/common/inferencer.js +60 -0
- package/dist/common/tsconfig.tsbuildinfo +1 -1
- package/dist/common/types/messageEvents.d.ts +4 -1
- package/dist/common/types/processor.d.ts +1 -0
- package/dist/common/utils.d.ts +1 -0
- package/dist/common/utils.js +13 -0
- package/dist/main/audio.js +20 -2
- package/dist/main/benchUtils.d.ts +28 -18
- package/dist/main/benchUtils.js +66 -56
- package/dist/main/tsconfig.tsbuildinfo +1 -1
- package/dist/main/utils.d.ts +9 -0
- package/dist/main/utils.js +12 -0
- package/dist/main/video/segmenter.d.ts +8 -1
- package/dist/main/video/segmenter.js +44 -29
- package/dist/main/video/types.d.ts +1 -1
- package/dist/main/video/video.d.ts +1 -1
- package/dist/main/video/video.js +25 -12
- package/dist/workers/mediaWorker.js +23 -23
- package/dist/workers/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -9
|
@@ -4,7 +4,7 @@ Wrapper for a mask produced by a Segmentation Task.
|
|
|
4
4
|
|
|
5
5
|
| Property | Modifier | Type | Description |
|
|
6
6
|
| ------ | ------ | ------ | ------ |
|
|
7
|
-
| <a id="canvas"></a> `canvas` | `readonly` | `OffscreenCanvas
|
|
7
|
+
| <a id="canvas"></a> `canvas` | `readonly` | `OffscreenCanvas \| undefined` | Returns the canvas element that the mask is bound to. |
|
|
8
8
|
| <a id="width"></a> `width` | `readonly` | `number` | Returns the width of the mask. |
|
|
9
9
|
| <a id="height"></a> `height` | `readonly` | `number` | Returns the height of the mask. |
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
| Property | Type |
|
|
14
14
|
| ------ | ------ |
|
|
15
|
-
| <a id="status"></a> `status` |
|
|
15
|
+
| <a id="status"></a> `status` | `\| "closed" \| "closing" \| "Error" \| "destroyed" \| "destroying" \| "idle" \| "new" \| "opened" \| "opening" \| "processing" \| "updated" \| "updating"` |
|
|
16
16
|
|
|
17
17
|
## Methods
|
|
18
18
|
|
|
@@ -24,19 +24,19 @@ open(): Promise<T>;
|
|
|
24
24
|
|
|
25
25
|
#### Returns
|
|
26
26
|
|
|
27
|
-
`Promise
|
|
27
|
+
`Promise<T>`
|
|
28
28
|
|
|
29
29
|
***
|
|
30
30
|
|
|
31
31
|
### close()
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
|
-
close(): void
|
|
34
|
+
close(): Promise<void>;
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
#### Returns
|
|
38
38
|
|
|
39
|
-
`void
|
|
39
|
+
`Promise<void>`
|
|
40
40
|
|
|
41
41
|
***
|
|
42
42
|
|
|
@@ -48,4 +48,4 @@ destroy(): Promise<void>;
|
|
|
48
48
|
|
|
49
49
|
#### Returns
|
|
50
50
|
|
|
51
|
-
`Promise
|
|
51
|
+
`Promise<void>`
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
| Property | Type |
|
|
4
4
|
| ------ | ------ |
|
|
5
|
-
| <a id="type"></a> `type` |
|
|
5
|
+
| <a id="type"></a> `type` | `\| "Error" \| "ContextCreationError" \| "ContextLost" \| "ContextRestored" \| "ProcessorRestarted" \| "SamplingError"` |
|
|
6
|
+
| <a id="error"></a> `error?` | `Error` |
|
|
6
7
|
| <a id="message"></a> `message?` | `string` |
|
|
7
8
|
| <a id="track"></a> `track?` | `MediaStreamTrack` |
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
| Property | Type |
|
|
4
4
|
| ------ | ------ |
|
|
5
5
|
| <a id="track"></a> `track?` | `MediaStreamTrack` |
|
|
6
|
-
| <a id="readable"></a> `readable?` | `ReadableStream
|
|
7
|
-
| <a id="writable"></a> `writable?` | `WritableStream
|
|
6
|
+
| <a id="readable"></a> `readable?` | `ReadableStream<VideoFrame>` |
|
|
7
|
+
| <a id="writable"></a> `writable?` | `WritableStream<VideoFrame>` |
|
|
8
8
|
| <a id="renderoptions"></a> `renderOptions?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
|
|
9
9
|
| Property | Type |
|
|
10
10
|
| ------ | ------ |
|
|
11
|
-
| <a id="readable"></a> `readable` | `ReadableStream
|
|
12
|
-
| <a id="writable"></a> `writable` | `WritableStream
|
|
11
|
+
| <a id="readable"></a> `readable` | `ReadableStream<T>` |
|
|
12
|
+
| <a id="writable"></a> `writable` | `WritableStream<T>` |
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
| Property | Type |
|
|
4
4
|
| ------ | ------ |
|
|
5
|
-
| <a id="contextlost"></a> `contextLost` | (
|
|
6
|
-
| <a id="contextrestored"></a> `contextRestored` | (
|
|
7
|
-
| <a id="contextcreationerror"></a> `contextCreationError` | (
|
|
5
|
+
| <a id="contextlost"></a> `contextLost` | `(message) => void` |
|
|
6
|
+
| <a id="contextrestored"></a> `contextRestored` | `(message) => void` |
|
|
7
|
+
| <a id="contextcreationerror"></a> `contextCreationError` | `(message) => void` |
|
|
@@ -8,16 +8,16 @@ All values are stable per-frame and can be safely updated in real-time.
|
|
|
8
8
|
| <a id="backgroundimageurl"></a> `backgroundImageUrl` | `string` | URL or Data URI for the virtual background image (used in "overlay" effect). |
|
|
9
9
|
| <a id="backgroundbluramount"></a> `backgroundBlurAmount` | `number` | Amount of background blur (radius in px): [0,9]. Recommend: 3–6 for portraits. Higher may be slow and over-blurred. **Default** `3` |
|
|
10
10
|
| <a id="edgebluramount"></a> `edgeBlurAmount` | `number` | Edge blur for mask boundary antialiasing (radius in px): [0,9]. Small values (1–5) smooth mask stair-steps; large values soften edges more visibly. **Default** `4` |
|
|
11
|
-
| <a id="effects"></a> `effects` | `"blur"
|
|
12
|
-
| <a id="backend"></a> `backend` | `"webgl"
|
|
13
|
-
| <a id="foregroundthreshold"></a> `foregroundThreshold` | `number` | [0,1] Upper mask confidence: all mask pixels
|
|
14
|
-
| <a id="backgroundthreshold"></a> `backgroundThreshold` | `number` | [0,1] Lower mask confidence: all mask pixels
|
|
11
|
+
| <a id="effects"></a> `effects` | `"blur" \| "none" \| "overlay"` | Effects to apply: "none", "blur", or "overlay". "blur" = background blur. "overlay" = replace BG with backgroundImageUrl. |
|
|
12
|
+
| <a id="backend"></a> `backend` | `"webgl" \| "webgpu" \| "canvas2d"` | Backend to render background effects |
|
|
13
|
+
| <a id="foregroundthreshold"></a> `foregroundThreshold` | `number` | [0,1] Upper mask confidence: all mask pixels \>= this are considered definite foreground. Adjust to make mask edges tighter or more permissive for foreground inclusion. Example: 0.8 ("mask \> 0.8 = sure foreground"). Must always be \>= backgroundThreshold. **Default** `0.85` |
|
|
14
|
+
| <a id="backgroundthreshold"></a> `backgroundThreshold` | `number` | [0,1] Lower mask confidence: all mask pixels \<= this are considered definite background. Adjust to make mask edges tighter or more permissive for background inclusion. Example: 0.3 ("mask \< 0.3 = sure background"). **Default** `0.35` |
|
|
15
15
|
| <a id="sigmaspace"></a> `sigmaSpace` | `number` | Bilateral filter: sigma in pixel space for mask edge snapping. Controls the neighborhood/pixel distance—higher is larger window (5–10 typical). **Default** `5` |
|
|
16
16
|
| <a id="sigmarangelo"></a> `sigmaRangeLo` | `number` | Bilateral filter: minimum sigma in color/luma (for mask interiors), [0,1]. Controls how little color difference is needed to cross-mask regions away from edge. Lower = sharper edge preservation in mask interiors. Example: 0.2 **Default** `0.2` |
|
|
17
17
|
| <a id="sigmarangehi"></a> `sigmaRangeHi` | `number` | Bilateral filter: maximum sigma in color/luma (for mask uncertain zones), [0,1]. Controls how much color similarity is required at uncertain/edge mask locations. Higher = more mask smoothing at edges. Example: 0.8 **Default** `0.8` |
|
|
18
18
|
| <a id="maskcombineratio"></a> `maskCombineRatio` | `number` | Ratio for mask smoothing (how much uncertainty enables temporal blend), [0,1]. Higher = more frame-to-frame blending, more stability but more trailing ghosts. Typical: 0.6–0.85. **Default** `0.8` |
|
|
19
19
|
| <a id="excludebystanders"></a> `excludeBystanders` | `boolean` | **`Experimental`** Whether to exclude bystanders/connected people from the output mask. The main person instance (closest to personCenter OR largest blob) is kept in the output mask. All other bystanders/connected people are suppressed (bystander removal). **Default** `false (no bystander removal, all detected people are included in the mask). @experimental This feature is experimental and only works in WebGL backend.` |
|
|
20
|
-
| <a id="personcenter"></a> `personCenter` |
|
|
20
|
+
| <a id="personcenter"></a> `personCenter` | `[number, number]` | **`Experimental`** Person center: normalized (x, y) in [0,1] image coordinates for main subject selection. Used by the CCL/bias filter to select the main person blob. **Default** `[0.5, 0.42] (= center, slightly above vertical midpoint). @experimental This feature is experimental and only works in WebGL backend.` |
|
|
21
21
|
| <a id="morpheroderadiuspx"></a> `morphErodeRadiusPx` | `number` | **`Experimental`** Morphological erosion: radius in pixels [1,12]. Sets kernel size for bridge-breaking. Larger values break thicker bridges but may erode fine details. **Default** `5 @experimental This feature is experimental and only works in WebGL backend.` |
|
|
22
22
|
| <a id="morphpass"></a> `morphPass` | `number` | **`Experimental`** Morphological pass: number of separable passes [1,10]. More passes increase the effective span. **Default** `4 @experimental This feature is experimental and only works in WebGL backend.` |
|
|
23
23
|
| <a id="morphdilateradiuspx"></a> `morphDilateRadiusPx` | `number` | **`Experimental`** Geodesic dilation: radius in pixels [1,12]. Must match erosion for good reconstruction. **Default** `6 @experimental This feature is experimental and only works in WebGL backend.` |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
| Type Parameter |
|
|
4
4
|
| ------ |
|
|
5
|
-
| `P
|
|
5
|
+
| `P extends unknown[]` |
|
|
6
6
|
|
|
7
7
|
## Properties
|
|
8
8
|
|
|
@@ -22,11 +22,11 @@ start(...params): Promise<void>;
|
|
|
22
22
|
|
|
23
23
|
| Parameter | Type |
|
|
24
24
|
| ------ | ------ |
|
|
25
|
-
|
|
|
25
|
+
| `...params` | `P` |
|
|
26
26
|
|
|
27
27
|
#### Returns
|
|
28
28
|
|
|
29
|
-
`Promise
|
|
29
|
+
`Promise<void>`
|
|
30
30
|
|
|
31
31
|
***
|
|
32
32
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
## Extends
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```ts
|
|
4
|
+
- Process<Partial<RendererOptions>>
|
|
5
|
+
```
|
|
4
6
|
|
|
5
7
|
## Properties
|
|
6
8
|
|
|
7
9
|
| Property | Type | Inherited from |
|
|
8
10
|
| ------ | ------ | ------ |
|
|
9
|
-
| <a id="status"></a> `status` |
|
|
11
|
+
| <a id="status"></a> `status` | `\| "closed" \| "closing" \| "Error" \| "destroyed" \| "destroying" \| "idle" \| "new" \| "opened" \| "opening" \| "processing" \| "updated" \| "updating"` | [`Process`](Process.mdx).[`status`](Process.mdx#status) |
|
|
10
12
|
| <a id="modelasset"></a> `modelAsset` | [`SegmentationModelAsset`](SegmentationModelAsset.mdx) | - |
|
|
11
13
|
| <a id="backgroundimage"></a> `backgroundImage?` | [`BackgroundImage`](BackgroundImage.mdx) | - |
|
|
12
14
|
|
|
@@ -15,12 +17,12 @@
|
|
|
15
17
|
### close()
|
|
16
18
|
|
|
17
19
|
```ts
|
|
18
|
-
close(): void
|
|
20
|
+
close(): Promise<void>;
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
#### Returns
|
|
22
24
|
|
|
23
|
-
`void
|
|
25
|
+
`Promise<void>`
|
|
24
26
|
|
|
25
27
|
#### Inherited from
|
|
26
28
|
|
|
@@ -36,7 +38,7 @@ destroy(): Promise<void>;
|
|
|
36
38
|
|
|
37
39
|
#### Returns
|
|
38
40
|
|
|
39
|
-
`Promise
|
|
41
|
+
`Promise<void>`
|
|
40
42
|
|
|
41
43
|
#### Inherited from
|
|
42
44
|
|
|
@@ -61,7 +63,9 @@ It is expected to be called once.
|
|
|
61
63
|
|
|
62
64
|
#### Returns
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
```ts
|
|
67
|
+
Promise<Partial<RendererOptions>>
|
|
68
|
+
```
|
|
65
69
|
|
|
66
70
|
#### Overrides
|
|
67
71
|
|
|
@@ -85,7 +89,9 @@ Update the processor options
|
|
|
85
89
|
|
|
86
90
|
#### Returns
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
```ts
|
|
93
|
+
Promise<Partial<RendererOptions>>
|
|
94
|
+
```
|
|
89
95
|
|
|
90
96
|
***
|
|
91
97
|
|
|
@@ -128,7 +134,7 @@ Process provided input
|
|
|
128
134
|
|
|
129
135
|
##### Returns
|
|
130
136
|
|
|
131
|
-
`Promise
|
|
137
|
+
`Promise<MediaStreamTrack>`
|
|
132
138
|
|
|
133
139
|
#### Call Signature
|
|
134
140
|
|
|
@@ -142,14 +148,20 @@ process(input, options?): Promise<
|
|
|
142
148
|
|
|
143
149
|
| Parameter | Type |
|
|
144
150
|
| ------ | ------ |
|
|
145
|
-
| `input` | [`ReadWritableStream
|
|
151
|
+
| `input` | [`ReadWritableStream<VideoFrame>`](ReadWritableStream.mdx) |
|
|
146
152
|
| `options?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
147
153
|
|
|
148
154
|
##### Returns
|
|
149
155
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
```ts
|
|
157
|
+
Promise<
|
|
158
|
+
```
|
|
159
|
+
```ts
|
|
160
|
+
| ReadWritableStream<VideoFrame>
|
|
161
|
+
```
|
|
162
|
+
```ts
|
|
163
|
+
| undefined>
|
|
164
|
+
```
|
|
153
165
|
|
|
154
166
|
#### Call Signature
|
|
155
167
|
|
|
@@ -164,15 +176,23 @@ process(input, options?): Promise<
|
|
|
164
176
|
|
|
165
177
|
| Parameter | Type |
|
|
166
178
|
| ------ | ------ |
|
|
167
|
-
| `input` | \| `MediaStreamTrack` \| [`ReadWritableStream
|
|
179
|
+
| `input` | \| `MediaStreamTrack` \| [`ReadWritableStream<VideoFrame>`](ReadWritableStream.mdx) |
|
|
168
180
|
| `options?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
169
181
|
|
|
170
182
|
##### Returns
|
|
171
183
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
184
|
+
```ts
|
|
185
|
+
Promise<
|
|
186
|
+
```
|
|
187
|
+
```ts
|
|
188
|
+
| MediaStreamTrack
|
|
189
|
+
```
|
|
190
|
+
```ts
|
|
191
|
+
| ReadWritableStream<VideoFrame>
|
|
192
|
+
```
|
|
193
|
+
```ts
|
|
194
|
+
| undefined>
|
|
195
|
+
```
|
|
176
196
|
|
|
177
197
|
***
|
|
178
198
|
|
|
@@ -188,8 +208,8 @@ Subscribe rendering events,
|
|
|
188
208
|
|
|
189
209
|
| Parameter | Type |
|
|
190
210
|
| ------ | ------ |
|
|
191
|
-
| `event` |
|
|
192
|
-
| `callback` | `Callback
|
|
211
|
+
| `event` | `\| "Error" \| "ContextCreationError" \| "ContextLost" \| "ContextRestored" \| "ProcessorRestarted" \| "SamplingError"` |
|
|
212
|
+
| `callback` | `Callback<void>` |
|
|
193
213
|
|
|
194
214
|
#### Returns
|
|
195
215
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
| Property | Type |
|
|
4
4
|
| ------ | ------ |
|
|
5
|
-
| <a id="frame"></a> `frame` | `ImageBitmap
|
|
5
|
+
| <a id="frame"></a> `frame` | `ImageBitmap \| VideoFrame` |
|
|
6
6
|
| <a id="timestamp"></a> `timestamp` | `number` |
|
|
7
7
|
| <a id="width"></a> `width` | `number` |
|
|
8
8
|
| <a id="height"></a> `height` | `number` |
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
| Property | Modifier | Type | Description |
|
|
4
4
|
| ------ | ------ | ------ | ------ |
|
|
5
|
-
| <a id="status"></a> `status` | `readonly` |
|
|
6
|
-
| <a id="process"></a> `process` | `public` | (
|
|
7
|
-
| <a id="destroy"></a> `destroy` | `public` | () =>
|
|
5
|
+
| <a id="status"></a> `status` | `readonly` | `\| "closed" \| "closing" \| "Error" \| "destroyed" \| "destroying" \| "idle" \| "new" \| "opened" \| "opening" \| "processing" \| "updated" \| "updating"` | - |
|
|
6
|
+
| <a id="process"></a> `process` | `public` | `(source) => Promise<MediaStreamTrack>` | Process the video and return a MediaStream |
|
|
7
|
+
| <a id="destroy"></a> `destroy` | `public` | `() => Promise<void>` | Destroy the segmentation wasm instance |
|
|
8
8
|
| <a id="renderoptions"></a> `renderOptions` | `readonly` | [`RendererOptions`](RendererOptions.mdx) | Current renderer options |
|
|
9
9
|
| <a id="processingwidth"></a> `processingWidth` | `readonly` | `number` | Current processing width |
|
|
10
10
|
| <a id="processingheight"></a> `processingHeight` | `readonly` | `number` | Current processing height |
|
|
@@ -27,7 +27,7 @@ Initialize the video processor and related
|
|
|
27
27
|
|
|
28
28
|
#### Returns
|
|
29
29
|
|
|
30
|
-
`Promise
|
|
30
|
+
`Promise<void>`
|
|
31
31
|
|
|
32
32
|
***
|
|
33
33
|
|
|
@@ -47,7 +47,7 @@ Update the video processor with provided options
|
|
|
47
47
|
|
|
48
48
|
#### Returns
|
|
49
49
|
|
|
50
|
-
`Promise
|
|
50
|
+
`Promise<void>`
|
|
51
51
|
|
|
52
52
|
***
|
|
53
53
|
|
|
@@ -72,11 +72,11 @@ mute(muted): void;
|
|
|
72
72
|
### close()
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
|
-
close(): void
|
|
75
|
+
close(): Promise<void>;
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
Stop the process of video segmentation
|
|
79
79
|
|
|
80
80
|
#### Returns
|
|
81
81
|
|
|
82
|
-
`void
|
|
82
|
+
`Promise<void>`
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
|
|
13
13
|
| Property | Type |
|
|
14
14
|
| ------ | ------ |
|
|
15
|
-
| <a id="messagehandler"></a> `messageHandler` | (
|
|
16
|
-
| <a id="errorhandler"></a> `errorHandler?` | (
|
|
15
|
+
| <a id="messagehandler"></a> `messageHandler` | `(message) => void` |
|
|
16
|
+
| <a id="errorhandler"></a> `errorHandler?` | `(event) => void` |
|
|
@@ -7,13 +7,13 @@ type Callback<R, T> = (...params) => R;
|
|
|
7
7
|
| Type Parameter |
|
|
8
8
|
| ------ |
|
|
9
9
|
| `R` |
|
|
10
|
-
| `T
|
|
10
|
+
| `T extends unknown[]` |
|
|
11
11
|
|
|
12
12
|
## Parameters
|
|
13
13
|
|
|
14
14
|
| Parameter | Type |
|
|
15
15
|
| ------ | ------ |
|
|
16
|
-
|
|
|
16
|
+
| `...params` | `T` |
|
|
17
17
|
|
|
18
18
|
## Returns
|
|
19
19
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
type Logger = object;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
| Property | Type |
|
|
8
|
+
| ------ | ------ |
|
|
9
|
+
| <a id="debug"></a> `debug` | `LogMethod` |
|
|
10
|
+
| <a id="info"></a> `info` | `LogMethod` |
|
|
11
|
+
| <a id="warn"></a> `warn` | `LogMethod` |
|
|
12
|
+
| <a id="error"></a> `error` | `LogMethod` |
|
|
@@ -6,16 +6,16 @@ type RunnerCreator<P, R> = (callback, frameRate) => Runner<P>;
|
|
|
6
6
|
|
|
7
7
|
| Type Parameter |
|
|
8
8
|
| ------ |
|
|
9
|
-
| `P
|
|
9
|
+
| `P extends unknown[]` |
|
|
10
10
|
| `R` |
|
|
11
11
|
|
|
12
12
|
## Parameters
|
|
13
13
|
|
|
14
14
|
| Parameter | Type |
|
|
15
15
|
| ------ | ------ |
|
|
16
|
-
| `callback` | [`Callback
|
|
16
|
+
| `callback` | [`Callback<R, P>`](Callback.mdx) |
|
|
17
17
|
| `frameRate` | `number` |
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
|
-
[`Runner
|
|
21
|
+
[`Runner<P>`](../interfaces/Runner.mdx)
|
|
@@ -6,7 +6,7 @@ const createObjectUpdater: <T>(original) => (another) => void;
|
|
|
6
6
|
|
|
7
7
|
| Type Parameter |
|
|
8
8
|
| ------ |
|
|
9
|
-
| `T
|
|
9
|
+
| `T extends { [K in keyof T]: unknown }` |
|
|
10
10
|
|
|
11
11
|
## Parameters
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@ const createObjectUpdater: <T>(original) => (another) => void;
|
|
|
24
24
|
|
|
25
25
|
| Parameter | Type |
|
|
26
26
|
| ------ | ------ |
|
|
27
|
-
| `another` | `Partial
|
|
27
|
+
| `another` | `Partial<T>` |
|
|
28
28
|
|
|
29
29
|
### Returns
|
|
30
30
|
|
|
@@ -14,8 +14,8 @@ const createRemoteImageBitmap: (map?) => object;
|
|
|
14
14
|
|
|
15
15
|
| Name | Type |
|
|
16
16
|
| ------ | ------ |
|
|
17
|
-
| `tryFetchingImage()` | (
|
|
18
|
-
| `setImage()` | (
|
|
19
|
-
| `getImage()` | (
|
|
20
|
-
| `removeImage()` | (
|
|
21
|
-
| `clear()` | () =>
|
|
17
|
+
| `tryFetchingImage()` | `(uri, abortSignal) => Promise<ImageBitmap` | null | undefined\>` |
|
|
18
|
+
| `setImage()` | `(uri, image) => void` |
|
|
19
|
+
| `getImage()` | `(uri) => ImageBitmap \| null` |
|
|
20
|
+
| `removeImage()` | `(uri) => boolean` |
|
|
21
|
+
| `clear()` | `() => void` |
|
|
@@ -8,7 +8,7 @@ const handleWebGLContextLoss: (canvas, eventHandlers, contextLostCb?) => () => v
|
|
|
8
8
|
| ------ | ------ |
|
|
9
9
|
| `canvas` | `OffscreenCanvas` |
|
|
10
10
|
| `eventHandlers` | [`RenderEventHandlers`](../interfaces/RenderEventHandlers.mdx) |
|
|
11
|
-
| `contextLostCb?` | () =>
|
|
11
|
+
| `contextLostCb?` | `() => void` |
|
|
12
12
|
|
|
13
13
|
## Returns
|
|
14
14
|
|
|
@@ -6,5 +6,5 @@ const urls: object;
|
|
|
6
6
|
|
|
7
7
|
| Name | Type |
|
|
8
8
|
| ------ | ------ |
|
|
9
|
-
| <a id="denoise"></a> `denoise()` | () =>
|
|
10
|
-
| <a id="mediaworker"></a> `mediaWorker()` | () =>
|
|
9
|
+
| <a id="denoise"></a> `denoise()` | `() => URL` |
|
|
10
|
+
| <a id="mediaworker"></a> `mediaWorker()` | `() => URL` |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PROCESSING_HEIGHT, PROCESSING_WIDTH } from '../../constants';
|
|
2
|
+
import { createCanvasRenderUtils } from '../../canvasRenderUtils';
|
|
3
|
+
export const createRenderer = (renderEventHandlers, canvas = new OffscreenCanvas(PROCESSING_WIDTH, PROCESSING_HEIGHT)) => {
|
|
4
|
+
const utils = createCanvasRenderUtils(canvas.width, canvas.height);
|
|
5
|
+
let ctx = null;
|
|
6
|
+
const init = () => {
|
|
7
|
+
ctx = canvas.getContext('2d');
|
|
8
|
+
if (!ctx) {
|
|
9
|
+
renderEventHandlers.contextCreationError('Failed to create 2D rendering context');
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const render = (mask, frame, options) => {
|
|
13
|
+
if (!ctx) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
17
|
+
const inputImage = utils.evaluateInput(frame);
|
|
18
|
+
if (options.effects === 'blur' && options.backgroundBlurAmount) {
|
|
19
|
+
utils.drawBlurEffect(canvas, inputImage, mask, options.foregroundThreshold, options.backgroundBlurAmount, options.edgeBlurAmount);
|
|
20
|
+
}
|
|
21
|
+
else if (options?.effects === 'overlay' && options.backgroundImage) {
|
|
22
|
+
utils.drawOverlayEffect(canvas, inputImage, options.backgroundImage, mask, options.foregroundThreshold, 0, options.edgeBlurAmount);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const cleanup = () => {
|
|
26
|
+
utils.reset();
|
|
27
|
+
ctx = null;
|
|
28
|
+
};
|
|
29
|
+
const release = () => {
|
|
30
|
+
cleanup();
|
|
31
|
+
};
|
|
32
|
+
const isContextLost = () => {
|
|
33
|
+
return !ctx || ctx.isContextLost();
|
|
34
|
+
};
|
|
35
|
+
return { init, render, release, isContextLost };
|
|
36
|
+
};
|
|
@@ -2,7 +2,7 @@ import type { TextureInfo } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Blur provided frame
|
|
4
4
|
*/
|
|
5
|
-
export declare const createBlurRenderer: (processor: OffscreenCanvas,
|
|
5
|
+
export declare const createBlurRenderer: (processor: OffscreenCanvas, redOnly?: boolean) => {
|
|
6
6
|
render: (frame: TextureInfo, pass: number) => TextureInfo;
|
|
7
7
|
release: () => void;
|
|
8
8
|
};
|