'MediaPipe Selfie Segmentation results are not invoking when moved to other Chrome tabs
const videoElement =document.getElementsByClassName('input_video')[0];
selfieSegmentationObj = new SelfieSegmentation({locateFile: (file) => {
return `https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation/${file}`;
}});
selfieSegmentationObj.setOptions({
modelSelection: 1,
selfieMode: false,
effect: 'mask',
});
selfieSegmentationObj.onResults(selfieSegmentationResults);
cameraObj = new Camera(videoElement, {
onFrame: async () => {
await selfieSegmentationObj.send({image: videoElement});
},
width: 1280,
height: 720
});
cameraObj.start();
function selfieSegmentationResults(results) {
const canvasElement = document.getElementsByClassName('output_canvas')[0];
var canvasCtx = canvasElement.getContext('2d');
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
canvasCtx.save();
canvasCtx.drawImage(results.segmentationMask, 0, 0, canvasElement.width, canvasElement.height);
}
When we moved from one tab to another tab then callback function "selfieSegmentationResults" is not getting called from the SelfieSegmentation object.
Please, someone, help if there is any other solution that can get the segmented image data even if we moved to another Chrome tab.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
