I'm trying to convert a Uint8Array to Blob then read Blob with FileReader but I'm getting the following error: Error: Unable to resolve data for blob: (...blob id)
My code looks like following:
const segmentation = await tfModel.segmentPerson(imageTensor);
const segmentBlob = new Blob([segmentation.data], {type: 'image/jpg'});
console.log('uInt8Arr', segmentation, 'blob', segmentBlob);
const fileReaderInstance = new FileReader();
fileReaderInstance.onload = () => {
console.log('start load');
};
fileReaderInstance.onerror = function(event) {
console.log('File could not be read: ' + event.target.error);
};
fileReaderInstance.onloadend = () => {
const base64data = fileReaderInstance.result;
console.log('End Load: BASEEEEEEEEEEE', base64data);
};
fileReaderInstance.readAsDataURL(segmentBlob);
console.log(fileReaderInstance);
Output: Logs
segmentPerson method comes from https://www.npmjs.com/package/@tensorflow-models/body-pix#returns
I'm on a React Navide environment and I would like to find a way to convert the return from segmentPerson in an image, any help is highly appreciated.