@stream-io/video-filters-web 0.7.2 → 0.7.3
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 +6 -0
- package/dist/index.cjs.js +6 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +6 -4
- package/dist/index.es.js.map +1 -1
- package/dist/src/WebGLRenderer.d.ts +5 -0
- package/dist/src/types.d.ts +31 -0
- package/package.json +1 -1
- package/src/VirtualBackground.ts +2 -0
- package/src/WebGLRenderer.ts +17 -3
- package/src/types.ts +34 -0
|
@@ -75,6 +75,11 @@ export declare class WebGLRenderer {
|
|
|
75
75
|
bgBlur: number;
|
|
76
76
|
bgBlurRadius: number;
|
|
77
77
|
isSelfieMode: boolean;
|
|
78
|
+
segmentationOptions?: {
|
|
79
|
+
smoothingFactor?: number;
|
|
80
|
+
smoothstepMin?: number;
|
|
81
|
+
smoothstepMax?: number;
|
|
82
|
+
};
|
|
78
83
|
}, categoryTexture?: WebGLTexture, confidenceTexture?: WebGLTexture): void;
|
|
79
84
|
close(): void;
|
|
80
85
|
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -7,11 +7,41 @@ export type BackgroundSource = {
|
|
|
7
7
|
};
|
|
8
8
|
export type BackgroundFilter = 'blur' | 'image';
|
|
9
9
|
export type BackgroundBlurLevel = 'low' | 'medium' | 'high' | number;
|
|
10
|
+
/**
|
|
11
|
+
* Options for controlling the segmentation mask smoothing.
|
|
12
|
+
* These values are passed to the WebGL shader that blends
|
|
13
|
+
* consecutive segmentation masks over time.
|
|
14
|
+
*/
|
|
15
|
+
export interface SegmentationOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Controls how fast the mask adapts to new segmentation results.
|
|
18
|
+
* Higher values make the mask react faster but may cause flickering.
|
|
19
|
+
* Lower values produce smoother transitions but increase latency.
|
|
20
|
+
* Value should be between 0 and 1.
|
|
21
|
+
* @default 0.8
|
|
22
|
+
*/
|
|
23
|
+
smoothingFactor?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Lower edge of the smoothstep function applied to the confidence mask.
|
|
26
|
+
* Confidence values below this are mapped to 0 (background).
|
|
27
|
+
* Value should be between 0 and 1, and less than smoothstepMax.
|
|
28
|
+
* @default 0.6
|
|
29
|
+
*/
|
|
30
|
+
smoothstepMin?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Upper edge of the smoothstep function applied to the confidence mask.
|
|
33
|
+
* Confidence values above this are mapped to 1 (foreground).
|
|
34
|
+
* Value should be between 0 and 1, and greater than smoothstepMin.
|
|
35
|
+
* @default 0.9
|
|
36
|
+
*/
|
|
37
|
+
smoothstepMax?: number;
|
|
38
|
+
}
|
|
10
39
|
export interface SegmenterOptions {
|
|
11
40
|
backgroundSource?: BackgroundSource | null;
|
|
12
41
|
bgBlur: number;
|
|
13
42
|
bgBlurRadius: number;
|
|
14
43
|
isSelfieMode: boolean;
|
|
44
|
+
segmentationOptions?: SegmentationOptions;
|
|
15
45
|
}
|
|
16
46
|
/**
|
|
17
47
|
* Static configuration for the processor, defining which background
|
|
@@ -23,6 +53,7 @@ export interface BackgroundOptions {
|
|
|
23
53
|
backgroundFilter?: BackgroundFilter;
|
|
24
54
|
backgroundBlurLevel?: BackgroundBlurLevel;
|
|
25
55
|
backgroundImage?: string | undefined;
|
|
56
|
+
segmentationOptions?: SegmentationOptions;
|
|
26
57
|
}
|
|
27
58
|
/**
|
|
28
59
|
* Performance statistics for video processing.
|
package/package.json
CHANGED
package/src/VirtualBackground.ts
CHANGED
|
@@ -124,6 +124,7 @@ export class VirtualBackground extends BaseVideoProcessor {
|
|
|
124
124
|
bgBlur: 0,
|
|
125
125
|
bgBlurRadius: 0,
|
|
126
126
|
isSelfieMode,
|
|
127
|
+
segmentationOptions: this.options.segmentationOptions,
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
130
|
|
|
@@ -138,6 +139,7 @@ export class VirtualBackground extends BaseVideoProcessor {
|
|
|
138
139
|
bgBlur: Math.min(strength * 1.5, 20),
|
|
139
140
|
bgBlurRadius: Math.min(strength, 10),
|
|
140
141
|
isSelfieMode,
|
|
142
|
+
segmentationOptions: this.options.segmentationOptions,
|
|
141
143
|
};
|
|
142
144
|
}
|
|
143
145
|
|
package/src/WebGLRenderer.ts
CHANGED
|
@@ -754,6 +754,11 @@ export class WebGLRenderer {
|
|
|
754
754
|
bgBlur: number;
|
|
755
755
|
bgBlurRadius: number;
|
|
756
756
|
isSelfieMode: boolean;
|
|
757
|
+
segmentationOptions?: {
|
|
758
|
+
smoothingFactor?: number;
|
|
759
|
+
smoothstepMin?: number;
|
|
760
|
+
smoothstepMax?: number;
|
|
761
|
+
};
|
|
757
762
|
},
|
|
758
763
|
categoryTexture?: WebGLTexture,
|
|
759
764
|
confidenceTexture?: WebGLTexture,
|
|
@@ -864,9 +869,18 @@ export class WebGLRenderer {
|
|
|
864
869
|
gl.bindTexture(gl.TEXTURE_2D, prevStateTexture);
|
|
865
870
|
gl.uniform1i(stateUpdateLocations.prevStateTexture, 2);
|
|
866
871
|
|
|
867
|
-
gl.uniform1f(
|
|
868
|
-
|
|
869
|
-
|
|
872
|
+
gl.uniform1f(
|
|
873
|
+
stateUpdateLocations.smoothingFactor,
|
|
874
|
+
options.segmentationOptions?.smoothingFactor ?? 0.8,
|
|
875
|
+
);
|
|
876
|
+
gl.uniform1f(
|
|
877
|
+
stateUpdateLocations.smoothstepMin,
|
|
878
|
+
options.segmentationOptions?.smoothstepMin ?? 0.6,
|
|
879
|
+
);
|
|
880
|
+
gl.uniform1f(
|
|
881
|
+
stateUpdateLocations.smoothstepMax,
|
|
882
|
+
options.segmentationOptions?.smoothstepMax ?? 0.9,
|
|
883
|
+
);
|
|
870
884
|
|
|
871
885
|
gl.uniform1i(
|
|
872
886
|
stateUpdateLocations.selfieModel,
|
package/src/types.ts
CHANGED
|
@@ -8,11 +8,44 @@ export type BackgroundSource = {
|
|
|
8
8
|
export type BackgroundFilter = 'blur' | 'image';
|
|
9
9
|
export type BackgroundBlurLevel = 'low' | 'medium' | 'high' | number;
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Options for controlling the segmentation mask smoothing.
|
|
13
|
+
* These values are passed to the WebGL shader that blends
|
|
14
|
+
* consecutive segmentation masks over time.
|
|
15
|
+
*/
|
|
16
|
+
export interface SegmentationOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Controls how fast the mask adapts to new segmentation results.
|
|
19
|
+
* Higher values make the mask react faster but may cause flickering.
|
|
20
|
+
* Lower values produce smoother transitions but increase latency.
|
|
21
|
+
* Value should be between 0 and 1.
|
|
22
|
+
* @default 0.8
|
|
23
|
+
*/
|
|
24
|
+
smoothingFactor?: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Lower edge of the smoothstep function applied to the confidence mask.
|
|
28
|
+
* Confidence values below this are mapped to 0 (background).
|
|
29
|
+
* Value should be between 0 and 1, and less than smoothstepMax.
|
|
30
|
+
* @default 0.6
|
|
31
|
+
*/
|
|
32
|
+
smoothstepMin?: number;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Upper edge of the smoothstep function applied to the confidence mask.
|
|
36
|
+
* Confidence values above this are mapped to 1 (foreground).
|
|
37
|
+
* Value should be between 0 and 1, and greater than smoothstepMin.
|
|
38
|
+
* @default 0.9
|
|
39
|
+
*/
|
|
40
|
+
smoothstepMax?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
11
43
|
export interface SegmenterOptions {
|
|
12
44
|
backgroundSource?: BackgroundSource | null;
|
|
13
45
|
bgBlur: number;
|
|
14
46
|
bgBlurRadius: number;
|
|
15
47
|
isSelfieMode: boolean;
|
|
48
|
+
segmentationOptions?: SegmentationOptions;
|
|
16
49
|
}
|
|
17
50
|
/**
|
|
18
51
|
* Static configuration for the processor, defining which background
|
|
@@ -24,6 +57,7 @@ export interface BackgroundOptions {
|
|
|
24
57
|
backgroundFilter?: BackgroundFilter;
|
|
25
58
|
backgroundBlurLevel?: BackgroundBlurLevel;
|
|
26
59
|
backgroundImage?: string | undefined;
|
|
60
|
+
segmentationOptions?: SegmentationOptions;
|
|
27
61
|
}
|
|
28
62
|
|
|
29
63
|
/**
|