Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await new Promise(resolve => {
this.video.onloadeddata = () => resolve();
});
}
this.config.palette = segmentationOptions.palette || this.config.palette;
this.config.outputStride = segmentationOptions.outputStride || this.config.outputStride;
this.config.segmentationThreshold = segmentationOptions.segmentationThreshold || this.config.segmentationThreshold;
const bodyPartsMeta = this.bodyPartsSpec(this.config.palette);
const segmentation = await this.model.estimatePartSegmentation(imgToSegment, this.config.outputStride, this.config.segmentationThreshold);
const colorsArray = Object.keys(bodyPartsMeta).map(part => bodyPartsMeta[part].color)
const result = {};
result.image = bp.toColoredPartImageData(segmentation, colorsArray);
result.raw = segmentation;
result.bodyParts = bodyPartsMeta;
if (p5Utils.checkP5()) {
const blob1 = await p5Utils.rawToBlob(result.image.data, segmentation.width, segmentation.height);
const p5Image1 = await p5Utils.blobToP5Image(blob1);
result.image = p5Image1;
}
return result;
}