i tried the following two ways o loading image and output of the following codes are commemnted
1st try
var imageAsBase64 = fs.readFileSync(path, 'base64');
console.log('Exists ' + typeof (imageAsBase64)) // output :Exists string
const image = await faceapi.bufferToImage(imageAsBase64)
.then(res =>{console.log(res)})
.catch(e=> console.log("Error e "+e)) //output :Error e TypeError: Right-hand side of 'instanceof' is not an object
2nd try
var imageAsBase64 = fs.readFileSync(path);
console.log('Exists ' + typeof (imageAsBase64)) // Exists object
const image = await faceapi.fetchImage(imageAsBase64)
.then(res =>{console.log(res)})
.catch(e=> console.log("Error e "+e)) //Error e Type Error: Only absolute URLs are supported
should i missing something or i need to try different way please help..
You should be able to just pass the file path like this faceapi.fetchImage(path). I am not 100% sure, but I am pretty certain.
You should be able to just pass the file path like this
faceapi.fetchImage(path). I am not 100% sure, but I am pretty certain.
i tried but the error is same if you want to look at my code will uppload my repo to github
var location = req.files[0].destination
var imgFile = req.files[0].filename;
if(!fs.existsSync(fspath.join(location,imgFile))) {
console.log("Not exists")
}else{
console.log('Exists') //yes Exists
}
const image = await faceapi.fetchImage(fspath.join(location,imgFile))
.then(res =>{console.log(res)})
.catch(e=> console.log("Error e "+e)) // Error e TypeError: Only absolute URLs are supported
I am not really sure then. I really do not know this library well enough to answer this question beyond the answer I gave.
i tried but the error is same if you want to look at my code will uppload my repo to github
Could you go ahead and do that?
i tried but the error is same if you want to look at my code will uppload my repo to github
Could you go ahead and do that?
Link to repo
faceapi.bufferToImage returns uses Blob under the hood, so you would need a node polyfill for that.
faceapi.fetchImage as the name implies uses fetch under the hood, thus it doesn't work with filepaths to local files.
I would recommend you to use the node canvas package for reading and writing images as stated in the README and shown in the node examples.
Most helpful comment
faceapi.bufferToImagereturns uses Blob under the hood, so you would need a node polyfill for that.faceapi.fetchImageas the name implies uses fetch under the hood, thus it doesn't work with filepaths to local files.I would recommend you to use the node canvas package for reading and writing images as stated in the README and shown in the node examples.