@pexip/media-processor 21.0.0 → 22.1.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 +80 -0
- package/README.md +17 -10
- package/api-docs/README.mdx +40 -19
- package/api-docs/functions/assertMediaStreamVideoTrack.mdx +13 -0
- 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/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 +10 -4
- package/api-docs/functions/createGainGraphNode.mdx +3 -1
- package/api-docs/functions/createMediaElementSourceGraphNode.mdx +1 -1
- package/api-docs/functions/createMediaStreamTrackInputProcessAdaptor.mdx +10 -0
- package/api-docs/functions/createReadWritableStreamFallbackInputProcessAdaptor.mdx +17 -0
- package/api-docs/functions/createReadWritableStreamInputProcessAdaptor.mdx +10 -0
- 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/createVideoProcessor.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/getDefaultInputProcessAdaptor.mdx +17 -0
- package/api-docs/functions/isMediaStreamVideoTrack.mdx +13 -0
- 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 +7 -5
- 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/Analyzer.mdx +4 -0
- 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 +17 -3
- package/api-docs/interfaces/Clock.mdx +1 -1
- package/api-docs/interfaces/Denoise.mdx +2 -2
- package/api-docs/interfaces/FrameTransformStats.mdx +9 -0
- package/api-docs/interfaces/Gain.mdx +4 -0
- package/api-docs/interfaces/ImageSegmenterOptions.mdx +0 -2
- package/api-docs/interfaces/InputProcessAdaptor.mdx +32 -0
- package/api-docs/interfaces/MPMask.mdx +1 -1
- package/api-docs/interfaces/Process.mdx +12 -7
- package/api-docs/interfaces/ProcessEventMute.mdx +6 -0
- package/api-docs/interfaces/ProcessWorkerDebugMessage.mdx +1 -1
- package/api-docs/interfaces/ProcessWorkerEventClosed.mdx +5 -0
- package/api-docs/interfaces/ProcessWorkerEventOpened.mdx +7 -0
- package/api-docs/interfaces/ProcessWorkerEventStats.mdx +6 -0
- package/api-docs/interfaces/ProcessWorkerEventUpdated.mdx +7 -0
- package/api-docs/interfaces/ProcessorEvent.mdx +3 -2
- package/api-docs/interfaces/ProcessorOptions.mdx +0 -1
- package/api-docs/interfaces/ProcessorProcessOptions.mdx +3 -1
- package/api-docs/interfaces/ProcessorUpdateOptions.mdx +17 -0
- package/api-docs/interfaces/ReadWritableStream.mdx +12 -0
- package/api-docs/interfaces/RenderEventHandlers.mdx +3 -3
- package/api-docs/interfaces/Renderer.mdx +5 -3
- package/api-docs/interfaces/RendererOptions.mdx +5 -9
- package/api-docs/interfaces/Runner.mdx +3 -3
- package/api-docs/interfaces/Segmentation.mdx +1 -1
- package/api-docs/interfaces/Segmenter.mdx +115 -16
- package/api-docs/interfaces/SegmenterOptions.mdx +0 -1
- package/api-docs/interfaces/VideoFrameLike.mdx +1 -1
- package/api-docs/interfaces/VideoProcessor.mdx +52 -8
- 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/ProcessEvents.mdx +1 -0
- package/api-docs/type-aliases/ProcessInputType.mdx +3 -1
- package/api-docs/type-aliases/ProcessWorkerEvents.mdx +7 -4
- package/api-docs/type-aliases/ProcessorWorkerEvents.mdx +1 -1
- package/api-docs/type-aliases/RunnerCreator.mdx +3 -3
- package/api-docs/type-aliases/Struct.mdx +9 -0
- package/api-docs/type-aliases/TupleOf.mdx +1 -1
- package/api-docs/variables/FRAME_RATE.mdx +1 -1
- package/api-docs/variables/ImageFetchError.mdx +3 -0
- package/api-docs/variables/MediaStreamTrackTransferable.mdx +5 -0
- package/api-docs/variables/RENDERER_OPTIONS_STRUCT.mdx +3 -0
- package/api-docs/variables/cloneImageRecord.mdx +21 -0
- package/api-docs/variables/compareImageRecords.mdx +18 -0
- 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/handleWebGLContextLoss.mdx +1 -1
- package/api-docs/variables/isRenderOptionsKey.mdx +13 -0
- package/api-docs/variables/isValidGpuAPI.mdx +13 -0
- package/api-docs/variables/urls.mdx +2 -2
- package/dist/common/backends/webgl/renderer.js +2 -12
- package/dist/common/backends/webgl/texture.d.ts +1 -2
- package/dist/common/backends/webgl/texture.js +2 -2
- package/dist/common/backends/webgl/webglUtils.js +8 -4
- package/dist/common/backends/webgpu/renderer.js +2 -12
- package/dist/common/backends/webgpu/tentBlur.js +1 -1
- package/dist/common/backends/webgpu/texture.d.ts +1 -2
- package/dist/common/backends/webgpu/texture.js +6 -2
- package/dist/common/constants.d.ts +3 -0
- package/dist/common/constants.js +4 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -0
- package/dist/common/tsconfig.tsbuildinfo +1 -1
- package/dist/common/typeGuards.d.ts +2 -0
- package/dist/common/typeGuards.js +7 -0
- package/dist/common/types/media.d.ts +5 -1
- package/dist/common/types/messageEvents.d.ts +34 -4
- package/dist/common/types/processor.d.ts +7 -4
- package/dist/common/types/render.d.ts +5 -2
- package/dist/common/types/render.js +23 -1
- package/dist/common/types/segmentation.d.ts +0 -12
- package/dist/common/utils.d.ts +13 -2
- package/dist/common/utils.js +54 -10
- package/dist/main/audio.js +3 -3
- package/dist/main/benchUtils.d.ts +2 -2
- package/dist/main/benchUtils.js +4 -4
- package/dist/main/index.d.ts +1 -1
- package/dist/main/index.js +1 -1
- package/dist/main/tsconfig.tsbuildinfo +1 -1
- package/dist/main/types.d.ts +0 -6
- package/dist/main/utils.d.ts +4 -0
- package/dist/main/utils.js +31 -0
- package/dist/main/video/constants.d.ts +1 -4
- package/dist/main/video/constants.js +1 -5
- package/dist/main/video/index.d.ts +2 -3
- package/dist/main/video/index.js +2 -3
- package/dist/main/video/inputProcessAdaptor.d.ts +30 -0
- package/dist/main/video/inputProcessAdaptor.js +198 -0
- package/dist/main/video/segmenter.d.ts +42 -0
- package/dist/main/video/{segmenters/mediapipe.js → segmenter.js} +130 -75
- package/dist/main/video/typeGuards.d.ts +2 -0
- package/dist/main/video/typeGuards.js +8 -1
- package/dist/main/video/types.d.ts +37 -17
- package/dist/main/video/utils.d.ts +5 -4
- package/dist/main/video/utils.js +49 -44
- package/dist/main/video/video.d.ts +30 -8
- package/dist/main/video/video.js +338 -32
- package/dist/workers/mediaWorker.js +24 -24
- package/dist/workers/tsconfig.tsbuildinfo +1 -1
- package/dist/worklets/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/api-docs/functions/createCanvasTransform.mdx +0 -14
- package/api-docs/functions/createVideoTrackProcessor.mdx +0 -9
- package/api-docs/functions/createVideoTrackProcessorWithFallback.mdx +0 -15
- package/api-docs/interfaces/Detector.mdx +0 -81
- package/api-docs/interfaces/SegmentationParams.mdx +0 -35
- package/api-docs/interfaces/Transform.mdx +0 -62
- package/api-docs/type-aliases/ProcessVideoTrack.mdx +0 -15
- package/api-docs/type-aliases/SegmentationTransform.mdx +0 -3
- package/dist/main/transformer.d.ts +0 -1
- package/dist/main/transformer.js +0 -4
- package/dist/main/video/canvasTransform.d.ts +0 -17
- package/dist/main/video/canvasTransform.js +0 -341
- package/dist/main/video/segmenters/mediapipe.d.ts +0 -22
- package/dist/main/video/transformer.d.ts +0 -9
- package/dist/main/video/transformer.js +0 -68
- package/dist/main/video/videoStreamTrackProcessor.d.ts +0 -20
- package/dist/main/video/videoStreamTrackProcessor.js +0 -86
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
Options controlling the rendering and effects for person/background segmentation.
|
|
2
2
|
All values are stable per-frame and can be safely updated in real-time.
|
|
3
3
|
|
|
4
|
-
## Extended by
|
|
5
|
-
|
|
6
|
-
- [`SegmentationParams`](SegmentationParams.mdx)
|
|
7
|
-
|
|
8
4
|
## Properties
|
|
9
5
|
|
|
10
6
|
| Property | Type | Description |
|
|
@@ -12,16 +8,16 @@ All values are stable per-frame and can be safely updated in real-time.
|
|
|
12
8
|
| <a id="backgroundimageurl"></a> `backgroundImageUrl` | `string` | URL or Data URI for the virtual background image (used in "overlay" effect). |
|
|
13
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` |
|
|
14
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` |
|
|
15
|
-
| <a id="effects"></a> `effects` | `"blur"
|
|
16
|
-
| <a id="backend"></a> `backend` | `"webgl"
|
|
17
|
-
| <a id="foregroundthreshold"></a> `foregroundThreshold` | `number` | [0,1] Upper mask confidence: all mask pixels
|
|
18
|
-
| <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"` | 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` |
|
|
19
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` |
|
|
20
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` |
|
|
21
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` |
|
|
22
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` |
|
|
23
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.` |
|
|
24
|
-
| <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.` |
|
|
25
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.` |
|
|
26
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.` |
|
|
27
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
|
|
|
@@ -47,9 +49,12 @@ destroy(): Promise<void>;
|
|
|
47
49
|
### open()
|
|
48
50
|
|
|
49
51
|
```ts
|
|
50
|
-
open(options?): Promise<
|
|
52
|
+
open(options?): Promise<Partial<RendererOptions>>;
|
|
51
53
|
```
|
|
52
54
|
|
|
55
|
+
Initialize the Segmenter as well as the underlying worker.
|
|
56
|
+
It is expected to be called once.
|
|
57
|
+
|
|
53
58
|
#### Parameters
|
|
54
59
|
|
|
55
60
|
| Parameter | Type |
|
|
@@ -58,7 +63,9 @@ open(options?): Promise<void>;
|
|
|
58
63
|
|
|
59
64
|
#### Returns
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
```ts
|
|
67
|
+
Promise<Partial<RendererOptions>>
|
|
68
|
+
```
|
|
62
69
|
|
|
63
70
|
#### Overrides
|
|
64
71
|
|
|
@@ -69,9 +76,11 @@ open(options?): Promise<void>;
|
|
|
69
76
|
### update()
|
|
70
77
|
|
|
71
78
|
```ts
|
|
72
|
-
update(options): Promise<
|
|
79
|
+
update(options): Promise<Partial<RendererOptions>>;
|
|
73
80
|
```
|
|
74
81
|
|
|
82
|
+
Update the processor options
|
|
83
|
+
|
|
75
84
|
#### Parameters
|
|
76
85
|
|
|
77
86
|
| Parameter | Type |
|
|
@@ -80,26 +89,110 @@ update(options): Promise<void>;
|
|
|
80
89
|
|
|
81
90
|
#### Returns
|
|
82
91
|
|
|
83
|
-
|
|
92
|
+
```ts
|
|
93
|
+
Promise<Partial<RendererOptions>>
|
|
94
|
+
```
|
|
84
95
|
|
|
85
96
|
***
|
|
86
97
|
|
|
87
|
-
###
|
|
98
|
+
### mute()
|
|
88
99
|
|
|
89
100
|
```ts
|
|
90
|
-
|
|
101
|
+
mute(muted): void;
|
|
91
102
|
```
|
|
92
103
|
|
|
104
|
+
Mute/unmute the track in the worker
|
|
105
|
+
|
|
93
106
|
#### Parameters
|
|
94
107
|
|
|
95
108
|
| Parameter | Type |
|
|
96
109
|
| ------ | ------ |
|
|
97
|
-
| `
|
|
98
|
-
| `options?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
110
|
+
| `muted` | `boolean` |
|
|
99
111
|
|
|
100
112
|
#### Returns
|
|
101
113
|
|
|
102
|
-
`
|
|
114
|
+
`void`
|
|
115
|
+
|
|
116
|
+
***
|
|
117
|
+
|
|
118
|
+
### process()
|
|
119
|
+
|
|
120
|
+
#### Call Signature
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
process(input, options?): Promise<MediaStreamTrack>;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Process provided input
|
|
127
|
+
|
|
128
|
+
##### Parameters
|
|
129
|
+
|
|
130
|
+
| Parameter | Type |
|
|
131
|
+
| ------ | ------ |
|
|
132
|
+
| `input` | `MediaStreamTrack` |
|
|
133
|
+
| `options?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
134
|
+
|
|
135
|
+
##### Returns
|
|
136
|
+
|
|
137
|
+
`Promise<MediaStreamTrack>`
|
|
138
|
+
|
|
139
|
+
#### Call Signature
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
process(input, options?): Promise<
|
|
143
|
+
| ReadWritableStream<VideoFrame>
|
|
144
|
+
| undefined>;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
##### Parameters
|
|
148
|
+
|
|
149
|
+
| Parameter | Type |
|
|
150
|
+
| ------ | ------ |
|
|
151
|
+
| `input` | [`ReadWritableStream<VideoFrame>`](ReadWritableStream.mdx) |
|
|
152
|
+
| `options?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
153
|
+
|
|
154
|
+
##### Returns
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
Promise<
|
|
158
|
+
```
|
|
159
|
+
```ts
|
|
160
|
+
| ReadWritableStream<VideoFrame>
|
|
161
|
+
```
|
|
162
|
+
```ts
|
|
163
|
+
| undefined>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### Call Signature
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
process(input, options?): Promise<
|
|
170
|
+
| MediaStreamTrack
|
|
171
|
+
| ReadWritableStream<VideoFrame>
|
|
172
|
+
| undefined>;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
##### Parameters
|
|
176
|
+
|
|
177
|
+
| Parameter | Type |
|
|
178
|
+
| ------ | ------ |
|
|
179
|
+
| `input` | \| `MediaStreamTrack` \| [`ReadWritableStream<VideoFrame>`](ReadWritableStream.mdx) |
|
|
180
|
+
| `options?` | [`RendererOptions`](RendererOptions.mdx) |
|
|
181
|
+
|
|
182
|
+
##### Returns
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
Promise<
|
|
186
|
+
```
|
|
187
|
+
```ts
|
|
188
|
+
| MediaStreamTrack
|
|
189
|
+
```
|
|
190
|
+
```ts
|
|
191
|
+
| ReadWritableStream<VideoFrame>
|
|
192
|
+
```
|
|
193
|
+
```ts
|
|
194
|
+
| undefined>
|
|
195
|
+
```
|
|
103
196
|
|
|
104
197
|
***
|
|
105
198
|
|
|
@@ -109,13 +202,19 @@ process(input, options?): Promise<VideoFrameLike | undefined>;
|
|
|
109
202
|
subscribe(event, callback): Unsubscribe;
|
|
110
203
|
```
|
|
111
204
|
|
|
205
|
+
Subscribe rendering events,
|
|
206
|
+
|
|
112
207
|
#### Parameters
|
|
113
208
|
|
|
114
209
|
| Parameter | Type |
|
|
115
210
|
| ------ | ------ |
|
|
116
|
-
| `event` |
|
|
117
|
-
| `callback` | `Callback
|
|
211
|
+
| `event` | `\| "Error" \| "ContextCreationError" \| "ContextLost" \| "ContextRestored" \| "ProcessorRestarted" \| "SamplingError"` |
|
|
212
|
+
| `callback` | `Callback<void>` |
|
|
118
213
|
|
|
119
214
|
#### Returns
|
|
120
215
|
|
|
121
216
|
`Unsubscribe`
|
|
217
|
+
|
|
218
|
+
#### See
|
|
219
|
+
|
|
220
|
+
RenderingEvents
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
| Property | Type |
|
|
8
8
|
| ------ | ------ |
|
|
9
9
|
| <a id="basepath"></a> `basePath?` | `string` |
|
|
10
|
-
| <a id="output"></a> `output?` | `OffscreenCanvas` \| `null` |
|
|
11
10
|
| <a id="processingwidth"></a> `processingWidth?` | `number` |
|
|
12
11
|
| <a id="processingheight"></a> `processingHeight?` | `number` |
|
|
13
12
|
| <a id="imagesegmenteroptions"></a> `imageSegmenterOptions?` | [`ImageSegmenterOptions`](ImageSegmenterOptions.mdx) |
|
|
@@ -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` |
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
## Properties
|
|
2
2
|
|
|
3
|
-
| Property | Type | Description |
|
|
4
|
-
| ------ | ------ | ------ |
|
|
5
|
-
| <a id="
|
|
6
|
-
| <a id="
|
|
3
|
+
| Property | Modifier | Type | Description |
|
|
4
|
+
| ------ | ------ | ------ | ------ |
|
|
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
|
+
| <a id="renderoptions"></a> `renderOptions` | `readonly` | [`RendererOptions`](RendererOptions.mdx) | Current renderer options |
|
|
9
|
+
| <a id="processingwidth"></a> `processingWidth` | `readonly` | `number` | Current processing width |
|
|
10
|
+
| <a id="processingheight"></a> `processingHeight` | `readonly` | `number` | Current processing height |
|
|
7
11
|
|
|
8
12
|
## Methods
|
|
9
13
|
|
|
@@ -13,26 +17,66 @@
|
|
|
13
17
|
open(options?): Promise<void>;
|
|
14
18
|
```
|
|
15
19
|
|
|
20
|
+
Initialize the video processor and related
|
|
21
|
+
|
|
22
|
+
#### Parameters
|
|
23
|
+
|
|
24
|
+
| Parameter | Type |
|
|
25
|
+
| ------ | ------ |
|
|
26
|
+
| `options?` | [`ProcessorUpdateOptions`](ProcessorUpdateOptions.mdx) |
|
|
27
|
+
|
|
28
|
+
#### Returns
|
|
29
|
+
|
|
30
|
+
`Promise<void>`
|
|
31
|
+
|
|
32
|
+
***
|
|
33
|
+
|
|
34
|
+
### update()
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
update(options): Promise<void>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Update the video processor with provided options
|
|
41
|
+
|
|
16
42
|
#### Parameters
|
|
17
43
|
|
|
18
44
|
| Parameter | Type |
|
|
19
45
|
| ------ | ------ |
|
|
20
|
-
| `options
|
|
46
|
+
| `options` | [`ProcessorUpdateOptions`](ProcessorUpdateOptions.mdx) |
|
|
21
47
|
|
|
22
48
|
#### Returns
|
|
23
49
|
|
|
24
|
-
`Promise
|
|
50
|
+
`Promise<void>`
|
|
51
|
+
|
|
52
|
+
***
|
|
53
|
+
|
|
54
|
+
### mute()
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
mute(muted): void;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Parameters
|
|
61
|
+
|
|
62
|
+
| Parameter | Type |
|
|
63
|
+
| ------ | ------ |
|
|
64
|
+
| `muted` | `boolean` |
|
|
65
|
+
|
|
66
|
+
#### Returns
|
|
67
|
+
|
|
68
|
+
`void`
|
|
25
69
|
|
|
26
70
|
***
|
|
27
71
|
|
|
28
72
|
### close()
|
|
29
73
|
|
|
30
74
|
```ts
|
|
31
|
-
close(): void
|
|
75
|
+
close(): Promise<void>;
|
|
32
76
|
```
|
|
33
77
|
|
|
34
78
|
Stop the process of video segmentation
|
|
35
79
|
|
|
36
80
|
#### Returns
|
|
37
81
|
|
|
38
|
-
`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` |
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
```ts
|
|
2
|
-
type ProcessWorkerEvents<T, E, D> =
|
|
2
|
+
type ProcessWorkerEvents<T, E, D, U> =
|
|
3
3
|
| ProcessWorkerEventProcessed<T>
|
|
4
|
-
| ProcessWorkerEventOpened
|
|
5
|
-
| ProcessWorkerEventUpdated
|
|
4
|
+
| ProcessWorkerEventOpened<U>
|
|
5
|
+
| ProcessWorkerEventUpdated<U>
|
|
6
|
+
| ProcessWorkerEventClosed
|
|
6
7
|
| ProcessWorkerEvent<E>
|
|
7
|
-
| ProcessWorkerEventDebug<D
|
|
8
|
+
| ProcessWorkerEventDebug<D>
|
|
9
|
+
| ProcessWorkerEventStats;
|
|
8
10
|
```
|
|
9
11
|
|
|
10
12
|
Message events returned from the processor
|
|
@@ -16,3 +18,4 @@ Message events returned from the processor
|
|
|
16
18
|
| `T` |
|
|
17
19
|
| `E` |
|
|
18
20
|
| `D` |
|
|
21
|
+
| `U` |
|
|
@@ -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)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
const cloneImageRecord: (image) => Promise<{
|
|
3
|
+
image: ImageBitmap;
|
|
4
|
+
key: string;
|
|
5
|
+
}>;
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| ------ | ------ |
|
|
12
|
+
| `image` | [`ImageRecord`](../interfaces/ImageRecord.mdx) |
|
|
13
|
+
|
|
14
|
+
## Returns
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
Promise<{
|
|
18
|
+
```
|
|
19
|
+
`image`: `ImageBitmap`;
|
|
20
|
+
`key`: `string`;
|
|
21
|
+
\}\>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
const compareImageRecords: (a, b) => boolean;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
Compare provided ImageRecord
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
| Parameter | Type |
|
|
10
|
+
| ------ | ------ |
|
|
11
|
+
| `a` | [`ImageRecord`](../interfaces/ImageRecord.mdx) |
|
|
12
|
+
| `b` | [`ImageRecord`](../interfaces/ImageRecord.mdx) \| `undefined` |
|
|
13
|
+
|
|
14
|
+
## Returns
|
|
15
|
+
|
|
16
|
+
`boolean`
|
|
17
|
+
|
|
18
|
+
true if the two records have the same key and image, false otherwise
|
|
@@ -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` |
|