@pexip/media-processor 20.3.5 → 22.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 +109 -0
- package/README.md +17 -10
- package/api-docs/README.mdx +69 -23
- package/api-docs/functions/assertMediaStreamVideoTrack.mdx +13 -0
- package/api-docs/functions/createBenchmark.mdx +17 -5
- package/api-docs/functions/createFrameCallbackRequest.mdx +8 -2
- 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/createVideoProcessor.mdx +3 -3
- package/api-docs/functions/createWindowedStats.mdx +23 -0
- package/api-docs/functions/getDefaultInputProcessAdaptor.mdx +17 -0
- package/api-docs/functions/iou.mdx +19 -0
- package/api-docs/functions/isMediaStreamVideoTrack.mdx +13 -0
- package/api-docs/functions/labelComponents.mdx +20 -0
- package/api-docs/functions/nearestPowerOfTwo.mdx +21 -0
- package/api-docs/functions/playVideo.mdx +16 -0
- package/api-docs/functions/scoreComponent.mdx +22 -0
- package/api-docs/functions/setVideoElementSrc.mdx +14 -0
- package/api-docs/interfaces/Analyzer.mdx +4 -0
- package/api-docs/interfaces/Benchmark.mdx +26 -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 +28 -0
- package/api-docs/interfaces/Process.mdx +8 -3
- package/api-docs/interfaces/ProcessEventMute.mdx +6 -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 +1 -1
- package/api-docs/interfaces/ProcessorOptions.mdx +0 -1
- package/api-docs/interfaces/ProcessorProcessOptions.mdx +3 -1
- package/api-docs/interfaces/ProcessorUpdateOptions.mdx +15 -0
- package/api-docs/interfaces/ReadWritableStream.mdx +12 -0
- package/api-docs/interfaces/Renderer.mdx +2 -2
- package/api-docs/interfaces/RendererOptions.mdx +25 -12
- package/api-docs/interfaces/Segmenter.mdx +89 -10
- package/api-docs/interfaces/SegmenterOptions.mdx +0 -1
- package/api-docs/interfaces/SelectionOptions.mdx +15 -0
- package/api-docs/interfaces/Stats.mdx +11 -0
- package/api-docs/interfaces/VideoProcessor.mdx +49 -5
- package/api-docs/interfaces/Weights.mdx +12 -0
- package/api-docs/type-aliases/OptionalKeys.mdx +10 -0
- 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 +6 -4
- package/api-docs/type-aliases/ProcessorWorkerEvents.mdx +1 -1
- package/api-docs/type-aliases/Struct.mdx +9 -0
- package/api-docs/variables/BACKGROUND_THRESHOLD.mdx +3 -0
- package/api-docs/variables/DOWN_SAMPLE_FACTOR.mdx +3 -0
- package/api-docs/variables/EDGE_BLUR_AMOUNT.mdx +1 -1
- package/api-docs/variables/EXCLUDE_BYSTANDERS.mdx +3 -0
- package/api-docs/variables/FOREGROUND_THRESHOLD.mdx +1 -1
- package/api-docs/variables/FRAME_RATE.mdx +1 -1
- package/api-docs/variables/ImageFetchError.mdx +3 -0
- package/api-docs/variables/LIGHT_WRAP_BLUR_AMOUNT.mdx +3 -0
- package/api-docs/variables/LIGHT_WRAP_EDGE_BAND.mdx +3 -0
- package/api-docs/variables/LIGHT_WRAP_INTENSITY.mdx +3 -0
- package/api-docs/variables/LIGHT_WRAP_TIGHTNESS.mdx +3 -0
- package/api-docs/variables/MASK_COMBINE_RATIO.mdx +1 -1
- package/api-docs/variables/MORPH_DILATE_RADIUS_PX.mdx +3 -0
- package/api-docs/variables/MORPH_ERODE_RADIUS_PX.mdx +3 -0
- package/api-docs/variables/MORPH_PASS.mdx +3 -0
- package/api-docs/variables/MediaStreamTrackTransferable.mdx +5 -0
- package/api-docs/variables/PERSON_CENTER.mdx +3 -0
- package/api-docs/variables/RENDERER_OPTIONS_STRUCT.mdx +3 -0
- package/api-docs/variables/SIGMA_RANGE.mdx +3 -0
- package/api-docs/variables/SIGMA_SPACE.mdx +3 -0
- package/api-docs/variables/STRONG_EDGE_BLUR_AMOUNT.mdx +3 -0
- package/api-docs/variables/cloneImageRecord.mdx +19 -0
- package/api-docs/variables/compareImageRecords.mdx +18 -0
- package/api-docs/variables/createRemoteImageBitmap.mdx +1 -1
- package/api-docs/variables/getCanvasRenderingContext2D.mdx +14 -0
- package/api-docs/variables/getImageSize.mdx +13 -0
- package/api-docs/variables/isRenderOptionsKey.mdx +13 -0
- package/api-docs/variables/isValidGpuAPI.mdx +13 -0
- package/dist/common/backends/webgl/binaryMask.d.ts +8 -0
- package/dist/common/backends/webgl/binaryMask.js +95 -0
- package/dist/common/backends/webgl/blender.d.ts +2 -1
- package/dist/common/backends/webgl/blender.js +18 -15
- package/dist/common/backends/webgl/blur.d.ts +1 -1
- package/dist/common/backends/webgl/blur.js +23 -16
- package/dist/common/backends/webgl/canvas.js +9 -4
- package/dist/common/backends/webgl/diffAbsMask.d.ts +10 -0
- package/dist/common/backends/webgl/diffAbsMask.js +103 -0
- package/dist/common/backends/webgl/geodesicReconstruction.d.ts +13 -0
- package/dist/common/backends/webgl/geodesicReconstruction.js +176 -0
- package/dist/common/backends/webgl/jointBilateralFilter.d.ts +12 -0
- package/dist/common/backends/webgl/jointBilateralFilter.js +108 -0
- package/dist/common/backends/webgl/morphErode.d.ts +13 -0
- package/dist/common/backends/webgl/morphErode.js +121 -0
- package/dist/common/backends/webgl/renderer.js +194 -44
- package/dist/common/backends/webgl/replace.d.ts +17 -0
- package/dist/common/backends/webgl/replace.js +126 -0
- package/dist/common/backends/webgl/selectComponent.d.ts +15 -0
- package/dist/common/backends/webgl/selectComponent.js +102 -0
- package/dist/common/backends/webgl/smoothingMask.d.ts +3 -3
- package/dist/common/backends/webgl/smoothingMask.js +22 -21
- package/dist/common/backends/webgl/tentBlur.d.ts +9 -0
- package/dist/common/backends/webgl/tentBlur.js +118 -0
- package/dist/common/backends/webgl/texture.d.ts +2 -3
- package/dist/common/backends/webgl/texture.js +21 -19
- package/dist/common/backends/webgl/textureToTexture.d.ts +1 -1
- package/dist/common/backends/webgl/textureToTexture.js +19 -16
- package/dist/common/backends/webgl/webglUtils.d.ts +7 -1
- package/dist/common/backends/webgl/webglUtils.js +72 -10
- package/dist/common/backends/webgpu/blender.d.ts +6 -1
- package/dist/common/backends/webgpu/blender.js +96 -51
- package/dist/common/backends/webgpu/constants.js +1 -1
- package/dist/common/backends/webgpu/dualFilterBlur.d.ts +2 -3
- package/dist/common/backends/webgpu/dualFilterBlur.js +146 -140
- package/dist/common/backends/webgpu/jointBilateralFilter.d.ts +7 -0
- package/dist/common/backends/webgpu/jointBilateralFilter.js +162 -0
- package/dist/common/backends/webgpu/renderer.js +205 -43
- package/dist/common/backends/webgpu/replace.d.ts +11 -0
- package/dist/common/backends/webgpu/replace.js +175 -0
- package/dist/common/backends/webgpu/resize.d.ts +4 -0
- package/dist/common/backends/webgpu/resize.js +76 -0
- package/dist/common/backends/webgpu/smoothingMask.d.ts +2 -2
- package/dist/common/backends/webgpu/smoothingMask.js +74 -40
- package/dist/common/backends/webgpu/tentBlur.d.ts +5 -0
- package/dist/common/backends/webgpu/tentBlur.js +131 -0
- package/dist/common/backends/webgpu/texture.d.ts +2 -3
- package/dist/common/backends/webgpu/texture.js +29 -20
- package/dist/common/backends/webgpu/textureToTexture.d.ts +1 -1
- package/dist/common/backends/webgpu/textureToTexture.js +28 -15
- package/dist/common/backends/webgpu/types.d.ts +2 -0
- package/dist/common/backends/webgpu/webgpuUtils.d.ts +24 -4
- package/dist/common/backends/webgpu/webgpuUtils.js +60 -11
- package/dist/common/constants.d.ts +22 -5
- package/dist/common/constants.js +23 -5
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.js +2 -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 +31 -4
- package/dist/common/types/processor.d.ts +6 -4
- package/dist/common/types/render.d.ts +147 -15
- package/dist/common/types/render.js +23 -1
- package/dist/common/types/segmentation.d.ts +0 -12
- package/dist/common/types/utils.d.ts +21 -0
- package/dist/common/utils.d.ts +29 -2
- package/dist/common/utils.js +206 -10
- package/dist/main/audio.js +3 -3
- package/dist/main/benchUtils.d.ts +35 -3
- package/dist/main/benchUtils.js +149 -15
- 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 +3 -4
- package/dist/main/video/index.js +3 -4
- package/dist/main/video/inputProcessAdaptor.d.ts +30 -0
- package/dist/main/video/inputProcessAdaptor.js +198 -0
- package/dist/main/video/segmenter.d.ts +35 -0
- package/dist/main/video/{segmenters/mediapipe.js → segmenter.js} +93 -53
- package/dist/main/video/typeGuards.d.ts +2 -0
- package/dist/main/video/typeGuards.js +8 -1
- package/dist/main/video/types.d.ts +36 -16
- package/dist/main/video/utils.d.ts +5 -4
- package/dist/main/video/utils.js +49 -44
- package/dist/main/video/video.d.ts +29 -7
- package/dist/main/video/video.js +323 -28
- package/dist/workers/mediaWorker.js +35 -162
- package/dist/workers/tsconfig.tsbuildinfo +1 -1
- package/dist/worklets/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -12
- 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 -18
- 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/common/backends/webgl/shaders/blendFragmentShader.d.ts +0 -1
- package/dist/common/backends/webgl/shaders/blendFragmentShader.js +0 -21
- package/dist/common/backends/webgl/shaders/dualFilterBlurFragmentShader.d.ts +0 -1
- package/dist/common/backends/webgl/shaders/dualFilterBlurFragmentShader.js +0 -45
- package/dist/common/backends/webgl/shaders/smoothingMaskFragmentShader.d.ts +0 -1
- package/dist/common/backends/webgl/shaders/smoothingMaskFragmentShader.js +0 -57
- package/dist/common/backends/webgl/shaders/textureFragmentShader.d.ts +0 -1
- package/dist/common/backends/webgl/shaders/textureFragmentShader.js +0 -16
- package/dist/common/backends/webgl/shaders/vertexShader.d.ts +0 -1
- package/dist/common/backends/webgl/shaders/vertexShader.js +0 -19
- 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 -253
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,114 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 22.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 498ff3b: A full architectural overhaul of the video processing pipeline:
|
|
8
|
+
|
|
9
|
+
BREAKING CHANGES:
|
|
10
|
+
|
|
11
|
+
- **`createCanvasTransform` removed**
|
|
12
|
+
- **`createVideoTrackProcessor` / `createVideoTrackProcessorWithFallback`
|
|
13
|
+
removed**
|
|
14
|
+
- **`createVideoProcessor` redesigned** — now accepts a `Segmenter` +
|
|
15
|
+
`InputProcessAdaptor` instead of an array of `Transform`s. Exposes
|
|
16
|
+
`update()`, `mute()`, `status`, `renderOptions`, and processing dimensions.
|
|
17
|
+
- **New `InputProcessAdaptor` system**:
|
|
18
|
+
- `createMediaStreamTrackInputProcessAdaptor` — uses native
|
|
19
|
+
`MediaStreamTrack` transfer (Safari v18+ compatible).
|
|
20
|
+
- `createReadWritableStreamInputProcessAdaptor` — uses
|
|
21
|
+
`MediaStreamTrackProcessor` + `MediaStreamTrackGenerator`.
|
|
22
|
+
- `createReadWritableStreamFallbackInputProcessAdaptor` — canvas/video
|
|
23
|
+
element fallback.
|
|
24
|
+
- `getDefaultInputProcessAdaptor` — picks the best path via feature
|
|
25
|
+
detection (`MediaStreamTrackTransferable`).
|
|
26
|
+
- **`createSegmenter` updated**
|
|
27
|
+
- Now processes `MediaStreamTrack` or `ReadWritableStream` directly (no more
|
|
28
|
+
`VideoFrameLike`).
|
|
29
|
+
- Added `mute()` method.
|
|
30
|
+
- Added `stats` callback for frame timing data.
|
|
31
|
+
- Worker is no longer re-created on every `open()`.
|
|
32
|
+
- **Worker rewritten**:
|
|
33
|
+
- Processing now uses `TransformStream` to pipe `VideoFrame`s through
|
|
34
|
+
segmentation.
|
|
35
|
+
- Supports both track-based
|
|
36
|
+
(`VideoTrackGenerator`/`MediaStreamTrackProcessor`) and ReadWritable
|
|
37
|
+
stream processing.
|
|
38
|
+
- Added frame timing stats (`FrameTransformStats`) batched and posted back
|
|
39
|
+
to main thread.
|
|
40
|
+
- Removes direct canvas-copy output (`directOutput`/`output`); renderer now
|
|
41
|
+
writes to `processCanvas` and creates a new `VideoFrame`.
|
|
42
|
+
- `close` and `suspend` separated; resource cleanup improved.
|
|
43
|
+
- Background image fetching is now abortable.
|
|
44
|
+
- **`Renderer.render()` signature simplified** — accepts `OffscreenCanvas` +
|
|
45
|
+
`VideoFrame` directly (no `VideoFrameLike` wrapper).
|
|
46
|
+
- **WebGL/WebGPU texture renderers** updated to accept
|
|
47
|
+
`VideoFrame | ImageBitmap | OffscreenCanvas` natively.
|
|
48
|
+
- **WebGL program release guard** added to prevent double-free.
|
|
49
|
+
- **`benchUtils`** extended to accept explicit timestamps in
|
|
50
|
+
`begin()`/`end()` + tests added.
|
|
51
|
+
- **`MediaStreamTrackTransferable`** feature-detection helper exported.
|
|
52
|
+
- **Default frame rate raised** from 20 → 30 fps.
|
|
53
|
+
- **Default backend changed** to `webgpu`.
|
|
54
|
+
|
|
55
|
+
- fe0a0a4: Set a max width of 300px of in meeting selfview.
|
|
56
|
+
|
|
57
|
+
Rename openEffectsModal prop on InMeetingSelfview to openEffects
|
|
58
|
+
|
|
59
|
+
Make selfview muted indicator look more like an indicator
|
|
60
|
+
|
|
61
|
+
Show tooltips for background effects button and upload background effect
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- f8bd1c5: Fix VideoProcessor and Segment open/update behavior
|
|
66
|
+
- 925cce6: Fix f16 issue
|
|
67
|
+
- fb41d4d: Changes related to Typescript V6 Upgrade
|
|
68
|
+
- Updated dependencies [498ff3b]
|
|
69
|
+
- Updated dependencies [fb41d4d]
|
|
70
|
+
- Updated dependencies [b99c070]
|
|
71
|
+
- @pexip/utils@17.3.0
|
|
72
|
+
|
|
73
|
+
## 21.0.0
|
|
74
|
+
|
|
75
|
+
### Major Changes
|
|
76
|
+
|
|
77
|
+
- 3963c2e: Post-processing the segmentation mask
|
|
78
|
+
|
|
79
|
+
- Add downsampling post-processing
|
|
80
|
+
- Refine mask boundaries for more edge snappy
|
|
81
|
+
- Reduce the gaps between the segmented areas
|
|
82
|
+
- Add bystander removal
|
|
83
|
+
|
|
84
|
+
### Minor Changes
|
|
85
|
+
|
|
86
|
+
- 4cc4701: WebGPU implementation improvements:
|
|
87
|
+
|
|
88
|
+
- Port WebGL2 post-processing steps to WebGPU, matching mask/edge quality and
|
|
89
|
+
performance
|
|
90
|
+
- Implement compute-based separable joint bilateral filter for mask refinement
|
|
91
|
+
- Add compute tent blur for edge feathering, using single half-float channel
|
|
92
|
+
for mask
|
|
93
|
+
- Introduce downsample/upsample and dual filter blur in compute for optimized
|
|
94
|
+
background effects
|
|
95
|
+
- Cache pipelines and textures to reduce per-frame allocation overhead
|
|
96
|
+
- Use `r16float` mask storage when available for efficiency
|
|
97
|
+
- Improve blend quality with smoothstep edge softening
|
|
98
|
+
- Integrate light wrap and H.264 noise stabilization into compositing
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 24bc717: Fix added noise YUV->RBG negative value issue
|
|
103
|
+
- 872971f: Mark `excludeBystanders` related params as `@experimental`:
|
|
104
|
+
`personCenter`, `morphErodeRadiusPx`, `morphPass`, and `morphDilateRadiusPx`
|
|
105
|
+
- 2e895ac: Add add an `@experimental` tag for `excludeBystanders`
|
|
106
|
+
- 4eaf9d7: Use the correct region to apply noise
|
|
107
|
+
- Updated dependencies [1fff975]
|
|
108
|
+
- Updated dependencies [3963c2e]
|
|
109
|
+
- Updated dependencies [762ebd2]
|
|
110
|
+
- @pexip/utils@17.2.0
|
|
111
|
+
|
|
3
112
|
## 20.3.5
|
|
4
113
|
|
|
5
114
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -106,10 +106,12 @@ await audioGraph.release();
|
|
|
106
106
|
|
|
107
107
|
```typescript
|
|
108
108
|
import {
|
|
109
|
+
createMediaStreamTrackInputProcessAdaptor,
|
|
110
|
+
createReadWritableStreamFallbackInputProcessAdaptor,
|
|
111
|
+
createReadWritableStreamInputProcessAdaptor,
|
|
109
112
|
createSegmenter,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
createVideoTrackProcessorWithFallback,
|
|
113
|
+
createVideoProcessor,
|
|
114
|
+
getDefaultInputProcessAdaptor,
|
|
113
115
|
} from '@pexip/media-processor';
|
|
114
116
|
|
|
115
117
|
// Grab the user's camera stream
|
|
@@ -129,17 +131,22 @@ const modelAsset = {
|
|
|
129
131
|
modelName: 'selfie' as const,
|
|
130
132
|
};
|
|
131
133
|
|
|
132
|
-
const segmenter = createSegmenter(tasksVisionBasePath, {
|
|
133
|
-
//
|
|
134
|
-
const
|
|
135
|
-
|
|
134
|
+
const segmenter = createSegmenter(tasksVisionBasePath, {modelAsset});
|
|
135
|
+
// Choose the appropriate input process adaptor based on browser capabilities
|
|
136
|
+
const inputProcessAdaptor = getDefaultInputProcessAdaptor(true);
|
|
137
|
+
// Create a processor and set the effects to `blur`
|
|
138
|
+
const processor = createVideoProcessor(segmenter, inputProcessAdaptor);
|
|
136
139
|
|
|
137
140
|
// Start the processor
|
|
138
141
|
await videoProcessor.open();
|
|
139
142
|
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
// Start the processor with blur effects
|
|
144
|
+
await processor.open({renderOptions: {effects: 'blur'}});
|
|
145
|
+
|
|
146
|
+
// Process the video track and create a new stream
|
|
147
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
148
|
+
const processedTrack = await processor.process(videoTrack);
|
|
149
|
+
const processedStream = new MediaStream([processedTrack]);
|
|
143
150
|
```
|
|
144
151
|
|
|
145
152
|
## Profiling Web Audio
|
package/api-docs/README.mdx
CHANGED
|
@@ -106,10 +106,12 @@ await audioGraph.release();
|
|
|
106
106
|
|
|
107
107
|
```typescript
|
|
108
108
|
import {
|
|
109
|
+
createMediaStreamTrackInputProcessAdaptor,
|
|
110
|
+
createReadWritableStreamFallbackInputProcessAdaptor,
|
|
111
|
+
createReadWritableStreamInputProcessAdaptor,
|
|
109
112
|
createSegmenter,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
createVideoTrackProcessorWithFallback,
|
|
113
|
+
createVideoProcessor,
|
|
114
|
+
getDefaultInputProcessAdaptor,
|
|
113
115
|
} from '@pexip/media-processor';
|
|
114
116
|
|
|
115
117
|
// Grab the user's camera stream
|
|
@@ -129,17 +131,22 @@ const modelAsset = {
|
|
|
129
131
|
modelName: 'selfie' as const,
|
|
130
132
|
};
|
|
131
133
|
|
|
132
|
-
const segmenter = createSegmenter(tasksVisionBasePath, {
|
|
133
|
-
//
|
|
134
|
-
const
|
|
135
|
-
|
|
134
|
+
const segmenter = createSegmenter(tasksVisionBasePath, {modelAsset});
|
|
135
|
+
// Choose the appropriate input process adaptor based on browser capabilities
|
|
136
|
+
const inputProcessAdaptor = getDefaultInputProcessAdaptor(true);
|
|
137
|
+
// Create a processor and set the effects to `blur`
|
|
138
|
+
const processor = createVideoProcessor(segmenter, inputProcessAdaptor);
|
|
136
139
|
|
|
137
140
|
// Start the processor
|
|
138
141
|
await videoProcessor.open();
|
|
139
142
|
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
// Start the processor with blur effects
|
|
144
|
+
await processor.open({renderOptions: {effects: 'blur'}});
|
|
145
|
+
|
|
146
|
+
// Process the video track and create a new stream
|
|
147
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
148
|
+
const processedTrack = await processor.process(videoTrack);
|
|
149
|
+
const processedStream = new MediaStream([processedTrack]);
|
|
143
150
|
```
|
|
144
151
|
|
|
145
152
|
## Profiling Web Audio
|
|
@@ -193,11 +200,13 @@ A library for media analysis using Web APIs.
|
|
|
193
200
|
| Interface | Description |
|
|
194
201
|
| ------ | ------ |
|
|
195
202
|
| [Segmentation](interfaces/Segmentation.mdx) | - |
|
|
203
|
+
| [ReadWritableStream](interfaces/ReadWritableStream.mdx) | - |
|
|
196
204
|
| [VideoFrameLike](interfaces/VideoFrameLike.mdx) | - |
|
|
197
205
|
| [ImageRecord](interfaces/ImageRecord.mdx) | - |
|
|
198
206
|
| [Rect](interfaces/Rect.mdx) | - |
|
|
199
207
|
| [ProcessEventOpen](interfaces/ProcessEventOpen.mdx) | Message event to initializing the Processor |
|
|
200
208
|
| [ProcessEventProcess](interfaces/ProcessEventProcess.mdx) | Message event to process the video frame |
|
|
209
|
+
| [ProcessEventMute](interfaces/ProcessEventMute.mdx) | - |
|
|
201
210
|
| [ProcessEventUpdate](interfaces/ProcessEventUpdate.mdx) | Message event to update processor options |
|
|
202
211
|
| [ProcessEventClose](interfaces/ProcessEventClose.mdx) | Message event to stop the processing |
|
|
203
212
|
| [ProcessEventDestroy](interfaces/ProcessEventDestroy.mdx) | Message event to release all the resources |
|
|
@@ -207,11 +216,13 @@ A library for media analysis using Web APIs.
|
|
|
207
216
|
| [ProcessWorkerEventUpdated](interfaces/ProcessWorkerEventUpdated.mdx) | - |
|
|
208
217
|
| [ProcessWorkerEvent](interfaces/ProcessWorkerEvent.mdx) | - |
|
|
209
218
|
| [ProcessWorkerEventDebug](interfaces/ProcessWorkerEventDebug.mdx) | - |
|
|
219
|
+
| [FrameTransformStats](interfaces/FrameTransformStats.mdx) | Frame transform statistic, i.e. the timing data for processing each frame |
|
|
220
|
+
| [ProcessWorkerEventStats](interfaces/ProcessWorkerEventStats.mdx) | - |
|
|
210
221
|
| [ProcessorOptions](interfaces/ProcessorOptions.mdx) | - |
|
|
211
222
|
| [ProcessorProcessOptions](interfaces/ProcessorProcessOptions.mdx) | - |
|
|
212
223
|
| [ProcessWorkerDebugMessage](interfaces/ProcessWorkerDebugMessage.mdx) | - |
|
|
213
224
|
| [ProcessorEvent](interfaces/ProcessorEvent.mdx) | - |
|
|
214
|
-
| [RendererOptions](interfaces/RendererOptions.mdx) | - |
|
|
225
|
+
| [RendererOptions](interfaces/RendererOptions.mdx) | Options controlling the rendering and effects for person/background segmentation. All values are stable per-frame and can be safely updated in real-time. |
|
|
215
226
|
| [Renderer](interfaces/Renderer.mdx) | - |
|
|
216
227
|
| [RenderEventHandlers](interfaces/RenderEventHandlers.mdx) | - |
|
|
217
228
|
| [SegmentationModelAsset](interfaces/SegmentationModelAsset.mdx) | Segmentation model asset that can be used to load a segmentation model. |
|
|
@@ -219,6 +230,9 @@ A library for media analysis using Web APIs.
|
|
|
219
230
|
| [SegmenterOptions](interfaces/SegmenterOptions.mdx) | - |
|
|
220
231
|
| [SegmentationSmoothingConfig](interfaces/SegmentationSmoothingConfig.mdx) | - |
|
|
221
232
|
| [MPMask](interfaces/MPMask.mdx) | Wrapper for a mask produced by a Segmentation Task. |
|
|
233
|
+
| [Stats](interfaces/Stats.mdx) | - |
|
|
234
|
+
| [Weights](interfaces/Weights.mdx) | - |
|
|
235
|
+
| [SelectionOptions](interfaces/SelectionOptions.mdx) | - |
|
|
222
236
|
| [Benchmark](interfaces/Benchmark.mdx) | - |
|
|
223
237
|
| [Point](interfaces/Point.mdx) | Interface for Point consist of coordinates x and y |
|
|
224
238
|
| [Size](interfaces/Size.mdx) | - |
|
|
@@ -239,13 +253,12 @@ A library for media analysis using Web APIs.
|
|
|
239
253
|
| [Clock](interfaces/Clock.mdx) | Clock interface to get the current time with now method, |
|
|
240
254
|
| [ThrottleOptions](interfaces/ThrottleOptions.mdx) | Limit the rate of flow in terms of millisecond, and provided Clock |
|
|
241
255
|
| [Runner](interfaces/Runner.mdx) | - |
|
|
242
|
-
| [Transform](interfaces/Transform.mdx) | - |
|
|
243
256
|
| [AsyncAssets](interfaces/AsyncAssets.mdx) | - |
|
|
244
257
|
| [Process](interfaces/Process.mdx) | - |
|
|
245
258
|
| [BackgroundImage](interfaces/BackgroundImage.mdx) | - |
|
|
246
259
|
| [Segmenter](interfaces/Segmenter.mdx) | - |
|
|
247
|
-
| [
|
|
248
|
-
| [
|
|
260
|
+
| [InputProcessAdaptor](interfaces/InputProcessAdaptor.mdx) | - |
|
|
261
|
+
| [ProcessorUpdateOptions](interfaces/ProcessorUpdateOptions.mdx) | - |
|
|
249
262
|
| [VideoProcessor](interfaces/VideoProcessor.mdx) | - |
|
|
250
263
|
|
|
251
264
|
## Type Aliases
|
|
@@ -263,11 +276,13 @@ A library for media analysis using Web APIs.
|
|
|
263
276
|
| [ProcessWorkerEvents](type-aliases/ProcessWorkerEvents.mdx) | Message events returned from the processor |
|
|
264
277
|
| [ProcessorEvents](type-aliases/ProcessorEvents.mdx) | - |
|
|
265
278
|
| [ProcessorWorkerEvents](type-aliases/ProcessorWorkerEvents.mdx) | - |
|
|
279
|
+
| [Struct](type-aliases/Struct.mdx) | - |
|
|
266
280
|
| [SegmentationModel](type-aliases/SegmentationModel.mdx) | - |
|
|
267
281
|
| [Delegate](type-aliases/Delegate.mdx) | - |
|
|
268
282
|
| [ExtractMessageEventType](type-aliases/ExtractMessageEventType.mdx) | - |
|
|
269
283
|
| [IncludeMessageEventDataType](type-aliases/IncludeMessageEventDataType.mdx) | - |
|
|
270
284
|
| [TupleOf](type-aliases/TupleOf.mdx) | From https://github.com/Microsoft/TypeScript/issues/26223#issuecomment-674500430 |
|
|
285
|
+
| [OptionalKeys](type-aliases/OptionalKeys.mdx) | - |
|
|
271
286
|
| [Canvas](type-aliases/Canvas.mdx) | - |
|
|
272
287
|
| [Unsubscribe](type-aliases/Unsubscribe.mdx) | Unsubscribe the subscription |
|
|
273
288
|
| [AudioBufferFloats](type-aliases/AudioBufferFloats.mdx) | Same as [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) Or the return from [AnalyserNode.getFloatFrequencyData()](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatFrequencyData) |
|
|
@@ -305,35 +320,55 @@ A library for media analysis using Web APIs.
|
|
|
305
320
|
| [WasmPaths](type-aliases/WasmPaths.mdx) | - |
|
|
306
321
|
| [Color](type-aliases/Color.mdx) | - |
|
|
307
322
|
| [InputFrame](type-aliases/InputFrame.mdx) | - |
|
|
308
|
-
| [SegmentationTransform](type-aliases/SegmentationTransform.mdx) | - |
|
|
309
|
-
| [ProcessVideoTrack](type-aliases/ProcessVideoTrack.mdx) | - |
|
|
310
323
|
|
|
311
324
|
## Variables
|
|
312
325
|
|
|
313
326
|
| Variable | Description |
|
|
314
327
|
| ------ | ------ |
|
|
315
|
-
| [
|
|
316
|
-
| [
|
|
317
|
-
| [FOREGROUND\_THRESHOLD](variables/FOREGROUND_THRESHOLD.mdx) | - |
|
|
328
|
+
| [getCanvasRenderingContext2D](variables/getCanvasRenderingContext2D.mdx) | - |
|
|
329
|
+
| [getImageSize](variables/getImageSize.mdx) | - |
|
|
318
330
|
| [BACKGROUND\_BLUR\_AMOUNT](variables/BACKGROUND_BLUR_AMOUNT.mdx) | - |
|
|
331
|
+
| [BACKGROUND\_THRESHOLD](variables/BACKGROUND_THRESHOLD.mdx) | - |
|
|
332
|
+
| [DOWN\_SAMPLE\_FACTOR](variables/DOWN_SAMPLE_FACTOR.mdx) | - |
|
|
319
333
|
| [EDGE\_BLUR\_AMOUNT](variables/EDGE_BLUR_AMOUNT.mdx) | - |
|
|
334
|
+
| [EXCLUDE\_BYSTANDERS](variables/EXCLUDE_BYSTANDERS.mdx) | - |
|
|
335
|
+
| [FOREGROUND\_THRESHOLD](variables/FOREGROUND_THRESHOLD.mdx) | - |
|
|
336
|
+
| [LIGHT\_WRAP\_BLUR\_AMOUNT](variables/LIGHT_WRAP_BLUR_AMOUNT.mdx) | - |
|
|
337
|
+
| [LIGHT\_WRAP\_EDGE\_BAND](variables/LIGHT_WRAP_EDGE_BAND.mdx) | - |
|
|
338
|
+
| [LIGHT\_WRAP\_INTENSITY](variables/LIGHT_WRAP_INTENSITY.mdx) | - |
|
|
339
|
+
| [LIGHT\_WRAP\_TIGHTNESS](variables/LIGHT_WRAP_TIGHTNESS.mdx) | - |
|
|
320
340
|
| [MASK\_COMBINE\_RATIO](variables/MASK_COMBINE_RATIO.mdx) | - |
|
|
341
|
+
| [MORPH\_DILATE\_RADIUS\_PX](variables/MORPH_DILATE_RADIUS_PX.mdx) | - |
|
|
342
|
+
| [MORPH\_ERODE\_RADIUS\_PX](variables/MORPH_ERODE_RADIUS_PX.mdx) | - |
|
|
343
|
+
| [MORPH\_PASS](variables/MORPH_PASS.mdx) | - |
|
|
344
|
+
| [PERSON\_CENTER](variables/PERSON_CENTER.mdx) | - |
|
|
345
|
+
| [PROCESSING\_HEIGHT](variables/PROCESSING_HEIGHT.mdx) | - |
|
|
346
|
+
| [PROCESSING\_WIDTH](variables/PROCESSING_WIDTH.mdx) | - |
|
|
347
|
+
| [SIGMA\_RANGE](variables/SIGMA_RANGE.mdx) | - |
|
|
348
|
+
| [SIGMA\_SPACE](variables/SIGMA_SPACE.mdx) | - |
|
|
349
|
+
| [STRONG\_EDGE\_BLUR\_AMOUNT](variables/STRONG_EDGE_BLUR_AMOUNT.mdx) | - |
|
|
321
350
|
| [PROCESS\_STATUS](variables/PROCESS_STATUS.mdx) | Process status |
|
|
322
351
|
| [RENDER\_EFFECT](variables/RENDER_EFFECT.mdx) | - |
|
|
323
352
|
| [RENDER\_BACKEND](variables/RENDER_BACKEND.mdx) | - |
|
|
324
353
|
| [RENDERING\_EVENTS](variables/RENDERING_EVENTS.mdx) | - |
|
|
354
|
+
| [isValidGpuAPI](variables/isValidGpuAPI.mdx) | - |
|
|
355
|
+
| [isRenderOptionsKey](variables/isRenderOptionsKey.mdx) | - |
|
|
356
|
+
| [RENDERER\_OPTIONS\_STRUCT](variables/RENDERER_OPTIONS_STRUCT.mdx) | - |
|
|
325
357
|
| [SEGMENTATION\_MODELS](variables/SEGMENTATION_MODELS.mdx) | - |
|
|
326
358
|
| [isSegmentationModel](variables/isSegmentationModel.mdx) | - |
|
|
327
359
|
| [isRenderingEvents](variables/isRenderingEvents.mdx) | - |
|
|
328
360
|
| [toRenderingEvents](variables/toRenderingEvents.mdx) | - |
|
|
329
361
|
| [getErrorMessage](variables/getErrorMessage.mdx) | - |
|
|
330
362
|
| [createObjectUpdater](variables/createObjectUpdater.mdx) | - |
|
|
363
|
+
| [ImageFetchError](variables/ImageFetchError.mdx) | - |
|
|
331
364
|
| [createRemoteImageBitmap](variables/createRemoteImageBitmap.mdx) | - |
|
|
332
365
|
| [clamping](variables/clamping.mdx) | - |
|
|
333
366
|
| [calculateMaxBlurPass](variables/calculateMaxBlurPass.mdx) | - |
|
|
334
367
|
| [resize](variables/resize.mdx) | Calculate the coordinates and size of the source and destination to fit the target aspect ratio. |
|
|
335
368
|
| [createLazyProps](variables/createLazyProps.mdx) | - |
|
|
336
369
|
| [handleWebGLContextLoss](variables/handleWebGLContextLoss.mdx) | - |
|
|
370
|
+
| [cloneImageRecord](variables/cloneImageRecord.mdx) | - |
|
|
371
|
+
| [compareImageRecords](variables/compareImageRecords.mdx) | Compare provided ImageRecord |
|
|
337
372
|
| [urls](variables/urls.mdx) | - |
|
|
338
373
|
| [SILENT\_THRESHOLD](variables/SILENT_THRESHOLD.mdx) | Default silent threshold At least one LSB 16-bit data (compare is on absolute value). |
|
|
339
374
|
| [MONO\_THRESHOLD](variables/MONO_THRESHOLD.mdx) | Default mono detection threshold Data must be identical within one LSB 16-bit to be identified as mono. |
|
|
@@ -341,6 +376,7 @@ A library for media analysis using Web APIs.
|
|
|
341
376
|
| [CLIP\_THRESHOLD](variables/CLIP_THRESHOLD.mdx) | Default clipping detection threshold |
|
|
342
377
|
| [VOICE\_PROBABILITY\_THRESHOLD](variables/VOICE_PROBABILITY_THRESHOLD.mdx) | Default Voice probability threshold |
|
|
343
378
|
| [CLIP\_COUNT\_THRESHOLD](variables/CLIP_COUNT_THRESHOLD.mdx) | Default clipping count threshold Number of consecutive clipThreshold level samples that indicate clipping. |
|
|
379
|
+
| [MediaStreamTrackTransferable](variables/MediaStreamTrackTransferable.mdx) | Result of the feature detection if `MediaStreamTrack` is `Transferable` |
|
|
344
380
|
| [FRAME\_RATE](variables/FRAME_RATE.mdx) | - |
|
|
345
381
|
| [PLAY\_VIDEO\_TIMEOUT](variables/PLAY_VIDEO_TIMEOUT.mdx) | - |
|
|
346
382
|
|
|
@@ -348,6 +384,10 @@ A library for media analysis using Web APIs.
|
|
|
348
384
|
|
|
349
385
|
| Function | Description |
|
|
350
386
|
| ------ | ------ |
|
|
387
|
+
| [nearestPowerOfTwo](functions/nearestPowerOfTwo.mdx) | Coerce any positive number to the nearest power of two within [minPow, maxPow] Example: nearestPowerOfTwo(13) => 16; nearestPowerOfTwo(3.2) => 4 |
|
|
388
|
+
| [iou](functions/iou.mdx) | Intersection over Union (IoU), how much two masks overlap as a fraction of either's total. 1.0 = perfect match, 0 = no overlap. Used for stable, robust tracking of the main person between frames, especially with bystander removal and temporal instance switching. |
|
|
389
|
+
| [labelComponents](functions/labelComponents.mdx) | - |
|
|
390
|
+
| [scoreComponent](functions/scoreComponent.mdx) | - |
|
|
351
391
|
| [createAudioContext](functions/createAudioContext.mdx) | A function to create `AudioContext` using constructor or factory function depends on the browser supports |
|
|
352
392
|
| [resumeAudioOnInterruption](functions/resumeAudioOnInterruption.mdx) | Resume the stream whenever interrupted |
|
|
353
393
|
| [resumeAudioOnUnmute](functions/resumeAudioOnUnmute.mdx) | Resume the AudioContext whenever the source track is unmuted |
|
|
@@ -366,7 +406,8 @@ A library for media analysis using Web APIs.
|
|
|
366
406
|
| [createChannelMergerGraphNode](functions/createChannelMergerGraphNode.mdx) | Create a ChannelMergerNode |
|
|
367
407
|
| [createAudioGraph](functions/createAudioGraph.mdx) | Accepts AudioNodeInitConnections to build the audio graph within a signal audio context |
|
|
368
408
|
| [createAudioGraphProxy](functions/createAudioGraphProxy.mdx) | - |
|
|
369
|
-
| [createBenchmark](functions/createBenchmark.mdx) |
|
|
409
|
+
| [createBenchmark](functions/createBenchmark.mdx) | Creates a benchmarking utility for measuring frame durations and calculating frames per second (FPS). |
|
|
410
|
+
| [createWindowedStats](functions/createWindowedStats.mdx) | - |
|
|
370
411
|
| [sum](functions/sum.mdx) | Sum an array of numbers |
|
|
371
412
|
| [avg](functions/avg.mdx) | Average an array of numbers |
|
|
372
413
|
| [pow](functions/pow.mdx) | pow function from Math in functional form `number -> number -> number` |
|
|
@@ -394,16 +435,21 @@ A library for media analysis using Web APIs.
|
|
|
394
435
|
| [isAudioNodeInit](functions/isAudioNodeInit.mdx) | - |
|
|
395
436
|
| [isAnalyzerNodeInit](functions/isAnalyzerNodeInit.mdx) | - |
|
|
396
437
|
| [createAsyncCallbackLoop](functions/createAsyncCallbackLoop.mdx) | Create an async callback loop to be called recursively with delay based on the `frameRate` |
|
|
397
|
-
| [
|
|
438
|
+
| [createReadWritableStreamInputProcessAdaptor](functions/createReadWritableStreamInputProcessAdaptor.mdx) | An implementation of `InputProcessAdaptor` which uses `MediaStreamTrackGenerator` and `MediaStreamTrackProcessor` APIs to create `ReadableStream` & `WritableStream` |
|
|
439
|
+
| [createReadWritableStreamFallbackInputProcessAdaptor](functions/createReadWritableStreamFallbackInputProcessAdaptor.mdx) | An implementation of `InputProcessAdaptor` which uses `HTMLCanvasElement` or `OffscreenCanvas` API to create `ReadableStream` & `WritableStream` |
|
|
440
|
+
| [createMediaStreamTrackInputProcessAdaptor](functions/createMediaStreamTrackInputProcessAdaptor.mdx) | An implementation of `InputProcessAdaptor` which adapts `MediaStreamTrack` directly as specified from the spec https://w3c.github.io/mediacapture-transform |
|
|
441
|
+
| [getDefaultInputProcessAdaptor](functions/getDefaultInputProcessAdaptor.mdx) | Get the supported InputProcessAdaptor based on feature detection and preference provided |
|
|
398
442
|
| [loadScript](functions/loadScript.mdx) | - |
|
|
399
443
|
| [loadWasms](functions/loadWasms.mdx) | - |
|
|
400
444
|
| [createSegmenter](functions/createSegmenter.mdx) | - |
|
|
401
445
|
| [isRenderEffects](functions/isRenderEffects.mdx) | - |
|
|
446
|
+
| [isMediaStreamVideoTrack](functions/isMediaStreamVideoTrack.mdx) | - |
|
|
447
|
+
| [assertMediaStreamVideoTrack](functions/assertMediaStreamVideoTrack.mdx) | - |
|
|
402
448
|
| [createCanvas](functions/createCanvas.mdx) | Create a Canvas element with provided width and height |
|
|
449
|
+
| [setVideoElementSrc](functions/setVideoElementSrc.mdx) | - |
|
|
450
|
+
| [playVideo](functions/playVideo.mdx) | - |
|
|
403
451
|
| [createFrameCallbackRequest](functions/createFrameCallbackRequest.mdx) | Create a callback loop for video frame processing using `requestVideoFrameCallback` under-the-hood when available otherwise our fallback implementation based on `setTimeout`. |
|
|
404
452
|
| [createVideoProcessor](functions/createVideoProcessor.mdx) | - |
|
|
405
|
-
| [createVideoTrackProcessor](functions/createVideoTrackProcessor.mdx) | Video track processor using MediaStreamTrackProcessor API |
|
|
406
|
-
| [createVideoTrackProcessorWithFallback](functions/createVideoTrackProcessorWithFallback.mdx) | Video track processor using Canvas[captureStream] API |
|
|
407
453
|
| [calculateDistance](functions/calculateDistance.mdx) | Calculate the distance between two Points |
|
|
408
454
|
| [getBezierCurveControlPoints](functions/getBezierCurveControlPoints.mdx) | Spline Interpolation for Bezier Curve |
|
|
409
455
|
| [line](functions/line.mdx) | Create a straight line path command |
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
```ts
|
|
2
|
-
function createBenchmark(clock,
|
|
2
|
+
function createBenchmark(clock, options): Benchmark;
|
|
3
3
|
```
|
|
4
4
|
|
|
5
|
+
Creates a benchmarking utility for measuring frame durations and calculating frames per second (FPS).
|
|
6
|
+
|
|
5
7
|
## Parameters
|
|
6
8
|
|
|
7
|
-
| Parameter | Type | Default value |
|
|
8
|
-
| ------ | ------ | ------ |
|
|
9
|
-
| `clock` | [`Clock`](../interfaces/Clock.mdx) | `performance` |
|
|
10
|
-
| `
|
|
9
|
+
| Parameter | Type | Default value | Description |
|
|
10
|
+
| ------ | ------ | ------ | ------ |
|
|
11
|
+
| `clock` | [`Clock`](../interfaces/Clock.mdx) | `performance` | An object with a `now()` method returning the current timestamp (in milliseconds). Defaults to `window.performance`. |
|
|
12
|
+
| `options` | `BenchmarkOptions` | `{}` | Optional configuration options for the benchmark utility. |
|
|
11
13
|
|
|
12
14
|
## Returns
|
|
13
15
|
|
|
14
16
|
[`Benchmark`](../interfaces/Benchmark.mdx)
|
|
17
|
+
|
|
18
|
+
An object with methods to start/end frame measurements, reset the benchmark, and calculate current FPS.
|
|
19
|
+
|
|
20
|
+
## Remarks
|
|
21
|
+
|
|
22
|
+
This function is designed for performance measurement in animation or game loops.
|
|
23
|
+
It records frame start/end times, ignores an initial warmup period, utilizes a circular buffer
|
|
24
|
+
to average recent frame durations, and computes a smoothed FPS value on demand.
|
|
25
|
+
The calculation may only occur if sufficient samples have been gathered and the minimum interval between
|
|
26
|
+
calculations has elapsed.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
```ts
|
|
2
|
-
function createFrameCallbackRequest(
|
|
2
|
+
function createFrameCallbackRequest<T>(
|
|
3
3
|
callback,
|
|
4
4
|
frameRate,
|
|
5
5
|
__namedParameters): object;
|
|
@@ -9,11 +9,17 @@ Create a callback loop for video frame processing using
|
|
|
9
9
|
`requestVideoFrameCallback` under-the-hood when available otherwise our
|
|
10
10
|
fallback implementation based on `setTimeout`.
|
|
11
11
|
|
|
12
|
+
## Type Parameters
|
|
13
|
+
|
|
14
|
+
| Type Parameter |
|
|
15
|
+
| ------ |
|
|
16
|
+
| `T` |
|
|
17
|
+
|
|
12
18
|
## Parameters
|
|
13
19
|
|
|
14
20
|
| Parameter | Type | Description |
|
|
15
21
|
| ------ | ------ | ------ |
|
|
16
|
-
| `callback` | [`Callback`](../type-aliases/Callback.mdx)\<`Promise`\<`void`\>, \[
|
|
22
|
+
| `callback` | [`Callback`](../type-aliases/Callback.mdx)\<`Promise`\<`void`\>, \[`T`\]\> | To be called by the loop |
|
|
17
23
|
| `frameRate` | `number` | A fallback frame rate when we are not able to get the rate from API |
|
|
18
24
|
| `__namedParameters` | `FrameCallbackRequestOptions` | - |
|
|
19
25
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function createMediaStreamTrackInputProcessAdaptor(): InputProcessAdaptor;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
An implementation of `InputProcessAdaptor` which adapts `MediaStreamTrack`
|
|
6
|
+
directly as specified from the spec https://w3c.github.io/mediacapture-transform
|
|
7
|
+
|
|
8
|
+
## Returns
|
|
9
|
+
|
|
10
|
+
[`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function createReadWritableStreamFallbackInputProcessAdaptor(__namedParameters): InputProcessAdaptor;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
An implementation of `InputProcessAdaptor` which uses `HTMLCanvasElement` or
|
|
6
|
+
`OffscreenCanvas` API to create `ReadableStream` & `WritableStream`
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Type | Description |
|
|
11
|
+
| ------ | ------ | ------ |
|
|
12
|
+
| `__namedParameters` | \{ `frameRate`: `number`; \} | - |
|
|
13
|
+
| `__namedParameters.frameRate` | `number` | Fallback frame rate |
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
[`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function createReadWritableStreamInputProcessAdaptor(): InputProcessAdaptor;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
An implementation of `InputProcessAdaptor` which uses `MediaStreamTrackGenerator` and
|
|
6
|
+
`MediaStreamTrackProcessor` APIs to create `ReadableStream` & `WritableStream`
|
|
7
|
+
|
|
8
|
+
## Returns
|
|
9
|
+
|
|
10
|
+
[`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
```ts
|
|
2
|
-
function createVideoProcessor(
|
|
2
|
+
function createVideoProcessor(segmenter, inputProcessAdaptor): VideoProcessor;
|
|
3
3
|
```
|
|
4
4
|
|
|
5
5
|
## Parameters
|
|
6
6
|
|
|
7
7
|
| Parameter | Type |
|
|
8
8
|
| ------ | ------ |
|
|
9
|
-
| `
|
|
10
|
-
| `
|
|
9
|
+
| `segmenter` | [`Segmenter`](../interfaces/Segmenter.mdx) |
|
|
10
|
+
| `inputProcessAdaptor` | [`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx) |
|
|
11
11
|
|
|
12
12
|
## Returns
|
|
13
13
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function createWindowedStats(windowSize): object;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
## Parameters
|
|
6
|
+
|
|
7
|
+
| Parameter | Type |
|
|
8
|
+
| ------ | ------ |
|
|
9
|
+
| `windowSize` | `number` |
|
|
10
|
+
|
|
11
|
+
## Returns
|
|
12
|
+
|
|
13
|
+
`object`
|
|
14
|
+
|
|
15
|
+
| Name | Type |
|
|
16
|
+
| ------ | ------ |
|
|
17
|
+
| `add()` | (`value`) => `void` |
|
|
18
|
+
| `get mean` | `number` |
|
|
19
|
+
| `get variance` | `number` |
|
|
20
|
+
| `get stddev` | `number` |
|
|
21
|
+
| `get stdError` | `number` |
|
|
22
|
+
| `get count` | `number` |
|
|
23
|
+
| `clear()` | () => `void` |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function getDefaultInputProcessAdaptor(tryNativeAPI, targetFrameRate): InputProcessAdaptor;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
Get the supported InputProcessAdaptor based on feature detection
|
|
6
|
+
and preference provided
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
| Parameter | Type | Default value | Description |
|
|
11
|
+
| ------ | ------ | ------ | ------ |
|
|
12
|
+
| `tryNativeAPI` | `boolean` | `true` | Whether or not to try to use the Native MediaStreamTrackProcessor APIs |
|
|
13
|
+
| `targetFrameRate` | `number` | `FRAME_RATE` | The target frame rate to use when fallback implementation of video frame extraction rate |
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
[`InputProcessAdaptor`](../interfaces/InputProcessAdaptor.mdx)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function iou(a, b): number;
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
Intersection over Union (IoU), how much two masks overlap as a fraction of either's total.
|
|
6
|
+
1.0 = perfect match, 0 = no overlap.
|
|
7
|
+
Used for stable, robust tracking of the main person between frames,
|
|
8
|
+
especially with bystander removal and temporal instance switching.
|
|
9
|
+
|
|
10
|
+
## Parameters
|
|
11
|
+
|
|
12
|
+
| Parameter | Type |
|
|
13
|
+
| ------ | ------ |
|
|
14
|
+
| `a` | `Uint8Array` |
|
|
15
|
+
| `b` | `Uint8Array` |
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
`number`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function labelComponents(
|
|
3
|
+
input,
|
|
4
|
+
labels,
|
|
5
|
+
width,
|
|
6
|
+
height): Map<number, Stats>;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
| Parameter | Type |
|
|
12
|
+
| ------ | ------ |
|
|
13
|
+
| `input` | `Uint8Array` |
|
|
14
|
+
| `labels` | `Int32Array` |
|
|
15
|
+
| `width` | `number` |
|
|
16
|
+
| `height` | `number` |
|
|
17
|
+
|
|
18
|
+
## Returns
|
|
19
|
+
|
|
20
|
+
`Map`\<`number`, [`Stats`](../interfaces/Stats.mdx)\>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function nearestPowerOfTwo(
|
|
3
|
+
n,
|
|
4
|
+
minPow?,
|
|
5
|
+
maxPow?): number;
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Coerce any positive number to the nearest power of two within [minPow, maxPow]
|
|
9
|
+
Example: nearestPowerOfTwo(13) => 16; nearestPowerOfTwo(3.2) => 4
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
| Parameter | Type |
|
|
14
|
+
| ------ | ------ |
|
|
15
|
+
| `n` | `number` |
|
|
16
|
+
| `minPow?` | `number` |
|
|
17
|
+
| `maxPow?` | `number` |
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`number`
|