Browse Source

fix(virtual-background) use tighter edge smoothing

j8
Saúl Ibarra Corretgé 4 years ago
parent
commit
31ace267ce

+ 16
- 2
react/features/stream-effects/virtual-background/JitsiStreamBackgroundEffect.js View File

80
         this._outputCanvasCtx.globalCompositeOperation = 'copy';
80
         this._outputCanvasCtx.globalCompositeOperation = 'copy';
81
 
81
 
82
         // Draw segmentation mask.
82
         // Draw segmentation mask.
83
-        this._outputCanvasCtx.filter = `blur(${blurValue})`;
83
+        //
84
+
85
+        // Smooth out the edges.
86
+        if (this._options.virtualBackground.isVirtualBackground) {
87
+            this._outputCanvasCtx.filter = 'blur(4px)';
88
+        } else {
89
+            this._outputCanvasCtx.filter = 'blur(8px)';
90
+        }
91
+
84
         this._outputCanvasCtx.drawImage(
92
         this._outputCanvasCtx.drawImage(
85
             this._segmentationMaskCanvas,
93
             this._segmentationMaskCanvas,
86
             0,
94
             0,
92
             this._inputVideoElement.width,
100
             this._inputVideoElement.width,
93
             this._inputVideoElement.height
101
             this._inputVideoElement.height
94
         );
102
         );
95
-
96
         this._outputCanvasCtx.globalCompositeOperation = 'source-in';
103
         this._outputCanvasCtx.globalCompositeOperation = 'source-in';
97
         this._outputCanvasCtx.filter = 'none';
104
         this._outputCanvasCtx.filter = 'none';
105
+
106
+        // Draw the foreground video.
107
+        //
108
+
98
         this._outputCanvasCtx.drawImage(this._inputVideoElement, 0, 0);
109
         this._outputCanvasCtx.drawImage(this._inputVideoElement, 0, 0);
99
 
110
 
111
+        // Draw the background.
112
+        //
113
+
100
         this._outputCanvasCtx.globalCompositeOperation = 'destination-over';
114
         this._outputCanvasCtx.globalCompositeOperation = 'destination-over';
101
         if (this._options.virtualBackground.isVirtualBackground) {
115
         if (this._options.virtualBackground.isVirtualBackground) {
102
             this._outputCanvasCtx.drawImage(this.virtualImage, 0, 0);
116
             this._outputCanvasCtx.drawImage(this.virtualImage, 0, 0);

Loading…
Cancel
Save