我正在尝试将 Uint8Array 转换为 Blob,然后使用 FileReader 读取 Blob,但出现以下错误:错误:无法解析 blob 的数据:(...blob id)
我的代码如下所示:
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);
输出:日志
segmentPerson 方法来自https://www.npmjs.com/package/@tensorflow-models/body-pix#returns
我在 React Navide 环境中,我想找到一种方法来转换图像中来自 segmentPerson 的返回,非常感谢任何帮助。