@stream-io/video-filters-web 0.1.4 → 0.1.6
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 +14 -0
- package/dist/index.cjs.js +7 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +7 -4
- package/dist/index.es.js.map +1 -1
- package/dist/src/webgl2/resizingStage.d.ts +1 -1
- package/dist/src/webgl2/webgl2Pipeline.d.ts +1 -1
- package/package.json +1 -1
- package/src/helpers/webglHelper.ts +3 -1
- package/src/webgl2/resizingStage.ts +4 -1
- package/src/webgl2/webgl2Pipeline.ts +2 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TFLite } from '../tflite';
|
|
2
2
|
import { SegmentationParams } from '../segmentation';
|
|
3
|
-
export declare function buildResizingStage(gl: WebGL2RenderingContext, vertexShader: WebGLShader, positionBuffer: WebGLBuffer, texCoordBuffer: WebGLBuffer, tflite: TFLite, segmentationConfig: SegmentationParams): {
|
|
3
|
+
export declare function buildResizingStage(gl: WebGL2RenderingContext, vertexShader: WebGLShader, positionBuffer: WebGLBuffer, texCoordBuffer: WebGLBuffer, tflite: TFLite, segmentationConfig: SegmentationParams, onError?: (error: any) => void): {
|
|
4
4
|
render: () => void;
|
|
5
5
|
cleanUp: () => void;
|
|
6
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TFLite } from '../tflite';
|
|
2
2
|
import { BackgroundBlurLevel, BackgroundFilter } from '../createRenderer';
|
|
3
3
|
import { SegmentationParams } from '../segmentation';
|
|
4
|
-
export declare function buildWebGL2Pipeline(videoSource: HTMLVideoElement, backgroundImage: HTMLImageElement | undefined, blurLevel: BackgroundBlurLevel | undefined, backgroundFilter: BackgroundFilter, canvas: HTMLCanvasElement, tflite: TFLite, segmentationConfig: SegmentationParams): {
|
|
4
|
+
export declare function buildWebGL2Pipeline(videoSource: HTMLVideoElement, backgroundImage: HTMLImageElement | undefined, blurLevel: BackgroundBlurLevel | undefined, backgroundFilter: BackgroundFilter, canvas: HTMLCanvasElement, tflite: TFLite, segmentationConfig: SegmentationParams, onError?: (error: any) => void): {
|
|
5
5
|
render: () => void;
|
|
6
6
|
updatePostProcessingConfig: () => void;
|
|
7
7
|
cleanUp: () => void;
|
package/package.json
CHANGED
|
@@ -111,8 +111,10 @@ async function getBufferSubDataAsync(
|
|
|
111
111
|
dstOffset?: number,
|
|
112
112
|
length?: number,
|
|
113
113
|
) {
|
|
114
|
-
const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0)
|
|
114
|
+
const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
115
115
|
gl.flush();
|
|
116
|
+
if (!sync) return;
|
|
117
|
+
|
|
116
118
|
const res = await clientWaitAsync(gl, sync);
|
|
117
119
|
gl.deleteSync(sync);
|
|
118
120
|
|
|
@@ -15,6 +15,7 @@ export function buildResizingStage(
|
|
|
15
15
|
texCoordBuffer: WebGLBuffer,
|
|
16
16
|
tflite: TFLite,
|
|
17
17
|
segmentationConfig: SegmentationParams,
|
|
18
|
+
onError?: (error: any) => void,
|
|
18
19
|
) {
|
|
19
20
|
const fragmentShaderSource = glsl`#version 300 es
|
|
20
21
|
|
|
@@ -81,7 +82,9 @@ export function buildResizingStage(
|
|
|
81
82
|
gl.RGBA,
|
|
82
83
|
gl.UNSIGNED_BYTE,
|
|
83
84
|
outputPixels,
|
|
84
|
-
)
|
|
85
|
+
).catch((error: any) => {
|
|
86
|
+
onError?.(error);
|
|
87
|
+
});
|
|
85
88
|
|
|
86
89
|
for (let i = 0; i < outputPixelCount; i++) {
|
|
87
90
|
const tfliteIndex = tfliteInputMemoryOffset + i * 3;
|
|
@@ -22,6 +22,7 @@ export function buildWebGL2Pipeline(
|
|
|
22
22
|
canvas: HTMLCanvasElement,
|
|
23
23
|
tflite: TFLite,
|
|
24
24
|
segmentationConfig: SegmentationParams,
|
|
25
|
+
onError?: (error: any) => void,
|
|
25
26
|
) {
|
|
26
27
|
const gl = canvas.getContext('webgl2')!;
|
|
27
28
|
if (!gl) throw new Error('WebGL2 is not supported');
|
|
@@ -95,6 +96,7 @@ export function buildWebGL2Pipeline(
|
|
|
95
96
|
texCoordBuffer,
|
|
96
97
|
tflite,
|
|
97
98
|
segmentationConfig,
|
|
99
|
+
onError,
|
|
98
100
|
);
|
|
99
101
|
const loadSegmentationStage = buildSoftmaxStage(
|
|
100
102
|
gl,
|