mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Load background detection network only when required
This commit is contained in:
		@@ -962,19 +962,25 @@ class CallWindow extends CustomEvents {
 | 
			
		||||
			canvasTarget.height = videoTarget.height;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			bodyPix.load({
 | 
			
		||||
				multiplier: 0.75,
 | 
			
		||||
				stride: 32,
 | 
			
		||||
				quantBytes: 4
 | 
			
		||||
			}).then( net => {
 | 
			
		||||
			// Process images
 | 
			
		||||
			(async () => {
 | 
			
		||||
				try {
 | 
			
		||||
 | 
			
		||||
						
 | 
			
		||||
					while(videoTrack.readyState == "live")
 | 
			
		||||
					{
 | 
			
		||||
						if (this.blurBackground) {
 | 
			
		||||
								const segmentation = await net.segmentPerson(videoTarget);
 | 
			
		||||
 | 
			
		||||
							// Load network if required
 | 
			
		||||
							if (!this.backgroundDetectionNetwork)
 | 
			
		||||
							{
 | 
			
		||||
								this.backgroundDetectionNetwork = await bodyPix.load({
 | 
			
		||||
									multiplier: 0.75,
 | 
			
		||||
									stride: 32,
 | 
			
		||||
									quantBytes: 4
 | 
			
		||||
								});
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
							const segmentation = await this.backgroundDetectionNetwork.segmentPerson(videoTarget);
 | 
			
		||||
 | 
			
		||||
							const backgroundBlurAmount = 6;
 | 
			
		||||
							const edgeBlurAmount = 2;
 | 
			
		||||
@@ -996,7 +1002,6 @@ class CallWindow extends CustomEvents {
 | 
			
		||||
					console.error("Failure", e);
 | 
			
		||||
				}
 | 
			
		||||
			})();
 | 
			
		||||
			});
 | 
			
		||||
			
 | 
			
		||||
			
 | 
			
		||||
			stream = canvasTarget.captureStream();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user