0
我在调用Microsoft Face API来检测图片中的人脸。 当装载从本地的图像,我总是得到一个错误如下从本地存储上传图片时,图片尺寸太小Microsoft Face API
{ code: 'InvalidImageSize',
message: 'Image size is too small.' }
但通过URL,它工作正常使用同一图像。
const fs = require("fs");
const axios = require("axios");
axios({
method : "post",
url : " https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true",
headers : {
'Content-Type': 'application/octet-stream',
"Ocp-Apim-Subscription-Key" : "2da8e41a647c4079b2f9a6XXXXXXXXX"
},
body : fs.readFileSync("./photos/shiva3.jpeg").toString("base64")
}).then((res)=>{
console.log("Response");
console.log(res.data);
}).catch((err)=>{
console.log(err.response.data.error);
})
是否需要'.toString(“base64”)? –