Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const coloredPartImageData = bodyPix.toColoredPartMask(
multiPersonPartSegmentation,
partColorScales[guiState.partMap.colorScale]);
const maskBlurAmount = 0;
switch (guiState.partMap.effect) {
case 'pixelation':
const pixelCellWidth = 10.0;
bodyPix.drawPixelatedMask(
canvas, state.video, coloredPartImageData,
guiState.partMap.opacity, maskBlurAmount, flipHorizontally,
pixelCellWidth);
break;
case 'partMap':
bodyPix.drawMask(
canvas, state.video, coloredPartImageData, guiState.opacity,
maskBlurAmount, flipHorizontally);
break;
case 'blurBodyPart':
const blurBodyPartIds = [0, 1];
bodyPix.blurBodyPart(
canvas, state.video, multiPersonPartSegmentation,
blurBodyPartIds, guiState.partMap.blurBodyPartAmount,
guiState.partMap.edgeBlurAmount, flipHorizontally);
}
drawPoses(multiPersonPartSegmentation, flipHorizontally, ctx);
break;
default:
break;
}
const flipHorizontally = guiState.flipHorizontal;
switch (guiState.estimate) {
case 'segmentation':
const multiPersonSegmentation = await estimateSegmentation();
switch (guiState.segmentation.effect) {
case 'mask':
const ctx = canvas.getContext('2d');
const foregroundColor = {r: 255, g: 255, b: 255, a: 255};
const backgroundColor = {r: 0, g: 0, b: 0, a: 255};
const mask = bodyPix.toMask(
multiPersonSegmentation, foregroundColor, backgroundColor,
true);
bodyPix.drawMask(
canvas, state.video, mask, guiState.segmentation.opacity,
guiState.segmentation.maskBlurAmount, flipHorizontally);
drawPoses(multiPersonSegmentation, flipHorizontally, ctx);
break;
case 'bokeh':
bodyPix.drawBokehEffect(
canvas, state.video, multiPersonSegmentation,
+guiState.segmentation.backgroundBlurAmount,
guiState.segmentation.edgeBlurAmount, flipHorizontally);
break;
}
break;
case 'partmap':
const ctx = canvas.getContext('2d');
const multiPersonPartSegmentation = await estimatePartSegmentation();